MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference page 1152

Actionscript 2.0 language reference
Table of Contents

Advertisement

Parameters
- The name of the style to add to the StyleSheet.
name:String
- An object that describes the style, or
style:Object
Example
The following example adds a style named
style includes two style properties:
the
operator.
{}
myStyleSheet.setStyle("emphasized", {color:'#000000',fontWeight:'bold'});
You could also create a style object using an instance of the Object class, and then pass that
object (
) as the
styleObj
import TextField.StyleSheet;
var my_styleSheet:StyleSheet = new StyleSheet();
var styleObj:Object = new Object();
styleObj.color = "#000000";
styleObj.fontWeight = "bold";
my_styleSheet.setStyle("emphasized", styleObj);
delete styleObj;
var styleNames_array:Array = my_styleSheet.getStyleNames();
for (var i=0;i<styleNames_array.length;i++) {
var styleName:String = styleNames_array[i];
var thisStyle:Object = my_styleSheet.getStyle(styleName);
trace(styleName);
for (var prop in thisStyle) {
trace("\t"+prop+": "+thisStyle[prop]);
}
trace("");
}
The following information appears in the Output panel:
emphasized
fontWeight: bold
color: #000000
Because Flash Player creates a copy of the style object you pass to
delete styleObj
original style object passed to
See also
{} object initializer operator
1152
ActionScript classes
emphasized
and
color
parameter, as the next example shows:
style
command in the code example reduces memory usage by deleting the
setStyle()
,
StyleSheet (TextField.StyleSheet)
.
null
to the StyleSheet
. The style object is defined with
fontWeight
.
. The
myStyleSheet
, the
setStyle()

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents