Textfield.stylesheet - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

TextField.styleSheet

Availability
Flash Player 7.
Usage
my_txt.styleSheet = TextField StyleSheet
Description
Property; attaches a style sheet to the text field specified by
style sheets, see the
Sheets"
in Using ActionScript in Flash.
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
to remove the style sheet. If the style sheet in use is removed, the text field is redrawn
undefined
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
Stage,
css1_btn
to
, or clear the style sheet from the text field. Add the following ActionScript to your
news_txt
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");
};
css2_btn.onRelease = function() {
var styleObj:TextField.StyleSheet = new TextField.StyleSheet();
styleObj.onLoad = function(success:Boolean) {
920
Chapter 2: ActionScript Language Reference
TextField.StyleSheet class
,
and
css2_btn
clearCss_btn
. For information on creating
my_txt
entry and
"Formatting text with Cascading Style
news_txt
, are used to change the style sheet that is applied
or
null
. Three buttons on the

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents