-
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!
-
Senior Member
putting inside that drop MC the line
this totally works, I did it myself before.
this makes no sense.
I would like to stay 30 frames per second, but i also would like to choose how many drops are created.
add "for (var i:int = 0; i < 5; i++) { ... }" around your code
-
Originally Posted by realMakc
this totally works, I did it myself before.
ypeError: Error #1009: Cannot access a property or method of a null object reference. at DROP/frame10()
-
Senior Member
maybe you do it twice, e g because your mc timeline loops. put a stop() there, or do if (this.parent != null) check
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|