Jasconius
01-29-2008, 06:53 PM
Here's the scenario:
I have a map, with 50 movieclips each representing a store in a mall.
Each one of these movieclips has a value appended to them of .storeID
so I just set
clipname.storeID = 1; and then some mojo fires off based on that later on.
My problem is that the mojo can't fire off unless I attach event handlers to each one of these clips. There are 50 of them, and somehow I doubt Adobe's intention was to simply have us type out
clipname.addEventListener
50 times.
I had two ideas, neither of which I can get to work in AS3.
Idea #1)
Create a for each on the main timeline, the store clips are actually a special class that extends MovieClip so the actual line I imagined would look something like
Code:
for each (var clip:StoreClip in Stage)
{
clip.addEventListener(arg1, arg2);
}
However the Stage, parent, and this properties seem to be sliiiightly different than they were in Flash 8. If I try any of those, it just doesn't execute the loop at all.
I know this works, I just don't know, nor can I find, the proper syntax.
Idea #2)
Create an array on the main timeline that would store the object reference to each one of the clips, and the clip itself would add itself to the array when it is created.
So in the StoreClip constructor, there is a line
parent.storeClipArray.push(this);
However, this raises a compiler error saying that storeClipArray does not exist, despite the fact that it clearly does. on line 2 of Frame 1 of the FLA. I've been reading that classes communicating with function and variables on the main timeline, hell, even in other instantiated classes is a big no-no, which raises the question, wtf?
Any help/links would be appreciated.
Thanks.
I have a map, with 50 movieclips each representing a store in a mall.
Each one of these movieclips has a value appended to them of .storeID
so I just set
clipname.storeID = 1; and then some mojo fires off based on that later on.
My problem is that the mojo can't fire off unless I attach event handlers to each one of these clips. There are 50 of them, and somehow I doubt Adobe's intention was to simply have us type out
clipname.addEventListener
50 times.
I had two ideas, neither of which I can get to work in AS3.
Idea #1)
Create a for each on the main timeline, the store clips are actually a special class that extends MovieClip so the actual line I imagined would look something like
Code:
for each (var clip:StoreClip in Stage)
{
clip.addEventListener(arg1, arg2);
}
However the Stage, parent, and this properties seem to be sliiiightly different than they were in Flash 8. If I try any of those, it just doesn't execute the loop at all.
I know this works, I just don't know, nor can I find, the proper syntax.
Idea #2)
Create an array on the main timeline that would store the object reference to each one of the clips, and the clip itself would add itself to the array when it is created.
So in the StoreClip constructor, there is a line
parent.storeClipArray.push(this);
However, this raises a compiler error saying that storeClipArray does not exist, despite the fact that it clearly does. on line 2 of Frame 1 of the FLA. I've been reading that classes communicating with function and variables on the main timeline, hell, even in other instantiated classes is a big no-no, which raises the question, wtf?
Any help/links would be appreciated.
Thanks.