Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-03-2003, 02:35 AM   #1
Pixel
Master of Monkeys
 
Join Date: Sep 2001
Location: Toronto
Posts: 132
Send a message via ICQ to Pixel
Default simple preloader problem

hey there guys....i am trying to add a preloader to an MC that I am loading into another MC, but having a little bit of problems. If i use this script just normally and have it just on a single MC, it works fine, but when i am trying to preload into an MC on the stage, nothing happens, it just skips to 100% and then moves on.

Here is the code that I have
ActionScript Code:
total_bytes = _root.portfolioMC.getBytesTotal(); loaded_bytes = _root.portfolioMC.getBytesLoaded(); remaining_bytes = total_bytes-loaded_bytes; percent_done = int((loaded_bytes/total_bytes)*100); bar.gotoAndStop(percent_done); ifFrameLoaded ("content", 1) {      gotoAndPlay ("content", 1); }

seems simple enough...i have movies loading into "portfolioMC" that is on the _root timeline. This script above is in its own scene of the loaded movie.

Any idea why this is not working?
thanks for anyone who can help out.
Pixel is offline   Reply With Quote
Old 02-03-2003, 03:54 AM   #2
Dev-Ash
Registered User
 
Join Date: Feb 2003
Location: Richmond, VA
Posts: 32
Default

This might help.


//Actionscript for Frame 1

downloaded = math.floor(_root.getbytesLoaded()/_root.getbytestotal()*100)+"%";
download_bar.gotoandstop(downloaded);
bytesloaded = math.floor(_root.getbytesloaded()/1000);
bytestotal = math.floor(_root.getbytestotal()/1000);
message = "Loading... "+bytesloaded+"Kb"+" ("+downloaded+")"+" of "+bytestotal+"Kb";
loadedbytes = getBytesLoaded();
totalbytes = getBytesTotal();
loadedkbytes = Math.ceil(loadedbytes/1000);
totalkbytes = Math.ceil(totalbytes/1000);
if (loadedbytes == totalbytes) {
gotoAndPlay(3); //I have my preloader in the same scene. The actual MC starts on Frame 3
}
frame = int(loadedbytes/(totalbytes/100));
tellTarget (_root.loader) {
gotoAndStop(_root.frame);
}

//Action Script for Frame 2
gotoAndPlay(1);


Hope this helps.

Feel free to email me.
Dev-Ash is offline   Reply With Quote
Old 02-03-2003, 02:27 PM   #3
Pixel
Master of Monkeys
 
Join Date: Sep 2001
Location: Toronto
Posts: 132
Send a message via ICQ to Pixel
Default thanks

thanks a lot...it seems my code is working properly when uploaded to a server.....

thanks for your help thou.
joshua
Pixel is offline   Reply With Quote
Old 02-03-2003, 08:32 PM   #4
Dev-Ash
Registered User
 
Join Date: Feb 2003
Location: Richmond, VA
Posts: 32
Default try this to

Oh cool.

You know if you go to Control Tab
Test Scene or Movie
Then go to ViewTab
and then go to show streaming
This will test your preloader and tell you how big your MC is and how long it will take to download using 16k 24k 56k or what ever you set it to. Hit Customize.

You will be required to set some things up first in the Test MC area.

email if you need to.
Dev-Ash is offline   Reply With Quote
Old 02-04-2003, 11:41 AM   #5
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

Also if u wanna test it while in the Authering mode (i.e. the fla), when testing the Movie (ctrl + Enter), hit the ctrl + Enter again
__________________
€* GOD Is Near €*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 02-04-2003, 06:15 PM   #6
kapjay1
Registered User
 
Join Date: Jan 2003
Location: Atlanta, Ga
Posts: 16
Unhappy Re: try this to

Dev-Ash,

Please help!!!!!!!!! I have a similar problem to Pixel's. Could you look at the following code and tell me how to get this thing right. I can't get the loading bar or the percentage to show properly on the stage when testing on the server. Or if you have an external preloader that really works, would you mind sending it to me. I have Flash 5. I've gotten several that don't work over the past three weeks. Thanks a bunch. Kev.

Frame 1:

loadMovie("Intro.swf","my_mc");
my_mc.stop();

Frame 2:

if (my_mc.getBytesLoaded()<my_mc.getBytesTotal()){
gotoAndPlay(_currentframe+1);
_root.percent_left = int(my_mc.getBytesLoaded()/my_mc.getBytesTotal()*100);
}else{
gotoAndPlay(_currentframe+2);
}

Frame 3:

gotoAndPlay(_currentframe-1);

Frame 4:

my_mc.play();

Code on loading bar movie clip:

onClipEvent(load){
_root.loadingBar.bar._xscale = 0;
}
onClipEvent(enterFrame){
//load function values to local variables
bytesLoaded = _root.getBytesLoaded();
bytesTotal = _root.getBytesTotal();
timer = getTimer();

percent = _root.getBytesLoaded()/_root.getBytesTotal();
_root.loadingBar.bar._xscale = percent*100;
//calculate and format percent loaded
percent_loaded = Math.round(percent*100)
//calculate and format download rate
bytes_per_second = Math.round(bytesLoaded/(timer/1000));
//calculate and format remaining time to download
seconds_left = (bytesTotal - bytesLoaded)/bytes_per_second;
//format time in mm:ss
minutes = math.floor(seconds_left/60);
if(number(minutes) < 10) {
minutes = "0"+minutes;
}
seconds = Math.round(seconds_left - (minutes*60));
if (number(seconds) < 10) {
seconds = "0"+seconds;
}
time_left = minutes + "m:" + seconds +"s";
//Play Movie
if (percent == 1){
_root.loadingBar._visible = false;
_root.gotoAndStop(2);
}
}
Attached Files
File Type: zip main.zip (4.7 KB, 158 views)
kapjay1 is offline   Reply With Quote
Old 02-04-2003, 09:26 PM   #7
Dev-Ash
Registered User
 
Join Date: Feb 2003
Location: Richmond, VA
Posts: 32
Default WOW!! Thats a lot of code.

Look at this fla that Billy T post for me. It was for loading external MC, it has some great preloader code in it that I found helpful also. Good luck. Hit me back if you need to.
Dev-Ash is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:55 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.