Wait to load all External SWF Files - SWiSHMax Tutorials
 
  Buy Ebooks, Video Games, DVDs, Electronics and more !
Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads Make Money Online Blog . Free Image and Photo Sharing and Hosting

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Free image hosting
   Web Design Pakistan
   Swish Templates
   SWiSH Climax
   Talkfreelance Community
   Template Desire
   Lite boards
   Script Sector
   GimpTalk
   13dots
   Idea Designs
   PHP Cafe
   Sposatoettore
   Free swishmax templates
   Swishzone

Manage your site with Flax Article Content Management System
Wait to load all External SWF Files
Category : SWiSHMax | Level : Intermediate | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

Wait to load all External SWF Files, then go Forward and play main movie

Description
This tutorial demonstrates an easy way to enable you to load
all external swf/jpg files first and then enter the main movie.

Follow the Steps
1. Put a stop(); action on first frame of main timeline as
CODE
  onFrame(1) {
     stop();
  }


2. Create a dynamic textbox name _myMsgObj and set target variable myMsg.
Remember, it must be multiline, make it about 3 lines viewable.
3. Create a rectangle of 20x20 pixels and group it as sprite
4. set Sprite name to 'myPg'
5. Collect all the sprite names, which are loading external swf files
and put them in the arr as shown below:

e.g. If I have 3 sprites that are loading external swf files,
their names are mySpr1, mySpr2, mySpr3.

now replace _____TEMP_____ with sprites' names (mySpr1, mySpr2, mySpr3)
in the following code (remember to put names in quotes ' or ")

CODE
onLoad() {
   sNames = new Array(_____TEMP_____);
}
onEnterFrame() {
   pLoads = tBytes = lBytes = 0;

   for(i=0; i<sNames.length; i++) {
        tBytes += eval(sNames[i]).getBytesTotal();
        lBytes += eval(sNames[i]).getBytesLoaded();
   }
   pLoads = int((tBytes / lBytes) * 100);
   myMsg = "";
   myMsg = myMsg + pLoads +"% Loaded of "+sNames.length+" SWFs\n";
   myMsg = myMsg + lBytes +"bytes Loaded of "+tBytes+"bytes";
   myPg._width = pLoads;
 
   if(pLoads==100)
     play();
}


so the final code becomes

CODE
onLoad() {
   myArr = new Array('mySpr1', 'mySpr2', 'mySpr3');
}
onEnterFrame() {
   pLoads = tBytes = lBytes = 0;

   for(i=0; i<sNames.length; i++) {
        tBytes += eval(sNames[i]).getBytesTotal();
        lBytes += eval(sNames[i]).getBytesLoaded();
   }
   pLoads = int((tBytes / lBytes) * 100);
   myMsg = "";
   myMsg = myMsg + pLoads +"% Loaded of "+sNames.length+" SWFs\n";
   myMsg = myMsg + lBytes +"bytes Loaded of "+tBytes+"bytes";
   myPg._width = pLoads;
 
   if(pLoads==100)
     play();
}

now copy this code and paste in the main timeline just after the onFrame(1) {.....
that's it....

post back if you have any question.

regards
Ali Imran


Further more:
If you want to add a percentage preloaded (with progressbar) to your externally loaded swf files, click below to read tutorial
http://www.swish-db.com/forum/index.php?showtopic=9994


© 2002-2005 Flaxweb Network | Article Manager | Gimp Tutorials Library | RAD C++ Library | Free C/C++ Sourcecode |
Sites of interest : Web Design Blog | Swish Templates | Swishmax Ebook | Photoshop Templates | Gimp Tutorials | Text Forum | Make Money Online