1 Reply Latest reply on Sep 6, 2006 12:14 PM by stratosnatcher

    Event Listener Scope

      I am writing a class, and adding the following code to its constructor:

      var oListener:Object = new Object();
      oListener.onMotionChanged = function(twObject:Tween):Void {
      _mDrawing._y = nYPixels - _mDrawing._height;

      var twInitBar:Tween = new Tween(_mDrawing, "_height", null, _mDrawing._height, nHeightPx, nTime, true);


      Vars starting with a '_' are private members, already initialized. Others are parameters passed to the constructor.

      Before this code, I can trace the _y and _height properties of _mDrawing just fine. However, I cannot access these from within the function literal declared above. I assume this is an issue of scope. I don't know much about using listeners...

      Can anyone help?
        • 1. Re: Event Listener Scope
          stratosnatcher Level 1
          Let me provide some clarification.

          I need to be able to do the following:

          Create a new Tween from within a custom class method or constructor.

          Execute some code (that is, more or less, a function), on the onMotionChanged event for the Tween i just started.

          This code should have access not only to class member variables but to variables passed in as parameters to the custom class method/constructor that started the Tween.

          Is this even possible?