Sunday 15 September 2013

actionscript 3 - Error #1009 in AS3 -



actionscript 3 - Error #1009 in AS3 -

this question still open, no viable reply has been found far i'm aware. i've tested current answers no result. if plan on answering inquire first @ solutions proposed, cannot work.

update: ok think i'm onto one, block not send error block @ bottom of checkforhit function, till trying figure out means.

cannot access property or method of null object reference. @ impossible_fla::maintimeline/checkforhit()

so created project timer on 1 frame, reason remove event listener isn't working.

here error text typeerror: error #1009: cannot access property or method of null object reference. @ impossible_fla::maintimeline/checkforhit()

even though did removeeventlistener(event.enter_frame, checkforhit); ?

stop(); var currentobject:movieclip = null; var dragging:boolean = false; initdrag(block1); initdrag(block2); initdrag(block3); initdrag(block4); var tcount:number = 50; var ttimer:timer = new timer(100,tcount); ttimer.addeventlistener(timerevent.timer, tcountdown); function tcountdown(e:timerevent):void { if (tcount == 1) { trace("done"); ttimer.removeeventlistener(timerevent.timer, tcountdown); gotoandstop("lose"); } else { queen.alpha += 0.02; tcount--; trace(tcount); } } function initdrag(obj:movieclip ) { obj.addeventlistener(mouseevent.mouse_down,startadrag); stage.addeventlistener(mouseevent.mouse_up,stopadrag); } function enddrag(obj:movieclip ) { obj.removeeventlistener(mouseevent.mouse_down,startadrag); stage.removeeventlistener(mouseevent.mouse_up,stopadrag); removeeventlistener(event.enter_frame, checkforhit); } function startadrag(e:mouseevent):void { currentobject = (movieclip)(e.target); var rect:rectangle = new rectangle(0,0,stage.stagewidth - currentobject.width,stage.stageheight - currentobject.height + 100); currentobject.startdrag(false,rect); dragging = true; } function stopadrag(e:mouseevent):void { if (currentobject != null) { dragging = false; currentobject.stopdrag(); } } addeventlistener(event.enter_frame, checkforhit); function checkforhit(e:event):void { if (dragging) { if (block2.hittestobject(dragtest)) { enddrag(block2); removeeventlistener(event.enter_frame, checkforhit); ttimer.start(); } if (block3.hittestobject(dragtest)) { removeeventlistener(event.enter_frame, checkforhit); enddrag(block3); removeeventlistener(event.enter_frame, checkforhit); gotoandstop("lose"); } if (block4.hittestobject(dragtest)) { enddrag(block4); removeeventlistener(event.enter_frame, checkforhit); gotoandstop("lose"); } if (block1.hittestobject(dragtest)) { removeeventlistener(event.enter_frame, checkforhit); enddrag(block1); gotoandstop("lose"); } } }

you can check, if ttimer object exist , remove event listener

if(ttimer) { ttimer.removeeventlistener(timerevent.timer, tcountdown); }

actionscript-3 flash actionscript flash-cs5 flash-cs6

No comments:

Post a Comment