-
Senior Member
contentLoaderInfo Help
Hi All,
I am trying to learn about the contentLoaderInfo property and have this code:
Code:
var thisLoader:Loader = new Loader();
var loaderStat:TextField = new TextField();
this.addChild(loaderStat);
thisLoader.contentLoaderInfo.addEventListener(Event.OPEN, handleOpen);
thisLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleProgress);
thisLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleComplete);
thisLoader.load(new URLRequest("Sebastian.jpg"));
thisLoader.x = 200;
thisLoader.y = 200;
thisLoader.scaleX = .05;
thisLoader.scaleY = .05;
this.addChild(thisLoader);
function handleOpen(e:Event):void{
loaderStat.text = "Loading: 0%";
}
function handleComplete(e:Event):void{
removeChild(loaderStat);
loaderStat = null;
}
function handleProgress(e:ProgressEvent):void{
var percent:Number = e.bytesLoaded / e.bytesTotal * 100;
loaderStat.text = "Loading: "+percent+"%";
}
From what the book I'm reading tells me, this should update the loaderStat textField as the image loads, but it is not. It is only showing 0% loaded and then the loaded image a bit later, no progress.
Where am I or the book going wrong here? I guess I'm looking for an upDateAfterEvent or something.
Thank you in advance.
_t
-
Works ok for me. If you comment out the Event.COMPLETE you'll be able to see it finished at 100%, but it just may be too fast to see it count up. (If you're testing it locally you won't see it.)
Do some traces to see if the ProgressEvent is triggering correctly for you.
-
Senior Member
That's odd. When I simulate download I do see it too, but when I do not and the image is already cached it takes a moment to appear. It seems like .25 of a second anyway, so I thought I should see some loading going on during that time, but I guess the delay is something else.
Thanks.
_t
-
Senior Member
Have you tested on the server? That is the best test.
- The right of the People to create Flash movies shall not be infringed. -
-
Senior Member
Not on the server yet. I'd like to get it working in the testing enviornment before I post to the server.
Actually, I'm just trying to learn so I have no intention of posting to the server.
_t
-
Senior Member
The reason why I said to test it on the server is because that is reliable. I never trust the download simulation.
- The right of the People to create Flash movies shall not be infringed. -
-
Senior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|