|
-
Preloading External Swfs Problem
In what combination of as2 code would instruct a preloader to recieve
bytes loaded and bytes total in addition to loading a external swf file into a blank movie clip? I've seen countless issues regarding the same problem but still haven't goten a clear answer. I dont want to use the video player component standard on Flash. I want a preloader to preload a external swf file and play it inside a movieclip.
I look forward to hearing your ideas + solutions
Keith
-
This is what works for me.
Create new layer and in frame one make an empty movie clip, give it an instance name (the code below uses the name "gallery"), and drag into the stage.
Create a new layer and in frame one make another movie clip for your loader text and give it an instance name (the code below uses the name "pct_mc"). Inside this movie clip create a text box. Leave the text box blank and make sure that you pick "dynamic text" in the properties.
Copy and paste the following code into the actions frame of your empty movie clip and at the bottom input the address of your external swf (code is annotated).
Code:
// set up loader, an instance of MovieClipLoader, and use the main timeline ("this")
// to listen to and respond to its broadcast events
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(this);
// define what happens when the jpg is completely loaded
function onLoadInit(_mc:MovieClip) {
_mc._xscale = 100;
_mc._yscale = 100;
pct_mc._visible = false;
};
// make pct_txt show cumulative loading progress
function onLoadProgress(_mc:MovieClip, loaded:Number, total:Number) {
pct_mc.pct_txt.text = "project gallery loading..." + Math.floor(loaded / total * 100) + "%";
};
loader.loadClip("address to your external swf", gallery);
Thats it. If done correctly and you test it using the simulate download, you will see the external swf load into your empty movie clip after it hits 100%.
-
Eliteseraphim,
Thanks for that. However it works perfertly integrated into a new doc. as your described keeping the fla. size small. When I use your code in my larger fla. project the percentage doesn't show up. The video still loads, but no loader. Also I've had no luck with creating a windows projector file and viewing a loader working either. I'm starting to suspect the projector file isn't compatible with loaders.
Thanks for your help,
keith
-
Windows Projector.exe & Preloaders
Last edited by Keith_D; 07-30-2009 at 03:33 PM.
-
I am fairly new to actionscript so I have no experience with projectors or whether loaders work with them. As for loading a large external swf file, I don't think there is a limit to file size. I am currently developing a personal portfolio site and am loading external swfs that are close to 1MB in size and can still see the percent loaded just fine.
Did you double check that your text is dynamic and labeled correctly?
-
Keith, one more thing I just discovered is that in the code, the movie clip "pct_mc" is set to disappear once the loading is finished. If you have more than one thing loading with this script, you are going to have to add another bit of code to what I already gave you.
When you enter a frame that loads external swf, this function tell pct_mc to reappear on the screen when the loading process starts.
Code:
function onLoadStart() {
pct_mc._visible = true;
}
Hopefully this solves your problem.
Cheers.
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
|