This function should loop through 5 times creating 5 different MovieClips, each
one with a mouse click event attached, which should trace the value of "i"
either 1, 2, 3, 4 or 5. So the first movieclip should output 1, second should
output 2 and so on...
for (var i = 0; i < itemList.length(); i++) // itemList.length() is equal
to 5
{
_summaryElement[i] = loadLibrary(itemContainer); // Loads MovieClip from
library
trace(i); // Outputs correctly "1... 2... 3... 4... 5..."
var summaryClick = function (ev:Event)
{
trace(i); // Outputs incorrectly (Outputs "5" on each MovieClip click)
???
}
addChild(_summaryElement[i]); // Adds MovieClip to stage
_summaryElement[i].addEventListener(MouseEvent.CLICK, summaryClick); //
Adds an click event to each MovieClip
}
Thanks
SJM
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders