MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual page 961

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

Advertisement

class MyShelf extends mx.core.UIObject
{
// required variables for all classes
static var symbolName:String = "MyShelf";
static var symbolOwner:Object = Object(MyShelf);
var className:String = "MyShelf";
// the Collection metadata tag and attributes
[Collection(variable="myCompactDiscs",name="My Compact
Discs",collectionClass="mx.utils.CollectionImpl",
collectionItem="CompactDisc", identifier="Title")]
// get and set methods for the collection
public function get MyCompactDiscs():mx.utils.Collection
{
return myCompactDiscs;
}
public function set MyCompactDiscs(myCDs:mx.utils.Collection):Void
{
myCompactDiscs = myCDs;
}
// private class member
private var myCompactDiscs:mx.utils.Collection;
// You must code a reference to the collection item class
// to force the compiler to include it as a dependency
// within the SWC
private var collItem:CompactDisc;
// You must code a reference to the mx.utils.CollectionImpl class
// to force the compiler to include it as a dependency
// within the SWC
private var coll:mx.utils.CollectionImpl;
// required methods for all classes
function init(Void):Void {
super.init();
}
function size(Void):Void {
super.size();
}
}
To create a FLA file to accompany this class for testing purposes:
In Flash, select File > New and create a Flash document.
1.
Select Insert > New Symbol. Give it the name, linkage identifier, and AS 2.0 class name
2.
MyShelf.
Deselect Export in First Frame and click OK.
3.
Select the MyShelf symbol in the library and choose Component Definition from the Library
4.
options menu. Enter the ActionScript 2.0 class name MyShelf.
Simple collection example
961

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?

Questions and answers

This manual is also suitable for:

Flash mx

Table of Contents