User Guide
52 Working with Components
8. Change the size of the component as desired by editing the values for the width and height.
For more information on sizing specific component types, see the individual component
entries in Components Language Reference.
9. If you want to change the color and text formatting of a component, do one or more of
the following:
■ Set or change a specific style property value for a component instance by using the
setStyle()
method, which is available to all components. For more information, see
UIObject.setStyle() on page 1343.
■ Edit multiple properties in the global style declaration assigned to all version 2
components.
■ Create a custom style declaration for specific component instances.
For more information, see “Using styles to customize component color and text”
on page 82.
10. If you want to customize the appearance of the component, do one of the following:
■ Apply a theme (see “About themes” on page 108).
■ Edit a component’s skins (see “About skinning components” on page 96).
Adding components at runtime with ActionScript
The instructions in this section assume an intermediate or advanced knowledge
of ActionScript.
Use the
createClassObject() method (which most components inherit from the UIObject
class) to add components to a Flash application dynamically. For example, you could add
components that create a page layout based on user-set preferences (as on the home page of a
web portal).
Version 2 components that are installed with Flash reside in package directories. (For more
information, see “About packages” in Learning ActionScript 2.0 in Flash. If you add a
component to the Stage during authoring, you can refer to the component simply by using its
instance name (for example,
myButton). However, if you add a component to an application
with ActionScript (at runtime), you must either specify its fully qualified class name (for
example,
mx.controls.Button) or import the package by using the import statement.
For example, to write ActionScript code that refers to an Alert component, you can use the
import statement to reference the class, as follows:
import mx.controls.Alert;
Alert.show("The connection has failed", "Error");