Link to home
Start Free TrialLog in
Avatar of thepan
thepan

asked on

Partial Preloader

Hi,
I'm creating a movie with heavy animation and audio in Flash 5.
From my base swf (myBase.swf), I have another swf (myToon.swf) that loads up on level 2.
I have a preloader on myToon.swf, it works fine.

There's a vast amount for users that are still using 56k-modems or older processors (due to location, financial, perference, for whatever).
It has come to my attention from several 56k-modem sources at myToon.swf takes 2 minutes to load up. This is a concern to me, I fear that most viewer will think that the file is

hung up and leave my site.

Here's what I'm trying to do:
I would like assistance on a preloader that when half the frames or bytes are loaded of myToon.swf, it will start to play.
Plus, still have the precentage text and progress bar tabulating at the preload frames.

myToon.swf is 1800 frames in lenght and approx 600k in size.

I tried to modify several preloader scripts, but no cigar.
I read in a tutorial at the Marcomedia site, at "_totalFrames" in a preloader script can be replace by a frame number, but doesn't explain how to do it.
Here's a simple example that I tied, where I replaced "_totalFrames" with "900" (for frame #):

onClipEvent (enterFrame) {
    if (_root._framesloaded>=_root.900) {
         _root.gotoAndPlay(2);
    } else {
         this.gotoAndStop(Math.floor((_root._framesloaded/_root.900)*this.900)+1);
    }
}

Any and all assistance will be appreciated. The page url: http://www.toonist.com/flash/ravine.html

--Thanx, The Pan
Avatar of Zeffer
Zeffer
Flag of New Zealand image

why do you want the download still being monitored if
the movie has begun to run..that's just a distraction
to the user..isn't it?

onClipEvent (enterFrame) {
   if (_framesloaded>=900) {
        _level2.gotoAndPlay(2);
   }

Z
Avatar of thepan
thepan

ASKER

Z,

In my observation, it's the contrary, the monitoring of the preload, gives the viewer reason to hang in there and confirm that the swf is loading.

I'm looking for assistance to monitor the script you posted, wheather by frames or bytes.

The Pan
Avatar of rascalpants
I totally disagree(with thepan)!

you should give the user the impression that your files are loading faster, and not let them see any type of preloader while the movie is running...

It is a basic GUI principle to not distract from the basic message, and having a preloading running while the loading movie is playing is a simple way to loose your message and possibly your audience.


as far as the help with putting the preloader on the page with the loading/playing movie, you need to have the preloader be a seperate movieclip the plays while the other is loading...

you would just use a simple looping movieclip that checks the status and displays the results...  

something like this would work in the loop:

if(_root.movie1._framesLoaded >= 300){
  _root.movie1.gotoAndPlay("start");
  gotoAndPlay(1);
} else if(_root.movie1._framesLoaded >= 900){
  _root.preloader.stop();
  _root.preloader._alpha = 100; //or move it off the stage
} else {
  gotoAndPlay(1);
}


put this in the sixth frame(or what every you want, just not 1).


let me know if you need more information...


rp

Avatar of thepan

ASKER

rascalpants and Z,

I misread your comments. Let me clarify:

I'm looking to preload half the movie, after half the movie is preloaded, then preload monitoring stops and the movie starts.

I will try both your scripts.
I thank you for your time, sorry for my confusion.
--The Pan
hi all,

wouldn't it be more accurate to check the byteloaded instead of the frames loaded? if the myToon.swf is 600K and spreads evenly across the 1800 frames, that's fine. but if the heavier graphics and sounds comes at the end it chokes the movie somehow ...

using code from rp

//frame 1
movie1.loadMovie("myToon.swf",1)
.. etc

//frame 2
var ttlByte = movie1.getBytesTotal();

//frame 3
// update the preloader graph here

//frame 4
if(_root.movie1.getBytesLoaded >= (/:ttlByte/2) ){

 // start player movie
 _root.movie1.gotoAndPlay("start");

 //hide the preloader here
  _root.preloader._visible = false;
  _root.gotoAndPlay(5)
 .. etc
 .. etc

} else {
 gotoAndPlay(3);
}

//frame 5
...
..
.

just a thought...

cheers
>>I'm creating a movie with heavy animation and audio in Flash 5.<<

..
//frame 4
if(_root.movie1.getBytesLoaded >= (/:ttlByte/2) ){
..


Flash 6

Z
i see ...
missed the "5"

cheers z
Avatar of thepan

ASKER

rascalpants and Z,

I tried the scripts, it seems to only loop the preloader and does not start the movie. I tried tweeking the scripts, but with no success.

--The Pan
have you given the movieclip an instance name?  

the below code will work properly if you set up your main movie correctly...


if you are still having problems, then post your .fla somewhere online and I will see what is wrong with it...

rp
Avatar of thepan

ASKER

rp,

Aah! I will check for the instance name on th movie clip (I remember if I did).

--The Pan
Hello,

How about trying this simple preload script.


onClipEvent (load) {
     this._xscale = 0;
}
onClipEvent (enterFrame) {
     this._xscale = ((_root.getBytesLoaded()/_root.getBytesTotal())*100);
if(this._xscale > 50 ){
//gotoAndPlay("start");
}
}


rex
ASKER CERTIFIED SOLUTION
Avatar of elhy
elhy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
he he he ... elhy, spend some time and read the questions & comments beforing throwing everything to it at once.

why? because u had just done something silly... i did it once and u did it the second time ....

getBytesLoaded!! FLASH 5??

:) cheers
didn't anyone know that flash 5 have getBytesLoaded()???

I've been using this coding since flash 5.
no ... ha ha ha ...
i don't even remember what 5 is like, i have been using mx since it release, but the "help" in mx does say that is MX only ... so i supppose z is right ...

sorry ... then ... my fault :)

Avatar of thepan

ASKER

rp,

This part of the partial preloader works. The progess bar-Mc loops until frames are loaded, this is to be expected.

onClipEvent (enterFrame) {
  if (_root_framesloaded>=900) {
       __root.gotoAndPlay(2);
  } }

If I extend it for the progress bar-MC to monitor the frames loading: first, in the "test movie" the MC stays looping on the preloader (flash 5), BUT loaded-up on the server the preloader does start the movie,...except the progress bar-MC does not monitor the frameloaded (it seems to loop or ignore it).

onClipEvent (enterFrame) {
  if (_framesloaded>=900) {
       _level2.gotoAndPlay(2);
     } else {
this.gotoAndStop(Math.floor((_root._framesloaded/_root.totalframes)*this._totalframes));
} }

I was looking to monitor the frameloaded best as possible or is this the nature of the beast (flash 5).
About the preloader getting stuck in "test movie", it may be a gish on my flash 5 installion or not.

--The Pan

Ps: rexmor and elhy, I'll give your scripts a whril.
what are you trying to do here:

this.gotoAndStop(Math.floor((_root._framesloaded/_root.totalframes)*this._totalframes));

are you trying to go to a specific frame and stop?  if so, then why?


but you say the preloader works fine, but your actionscript that changes some bar is not working properly?


you should just change the _xscale of the bar graphic by using some code like this:

b_loaded = _root.getBytesLoaded();
b_total = _root.getBytesTotal();

percent = (b_loaded/b_total)*100;

_root.bar._xscale = percent; //you could also use this._xscale


does this help you out...


rp
Avatar of thepan

ASKER

rp,

Thanks, I'll try it and get back to you.

--The Pan
sticking with _framesloaded..
in your preloader in myToon.swf..if you drop a movie clip containing a bar graphic onto the stage..give it the instance name ..loader.. and use the following code..

if (_framesloaded >= 900) {
     _level2.gotoAndPlay (2);
} else {
     _root.loader._xscale = (_framesloaded/_totalframes*100);
}

..it works fine.
you can mask the bar if you want it to only grow in one direction.

Z
I think the getBytesLoaded is more precise to when using a graphic...  it is more accurate because you could have all of the major bytes in the very last frame of the movie... if you use framesLoaded, then your graphic could show that all but 1 percent is loaded, and that could take a few minutes...

but I would still use framesloaded to make sure to play the movie when a certain frame is loaded...


hope this clears up some things


rp
framesloaded is easier, but bytesloaded is more accurate...

all as mentioned above by henry


rp
Avatar of thepan

ASKER

SUMMARY:

Thanks experts for your time and help.
I tested every script on the heavy-sized movie and had viewed by a user with a 56k-dialup/400mhz processer.

Though, the scripts would load half the movie and start, the monitoring MC would either: lockup, loop, or be ignored at loadup.

Except for "elhy", the script delivered as promised.

If I can get the "sysop" attention!
For their efforts, I would like to give from my account 50 points each to:

rascalpants,
henryww,
rexmor,
zeller.

Thanks again,
--The Pan
Avatar of thepan

ASKER

Thanks elhy, this script did the trick.

"Sysop":,
Please read a previous comment about giving token points the other experts on this question.

--The Pan
hooray ... elhy u have done it again :)

sorry for mistake, it proves that getBytesloaded() work for flash 5 - perfect :)
Pan Man,

If you want to give points to the above people, just post individual questions with the title of "points of rasclpants" or what ever...


I am glad you were able to sift through all of the information and come up with something that worked for you...


I should have just send you my preloader I use in my projects instead of messing around with all of the Q&A...


over and out...


rp
Avatar of thepan

ASKER

rp,

Will do

--The Pan
I think the accepted answer is quite the same with this!

onClipEvent (load) {
    this._xscale = 0;
}
onClipEvent (enterFrame) {
    this._xscale = ((_root.getBytesLoaded()/_root.getBytesTotal())*100);
if(this._xscale > 50 ){ //means 50 percent loaded
//gotoAndPlay("start");
}
}
no not really...  the results maybe the same, but if the person likes a particular solution, then it is up to them to award the points...

you got something out of this rexmor, so why are you complaining...


rp
Avatar of thepan

ASKER

Hi rexmor,

To explain why "elhy's" script worked for me.

For some reason the script placed on the frame action was more reliable in monitoring the MC precentage-bar.

Regardless of the size of the movie file, "elhy's" script would monitor the percentage-bar, exactly halway.

Though, "elhy's" script only made the MC precentage-bar move half way, I can indicate at the halfway mark as 100%.
I could also recycle the script to other movies, without changing a thing.

The other good scripts needed to be placed on the Movie-Clip; therefore a "onClipEvent" was needed.
Again, for some reason the script placed on the frame action was more reliable and no "onClipEvent" was needed.

--The Pan

working example of the Partial Preloader:
http://www.toonist.com/flash/ravine.html
Avatar of thepan

ASKER

Hi rexmor,

To explain why "elhy's" script worked for me.

For some reason the script placed on the frame action was more reliable in monitoring the MC precentage-bar.

Regardless of the size of the movie file, "elhy's" script would monitor the percentage-bar, exactly halway.

Though, "elhy's" script only made the MC precentage-bar move half way, I can indicate at the halfway mark as 100%.
I could also recycle the script to other movies, without changing a thing.

The other good scripts needed to be placed on the Movie-Clip; therefore a "onClipEvent" was needed.
Again, for some reason the script placed on the frame action was more reliable and no "onClipEvent" was needed.

--The Pan

working example of the Partial Preloader:
http://www.toonist.com/flash/ravine.html