getBytesLoaded etc. from index.swf through loadMovie

Maybe not the best description of this topic :wink:

I´m loading swf:s into my main movie to an empty MC (holder) and would like to have a preloader in my mainmovie to handle the preloading of all swf:s that I load. Using this code in my mainmovie.

[AS]

bytes_loaded = holder.Math.round(getBytesLoaded());
bytes_total = holder.Math.round(getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBarH._width = (getPercent*100)1.5;
this.loadTextH = Math.round(getPercent
100)+"%";
this.loadTotalH = getBytesTotal()/1000;
this.loadSofarH = getBytesLoaded()/1000;

AS]

But this do not work from me :slight_smile:

Anybody please please

Try this…

[AS]holder.onEnterFrame = function(){
bytes_loaded = holder.Math.round(getBytesLoaded());
bytes_total = holder.Math.round(getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBarH._width = (getPercent*100)1.5;
//give textbox an instance name of “loadTextH” (no quotes)
this.loadTextH.text = Math.round(getPercent
100)+"%";
if (bytes_loaded > 0 && bytes_loaded >= bytes_total){
//do this
}
}[/AS]

Liked the idea to use the instance name instead but unfortunately no go.

Ok, I have no idea why, but I didn’t finish editing that script before I posted my reply :sure: 'DOH!

[AS]
holder.onEnterFrame = function(){
this.bytes_loaded = Math.round(getBytesLoaded());
this.bytes_total = Math.round(getBytesTotal());
this.getPercent = bytes_loaded/bytes_total;
loadBarH._width = (this.getPercent*100)1.5;
//give textbox an instance name of “loadTextH” (no quotes)
loadTextH.text = Math.round(this.getPercent
100)+"%";
if (this.bytes_loaded > 0 && this.bytes_loaded >= this.bytes_total){
//do this
}
}
[/AS]

And if that doesn’t work, try the below link…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=15472

Can´t get it to work?

Tried this instead but with no luck

[AS]
this.loadTotalH.text = holder.loadTotal;

if (this.loadTotalH.text == 100) {
gotoAndPlay (“out”);
}
[/AS]

Haven´t anybody else used something to check when a swf is fully loaded and then had the main movie to do something?

Pleasw lostinbeta help me :egg:

Attaching the fla incase someones wants to take a peek.

does it have to say this.getBytesLoaded() ?

usually when no target is specified “this” is the target by default, but using this.getBytesLoaded() and this.getBytesTotal() is worth a try.

Hi again :slight_smile:
What does it mean when I get “NaN” in the textbox?

NaN = Not a Number

So when using this code

[AS]holder.onEnterFrame = function() {
this.bytes_loaded = Math.round(getBytesLoaded());
this.bytes_total = Math.round(getBytesTotal());
this.getPercent = bytes_loaded/bytes_total;
loadBarH._width = (this.getPercent*100)1.5;
// give textbox an instance name of “loadTextH” (no quotes)
loadTextH.text = Math.round(this.getPercent
100)+"%";[/AS]

I get a NaN in my textbox? I don´t get why the Math.round should give numbers to the loadTextH textbox.
Sorry to bug you time and time again but I can´t figure this one out. All my code looked ok and your code look great but I can´t get it to work…very frustrating.

Oops

this.getPercent = bytes_loaded/bytes_total;

should be

this.getPercent = this.bytes_loaded/this.bytes_total;

Also try using this.getBytesLoaded() and this.getBytesTotal() , it doesn’t hurt to try it, and it’s good coding practice (which im not showing much of today…lol)

Got the textfield to respond to the code but it just stands on 100% from the begining. And the loadbar don´t get it either.

The code as it looks now.

[AS]holder.onEnterFrame = function() {
this.bytes_loaded = Math.round(this.getBytesLoaded());
this.bytes_total = Math.round(this.getBytesTotal());
this.getPercent = this.bytes_loaded/this.bytes_total;
loadBarH._width = (this.getPercent*100)1.5;
// give textbox an instance name of “loadTextH” (no quotes)
loadTextH.text = Math.round(this.getPercent
100)+"%";
}

[/AS]

If you are testing on your computer it will always be at 100. Not event CTRL+Enter+Enter (Show streaming) can work for dynamically loaded in content, that always loads like lightning. You will have to test it on a server to actually test it (making sure not to cache your images or it will load quick anyway… you can do a search for no cache code on the forum).

And if this doesn’t work theres always that link I posted before. I know for a fact that code works, I use it all the time :sigh:

Thx for all your help lost I´ll figure the rest out. :slight_smile:

Err me again and another sleepless night but I can´t for the life of me figure this one out please have a look at the fla and help mie out with what is wrong?

THX

Hi again lost sorry to bug you with this again but I can´t get it to work?!!! After 2 weeks of this I´m pretty messed up :slight_smile:

This code goes into the MC that the swf:s are loaded into?

[AS]holder.onEnterFrame = function() {
this.bytes_loaded = Math.round(this.getBytesLoaded());
this.bytes_total = Math.round(this.getBytesTotal());
this.getPercent = this.bytes_loaded/this.bytes_total;
_root.loadBar._width = (this.getPercent*100)1.5;
// give textbox an instance name of “loadText” (no quotes)
_root.loadText.text = Math.round(this.getPercent
100)+"%";
}

[/AS]

And is it the instance name of the MC or the name that should be adressed ( instance name holder and name mc_holder tried both but no go).

attaching the fla so you may se my problem.

Others feel free to have a whack at this as well have been bugin´alot of people with this and have gotten a sollution from Claudio but that didn´t fit with my “build” of the fla.

DESPERATE!!!