Defining The Class For A Collection Item - MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual

Using components
Hide thumbs Also See for FLASH MX 2004-USING COMPONENTS:
Table of Contents

Advertisement

Choose Window > Other Panels > Common Libraries > Classes, and drag UtilClasses to the
5.
library of MyShelf.fla.
In the MyShelf symbol's Timeline, name one layer Assets. Create another layer and name it
6.
Actions.
Place a
7.
stop()
Select Frame 2 of the Assets layer and select Insert > Timeline > Keyframe.
8.
Open StandardComponents.fla from the Configuration/ComponentFLA folder, and drag an
9.
instance of UIObject to the Stage of MyShelf in Frame 2 of the Assets layer.
You must include UIObject in the component's FLA file because, as you can see in the above
class file, MyShelf extends UIObject.
In Frame 1 of the Assets layer, draw a shelf.
10.
This can be a simple rectangle; it's just a visual representation of the MyShelf component to use
for learning purposes.
Select the MyShelf movie clip in the library, and select Convert to Compiled Clip.
11.
This allows you to drag the MyShelf SWF file (the compiled clip that's added to the library)
into the MyShelf.fla file to test the component. Whenever you recompile the component, a
Resolve Library Conflict dialog box appears, because an older version of the component
already exists in the library. Choose to replace existing items.
Note: You should have already created the CompactDisc class; otherwise, you'll get compiler
errors when converting to a compiled clip.

Defining the class for a collection item

You code the properties for a collection item in a separate ActionScript class, which you define as
follows:
Define the class such that it does not extend UIObject or UIComponent.
Define all properties using the Inspectable tag.
Define all properties as variables. Do not write
The following is a simple example of a collection item class file called CompactDisc.as.
class CompactDisc{
[Inspectable(type="String", defaultValue="Title")]
var title:String;
[Inspectable(type="String", defaultValue="Artist")]
var artist:String;
}
To view the CompactDisc.as class file, see
962
Appendix: Collection Properties
function on Frame 1 of the Actions layer.
and
(getter/setter) methods.
get
set
"Simple collection example" on page
960.

Advertisement

Table of Contents
loading
Need help?

Need help?

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

This manual is also suitable for:

Flash mx

Table of Contents