Detailed instructions for use are in the User's Guide.
[. . . ] Using Components
Trademarks Add Life to the Web, Afterburner, Aftershock, Andromedia, Allaire, Animation PowerPack, Aria, Attain, Authorware, Authorware Star, Backstage, Bright Tiger, Clustercats, ColdFusion, Contribute, Design In Motion, Director, Dream Templates, Dreamweaver, Drumbeat 2000, EDJE, EJIPT, Extreme 3D, Fireworks, Flash, Flash Lite, Flex, Fontographer, FreeHand, Generator, HomeSite, JFusion, JRun, Kawa, Know Your Site, Knowledge Objects, Knowledge Stream, Knowledge Track, LikeMinds, Lingo, Live Effects, MacRecorder Logo and Design, Macromedia, Macromedia Action!, Macromedia Breeze, Macromedia Flash, Macromedia M Logo and Design, Macromedia Spectra, Macromedia xRes Logo and Design, MacroModel, Made with Macromedia, Made with Macromedia Logo and Design, MAGIC Logo and Design, Mediamaker, Movie Critic, Open Sesame!, Roundtrip, Roundtrip HTML, Shockwave, Sitespring, SoundEdit, Titlemaker, UltraDev, Web Design 101, what the web can be, and Xtra are either registered trademarks or trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words, or phrases mentioned within this publication may be trademarks, service marks, or trade names of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally. [. . . ] Broadcast when an object's state changes from invisible to visible. Broadcast when the subobjects are being unloaded.
Events inherited from the UIComponent class
The following table lists the events the List class inherits from the UIComponent class.
Event
UIComponent. focusIn UIComponent. focusOut UIComponent. keyDown UIComponent. keyUp
Description Broadcast when an object receives focus. Broadcast when a key is released.
List. addItem()
Availability
Flash Player 6 (6. 0 79. 0).
Edition
Flash MX 2004.
460
Chapter 6: Components Dictionary
Usage listInstance. addItem(label[, data]) listInstance. addItem(itemObject) Parameters label data
A string that indicates the label for the new item. This parameter is optional and can be of any data type. An item object that usually has label and data properties.
itemObject Returns
The index at which the item was added.
Description
Method; adds a new item to the end of the list. In the first usage example, an item object is always created with the specified label property, and, if specified, the data property. The second usage example adds the specified item object. Calling this method modifies the data provider of the List component. If the data provider is shared with other components, those components will update as well.
Example
Both of the following lines of code add an item to the myList instance. To try this code, drag a List component to the Stage and give it the instance name myList. Add the following code to Frame 1 in the Timeline:
myList. addItem("this is an Item"); myList. addItem({label:"Gordon", age:"very old", data:123});
List. addItemAt()
Availability
Flash Player 6 (6. 0 79. 0).
Edition
Flash MX 2004.
Usage listInstance. addItemAt(index, label[, data]) listInstance. addItemAt(index, itemObject) Parameters index label
A number greater than or equal to 0 that indicates the position of the item. A string that indicates the label for the new item.
List component
461
data
The data for the item. This parameter is optional and can be of any data type. An item object that usually has label and data properties.
itemObject Returns
The index at which the item was added.
Description
Method; adds a new item to the position specified by the index parameter. In the first usage example, an item object is always created with the specified label property, and, if specified, the data property. The second usage example adds the specified item object. Calling this method modifies the data provider of the List component. If the data provider is shared with other components, those components will update as well.
Example
The following line of code adds an item to the third index position, which is the fourth item in the list:
myList. addItemAt(3, {label:'Red', data:0xFF0000});
List. cellRenderer
Availability
Flash Player 6 (6. 0 79. 0).
Edition
Flash MX 2004.
Usage listInstance. cellRenderer Description
Property; assigns the cell renderer to use for each row of the list. This property must be a class object reference or a symbol linkage identifier. Any class used for this property must implement the CellRenderer API.
Example
The following example uses a linkage identifier to set a new cell renderer:
myList. cellRenderer = "ComboBoxCell";
462
Chapter 6: Components Dictionary
List. change
Availability
Flash Player 6 (6. 0 79. 0).
Edition
Flash MX 2004.
Usage
Usage 1:
on(change){ // your code here }
Usage 2:
listenerObject = new Object(); listenerObject. change = function(eventObject){ // your code here } listInstance. addEventListener("change", listenerObject) Description
Event; broadcast to all registered listeners when the selected index of the list changes as a result of user interaction. The first usage example uses an on() handler and must be attached directly to a List instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. [. . . ] Use the Values dialog box to enter values into the collection property. With the component selected on the Stage, open the Actions panel and enter the following code
(which must be attached to the component):
onClipEvent (mouseDown) { import mx. utils. Collection; import mx. utils. Iterator; var myColl:mx. utils. Collection; myColl = _parent. myShelf. MyCompactDiscs; var itr:mx. utils. Iterator = myColl. getIterator(); while (itr. hasNext()) { var cd:CompactDisc = CompactDisc(itr. next()); var title:String = cd. Title; var artist:String = cd. Artist; trace("Title: " + title + " Artist: " + artist); } }
To access a collection, use the syntax componentName. collectionVariable; to access an iterator and step through the collection items, use
componentName. collectionVariable. getIterator().
6. Select Control > Test Movie and click the shelf to see the collection data in the Output panel.
Exporting components that have collections to SWC files
When you distribute a component that has a collection, the SWC file must contain the following dependent files:
· · · ·
964
Collection interface Collection implementation class Collection item class Iterator interface
Appendix: Collection Properties
Of these files, your code typically uses the Collection and Iterator interfaces, which marks them as dependent classes. Flash automatically includes dependent files in the SWC file and output SWF file. [. . . ]