hi for all…
im new in as3 I wish some one can help me with that…
im coding some new game and Im here with this code trying to addchild(object) and after some sec’s to remove it for the stage
var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
myTimer.start();
var i:int = 0;
function timerListener (e:TimerEvent):void{
i++
var myMc:MovieClip = new cmc();
if(i == 2)
{
addChild(myMc);
myMc.x = Math.random() * 300;
myMc.y = Math.random() * 300;
}
if(i == 4)
{
(this.parent != null)
this.parent.removeChild(this);
i = 1;
}
}
so this code do it for once and then when he trying to addChild again I got this error
"
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at timer_fla::MainTimeline/timerListener()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
"
what to do please…?