TextFormat.target Property | Flash 6 |
specifies the window or frame for a hypertext link | read/write |
The string target property specifies the name of the browser window or frame into which to load the document at theFormat.url. It can be a custom name or one of the four presets: "_blank", "_parent", "_self", or "_top". If theFormat.url is not specified, target has no effect. Take special note that url, and hence also target, works only when TextField.html is set to true for the text field.
The target property must be used in conjunction with the url property. To set the target property for an entire text field, invoke TextField.setTextFormat( ) without specifying any index arguments:
this.createTextField("theField_txt", 1, 0, 0, 250, 40); theField_txt.border = true; theField_txt.text = "Visit www.moock.org."; theField_txt.html = true; // REQUIRED!! // Create a TextFormat object format = new TextFormat(); format.url = "http://www.moock.org/"; format.target = "_blank"; // Open link in new window format.underline = true; // Add underline manually // Apply the hypertext link theField_txt.setTextFormat(format);
To add a link to a single character, apply the format with a single index argument:
theField_txt.setTextFormat(0, format); // Link the first character, "V"
To add a link to a range of characters, apply the format with start and end index arguments:
// Link the text: "www.moock.org" theField_txt.setTextFormat(6, theField_txt.length, format);
The default target value (as contained in the TextFormat object returned by TextField.getTextFormat( )) for a text field that contains text is the empty string (""). For a text field without any text, the target value is null. For a completely new TextFormat object, it is also null, indicating that target will not be set when the format is applied to a text field:
trace(anyUnformattedField_txt.getTextFormat().target); // Displays nothing var format = new TextFormat(); trace(format.target); // Displays: "null"
TextField.html, TextFormat.url