Okay so here is a question that is more about method i think. I am fairly new at this and i therefore think a have the wrong approach.
I want to make a "game" where every time you click, the stage creates an addChild. After searching trough several sites, with my limited knowledge and trying back and forth, i have reached this conclusion:
mouse.addEventListener(MouseEvent.CLICK, CREATE);
function CREATE(e:Event):void {
var square:MovieClip = new squarelink();
addChild(square);
square.x = mouseX;
square.y = mouseY;
}
Now my problem is that i want to code it, give this new movieclip some "events" but because my movieclip do not appear on stage until after i click. Any addeventlistener in its name is going to come up as: access of possibly undefined property. This causing my swf to fail.
So therefor i tried to set the "var square:MovieClip = new squarelink();" out of my CREATE function. This just causing it to only move the square about as i clicked, not create new once. How ever made it possible for me to now add events.
So to sum up. I need a method that allows me to create several "children" as well as letting me add an event that states, if i click on it again: Delete it self.
This without it telling me that there is not yet any square on stage.
(This is an explanation of the problem, any comment on spelling mistake, or "you need a big R in that one for it to work" is welcome, but likely unusable. I know how to write the code properly, i just do not know which code do write.)
I hope that this problem is some what well explained, and i hope someone in here can help, as there is 1 month till i am back in school to ask my teacher. :D