Preload External Flash Movies with Components

Home Food Mates • Members Tutorials Forum Buy Templates Contact Us 

 


Flash Tutorials

   

Tutorial - Preload External Flash Movies with Components

 

Free Flash Tutorial


Step 6    <<   Previous      Intro   1   2   3   4   5   6    >>       >>   Webwasp Mates

 

Step Six: The ActionScript Layer - Frame 2

  1. Right click on Frame 2 of the layer: ActionScript
  2. Select: Insert Blank Keyframe
  3. Add this code to Frame 2 of the layer: ActionScript

    /* Set the Progress Bar to manual mode so that we can reset its value back to 0. We don't want it staring from 100 ! */
    myProgressBar.mode = "manual";

    // Reset the Progress Bar back to zero
    myProgressBar.setProgress(0, 100);

    // Makes the Progress Bar visible
    myProgressBar._visible = true;

    // Create a listener object event function. The Progress Bar is an object so needs an object function to work
    myProgressBarListener = new Object();

    // When the Progress Bar is complete and has preloaded this Movie, the listener will call and run this code below:
    myProgressBarListener = function (eventObject) {
    // Anything you place here will run after the External Movie loads.

    // Hide the Progress Bar now that we are done
    myProgressBar._visible = false;

    // This next section is optional.
    // If you wish to remain on Frame 2 and view the External Movie do nothing
    // Otherwise un-comment any of the options bellow:
    // Plays the Movie from Frame 2 onwards:
    // play();

    // Go to the next Frame:
    // nextFrame();
    // Go to the next scene but may not automatically play beyond the Frame 1 in the next scene:
    // nextScene();
    // Goes to a Frame Label or Frame number and Play:
    // gotoAndPlay("myFrameLabel");
    // gotoAndPlay(10);
    // Go to and stop at the Frame Label or Frame number:
    // gotoAndStop("myFrameLabel");
    // gotoAndStop(10);


    // closes the function
    };

    /* Declares a listener that detects when the Progress Component has loaded the External Movie. When it is complete it will call the function myProgressBarListener */
    myProgressBar.addEventListener("complete", myProgressBarListener);

    // Set up the Progress Bar Component to polled
    myProgressBar.mode = "polled";

    // Set the preloader location of the Progress of the loader Component
    myProgressBar.source = "myLoader";

    // Set the file name and location of the external swf Movie
    myLoader.contentPath = "myMovie.swf";

    // Set the external swf Movie scales to fit the loader (true), or the loader scales to fit the content (false).
    myLoader.scaleContent = false;

    // automatically load the external swf Movie
    myLoader.autoLoad = true;

    // Stop the Movie at the Frame until the Movie has been preloaded
    stop();

  4. Important:
    Make sure you change the name of the file to the name of your file:
    myMovie.swf

    Strange but True: It is the location of the web page and the Movie that is loading that is important not the location of this preloader Movie! If you wish to move this preloader Movie to a different folder you can. It can also be used several times on several different web pages as long as each time the web page is located in the same place as a Movie called:  myMovie.swf. Each version of the Movie  myMovie.swf could be a different Movie with different content!

    Usually the Main Content Movie would be in the same folder as the web page. If it is not you will need to type a target path like this:

    myLoader.contentPath = "images/myMovie.swf";

    You may also use a full URL like this:

    myLoader.contentPath = "
    http://www.webwasp.co.uk/images/myMovie.swf";

    Confused? If you get in a muddle the easiest thing is to have the Web Page, Preloader Movie and Main Movie all in the same folder.


Your Layers should now look like this:

That's it.

 

Please indicate what you thought of this tutorial 
10 is the best: 
10 9 8 7 6 5 4 3 2 1

         

Step 6    <<   Previous      Intro   1   2   3   4   5   6    >>       >>   Webwasp Mates


Webwasp Community: Webwasp Mates & Dates

Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates

33890 visitors to this page since Oct 05 •

 Top of Page Home Food Mates Members Tutorials Forum Buy Templates Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.