Custom ProgressEvent does not report bytesLoaded and bytesTotal.

Thus,.

I have created a progress event custom in order to pass a parameter useful to the event handler:

package CustomEventHandler:

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

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

{
Super (type, bubbles, cancelable);
grounds = arg;
}
override public function clone (): event

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

Then I have a following chunks of code inside the ImageLoader class:

private void addListeners(d:IEventDispatcher):void

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


private void onProgress(e:ProgressEvent):void

{

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

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

and finally, in the scenario of the film, I have the piece of code:

imageLoader.addEventListener (CustomProgressEvent.PROGRESS, progressImage);

function progressImage(e:CustomProgressEvent):void

{
trace (e.argumento, e.bytesLoaded, e.bytesTotal);
<-is to give the right value e.argumento e.bytesLoaded and e.bytesTotal are always 0 ! 
}

You see - I am unable to get the status of my CustomProgressEvent!

No idea what is the problem in my code?

Kind regards

Ziggi

You have not assigned these values to your custom event.

private void 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;

customProgressEvent.bytesLoaded = e.bytesLoaded;

customProgressEvent.bytesTotal = e.bytesTotal;
dispatchEvent (customProgressEvent);
}

Tags: Adobe Animate

Similar Questions

Maybe you are looking for