actionscript 3 - Action Script 3: Addchild within an already added child issue -
my issue error when function addspotlight called.
typeerror: error #1010: term undefined , has no properties. @ bubbleboy_fla::maintimeline/addspotlight() @ bubbleboy_fla::maintimeline/policeheli() @ flash.utils::timer/_timerdispatch() @ flash.utils::timer/tick()
my code this:
//adding helicopter function addhelicopter(xlocation: int, ylocation: int, passspeedx, passspeedy): void { var helicopter: helicopter = new helicopter(xlocation, ylocation, passspeedx, passspeedy); back.addchild(helicopter); helilist.push(helicopter); playfly(); } //adding spotlight function addspotlight(xspotlightlocation: int, yspotlightlocation: int, spotlightspeedx): void { var spotlight: spotlight = new spotlight(xspotlightlocation, yspotlightlocation, spotlightspeedx); back.helicopter.addchild(spotlight); spotlightlist.push(spotlight); }
the reason doing because helicopter can destroyed , spotlight gets removed @ same time, if don't destroy helicopter , spotlight hits caught.
i had code add spotlight container lined helicopter, remove first spotlight in array.
if (helilist.length > 0) { (var h: int = 0; h < helilist.length; h++) (var l: int = 0; l < spotlightlist.length; l++) { if (helilist[h].hittestpoint(boy.x + upbumppoint.x, boy.y + upbumppoint.y, true)) { trace("score points") score += 100; playcrash(); playfly(); helilist[h].removeheli(); spotlightlist[l].removespotlight(); //policetimer.start(); } } }
any suggestions on these 2 issues??
in addspotlight
use:
trace('spotlight: ', spotlight); trace('back: ', back); trace('back.helicopter: ', back.helicopter); trace('spotlightlist: ', spotlightlist);
whatever missing - causes issue :)
Comments
Post a Comment