3 Replies Latest reply: Jun 12, 2009 6:17 AM by Raymond Basque RSS

    Custom ProgressEvent does not report bytesLoaded and bytesTotal !!!

    Ziggizag Community Member

      So,

       

      I have created a custom  progress event in a purpose to pass a handy parameter to event handler:

       

      package CustomEventHandler:

       

      package {
           import flash.events.ProgressEvent;
           import flash.events.Event;
           public class CustomProgressEvent extends ProgressEvent

           {
                public static const PROGRESS:String = "PROGRESSO";
                public var argumento:*;
                public function CustomProgressEvent(type:String, arg:*, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:uint=0, bytesTotal:uint=0

                {
                     super(type, bubbles, cancelable);
                     argumento = arg;
                }
                override public function clone():Event

                {
                     var evento:CustomProgressEvent = new CustomProgressEvent(this.type, this.argumento, this.bubbles, this.cancelable, this.bytesLoaded, this.bytesTotal);
                     return evento;
                }
           }
      }

       

      then I have a following pieces of code inside ImageLoader class:

       

      private function addListeners(d:IEventDispatcher):void

      {
           d.addEventListener(Event.COMPLETE, onComplete);
           d.addEventListener(ProgressEvent.PROGRESS, onProgress);
           d.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandling);
      }


      private function onProgress(e:ProgressEvent):void

      {

           trace(e.bytesLoaded, e.bytesTotal); <- this is giving the right output !!!

           var customProgressEvent:CustomProgressEvent = new CustomProgressEvent("PROGRESSO", CustomProgressEvent.PROGRESS);
           customProgressEvent.argumento = myParameter;
           dispatchEvent(customProgressEvent);
      }

       

      and finally in the movie timeline I have the following piece of code:

       

      imageLoader.addEventListener(CustomProgressEvent.PROGRESS, progressImage);

       

      function progressImage(e:CustomProgressEvent):void

      {
           trace(e.argumento, e.bytesLoaded, e.bytesTotal);
        <- this is giving the right value of e.argumento while e.bytesLoaded and e.bytesTotal are always 0 !!!
      }

       

      You see - I am unable to get progress status from my CustomProgressEvent !

       

      Any idea what's wrong in my code?

       

      Regards,

      Ziggi