Little help with addChild
Hello everybody!
I am trying to make a rain effect (kind of), and i don't know how to set the drops quantity based on a variable.
This is the code i did so far:
Code:
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event): void {
drop[i] = new drop();
addChild(drop[i]);
//Random position of drop
drop[i].y = Math.random() * stage.stageHeight;
drop[i].x = Math.random() * stage.stageWidth;
}
Maybe the problem here is the enterframe, infact ofcourse it creates more drops if i raise the frames per second of the swf.
I would like to stay 30 frames per second, but i also would like to choose how many drops are created.
Another big problem is that i want to remove the drop after a while with a command inside the MC itself, and putting inside that drop MC the line:
Code:
this.parent.removeChild(this);
it does not work :(
Any hint for both things please?
Thanks a lot!