A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Timeline-based Preloadeder using equivalent of _framesloaded?

  1. #1
    Junior Member
    Join Date
    Jun 2005

    Timeline-based Preloadeder using equivalent of _framesloaded?


    I'm trying to recreate one of the old-school, timeline-based preloaders. Here's what I want:

    Frame 1 starts the preloader. There's a silly frame-by-frame "jumping letters" animation until Frame 10. On Frame 10, there's a script that checks _framesTotal against _framesLoaded (whatever those commands were in AS2). If the two are equal, then I jump the playhead to Frame 11 for the rest of the movie.

    How do I do that in AS3? Everything I see talks about:

    1: Doing it in external class files - Not what I want to do.
    2: Doing it as part of loading in some external MovieClip - Not what I want to do.
    3: Using a component - Not what I want to do.

    I'm thinking the crux of the matter is Frame 10's script, but I can't seem to suss out what the new AS3 commands are.

    Can anyone help?


  2. #2
    Join Date
    Nov 2007
    The _ is pretty much nonexistent in as3. I did however look up the information that you need.

    framesLoaded property

    framesLoaded:int [read-only]

    Language version: ActionScript 3.0
    Player version: Flash Player 9

    The number of frames that are loaded from a streaming SWF file. You can use the frameLoaded property to determine whether the contents of a specific frame and all the frames before it loaded and are available locally in the browser. You can also use it to monitor the downloading of large SWF files. For example, you might want to display a message to users indicating that the SWF file is loading until a specified frame in the SWF file finishes loading.

    If the movie clip contains multiple scenes, the framesLoaded property returns the number of frames loaded for all scenes in the movie clip.

    public function get framesLoaded():int

    See also

    Loader class

    How to use examples

    The following code illustrates how to use the framesLoaded property and the totalFrames property to determine if a streaming MovieClip object named mc1 is fully loaded:
    if (mc1.framesLoaded == mc1.totalFrames) {

    and we also have

    totalFrames property

    totalFrames:int [read-only]

    Language version: ActionScript 3.0
    Player version: Flash Player 9

    The total number of frames in the MovieClip instance.

    If the movie clip contains multiple frames, the totalFrames property returns the total number of frames in all scenes in the movie clip.

    public function get totalFrames():int

    How to use examples

    The following code illustrates the use of the totalFrames property of a MovieClip object named mc1:

    I hope that this answers your question suffeciantly enough. If not you can always ask for a more detailed explanation or examples.

    Stephen E.

  3. #3
    Junior Member
    Join Date
    Jun 2005
    Thanks for the help. I think what's confusing me is the term "streaming MovieClip." Perhaps you can shed some light.

    Supposing that the movie I want to load is nothing more than a large timeline movie with Tweens, etc...and I just want that simple little preloader in front to stall until all the Frames are loaded.

    I don't consider that sort of movie to be a "streaming" movieClip, even though I realize that AS3 now considers the stage/timeline to be a movieclip.

    So can you shed some more insight?


  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    press the picture...
    Here is an example for a preloader:

    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Junior Member
    Join Date
    Jun 2005
    Thanks for the link! I'll be looking at it for myself later on.

    However, I'm trying to avoid using the Document Class and other "class" based versions as I'm trying to teach the idea to complete Flash noobies who are only going to be doing timeline work.

    Which is why I keep referring to this design:

    Frame 1 is the start of the sequence.
    Frame 10 has a frame script that checks _framesLoaded against _framesTotal (whatever they've now become)

    If they're not equal, playhead returns to Frame 1. If they are equal, Playhead goes to Frame 11.

    Something simple...simple...simple...


  6. #6
    Senior Member
    Join Date
    Oct 2003
    In my opinion, the preloader should be limited to the first frame. Any animations should be put inside a movieClip placed on the first frame. Here is a simple preloader example using the framesLoaded and frameTotal properties...

    //where there is a movieclip on the first frame.
    //inside that movieclip is whatever animation (like a spinning star) 
    //where we have a dynamic text box on the stage named 'progressTxt'
    this.addEventListener(Event.ENTER_FRAME, checkProgress);
    function checkProgress(event:Event):void {
    	var myLoaded:Number = this.framesLoaded;
    	var myTotal:Number = this.totalFrames;
    	var myPercentage:Number = Math.round(myLoaded/myTotal*100);
    	var myMessage:String = String(myLoaded)+" frames of "+String(myTotal)+ " total frames   :   "+ String(myPercentage) + "%";
    	progressTxt.text = myMessage;
    	if (myLoaded == myTotal) {
    		this.removeEventListener(Event.ENTER_FRAME, checkProgress);

    Now if you want the animation to change based on the load progress, you can add a line to move the playhead..
    //where there is a clip on the stage called 'myAnimation'
    //'myAnimation' has a movie with 10 frames to represent each 10 percent loaded.
    //add these lines inside the checkProgress function
    var my10percent = Math.floor(myLoaded/myTotal*10);
    Keep in mind that because different amounts of information may be on different frames, that the above method is not 100% accurate. If there is a great disparity between frame sizes, you should used the LoaderInfo class which returns bytesloaded.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center