dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [CS3] preloader and scenes

  1. #1
    Junior Member
    Join Date
    May 2008
    Location
    Hawaii
    Posts
    27

    [CS3] preloader and scenes

    Hi,
    I have a turtle movie that i am working on for a class project. It will be a turtle animation, and I thought that I would put a preloader in it, not required, but I thought that it would be cool. I does not seem to work as both the scenes load at once. There are two scenes "preloader" and scene 1. I want to preloader scene to load and then go to scene 1(there will be more scenes later). Is this possible or do you have to load the swf externally?

    you can see the weirdness at:
    http://www2.hawaii.edu/~johnbarr/tur...rtle_boy2.html

    Attached is the fla, can somebody please help me save my class project

    thanks so much,
    Johnny

    Here is the actionscript I am using in the movie:
    PHP Code:
    stop();

    var 
    loaded:Number;
    var 
    percent:Number;
    bar.addEventListenerEvent.ENTER_FRAMEload_progress );

    function 
    load_progress(e:Event):void{
        
    loaded stage.loaderInfo.bytesLoaded stage.loaderInfo.bytesTotal;
        
    percent Math.round(loaded 100);
        
        
    bar.scaleX loaded;
        
    loader_info.text "Loading... " percent "%";
        
        if( 
    percent == 100 ){
            
    bar.removeEventListenerEvent.ENTER_FRAMEload_progress );
            
    play();
        }

    Attached Files Attached Files

  2. #2
    Junior Member
    Join Date
    Dec 2008
    Location
    Chattanooga
    Posts
    29
    In the second frame of the timeline insert new keyframes with the movieclips you want to be in there ... and instead of play() use gotoAndStop(2);

    What this will do is advance the playhead to the second frame.
    Code:
    stop();
    
    var loaded:Number;
    var percent:Number;
    bar.addEventListener( Event.ENTER_FRAME, load_progress );
    
    
    function load_progress(e:Event):void
    {
    	loaded = stage.loaderInfo.bytesLoaded / stage.loaderInfo.bytesTotal;
    	percent = Math.round(loaded * 100);
    	
    	bar.scaleX = loaded;
    	loader_info.text = "Loading... " + percent + "%";
    	
    	if( percent == 100 )
    	{
    		bar.removeEventListener( Event.ENTER_FRAME, load_progress );
    		
    		gotoAndStop(2);
    	}
    }
    Hope this helps.
    Attached Files Attached Files
    Last edited by earthwyrm; 12-05-2008 at 05:39 PM.

  3. #3
    Junior Member
    Join Date
    May 2008
    Location
    Hawaii
    Posts
    27
    Hi earthwyrm,
    Thanks so much, that worked perfect, you saved my turtle`-`

    All I had to do was to replace the line of code instead of play(); I used gotoAndStop(2); I guess it is going to the frame "2" and does not care that the two scenes are called pre loader and beach.

    Thanks so much,
    Johnny

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