Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Flash actionscript 2 load external swf with preloader

Posted on 2010-09-13
4
Medium Priority
?
746 Views
Last Modified: 2013-11-11
Im looking to load an external swf file into my movieclip with the instance name holder_mc, i would like to show the progress of loading within my dynamic text field instance name loading_txt

how would i do this in actionscript 2
0
Comment
Question by:Brant Snow
4 Comments
 
LVL 2

Expert Comment

by:florimit
ID: 33664740
try something like this :

loading_txt.text = (holder_mc.getBytesLoaded() / holder_mc.getBytesTotal() * 100) + "%";
0
 
LVL 4

Author Comment

by:Brant Snow
ID: 33665010
so that would maybe show the loading but what about loading the swf.   So lets so my external swf file is called external.swf and i want holder_mc to load it, what is that going to look like?
0
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 2000 total points
ID: 33669222
Something like this should do it:

(You should have a textField called "txt" for this example to work).

<code>

-V
var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(this);
loader.loadClip("loadme.swf", container);

function onLoadProgress(mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
	txt.text = (bytesLoaded / bytesTotal) * 100 + "%";
}

Open in new window

0
 
LVL 3

Expert Comment

by:ayanaculis
ID: 33674087
I usually use this (attached) class for all my preloader needs. It's completely customizable and reusable in other projects. Since I can't attach FLA files, please drop me an e-mail at ayanaculis@shoclabs.com and I'll be happy to send you the rest of the code.

Just copy the class in the same folder as your *.fla, then just copy the frames in the FLA I'll send to you to your own. You can change the loading animation (progress_mc_ext) Note that it should always be 100 frames long. You can also change the font and size of the preloading text, just remember to embed the font.

If you need further explanation on how it works, please feel free to ask.
Preloader.as
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question