I've tried everything. Arrays are quite simple so I don't know why this doesn't function:
var menuList:Array = [menu_bag_mc,menu_chips_mc,menu_coke_mc,menu_cup_mc,menu_deodorant_mc,menu_fork_mc,menu_knife_mc,menu_lighter_mc,menu_milk_mc,menu_pill_mc,menu_rings_mc,menu_shampoo_mc,menu_spoon_mc,menu_straw_mc,menu_toothbrush_mc,menu_trashbag_mc,menu_water_mc];
function captureAllClicks(event:MouseEvent):void
{
trace(menuList.indexOf(event.target));
}
stage.addEventListener(MouseEvent.CLICK, captureAllClicks);
Every time I click on any of the items on the stage (which are all given the instance names listed above. each is a tweening movieclip containing a button) I get a trace of -1. WHY?!
edit2
What needs to happen:
for each (var mc:MovieClip in menuList) mc.addEventListener(MouseEvent.CLICK, createContent);
//right here, i need to make a variable that I can put in the "addchild" so that
//for every one of the list items clicked, it adds a movieclip child with
//the same name (such as menu_bag_mc from above) with "_frame" appended.
var framevar:MovieClip = menuList[i] += "_frame";
function createContent(event:MouseEvent):void {
if(MovieClip(root).currentFrame == 850) {
while(MovieClip(root).numChildren > 1)
{
MovieClip(root).removeChild(MovieClip(root).getChildAt(MovieClip(root).numChildren - 1));
}
MovieClip(root).addChild (framevar);
MovieClip(root).addChild (closeBtn);
}
else {
MovieClip(root).addChild (framevar);
MovieClip(root).addChild (closeBtn);
MovieClip(root).gotoAndPlay(806);
}
}
If I can't do a variable, there's no point for the whole "for each" statement you put together... not really any point for an array, because I'll still have to create 20 lines of code for each separate one. What's the point of having an array if you can't make variables from them?