Solved

Flash actionscript 2 load external swf with preloader

Posted on 2010-09-13
4
704 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 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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,…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now