actionscript 3 - ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller -
i trying rid of object it's throwing error not sure problem.
the error getting:
argumenterror: error #2025: supplied displayobject must child of caller. @ flash.display::displayobjectcontainer/removechild() @ schoolbook_final_fla::maintimeline/garbage_cl_2()[schoolbook_final_fla.maintimeline::frame2:98] @ function/schoolbook_final_fla:maintimeline/choice_play_ev/schoolbook_final_fla:play_target()[schoolbook_final_fla.maintimeline::frame2:81]
my code:
import flash.display.sprite; import flash.ui.mouse; import flash.events.event; var week_pick:weekday_choice = new weekday_choice (); var weekdayarray: array = new array (); var monday:mon_d_but = new mon_d_but (); var tuesday:tues_d_but = new tues_d_but (); var wednesday:wed_d_but = new wed_d_but (); var thursday:thurs_d_but = new thurs_d_but (); var friday:fri_d_but = new fri_d_but (); var choice_play: array = new array (); choice_play.push(monday, tuesday, wednesday, thursday, friday); //adding week pick addchild(week_pick); //placing buttons choice_play[0].x = 73.1; choice_play[0].y = 316.75; choice_play[1].x = 251.9; choice_play[1].y = 278.35; choice_play[2].x = 399.95; choice_play[2].y = 375.85; choice_play[3].x = 345.2; choice_play[3].y = 602.4; choice_play[4].x = 80.15; choice_play[4].y = 603.05; (var = 0; < choice_play.length; a++) { //asking buttons stop choice_play[a].alpha = 0; choice_play[a].stop(); } //event week pick start week_pick.addeventlistener(event.enter_frame, moveon); //getting function started function moveon(event:event) { if (week_pick.currentframe == 103) { week_pick.stop(); (a = 0; < choice_play.length; a++) { addchild(choice_play [a]); } //adding event listener clicking buttons this.addeventlistener(mouseevent.click,choice_play_ev); } } function choice_play_ev(play_event: mouseevent) { trace ("event gets added"); trace (play_event.target); //work if target isn't background clip if (play_event.target != week_pick) { trace (play_event.target); //turn opacity ever cliked on play_event.target.alpha = 1; //asking choice play it's animation play_event.target.addeventlistener(event.enter_frame, play_target); this.removeeventlistener(mouseevent.click,choice_play_ev); function play_target(play_event_cl:event) { play_event_cl.target.play (); if (play_event_cl.target.currentframe == 15) { //remove [;ace event listener once animation done play_event.target.removeeventlistener(event.enter_frame, play_target); garbage_cl_2 (); } } } } function garbage_cl_2 () { trace("it works"); (a = 0; < choice_play.length; a++) { //remove choices display list removechild(choice_play [a]); } //remove choices array better garbage cleaning choice_play.splice(0, choice_play.length); removechild(week_pick); week_pick.removeeventlistener(event.enter_frame, moveon); trace("the choice_play " + choice_play.length); gotoandstop(3); }
can me out please? tell me why throwing error?
your loop inside garbage_cl_2 ()
function
for (a = 0; < choice_play.length; a++) { //remove choices display list removechild(choice_play [a]); }
and / or call removechild(week_pick);
tries remove movieclip
that's not direct child of current movieclip
object. current clip 1 timeline contains frame code of garbage_cl_2 ()
function. removechild()
method can remove direct child of displayobjectcontainer
instance - if current clip not direct parent of these clips, need specify parent clip so:
parentclip.removechild ( ... );
Comments
Post a Comment