Jump to content
Search Community

unload() doesn't set bytesLoaded=0

Eckstein1 test
Moderator Tag

Recommended Posts

Hi,

after unloading i.e. an image or video bytesLoaded isn't set to 0.

 

This example makes no sense, but it repeatable shows the effect described:

 

import com.greensock.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.*;

var IMAGE1:ImageLoader = new ImageLoader("images/flower.jpg", {name:"flower", container:this, x:0, y:0, width:200, height:200, onComplete:imageLoaded});
IMAGE1.load();

function imageLoaded(e1:LoaderEvent):void {
IMAGE1.unload();
trace(IMAGE1.bytesLoaded); // for images a number equal to bytesTotal
}

Kind regards

Uli

Link to comment
Share on other sites

Hey ya mate,

 

Think you have to listen for the unload event and then do your trace from there:

http://www.greensock.com/as/docs/tween/ ... tml#unload

 

var IMAGE1:ImageLoader = new ImageLoader("images/flower.jpg", {name:"flower", container:this, x:0, y:0, width:200, height:200, onComplete:imageLoaded});
IMAGE1.addEventListener(LoaderEvent.UNLOAD, imageUnloaded);
IMAGE1.load();

function imageLoaded(e1:LoaderEvent):void {
  IMAGE1.unload();
  trace(IMAGE1.bytesLoaded); // unload event hasn't completed yet
}

function imageUnloaded(e1:LoaderEvent):void {
  trace(IMAGE1.bytesLoaded); // should work now
}

Link to comment
Share on other sites

Hey Zync,

 

Thanks for your reply. I immediatelly check it out, but...

 

import com.greensock.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.*;

var IMAGE1:ImageLoader = new ImageLoader("images/flower.jpg", {name:"flower", container:this, x:0, y:0, width:200, height:200, onComplete:imageLoaded});
IMAGE1.addEventListener(LoaderEvent.UNLOAD, imageUnloaded);
IMAGE1.load();

function imageLoaded(e1:LoaderEvent):void {
IMAGE1.unload();
trace(IMAGE1.bytesLoaded); // 18067
}

function imageUnloaded(e1:LoaderEvent):void {
trace(IMAGE1.bytesLoaded); // 18067
}

Link to comment
Share on other sites

Hmm thats weird, I'm getting the same result. Figured at that point the bytes loaded should be back to 0.

 

Edit: Just had a look see at the LoaderCore.as and around line 250 I justadded in:

 

if (scrubLevel != 2) {
_cachedBytesLoaded = 0; //Add this in for a quickfix
dispatchEvent(new LoaderEvent(LoaderEvent.UNLOAD, this));
}

 

But might wanna wait for Jack to see if its meant to function like this or not.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...