4 Replies Latest reply on Oct 21, 2006 2:22 PM by macdaddy256

    A Question Of Scope

    macdaddy256
      I'm trying to report download progress of a FileReference download within a class. Does anyone know how to get the onProgress event, with the file reference and bytes loaded/bytes total parameters back to a function scoped to the class rather than the listener object or the FileReference object?

      I know scope is a common issue, but the solutions I've seen involve addEventListener, which as far as I know only applies to components, and I don't see a way of getting the parameters back via the Delegate class.

      Any help would be very much appreciated.
        • 1. Re: A Question Of Scope
          TimSymons Level 1
          This is only an outline of a class but should give you the idea. Also, you can use addEventListener() with classes that you define as well, it is not just for components.

          Tim

          • 2. Re: A Question Of Scope
            TimSymons Level 1
            This is only an outline of a class but should give you the idea. Also, you can use addEventListener() with classes that you define as well, it is not just for components.

            Tim

            • 3. Re: A Question Of Scope
              anonymous thing Level 1
              the only way I've found without using Delegate is this single line :

              objFunction[Function(strFuncToCallBack)].apply(objFunction, arrParams)


              objFunction is an Object to callBack
              strFuncToCallBack is a String with the name of the method to callBack
              arrParams is a one dimension Array([1,2,3...]) with arguments
              you want to pass(if no arguments use [] or new Array())

              it's important to keep the cast to Function type...


              • 4. Re: A Question Of Scope
                macdaddy256 Level 1
                Thanks guys.

                Both answers made me think a lot harder about listeners (I've been using delegates to avoid that) and I finally settled on this - should help anybody else with the same brain block as me - it sticks with the basic documented examples of listener use, but also gives the scope I was after.