dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 30

Thread: Preloader

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Posts
    20

    Preloader

    hello,
    i am using the here code as my preloader for the entire movie. i know that it cannot load any quicker. so..i would like to load each section of the site instead so that each section will load quicker than waiting for the entire movie to load.
    this code works great, but how can i use this code to load each section instead of the entire movie?
    what could be added, deleted, etc..to the code so i could use it for each section of the site?
    thanks
    Code:
    //stop the play head
    stop();
    
    this.loader.gotoAndPlay(1);
    
    //create the movie clip to hold the preloader
    this.createEmptyMovieClip("preLoader_mc",1);
    //put the preloader in the right spot
    preLoader_mc._x = 350;
    preLoader_mc._y = 200;
    //create some variables for the preloader
    preLoader_mc.tBytes = this.getBytesTotal();
    preLoader_mc.startX = 0;
    preLoader_mc.startY = 0;
    //create the text field to display the information
    preLoader_mc.createTextField("loader_txt",10,0,-40,200,40);
    //create a text format and set some properties
    var loadFormat:TextFormat = new TextFormat();
    loadFormat.font="_sans";
    loadFormat.bold=true;
    loadFormat.size=14;
    preLoader_mc.loader_txt.setNewTextFormat(loadFormat);
    //this callback will run the preloader
    preLoader_mc.onEnterFrame = function(){
         this.clear();
         //create the lineStyle
         preLoader_mc.lineStyle(2,0x000000,100);
         //get the amount of loaded bytes
         lBytes = _root.getBytesLoaded();
         //create the percentage variable
         var percentLoaded:Number = Math.floor((lBytes/this.tBytes)*100);
         if(lBytes != this.tBytes){
    		 	 
              //insert the text into the text field
              this.loader_txt.text="Loaded "+lBytes+" of "+this.tBytes+"\nat "+percentLoaded+"%";
              //start the fill
    		  this.beginFill(0x8B5B2A,100);
              //draw the loader
    		  this.moveTo(this.startX,this.startY);
    		  this.lineTo(this.startX,this.startY+25);
              this.lineTo(this.startX+(percentLoaded*2),this.startY+25);
              this.lineTo(this.startX+(percentLoaded*2),this.startY);
              this.lineTo(this.startX,this.startY);
              this.endFill();
    		  		  
    
         }else{
              //go to the second frame
              _root.gotoAndPlay(2);
              //remove this preloader
              this.removeMovieClip();
         }
    }

  2. #2
    http://pat.theorigin.net cresquin's Avatar
    Join Date
    Jun 2003
    Location
    Los Angeles, CA
    Posts
    685
    what you'll need to do is break your movie sections into separate swfs then you can use the preloader script to load each of the external swfs as needed.

  3. #3
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    ok, then i would need a button to tell flash to go to each of the swf's?
    how would do that? how would i tell flash to go to another .swf?
    would it be something like this?

    Code:
    on (press) {
    	getURL("movie2.swf");
    }
    thanks
    Last edited by mikewooten; 09-24-2007 at 02:27 PM.

  4. #4
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    how would i use a button to go to another .swf?
    would it be something like this?

    on (press) {
    getURL("movie2.swf");
    }


    also, what code on the timeline would i use to jump from one .swf to another .swf? once one .swf gets done playing, i would like it to go to another .swf. how would i make it do that?
    would i just use the getURL("nextmovie.html"); on the last frame of the timeline.

  5. #5

  6. #6
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    ok, this is what im using & its not doing anything. it just keeps looping and starting the movie over. is this correct?

    loadMovie("brendaintro.html","new","POST");

    i want this to go to another .swf. from a frame in the timeline.
    what do i change? do i add this to the frame in the timeline?
    thanks

  7. #7
    http://pat.theorigin.net cresquin's Avatar
    Join Date
    Jun 2003
    Location
    Los Angeles, CA
    Posts
    685
    do you want the second movie to play and the first to be destroyed?

    for that you'd use _root.loadMovie("brendaintro.swf");

    reference teh swf directly, not the html

    if you want to use a new HTML page, the you would use getURL() as you said above. I may have isunderstood your intentions.

  8. #8
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    i do not want the first one to be destroyed. i tried the _root.loadMovie("brendaintro.swf"); and it takes too long to load between each .swf movie. the screen was white for at least 2 seconds before the movie showed up.
    is there is a faster way for the movie to show up without there being any white in the background?
    i do want to load each section of the site without there being any gliches. is loadMovie the only way to load each of the sections?

  9. #9
    http://pat.theorigin.net cresquin's Avatar
    Join Date
    Jun 2003
    Location
    Los Angeles, CA
    Posts
    685
    there are two alternatives, one is easy but bad the other is less easy but still pretty simple, and better.

    the bad way is to use loadMovieNum() this is old and busted, and can get very complicated very quickly. if you must know, google it.

    the other way is to create an empty MovieClip within your first swf to serve as a placeholder for the second. your second swf will be loaded into this placeholder, but the first will remain as well. This has the added benefit of being able to re-use elements from the first movie, but that's much more advanced.

    First create an empty movie clip and place an instance on stage. give it an instance name of "placeholder"

    then you can use the following script to load a movie into it.
    PHP Code:
    placeholder.loadMovie("brendaintro.swf"); 

  10. #10
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    ok, i created an empty movie clip on the stage and gave it an instance name of placeholder. then i used this script placeholder.loadMovie("brendaintro.swf"); on the last frame of the timeline of the first movie and when i play the movie, it repeats itself and goes back to the beginning of the movie instead of going on to the second movie(the brendaintro.swf movie).
    am i doing something wrong? how can i get this to work?
    Last edited by mikewooten; 09-25-2007 at 11:01 AM.

  11. #11
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    how can i get this to work?

  12. #12

  13. #13
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    ok, it worked, but it seems like the second movie is transparent. i can still see the first movie when the second is playing. how can i get that to not happen and only show the second movie?

  14. #14
    http://pat.theorigin.net cresquin's Avatar
    Join Date
    Jun 2003
    Location
    Los Angeles, CA
    Posts
    685
    the loaded movie isn't "transparent", it simply doesn't have a background unless you place an element to serve as the background. So, you see "through" the loaded movie.

    The process you're talking about is getting somewhat coplex for your level, what is this project for?

  15. #15
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    i have an image for the background. how can i specify what frame i want the movie to start playing in the second movie?(in the brendaintro.swf movie)
    The project is for our company new website
    i have a few .swf's that need to be put together
    here's what i have so far:
    http://www.fulfillmentcentral.com/vi...ideodemo1.html

  16. #16
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    how can i specify what frame i want the movie to start playing in the second movie?(in the brendaintro.swf movie)

  17. #17
    http://pat.theorigin.net cresquin's Avatar
    Join Date
    Jun 2003
    Location
    Los Angeles, CA
    Posts
    685
    you'll need to build some sort of pre-loader (there are any examples in the forums if you search "preloader") and wait until the entire swf is loaded, then you can use gotoAndPlay() to get to your desired frame.

  18. #18
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    can i use my preloader script that i have above? what could i change or add to that to get this to work? or do i need a different preloader script?

  19. #19
    http://pat.theorigin.net cresquin's Avatar
    Join Date
    Jun 2003
    Location
    Los Angeles, CA
    Posts
    685
    you can use your pre-loader script above, include it on the first frame of the clip you are loading in. Near the bottom there is a gotoAndPlay() change the 2 to the frame you want to start on.

  20. #20
    Junior Member
    Join Date
    Sep 2007
    Posts
    20
    is there a way to specify which frame i want the movie to start playing from the first movie on the last frame where i have the loadMovie()?
    or is this the better way to do this in the preloader?

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