Solved

Flash actionscript 2 load external swf with preloader

Posted on 2010-09-13
4
718 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Link puzzle piece images together and change color on hover 2 461
Crash with shockwave flash 8 259
File drag and drop 6 158
Cannot install Adove Flash player on Windows 2012R2 6 110
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

752 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