PDA

View Full Version : [AS3] List Component and TileList


Mr_Fish
03-18-2009, 02:51 PM
Hi all,

Has any one ever used a List component of TileList component to display movieclips in a scrollable format?

I have a number of MovieClips which i need to display in a list which has a scrollbar on it so you can scroll through the movie clips.

I know you can use the List.addItem(object) command, but that doesnt seem to work, and it doesnt add a scroll.

Any one have any ideas how to get this working?

Cheers
J

caseyctg
03-18-2009, 03:29 PM
Add item works fine for me. I just used the instance name. The catch is I had to physically place the movieclip in the outskirts of my document. Is your movie clip in the library?

caseyctg
03-18-2009, 03:33 PM
my example:
http://www.iiconf.com/ftp/NY09_CommGraphs/NY09_CommGraphs.html

Mr_Fish
03-18-2009, 03:45 PM
Yeah the movie clip has its own class so i can access it from within my actionscript.

Here is my code:



var newMC:myMC= new myMC();
myListComponent.addItem(newMC);

newMC.name = "My MC";



the error i get is:

ReferenceError: Error #1069: Property label not found on myMC and there is no default value.
at fl.controls::List/itemToLabel()
at fl.controls::List/drawList()
at fl.controls::List/draw()
at fl.core::UIComponent/callLaterDispatcher()


My class (myMC) has a base class of MovieClip.

If i add a standard movieclip to the list it works fine, it seems to be jusy my sub class (myMC) that is having the problem.

Mr_Fish
03-18-2009, 04:30 PM
I have done a little research:

the addItem command sais that it accepts an argument of type 'Object'.

However, all the examples on the internet that i can find are using this method:


myList.addItem({label:"hello world", data:1000});


Is this the format that i should be using to add my movieclip, e.g.


myList.addItem({MovieClip:myMC});


Or something along those lines?

Cheers
J

robh2255
04-07-2009, 09:06 PM
I'm interested in adding a movie clip to a list component as well. Haven't figured out a way though either. I will post something here if I find a solution.

robh2255
04-13-2009, 07:05 PM
I found a solution for adding a movieclip to a scrolling component list!

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/List.html#iconField

Check out the entry on "IconField". Note that in the example, RedBox would be the instance name of your MovieClip.

Here's the example it gives:

The following example creates a list with an icon for each item. A symbol named RedBox must exist in the library and have "Export for ActionScript" toggled in its symbol properties:

import fl.data.DataProvider;
import fl.controls.List;

var dp:DataProvider = new DataProvider();
dp.addItem( { iconSource:RedBox, label:"Item 1" } );
dp.addItem( { iconSource:RedBox, label:"Item 2" } );
dp.addItem( { iconSource:RedBox, label:"Item 3" } );

var list:List = new List();
list.iconField = "iconSource";
list.dataProvider = dp;
addChild(list);

Good luck and I hope this helps someone!