Skip to main content
December 30, 2007
Question

List Component

  • December 30, 2007
  • 2 replies
  • 421 views
Ridiculously simple, but doing my head in - how do I add links into a list compnent - I'm really new to this actionscripting stuff and I ain't got a clue.

I just want each item in a lst of 7 items to link to a particular keyframe in the movie. So simple in old versions of Flash, but can I fgure it out in Flas CS3?

Help!
This topic has been closed for replies.

2 replies

Inspiring
December 31, 2007
Yes, it's AS3 because you said you're working in CS3. I assumed AS3. My bad.

In AS2, it's not too much different though:

alist.dataProvider = [{label:"link1", data:"somelink"},{label:"link2",
data:"some other link"}];
alist.addEventListener("change", listClick);
function listClick():Void {
trace(alist.selectedItem.data);
}



--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


Inspiring
December 31, 2007
Here's a little tidbit that should get you there:

import fl.data.DataProvider;
import fl.events.ListEvent;

var dp:DataProvider = new DataProvider();
dp.addItems([{label:"link1", data:"somelink"},{label:"link2", data:"some
other link"}]);
alist.dataProvider = dp;

alist.addEventListener(ListEvent.ITEM_CLICK, listClick);
function listClick(e:ListEvent):void {
trace(e.item.data);
}


It assumes a list component on stage with an instance name of alist. When
you click a list item you'll see the string from the data part of the
objects you added with addItems.



--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


December 31, 2007
I can't get this to work - I keep getting the following error...

1046: Type was not found or was not a compile-time constant: ListEvent.