Skip navigation
Currently Being Moderated

removeEventListeners triggered by another class

Jun 14, 2012 9:17 PM

Tags: #air #cs5 #error #cs5.5 #3.0 #button #action #3 #code_snippets #actionscript #event #as3.0 #movieclip #ac3 #actionscript3 #actionscript_3.0

Hello everyone,

 

I've encountered a scenario where I'm kinda stuck with going around it.

I have 2 classes, Class A and Class B. Class A detects the user input while Class B is a movieclip that has a function in it where it detects the accelerometer input and returns as an animation.

 

When a user selects the Option menu (Class A input), I'd like Class A to activate a function in Class B where Class B will remove it's accelerometer's eventListener to stop the animation.

 

I understand the word "static" will come in play, but I threw in a static function in Class B and it appears that whatever movieClip that is the child of Class B becomes undefined.

 

Is there perhaps another way around this?

 

Thanks

 

P.S: I was thinking about removing the accelerometer's eventlistener to reduce battery consumption on a mobile device and optimize performance.

 
Replies
  • kglad
    62,158 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 14, 2012 9:28 PM   in reply to BlazeRazgriz

    if the class B instance is created in A, you can reference a public function in B to do whatever you want to that instance of B and its properties (including that movieclip).

     

    if A does not have a reference to B, then you can use a static function in B to reference any other static property of B.  if that movieclip in B is not static it will not be referenceable via a static function in B.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points