I have some problems getting my code working properly. I'm very new to coding in general and I have hit a wall regarding this. When playing the animation I get an error
(TypeError: Error #2007: Le paramètre child ne doit pas être nul.
at flash.display::DisplayObjectContainer/removeChild()
at muis_fla::MainTimeline/onEnter()
Any idea why this is?
this.addEventListener( Event.ENTER_FRAME, onEnter );
function onEnter( e: Event ):void {
if (currentFrame <= 320){
var s: Snow = new Snow();
s.x=550*Math.random();
s.y=0;
s.width=s.height=9+12*Math.random();// 1 ~ 9
s.xSpeed=-16+20*Math.random();// -2 ~ 2
s.ySpeed=16+20*Math.random();// 1 ~ 5
s.at = -0.001 -0.001*Math.random();
s.vt = 0;
this.addChild( s );
s.addEventListener( Event.ENTER_FRAME, onSnowEnter );
} else {
if(currentFrame == 321){
this.removeChild(s);
}
}
}
function onSnowEnter( e: Event ):void {
var s:Snow=e.currentTarget as Snow;
s.x+=s.xSpeed;
s.y+=s.ySpeed;
if (s.y>=0) {
}
A few things, what is "this" referring to when you call "this.removeChild(s)"? I don't read French, but it looks like you are getting the error "Isn't a child of the caller" when trying to remove the child. Whenever I get that error, I add an if condition to make sure that what I am trying to move is a child of the event.target.