Hi all,
I’m working on a small game right now that is a basic drag drop with collision detection etc.
Im trying to get to grips with AS3 but am having some problems.
Currently I am using a loop to populate the screen with MCs, and am trying to access them to manipulate them once they are on screen. The issue I have is when I assign a name to the MCs in the array I cant access it after and am not sure why.
Heres the code:
var bunny:Array=[];
for (var i:int = 0; i < checkBunnyCounter; i++) {
var bunnyClip:MovieClip = new bunnyleft_mc();
bunnyClip.name="bunny"+i;
addChild(bunnyClip);
bunny*=bunnyClip;
bunny*.buttonMode=true;
bunny*.addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
bunny*.addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);
trace("Bunnyclip MC Name: "+bunnyClip.name);
trace("Bunnyclip MC when added: "+bunnyClip);
trace("Bunny Array: "+bunny);
When I run it I get the following output:
Bunnyclip MC Name: bunny0
Bunnyclip MC when added: [object bunnyleft_mc]
Bunny Array: [object bunnyleft_mc]
Bunnyclip MC Name: bunny0
Bunnyclip MC when added: [object bunnyleft_mc]
Bunny Array: [object bunnyleft_mc]
Bunnyclip MC Name: bunny1
Bunnyclip MC when added: [object bunnyleft_mc]
Bunny Array: [object bunnyleft_mc],[object bunnyleft_mc]
etc.
When I try to click on one of the bunny MCs I get the following error:
TypeError: Error #1010: A term is undefined and has no properties.
at MethodInfo-3()
I know its probably a simple error, but I’ve spent a while trying to figure it out to no avail. Can anyone help me out please?
Thanks!