-
Textual Preloader
Hi,
I have a container movie clip on the stage, and it loads another SWF.
What I'm trying to do while the preloading is happening, is to have a dynamic text field update itself with new text strings after every 200KB are loaded.
This is the code I wrote for the preloading:
PHP Code:
var swfLoader:Loader = new Loader();
holderMC1.addChild(swfLoader);
var bgURL:URLRequest = new URLRequest("main.swf");
var total:Number = swfLoader.loaderInfo.bytesTotal;
var loaded:Number = swfLoader.loaderInfo.bytesLoaded;
if (loaded < 200000) {
dynamicText.Text = "Loading...";
}
if (loaded > 200000 && loaded < 400000) {
dynamicText.text = "Still Loading...";
}
swfLoader.load(bgURL);
For some reason, the dynamic text field does not update the second time.
Any ideas why?
Thanks a lot!
-
Senior Member
Use "View" from the menu when the movie is showing and go to "simulate download".
- The right of the People to create Flash movies shall not be infringed. -
-
Hi,
I did do that - it still doesn't work.
The first line shows up ("Loading..."), but it stays all the way through the preloading process and does not change according to the bytes loaded (into "Still Loading...").
-
You need to use a ProgressEvent because all you did was set the text before the loader even starts loading.
PHP Code:
var swfLoader:Loader = new Loader(); holderMC1.addChild(swfLoader); var bgURL:URLRequest = new URLRequest("main.swf"); swfLoader.addEventListener (ProgressEvent.PROGRESS, onProgress, false, 0, true);
function onProgress (e:ProgressEvent) { var total:Number = swfLoader.loaderInfo.bytesTotal; var loaded:Number = swfLoader.loaderInfo.bytesLoaded;
if (loaded < 200000) { dynamicText.Text = "Loading..."; }
if (loaded > 200000 && loaded < 400000) { dynamicText.text = "Still Loading..."; } } swfLoader.load(bgURL);
So that event will fire every time the loader makes some....progress in loading.
-
Okay, I've used your code (with all the correct instance names etc.), and now the text box stays empty all through the preloading process...
-
I made a mistake, it should be
PHP Code:
var swfLoader:Loader = new Loader(); holderMC1.addChild(swfLoader); var bgURL:URLRequest = new URLRequest("main.swf"); swfLoader.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, onProgress, false, 0, true);
function onProgress (e:ProgressEvent) { var total:Number = e.bytesTotal; var loaded:Number = e.bytesLoaded;
if (loaded < 200000) { dynamicText.Text = "Loading..."; }
if (loaded > 200000 && loaded < 400000) { dynamicText.text = "Still Loading..."; } } swfLoader.load(bgURL);
I only use loaderInfo for the main SWF's preloader, I use contentLoaderInfo for any loading I have to do inside of the main SWF.
-
It still loads just the first line ("Loading..."), and doesn't change into "Still Loading..." etc.
Sorry for the truoble, but it just doesn't seem to work...
Tags for this Thread
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
|