Previous Page
Next Page

Tripod >> 3pod Tips & Learning and manuals for educations

Recipe 15.4. Applying Styles Globally

Problem

You want to assign style settings to all component instances in your Flash movie.

Solution

Assign the settings to the _global.style object using the setStyle( ) method.

Discussion

Flash automatically creates a style object that you can use to manage the styles of all component instances in your Flash movie. The name (exp 3pod.com) of the object is _global.style. It's a fairly common mistake for novices and experts alike to accidentally use the incorrect name (exp 3pod.com) by pluralizing _global.style as _global.styles. The _global.styles (plural) object is a container object that Flash uses to hold all the other style objects you might define (see Recipe 15.2 and Recipe 15.3). However, the _global.style (singular) object is an actual style object from which all component instances can inherit their style settings.

The _global.style object is created automatically for you by Flash, so there is no need to declare it anew as with many of the other style objects you need to create (see Recipe 15.2 and Recipe 15.3). Instead, all you need to do is use the setStyle( ) method to assign new style settings. For example, the following code will set the themeColor and fontFamily styles for all component instances in your Flash movie:

	_global.style.setStyle("fontFamily", "_typewriter");
	_global.style.setStyle("themeColor", "haloOrange");

The global style settings will take effect for all component instances for which you have not otherwise applied settings for the same styles. The _global.style object has the lowest precedence of all other style objects. Therefore, if you have applied a themeColor setting to a component instance via a component class style object, a group style object, or on the instance itself, the global themeColor style setting will not be inherited by that instance.

Tripod >> 3pod Botom Tips & Learning and manuals for educations

Previous Page
Next Page

 

bluedot bluedots greydots pinkdots

Tripod >> 3pod Tips & Learning and manuals for educations