actionscript 3 - removing instance after excecuted 2 -
got parameter child must non-null error code can ?
for (i=1; i<=4; i++) { this["box" + i].addeventlistener(event.enter_frame, move); this["box" + i].addeventlistener(mouseevent.click, action); } function move(e:event):void { e.target.y -= 6; if (e.target.y <= 56) { movieclip(e.target).removeeventlistener(event.enter_frame, move); removechild(getchildbyname(e.target.name)); comment.text = "miss"; miss += 1; score += 0; } } function action(event:mouseevent):void { if ((event.target.hittestobject(bts1))&&(event.target.hittestobject(bts2))&&(event.target.hittestobject(bts3))&&(event.target.hittestobject(bts4))) { movieclip(event.target).removeeventlistener(mouseevent.click, action); removechild(getchildbyname(event.target.name)); comment.text = "perfect"; perfect += 1; score += 10000; } else if ((event.target.hittestobject(bts2)&&event.target.hittestobject(bts3)&&event.target.hittestobject(bts4))||(event.target.hittestobject(bts1)&&event.target.hittestobject(bts2)&&event.target.hittestobject(bts3))) { movieclip(event.target).removeeventlistener(mouseevent.click, action); removechild(getchildbyname(event.target.name)); comment.text = "great"; great += 1; score += 5000; } else if ((event.target.hittestobject(bts3)&&event.target.hittestobject(bts4))||(event.target.hittestobject(bts1)&&event.target.hittestobject(bts2))) { movieclip(event.target).removeeventlistener(mouseevent.click, action); removechild(getchildbyname(event.target.name)); comment.text = "good"; += 1; score += 2500; } else if ((event.target.hittestobject(bts4))||(event.target.hittestobject(bts1))) { movieclip(event.target).removeeventlistener(mouseevent.click, action); removechild(getchildbyname(event.target.name)); comment.text = "boo"; boo += 1; score += 1000; } else { movieclip(event.target).removeeventlistener(mouseevent.click, action); removechild(getchildbyname(event.target.name)); comment.text = "miss"; miss += 1; score += 0; } }
btw "bts1,2,3" line movie clip problem occur on mouse click event, want when clik box hittest on "bts" , box remove after user click, if user didn't click disappear @ point
before removing child , must remove listeners attached , enter_frame
, click
etc . copy , paste same lines (it's little bit bad practice , when fixed you'll need make refactoring here).
Comments
Post a Comment