# How do I combine the preloader transition with the preloader percentage bar?

**URL:** <https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057>\
**Category:** Uncategorized\
**Created:** [August 15, 2004, 1:06pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057 "2004-08-15T13:06:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrEmonkey](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mrEmonkey](https://forum.kirupa.com/u/mrEmonkey)\
**Post date:** [August 15, 2004, 1:06pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/1 "2004-08-15T13:06:07Z")

</div>

Hi guys,

Got to say what a great site, i’ve learnt so much since i’ve discovered it!

I’m still having trouble getting my head around AS.

What I want to do is use a transition when loading external files into my main flash site, as described here:

[http://www.kirupa.com/developer/mx/preloader\_transition.htm](http://www.kirupa.com/developer/mx/preloader_transition.htm)

but while the’re loading I want to show a percentage bar, as per this tut:

[color=#003366][http://www.kirupa.com/developer/mx/percentagepreloader.htm](http://www.kirupa.com/developer/mx/percentagepreloader.htm)[/color]

I’m pretty sure its got something to do with combining this AS:

```auto

onClipEvent (enterFrame) {	
if (!loaded && this._url != _root._url) {	 
if (this.getBytesLoaded() == this.getBytesTotal()) {
loaded = true;			
_root.transition.gotoAndPlay("opening");		
}	
}
}

```

with this:

```auto

bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
this.loadBar._width = getPercent*100;
this.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {	
this.gotoAndPlay(3);} 

```

I’ve tried playing around with combining them, but i just cant get my head around it.

I know its probably simple, but if anyone can tell me how to do it I’d be most greatfull.

Thanks

---

<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:** [August 15, 2004, 2:41pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/2 "2004-08-15T14:41:04Z")

</div>

in the transition movieclip:  
add in some extra frames to do the calculations and another layer to hold the percentage bar.  
the new frames should go in the middle of all the motion tweens, and after the frame on the actions layer that loads the movie in the content movie clip.

---

<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:** [August 15, 2004, 2:52pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/3 "2004-08-15T14:52:10Z")

</div>

Thanks for the reply,

But it the AS i’ve got trouble with, i’m trying something like this:

```auto
onClipEvent (enterFrame) {
 bytes_loaded2 = Math.round(this.getBytesLoaded());
	bytes_total2 = Math.round(this.getBytesTotal());
	getPercent2 = bytes_loaded2/bytes_total2;
 if (!loaded && this._url != _root._url) {
   this.loadBar2._height = getPercent2*80;
		 this.loadText2 = Math.round(getPercent2*100)+"%"
  if (bytes_loaded == bytes_total) {
   loaded = true;
   _root.transition.gotoAndPlay("open");
  }
 }
}

```

I can’t get the AS to read how much is left of the external .swf and convert into a bar.

Thanks

---

<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:** [August 15, 2004, 3:13pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/4 "2004-08-15T15:13:40Z")

</div>

that’s a pretty complicated way of doing it.  
make a rectangle, convert it to a MovieClip and give it an instance name of something like loaderBar, which is what i will use.  
This goes in the frame after the frame which loads the content into the \_root.content movieclip.

```auto
percentloaded = (_root.content.getBytesLoaded() / _root.content.getBytesTotal())*100;
loaderBar._xScale = Math.round(percentLoaded);

```

in the next frame, we want to see if the movie has completed loading, so we use this simple test:

```auto
if (_root.content.getBytesLoaded == _root.content.getBytesTotal) {
_root.transition.gotoAndPlay("open");
} else {
gotoAndPlay(_currentFrame-1);
}

```

also, i should point out, the loaderBar should be on a seperate layer from the actionscript because it must last over the 2 frames of the actions, and must not be seperated into keyframes.

---

<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:** [August 15, 2004, 3:32pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/5 "2004-08-15T15:32:45Z")

</div>

sort of like this…  
[note: you will need the other files that came with the original file from [here](http://www.kirupa.com/developer/mx/preloader_transition.htm).]

---

<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:** [August 15, 2004, 3:38pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/6 "2004-08-15T15:38:12Z")

</div>

sort of like this:  
i have not included the other .swf files, you can get them from the transition tutorial here: [http://www.kirupa.com/developer/mx/preloader\_transition.htm](http://www.kirupa.com/developer/mx/preloader_transition.htm)

---

<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:** [August 15, 2004, 4:30pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/7 "2004-08-15T16:30:06Z")

</div>

ok, thanks for that.

This is gonna take some tinkering.

I also have a preloader before the main file has loaded.

The transition preloader doesn’t seem to work when I have the main preloader as well!

---

<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:** [August 15, 2004, 11:10pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/8 "2004-08-15T23:10:19Z")

</div>

Ok, I think I have this working now, my connection is too fast for me to be sure!!!

Thanks for all the help Cyberathlete.

:thumb:

---

<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:** [August 15, 2004, 11:22pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/9 "2004-08-15T23:22:59Z")

</div>

Glad to help (-:

---

<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:** [August 20, 2004, 10:34am UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/10 "2004-08-20T10:34:38Z")

</div>

Dear helpers,

I thought I was nearly there with this and was feeling very happy with myself but, after combining the two tutorials into one, I find that not only do the external swf’s not load, but the ‘transition’ MC doesn’t play either!

Is this a targeting issue and the fact that I’ve added a new scene with frames? Does the \_root mean the main timeline, and would that be part of the problem?

I’m a bit of a lightweight when it comes to AS and need to be told in a similar way to speaking to a very young child! 🙂

Any help would be greatly apreciated.

---

<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:** [August 20, 2004, 6:38pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/11 "2004-08-20T18:38:24Z")

</div>

lol. yes, \_root is the main timeline. everything is on this timeline, in some way or another. eg:  
\_root -\> movie1  
\_root -\> movie1 -\> movie2 -\> movie3

you see?  
As to answer your question - “would that be part of the problem?” - who knows? how exactly are you using as in your scripts?

a bit more information would be useful :).  
if you get stuck, there’s already an example there with the completed preloader bar + transition. you can use it as an example of how to do it.

---

<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:** [August 22, 2004, 6:48pm UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/12 "2004-08-22T18:48:57Z")

</div>

Thanks for the reply cyberathlete.

I have attached the files that I am having trouble with. Any chance of quickly glancing at them and seeing if the problem has a straightfoward answer?

thanks mate

---

<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:** [August 23, 2004, 9:36am UTC](https://forum.kirupa.com/t/how-do-i-combine-the-preloader-transition-with-the-preloader-percentage-bar/61057/13 "2004-08-23T09:36:59Z")

</div>

> [@cyberathlete](#):
>
> lol. yes, \_root is the main timeline. everything is on this timeline, in some way or another. eg:  
> \_root -\> movie1  
> \_root -\> movie1 -\> movie2 -\> movie3
> 
> you see?  
> As to answer your question - “would that be part of the problem?” - who knows? how exactly are you using as in your scripts?
> 
> a bit more information would be useful :).  
> if you get stuck, there’s already an example there with the completed preloader bar + transition. you can use it as an example of how to do it.

Thanks for the reply cyberathlete. I have attached the .fla file I’m having problems with. I have excluded the external .swf’s due to the maximum file size allowed to attach. I fully understand if you are unable to have a look at this, but would be very grateful if you could cast an experienced eye over it and have a quick shuffties to see if there is an obvious problem.

Yours in anticipation

Twang
