Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onLoadInit alternatives....

Status
Not open for further replies.

michanagel

Technical User
Jun 23, 2007
34
US
Hi,

I have a preloader here that works great, but I would like to change one part
of the code...

I am using 'onLoadInit' to declare some actions as soon as the movie is loaded, but I want those actions to start when the movie is loaded to 80 % because the movie has an intro that will gain me some time to load the rest...

here's the part of code that I want to change:

Code:

myListener.onLoadInit = function (target:MovieClip){
_root.gotoAndPlay("sections");
_root.container.play();
trace ("Loaded!!!!");
loader_2.loadbar._visible = false;
}

What are my options to replace 'onLoadInit' with something that I have more control over the load progress ?

As always, thanx for your help in advance !!!

Mike
 
alright, first of all thanx for the tip for 'onLoadProgress', it kinda works but now I have a different problem...

When I leave everything as is, reaching 100% and then do something it works, but for that I didn't had to change the code...

What I want is to do certain actions when 80% of the content is loaded ...

But to make it look like on the progress bar it's 100 % and to make the dynamic percentage number shown on screen to be a 100% I simply multiplied the 'bytes loaded/byted total' with 125...

Here's the code:
Code:

myListener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number ){
_root.percent_2 = Math.floor( bytesLoaded / bytesTotal * 125);
loader_2.loadbar._visible = true;
loader_2.loadbar.gotoAndStop( _root.percent_2 );
trace ( _root.percent_2 + "% loaded" );
if (_root.percent_2 == 100){
_root.gotoAndPlay("sections");
trace ("Loaded!!!!");
loader_2.loadbar._visible = false;
}
}

--> that means that when the content loaded reaches a value of 0.8 (80%) the variable _root.percent_2 is 100...

Problem is:

it works 3/5 times...

the loader loads it, u can see the progress bar going up to 100% and the doing the actions it should, with the trace function I see, that it's actually loading till 125% (which it should)...

BUT 2/5 times it will keep loading till 125% - I still see the loader (which should be invisible by now) and the dynamic percentage number on screen goes up till 125) and then just hangs because it kinda 'missed' the 100 count...

Now that happens with 2 swf files that have uneven file size, 1.5MB and 1.7MB... the three other .swf files that work have even file sizes (1.8MB, 2.6 MB, 1.6MB)...

How can that happen ?

I am testing my movie in Flash Player 9 - simulating download with 1mbit, 2mbit and 3mbit settings...

I have Flash 9 CS3, this is an AS2 movie exported for Flash Player 8...

As always, thanx for your help in advance !

Mike
 
oldnewbie,

yes I do use the movieClipLoader (later in the code)...

I just figure that the code I posted earlier is key for my problem, although I think the code is okay, it's just very strange that Flash sometimes does not react when certain conditions are met...
 
Of course after passing the test, [tt]if (_root.percent_2 >= 100)[/tt], you have to stop the same command being called again and again. Putting up a flag is the easiest way. Do you need a code for that?

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top