dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: preloader with many externe movies ??!

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    1

    Post

    i made a preloader with the task 'getbytes' and 'bytesloaded' etc. It worked, but how can i load other movies and let the preloader work for it ?? i.e. the preloader should add and stream extern movies while the preloader starts ???!!

    please help me....Thx )

  2. #2
    Registered User
    Join Date
    Jun 2000
    Location
    UK, Exeter
    Posts
    350
    You mean like I have done here? Basically I have set up an empty movie clip and a preloader movie clip with all my calculations in. Create an array of your movies you want to load and then just load them into the target (empty) with the loadmovie command. When your load percentage reaches 100& just load the next movie in your array in....

    Easy.

  3. #3
    Junior Member
    Join Date
    Jan 2001
    Posts
    12

    Talking

    How do you determine when the load percentage is 100%. This has to make it's calculations dynamically. Here's my code:

    Code:
    loadMovie ("intro.swf", "fakemc");
    tp = Math.round((_root.fakemc.getBytesLoaded()/_root.fakemc.getBytesTotal())*100);
    loaded = "Loading intro: " add tp add "%";
    if (tp>=100) {
        tellTarget ("next") {
            gotoAndPlay ("menu");
        }
        gotoAndPlay ("menu");
    }
    now I'm not using an array but rather seperate keyframes to load each movie in sequence but I don't believe that's the problem. I just can't figure out the current bytes loaded to the total bytes loaded dynamically per movie. If each movie where finished this would be a differrent story. but each external movie is still being developed and I don't want to go in and change code on my preloader everytime to change the total bytes value. Any help would be appreciated. By the way your's looks very slick.

  4. #4
    Senior Member
    Join Date
    Dec 2000
    Posts
    120

    Lightbulb boy do we need a tutorial on this....

    I've also looked through the whole forum and not found a good tutorial on how to do this. I'm also kinda stuck, so one of you smarties out there help me and I'll make the tutorial. (and help anyone with ASP connectivity )

    The background: my first real flash site (obviously, like many people asking questions). I've got the whole preloader thing going thanks to the flashkit tutorials (and moocks script) all is well there.

    My main (and familiar) preloader code therefore is:
    Code:
    if (_framesloaded>0 && _framesloaded == _totalframes) {
    gotoAndPlay ("continue");
    } else {
    percentVAL = Int((getBytesLoaded()/getBytesTotal())*100);
    percent = percentVAL add " % loaded";
    setProperty ("statusbar", _width, percentVAL);
    }
    So I figure I'll do like all those cool sites and just load my content into a movieclip when someone presses a button. But hey, we want people to know how long that's going to take, so I'll make a "modular" preloader. Sounds easy enough as the above post asserts.

    So I have my empty movieclip named "maincontent" placed just right as well as another movieclip named "movieloader"

    the buttons say the following:
    Code:
    on (release) {
    mc2load = "http://www.whereever.com/whatever.swf";
    loadMovie (mc2load, "maincontent");
    tellTarget ("movieloader") {
        gotoAndPlay ("loop");
    }
    }
    thinking movieloader should be like my main preloader I used:
    Code:
    if (_root.mc2load._framesloaded>0 && _root.mc2load._framesloaded == _root.mc2load._totalframes) {
    gotoAndPlay ("continue");
    } else {
    percentVAL = int((_root.maincontent.getBytesLoaded()/_root.maincontent.getBytesTotal())*100);
    percentloaded = percentVAL add " % loaded";
    setProperty ("stat2", _width, percentVAL);
    }
    now it kind've works but it doesn't. i've figured out that I can't use _framesloaded that way but I don't know what to use as an if condition.
    if I try and use if (int((_root.maincontent.getBytesLoaded()/_root.maincontent.getBytesTotal())*100)) >= 100) it seems to see that 100% is loaded before any of it is. I'm assuming it's just ahead of itself and hasn't seen the new clip load yet.

    anyway, any and all advice will be waited for with bated breath, and I'll be refreshing the forum every thirty seconds hoping a guru out there has relieved my pain.

    >>>Michael

  5. #5
    Senior Member
    Join Date
    Dec 2000
    Posts
    120

    OK, I figured it out, finally! by myself.

    I'm going to post what I did to a new message, though so that those searching the forums in the future will have a clean message to work with (not that I'm smart yet or anything.)

    >>>Michael

  6. #6
    Senior Member
    Join Date
    Dec 2000
    Posts
    120

    resolved I take that back I'll post it here too...

    Ok, two things I had to change, and I knew better for one of them, I just copied the wrong code... The main code in the movieloader had to be like this:
    Code:
    if (_root.maincontent._framesloaded>0 && _root.maincontent._framesloaded == _root.maincontent._totalframes) {
         gotoAndPlay ("cont");
    } else {
         percentVAL = int((_root.maincontent.getBytesLoaded()/_root.maincontent.getBytesTotal())*100);
         percentloaded = percentVAL add " % loaded";
         setProperty ("stat2", _width, percentVAL);
    }
    And I was right it was all about the timing, and I figured out it was my methodology. Instead of having the button both load the movie and launch the preloader bar, I have it just load the movie.

    On the other hand I learned a new command OnClipEvent(). Now I set the action on the clip
    Code:
    onClipEvent (load) {
        tellTarget ("_root.movieloader") {
            gotoAndPlay ("loop");
        }
    }
    I figured the best way to get the timing down to know when the clip was loading was let it decide and run the preloader at the appropriate time! dumb me. But I'm learning... sigh

    >>>Michael

  7. #7
    Junior Member
    Join Date
    Sep 2000
    Posts
    9

    Smile Caching swfs

    I have a major problem which involves caching swf's. Can you please help me. The thing is i have a interface which loads about 30 to 50 swfs in it. What i want to do is when the user is having a look at the first swf the others get cached automatically. Can you please help me on this.

    Cheers,

    Rahul Godse.

  8. #8
    Junior Member
    Join Date
    Jan 2001
    Posts
    12

    Talking The end is near... :)

    I have a solution for you. You can view it here: http://rjewels.com It only loads 2 external swf's but it works great. I am working on a better solution because this one takes alot of work, but here it is anyways:
    Code:
    symbols:
    1 movie clip named fakemc
    1 dynamic textbox named loaded
    1 square to cover the whole movie
    
    instructions:
    Make four layers in order named from top to bottom; content, mask, fakemc, actions.
    Place your fakemc in the fakemc layer (anywhere it doesn't matter). This is where your swf's are going to load to.
    Place the square on the mask layer. This is to hide your swf's from being seen while there being cached.
    Place loaded on the content layer.
    Make 7 keyframes in the action layer. All the other layers need to have 7 frames.
    Here's the actions for the actions keyframes in order from 1-7:
    
    frame1:
    loadmovie("mc1.swf","fakemc");
    //This loads your first swf into the hidden movieclip fakemc;
    
    frame2:
    //Set percentage;
    tp=math.round((fakemc.getBytesLoaded()/fakemc.getBytesTotal())*100);
    //Display percentage. I will be using add instead of += because I will be turning it into text;
    loaded="Loading mc1: " add tp add "%";
    //Checking to see if percentage is >= 100 and fakemc file size is > 100 bytes;
    if(tp>=100 && fakemc.getBytesTotal()>=100){
      gotoAndPlay(4);
    }
    
    frame3:
    _currentframe -1;
    play;
    
    frame4:
    loadmovie("mc2.swf","fakemc");
    //This loads your first swf into the hidden movieclip fakemc;
    
    frame5:
    //Set percentage;
    tp=math.round((fakemc.getBytesLoaded()/fakemc.getBytesTotal())*100);
    //Display percentage. I will be using add instead of += because I will be turning it into text;
    loaded="Loading mc1: " add tp add "%";
    //Checking to see if percentage is >= 100 and fakemc file size is > 100 bytes;
    if(tp>=100 && fakemc.getBytesTotal()>=100){
      gotoAndPlay(7);
    }
    
    frame6:
    _currentframe -1;
    play;
    
    frame7:
    loaded="Site Loaded...";
    stop;
    You can make as many key frames as you need to. You can also use fakemc.visible=false on frame1 instead of using the big square. What this does is loads each swf in order until there all done. Then continues to wherever you want on the last frame. I hope I explained this well enough. I'm also going to post this on flashkit. Warning! This will not show right using the show streaming that macromedia provides. There's a bug in it that I haven't found a work around on. Just upload it to your server and it will work great.

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