![MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference Download Page 751](http://html1.mh-extra.com/html/macromedia/flex-flex-actionscript-language/flex-flex-actionscript-language_reference_3387192751.webp)
TextField.styleSheet
751
See also
TextField.setNewTextFormat()
,
TextFormat class
TextField.styleSheet
Availability
Flash Player 7.
Usage
my_txt
.styleSheet =
TextField StyleSheet
Description
Property; attaches a style sheet to the text field specified by
my_txt
. For information on creating
style sheets, see the
TextField.StyleSheet class
entry.
The style sheet associated with a text field may be changed at any time. If the style sheet in use is
changed, the text field is redrawn using the new style sheet. The style sheet may be set to
null
or
undefined
to remove the style sheet. If the style sheet in use is removed, the text field is redrawn
without a style sheet. The formatting done by a style sheet is not retained if the style sheet is
removed.
Example
The following example creates a new text field at runtime, called
news_txt
. Three buttons on the
Stage,
css1_btn
,
css2_btn
and
clearCss_btn
, are used to change the style sheet that is applied
to
news_txt
, or clear the style sheet from the text field. Add the following ActionScript to your
FLA or AS file:
this.createTextField("news_txt", this.getNextHighestDepth(), 0, 0, 300, 200);
news_txt.wordWrap = true;
news_txt.multiline = true;
news_txt.html = true;
var newsText:String = "<p class='headline'>Description</p> Method; starts
loading the CSS file into styleSheet. The load operation is asynchronous;
use the <span class='bold'>TextField.StyleSheet.onLoad</span> callback
handler to determine when the file has finished loading. <span
class='important'>The CSS file must reside in exactly the same domain as the
SWF file that is loading it.</span> For more information about restrictions
on loading data across domains, see Flash Player security features.";
news_txt.htmlText = newsText;
css1_btn.onRelease = function() {
var styleObj:TextField.StyleSheet = new TextField.StyleSheet();
styleObj.onLoad = function(success:Boolean) {
if (success) {
news_txt.styleSheet = styleObj;
news_txt.htmlText = newsText;
}
};
styleObj.load("styles.css");
};
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...