?
Solved

Partial Preloader

Posted on 2003-02-21
30
Medium Priority
?
612 Views
Last Modified: 2010-05-18
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
0
Comment
Question by:thepan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 7
  • 5
  • +3
30 Comments
 
LVL 23

Expert Comment

by:Zeffer
ID: 7995114
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
0
 

Author Comment

by:thepan
ID: 7995230
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
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 7995411
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

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:thepan
ID: 7995567
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
0
 
LVL 6

Expert Comment

by:henryww
ID: 7998097
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
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7998291
>>I'm creating a movie with heavy animation and audio in Flash 5.<<

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


Flash 6

Z
0
 
LVL 6

Expert Comment

by:henryww
ID: 8002100
i see ...
missed the "5"

cheers z
0
 

Author Comment

by:thepan
ID: 8009479
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
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8009674
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
0
 

Author Comment

by:thepan
ID: 8009734
rp,

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

--The Pan
0
 
LVL 9

Expert Comment

by:rexmor
ID: 8023207
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
0
 
LVL 5

Accepted Solution

by:
elhy earned 800 total points
ID: 8023986
Hi,

my preloader consist of a loading bar. not sure if u want that. if u don't need it just remove the part stated in the code.


1. create a new scene, name it preloading.
2. Create 2 empty key frames.
3. create a bar mc. name it loader.
4. On the first key frame, add this:
 
  if(this.getBytesLoaded()>=(this.getBytesTotal()/2)){
     gotoAndPlay("Scene 1", 2); //change accordingly.
  }else{
     setProperty ("/loader", _width, (this.getBytesLoaded()/this.getBytesTotal())*107.7);
  }
  //note that 107.7 is the width you want your loading to be. You can change this length to any length u like.
  //remove the else{.....} and ignore point 3 if you don't require the loading bar.


5. On the second key frame, add this:
  gotoAndPlay(1);


6. Test your movie see if it runs well.
0
 
LVL 6

Expert Comment

by:henryww
ID: 8024337
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
0
 
LVL 5

Expert Comment

by:elhy
ID: 8024685
didn't anyone know that flash 5 have getBytesLoaded()???

I've been using this coding since flash 5.
0
 
LVL 6

Expert Comment

by:henryww
ID: 8024774
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 :)

0
 

Author Comment

by:thepan
ID: 8027207
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.
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8028145
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
0
 

Author Comment

by:thepan
ID: 8028325
rp,

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

--The Pan
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 8028969
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
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8029110
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
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8029123
framesloaded is easier, but bytesloaded is more accurate...

all as mentioned above by henry


rp
0
 

Author Comment

by:thepan
ID: 8035219
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
0
 

Author Comment

by:thepan
ID: 8035262
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
0
 
LVL 6

Expert Comment

by:henryww
ID: 8035299
hooray ... elhy u have done it again :)

sorry for mistake, it proves that getBytesloaded() work for flash 5 - perfect :)
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8035858
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
0
 

Author Comment

by:thepan
ID: 8036492
rp,

Will do

--The Pan
0
 
LVL 9

Expert Comment

by:rexmor
ID: 8038078
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");
}
}
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8042178
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
0
 

Author Comment

by:thepan
ID: 8059539
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
0
 

Author Comment

by:thepan
ID: 8060305
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
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question