actionscript 3 - eventListeners Won't Leave -


these last 2 lines of action script frame :

removelisteners(); if(!stage.haseventlistener(event.enter_frame)){trace("stage has no eventlisteners");} 

with removelisteners() function having been described :

function removelisteners(){     if(button){         button.removeeventlistener(mouseevent.click,leavegamescene);             }     stage.removeeventlistener(event.enter_frame,menuonframe);     stage.removeeventlistener(event.enter_frame,collectdrachmas);     stage.removeeventlistener(event.enter_frame,updatehealth);     stage.removeeventlistener(event.enter_frame,updatecards);     stage.removeeventlistener(event.enter_frame,updatequestions);     stage.removeeventlistener(event.deactivate,stagedeactivate);     stage.removeeventlistener(keyboardevent.key_down,key_down);     stage.removeeventlistener(keyboardevent.key_up,key_up);     stage.removeeventlistener(event.enter_frame,charenterframe);     stage.removeeventlistener(event.enter_frame,updateinteractives);     stage.removeeventlistener(event.enter_frame,onframebadguy);     stage.removeeventlistener(event.enter_frame,onframestage);     stage.removeeventlistener(event.enter_frame,updateconversations);     stage.removeeventlistener(event.enter_frame,updatepit);     //etc etc etc  } 

thus thoroughly removing possible existing eventlisteners occur throughout project. know no eventlisteners added multiple times, because of reason given below , because existing eventlisteners terminated code upon exiting frame.

all eventlisteners through project declared , not added within other functions or (ex shown below), therefore removing possibility of problem originating having multiples of same eventlisteners :

stage.addeventlistener(event.enter_frame,updatehealth); 

when last 2 lines of action script frame executed, flash acts though there absolutely no enter_frame eventlisteners on stage, tracing stubbornly that

"stage has no eventlisteners"

accordingly. however, after running through code on frame multiple enter_frame eventlisteners of stage run had been declared on previous frame (this causes multiple errors, since null objects being called upon)! eventlistener seems reappear out of no , no cause. how can possible? root of problem?

perhaps should mention used exact same method button advance frame without trouble. both ways end :

removelisteners(); gotoandplay(1,"menu"); 

update

here errors given :

typeerror: error #1009: cannot access property or method of null object reference.     @ _109_fla::maintimeline/collectdrachmas()[_109_fla.maintimeline::frame1:369] typeerror: error #1009: cannot access property or method of null object reference.     @ _109_fla::maintimeline/updatehealth()[_109_fla.maintimeline::frame1:417] typeerror: error #1009: cannot access property or method of null object reference.     @ _109_fla::maintimeline/updatequestions()[_109_fla.maintimeline::frame1:592] typeerror: error #1009: cannot access property or method of null object reference.     @ _109_fla::maintimeline/updatecards()[_109_fla.maintimeline::frame1:810] typeerror: error #1009: cannot access property or method of null object reference.     @ _109_fla::maintimeline/charenterframe()[_109_fla.maintimeline::frame1:978] typeerror: error #1009: cannot access property or method of null object reference.     @ _109_fla::maintimeline/updateinteractives()[_109_fla.maintimeline::frame1:1892] typeerror: error #1009: cannot access property or method of null object reference.     @ _109_fla::maintimeline/onframebadguy()[_109_fla.maintimeline::frame1:2015] typeerror: error #1009: cannot access property or method of null object reference.     @ _109_fla::maintimeline/onframestage()[_109_fla.maintimeline::frame1:2638] typeerror: error #1009: cannot access property or method of null object reference.     @ _109_fla::maintimeline/updateconversations()[_109_fla.maintimeline::frame1:2760] 

these errors occur on account of following eventlisteners in respective functions:

function collectdrachmas(e:event) function updatehealth(e:event) function updatecards(e:event) function charenterframe(e:event) function updateinteractives(e:event) function onframebadguy(e:event) function onframestage(e:event) function updateconversations(e:event) 

i couldn't idea problem. here understanding it.

  1. stage global object. wherever or whenever add eventlistener object it's listening same object. care it.
  2. also using different function same event same object bad idea.
  3. enterframe nasty thing in experience .
  4. the stage global accessible code after display object added stage. means if going use stage object inside class constructer probable throw null error. means accessing object before available you. in case may trying access stage object before it's available you.

please share more code idea of whats happening. on this.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -