A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [RESOLVED] Preloader: ALMOST resolved

  1. #1
    Member
    Join Date
    Dec 2004
    Posts
    68

    resolved [RESOLVED] Preloader: ALMOST resolved

    OK, the resolved problem with my preloader in this thread:

    http://board.flashkit.com/board/showthread.php?t=750154

    has just created a new one.

    My preloader mc has 10 frames, each with an animated movieclip. I also have an animated MC that should play constantly across the 10 frames during the loading process.

    When the preloader mc enters a new frame, it should play one mc, then gotoAndStop(10); another mc. When the movie clip moves to the next frame, the gotoandStop(10); mc should start playing, and another mc gotoandStop(10);

    The gotoAndStop(10); script works, but the play(): doesn’t. None of the animated mcs will play, including the animated mc that should play constantly, that is until the loading is 100% finished, and then everything plays.

    When I had the original script, everything worked as it should, but there was a lag when the preloader mc moved to the next frame and all animated mcs hesitated. Why did the new script interfere with the execution of the animated mcs inside the preloader mc

  2. #2
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    If I am understanding your question, you want the movie to play a small animation between each 10%. As well as have another animation always playing.

    For the always playing part. Place all of that animation inside a moveClip. Put that movieclip on a separate layer. Then make sure that layer has frames for the whole preloader.

    For the playing of small bits. You could put stop actions in the frames where you want the playhead to pause at, then use an if statement based on the load progress to tell the playHead when to move again.

    In the attached example
    1) I use a timer event to simulate the download, Im sure you can re-write that part.
    2) This only has 4 parts vs. your 10 parts..
    3) I use a 'movePoint' variable, which I increase each time the playhead moves to constantly give the if statement a higher point to check against.
    Attached Files Attached Files

  3. #3
    Member
    Join Date
    Dec 2004
    Posts
    68
    Hi DallasNYC! I really appreciate you helping me. I am really impressed with the file you whipped up to help explain your answer. Unfortunately, it doesn't address my problem.

    For the always playing part. Place all of that animation inside a moveClip. Put that movieclip on a separate layer. Then make sure that layer has frames for the whole preloader.
    That is how I have the movieclip nested in the preloader MC and that is the problem, the movie clip doesn't play. None of the movieclips nested in the preloader MC play until the loading is complete.

    If I use the script from the first attempt:

    PHP Code:
    if (my10percent ==30){
    tree_mc.gotoAndStop(4);
    }
    (and 
    so on
    The movieclips play the way I want them to, but it creates a lag in the animation when the preloader MC moves to the next frame. If I use the script you gave me:

    PHP Code:
    var myFrame Math.floor(pcent/10+1);
    gotoAndStop(myFrame); 
    NONE of the nested animated movieclips play until the file is completely loaded, then everything plays.

    Here is the file. Do a Ctl + enter, and do the bandwidth/simulate download thing.

    Now paste this script over the script in the first frame:

    PHP Code:
    stop();
    this.loaderInfo.addEventListener (ProgressEvent.PROGRESSprldr);

    function 
    prldr(event:ProgressEvent):void {
    var 
    pcent:Number=event.bytesLoaded/event.bytesTotal*100;
    var 
    myFrame Math.floor(pcent/10+1);
    tree_mc.gotoAndStop(myFrame);


    You will see the extreme difference in how the preloader MC reacts.


    OK, why can't I get my file to attach? I uploaded it through 'Manage Attachments', but it doesn't show up in my post. How do I clear my upload and try again? I feel like such a dweeb.
    Last edited by friedegg3; 11-14-2007 at 10:06 PM. Reason: can't attach file

  4. #4
    Senior Member
    Join Date
    Jul 2004
    Posts
    140
    maybe I can get some help too... I am trying a preloader, but even using using the ProgressEvent it does not load the content. I am builing my script using Flash CS3, but it is all dynamic, and any MC are imported into the frist frame via library. Now I use my made classes, and call them, however when they get called, flash freezes while it is loading (they are not loaded during the preloader)... so even if I have a loading animation, that freezes as well... any help here would be appericiated.

  5. #5
    Senior Member
    Join Date
    Jul 2004
    Posts
    140
    here is my swf:
    http://www.pilotsnetwork.com/LoZGC.swf
    Everything is created dynamically using as3 code, now the classes that I made, when called, create the windows, which is all imported and run on frame 2. On frame 1 I have the preloader, which is shown, but it seems that flash is assuming the program loaded, and going to frame two... at which point flash player somewhat freezes until my components are loaded.
    So If I had a loader image, that just constantly loops to show loading, it would freeze while frame 2 is building.

    Now the grid see in one of the windows is a bunch of movie clips while hold different display data, which I loop to add each mc to the grid (each square is a mc) --> while this is looping and loading does it force the freezing of flash player? (which I am assuming it does), is there anyway I can expedite this process, or make it so it does not freeze at runtime?

    part of my class that executes loading of grid/movie clips
    Code:
    MC_Ground is the movie clip that i have exported to the first frame via library.
    private function build_layer(build_layer:Sprite) {
    			for (var i:int = 0; i<tile_row; ++i) {
    				for (var j:int = 0; j<tile_col; ++j) {
    					var layer:MC_Ground = new MC_Ground();
    					layer.gotoAndStop(4);
    					layer.name = 't_'+i+'_'+j;
    					layer.x = (j*tile_width);
    					layer.y = (i*tile_height);
    					layer.width = tile_width;
    					layer.height = tile_height;
    					layer.gotoAndStop(1);
    					build_layer.addChild(layer);
    				}
    			}
    			layerStage.addChild(build_layer);
    		}
    MC_Ground is the movie clip that I have executed to the first frame via the library.
    Last edited by crowebird; 11-15-2007 at 03:50 AM.

  6. #6
    Member
    Join Date
    Dec 2004
    Posts
    68
    Sorry to take so long in getting this file up, but life happens.

    Here is the file:

    http://www.awn.com/friedegg/cs3/xmas_preloader.zip

    If you do the bandwidth profiler/simulate download, you will see the file works the way I want it to, except when the preloader movieclip moves to the next frame, then there is an hesitation.

    If you paste the following script over the script in the first frame in the time line and try the bandwidth profiler/simulate download again, NONE of the nested animated movieclips play until the file is completely loaded.

    PHP Code:
    stop(); 
    this.loaderInfo.addEventListener (ProgressEvent.PROGRESSprldr); 

    function 
    prldr(event:ProgressEvent):void 
    var 
    pcent:Number=event.bytesLoaded/event.bytesTotal*100
    var 
    myFrame Math.floor(pcent/10+1); 
    tree_mc.gotoAndStop(myFrame); 



  7. #7
    Member
    Join Date
    Dec 2004
    Posts
    68
    OK, I finally go this to work properly. I really haven’t been working on this non stop for the last few months; I would pick it up, set it down, and so on, but I just figured out the problem this morning.

    The problem was that I put all the preloading script on the main time and tried to control the preloader mc from there. Once I placed all the script in time line of the preloader mc timeline, everything worked just hunky-dory. The only script in first frame of the maintime line is stop();.

    In the first frame of the preloader mc (which also contains a nested animated mc), is:

    Code:
    stop();
    this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, ten);
    function ten(event:ProgressEvent):void {
    	var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
    if (pcent >= 10) {
    gotoAndStop(2);
    }
    
    }
    In the second frame of the preloader mc is this script:

    Code:
    this.loaderInfo.removeEventListener (ProgressEvent.PROGRESS, ten);
    this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, twenty);
    function twenty(event:ProgressEvent):void {
    	var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
    if (pcent >= 20) {
    gotoAndStop(3);
    }
    
    }
    And so on through the 10 frames of the preloader mc until 100% loaded takes the movie to frame 2 on the main time line.

    Here is a sample file. You will have to load something of file size in the third frame to simulate download.
    Attached Files Attached Files

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