ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > StyleSheet (TextField.StyleSheet) > load (StyleSheet.load method) | |||
public load(url:String) : Boolean
Starts loading the CSS file into the StyleSheet. The load operation is asynchronous; use the onLoad() callback handler to determine when the file has finished loading. The CSS file must reside in the same domain as the SWF file that is loading it.
Availability: ActionScript 1.0; Flash Player 7
url:String - The URL of a CSS file to load. The URL must be in the same domain as the URL where the SWF file currently resides.
Boolean - false if no parameter (null) is passed; true otherwise. Use the onLoad() callback handler to check the success of a loaded StyleSheet.
For an example of asynchronously loading style sheets using ActionScript 2.0, see the example for getStyle().
The following example loads the CSS file named styles.css into the StyleSheet object my_styleSheet. When the file has loaded successfully, the StyleSheet object is applied to a TextField object named news_txt.
import TextField.StyleSheet;
this.createTextField("news_txt", 999, 10, 10, 320, 240);
news_txt.multiline = true;
news_txt.wordWrap = true;
news_txt.html = true;
var my_styleSheet:StyleSheet = new StyleSheet();
my_styleSheet.onLoad = function(success:Boolean) {
if (success) {
news_txt.styleSheet = my_styleSheet;
news_txt.htmlText = "<p class=\"heading\">Heading goes here!</p>"
+ "<p class=\"mainBody\">Lorem ipsum dolor sit amet, consectetuer "
+ "adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet "
+ "dolore magna aliquam erat volutpat.</p>";
}
};
my_styleSheet.load("styles.css");
For the complete code for styles.css, see the example for getStyle().
onLoad (StyleSheet.onLoad handler), getStyle (StyleSheet.getStyle method)
|
|
|
|