# getBytesLoaded etc. from index.swf through loadMovie

**URL:** <https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557>\
**Category:** flash\
**Created:** [June 19, 2003, 2:48pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557 "2003-06-19T14:48:49Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![mooler](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mooler](https://forum.kirupa.com/u/mooler)\
**Post date:** [June 19, 2003, 2:48pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/1 "2003-06-19T14:48:49Z")

</div>

Maybe not the best description of this topic 😉

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 3:36pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/2 "2003-06-19T15:36:20Z")

</div>

Anybody please please

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 4:04pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/3 "2003-06-19T16:04:01Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 4:21pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/4 "2003-06-19T16:21:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 4:24pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/5 "2003-06-19T16:24:48Z")

</div>

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](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=15472)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 5:29pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/6 "2003-06-19T17:29:18Z")

</div>

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 🥚

Attaching the fla incase someones wants to take a peek.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:04pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/7 "2003-06-19T19:04:03Z")

</div>

does it have to say this.getBytesLoaded() ?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:05pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/8 "2003-06-19T19:05:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:19pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/9 "2003-06-19T19:19:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:23pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/10 "2003-06-19T19:23:15Z")

</div>

NaN = Not a Number

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:42pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/11 "2003-06-19T19:42:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 7:46pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/12 "2003-06-19T19:46:09Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 8:22pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/13 "2003-06-19T20:22:22Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 8:26pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/14 "2003-06-19T20:26:05Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 8:56pm UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/15 "2003-06-19T20:56:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 7:31am UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/16 "2003-06-20T07:31:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 8:12am UTC](https://forum.kirupa.com/t/getbytesloaded-etc-from-index-swf-through-loadmovie/23557/17 "2003-06-27T08:12:53Z")

</div>

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 🙂

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!!!
