Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Feb 2004
    Location
    United Kingdom
    Posts
    6
    Member #
    4990
    Ever wondered how to make one of those percentage loaded counters on a Flash Movie? The one's that tell you what percent of the movie has loaded? Here's how:

    [list=1][*]Add a blank keyframe at the beginning of your movie and name it Preload.[*]Name the frame which holds the first frame of your movie MovieStart.[*]Add a text field to the part of the page where you want your counter.[*]Set the properties of the text field to be a Dynamic Text Field[*]Set the variable field in the text box to say PercentLoaded.[*]Add this code to the keyframe containing your text field:
    MovieSize = _root.getBytesTotal ();
    LoadedSize = _root.getBytesLoaded();
    PercentLoaded = LoadedSize / MovieSize * 100
    if (PercentLoaded < 1) {
    gotoAndPlay("Preload");
    }
    else {
    gotoAndPlay("MovieStart");[/list=1]

    Lines 5 and 8 of the code have tab spaces before them, but I couldnt do that in the thread...sorry.

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    I would change the if statement to this, just to be more exact.
    Code:
    if (_root.getBytesLoaded() < _root.getBytesTotal()) {
        gotoAndPlay("Preload");
    } else {
        gotoAndPlay("MovieStart");
    }

  4. #3
    Senior Member
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    162
    Member #
    2563
    What changes to this would I need to do so it would fetch external files into the IE cache?

    IE. To have it preload jpg and gifs to make a site run faster.

    EDIT: And to have it load external flash files that will run elsewhere on the site.

  5. #4
    Member sopiaz57's Avatar
    Join Date
    Sep 2003
    Posts
    41
    Member #
    3058
    This isnt really working well for me, I am using a new version of flash, mx 2004.

    I basically did exactly what you posted, however when i go to test the movie using a 14.4 bandwidth setting, all i see real fast is a large decimal number where my text field was.

    I embedded a 15 MB movie into the movie frame.

    Thanks
    "It's very important not to embellish on your order. No extraneous comments. No questions. No compliments."
    - Jerry, in "The Soup Nazi"

  6. #5
    Member themayanlion's Avatar
    Join Date
    Mar 2005
    Posts
    40
    Member #
    9225
    the preloader i use, which seems to work in everything i do is this. all that's different is that percentLoaded is my variable name, but i mean you can change that.

    in the first frame, add this:

    Code:
    stop();
    myInterval = setInterval(preloader, 10);
    function preloader(){
    	if(getBytesLoaded()>=getBytesTotal()){
    		play();
    		clearInterval(myInterval);
    		}
    	percentLoaded = Math.ceil ((getBytesLoaded()/getBytesTotal()) * 100);
    	preloader_text.text = percentLoaded + "%";
    }
    if you want a loading bar as well, just create one and call it loader (only on the first frame), then add (in blue)

    Code:
    stop();
    myInterval = setInterval(preloader, 10);
    function preloader(){
    	if(getBytesLoaded()>=getBytesTotal()){
    		play();
    		clearInterval(myInterval);
    		}
    	percentLoaded = Math.ceil ((getBytesLoaded()/getBytesTotal()) * 100);
    	preloader_text.text = percentLoaded + "%";
            loader._xscale = (getBytesLoaded()/getBytesTotal())*100;
    }
    you can of course, modify that to _alpha, _yscale, whatever you want.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:34 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com