6 Replies Latest reply on Jun 10, 2008 1:02 PM by ooba

    ActionScript Guru needed

    ooba
      Issue is inside of a Class file i have created.
      I have created several private members and all can be seen except for the variables that are being referenced by event handlers for onload events.

      What gives? If i use a _global var i can see it but i am baffled as to why i can not see my class members from within the event handler functions.

      Please response asap.
        • 1. Re: ActionScript Guru needed
          Rothrock Level 5
          Not sure I follow exactly, but in AS2 event handlers usually change the scope away from the class instance to their own instance.

          I think you need to use the Delegate class to keep the scope within your class.

          someInstance.addEventListener("event",Delegate.create(this,callbackFunction);

          Don't forget to import mx.utils.Delegate
          • 2. Re: ActionScript Guru needed
            ooba Level 1
            The reading on this is assigning to a specific function for a specific event.
            But, what about when using
            _MCLiListener = new Object();
            _MCLiListener.onLoadStart = function(...
            _MCLiListener.onLoadInit = function(... etc.

            _MCLi = new MovieClipLoader();
            _MCLi.addListener( _MCLiListener, Delegate.create(this,_MCLiListener) );

            How exactly would i write that to it?
            • 3. Re: ActionScript Guru needed
              kglad Adobe Community Professional & MVP
              or you may be making your variables local the functions where they are typed using the var prefix.
              • 4. Re: ActionScript Guru needed
                ooba Level 1
                the vars are definitely not local to the function. They are accesible from within all the functions of the Class just not the event handlers
                • 5. Re: ActionScript Guru needed
                  Rothrock Level 5
                  I would try:

                  _MCLi.addListener(Delegate.create(this,_MCLiListener));

                  I thought you were using the other kind of event listeners. I've never tried this, but it seems like it should work? Let us know.
                  • 6. Re: ActionScript Guru needed
                    ooba Level 1
                    hmm. well right now i've done the following which is partially working. The variables that i was not able to get at I can now get at. The only remaining problem is that the getBytesTotal is never found or defined something odd.?