# Preloading to a target MC

**URL:** <https://forum.kirupa.com/t/preloading-to-a-target-mc/6022>\
**Category:** Uncategorized\
**Created:** [September 27, 2002, 7:38pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022 "2002-09-27T19:38:41Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![heed](https://avatars.discourse-cdn.com/v4/letter/h/bcef8e/32.png) [@heed](https://forum.kirupa.com/u/heed)\
**Post date:** [September 27, 2002, 7:38pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/1 "2002-09-27T19:38:41Z")

</div>

I’ve been trying to figure this out for awhile now and can’t seem to get it. I can create preloaders that load the main movie with this AS.:

total = \_root.getBytesTotal();  
loaded = \_root.getBytesLoaded();  
percentage = Math.floor((loaded/total)\*100);  
percframe = Math.floor(percentage/2);

//trace(total);  
//trace(loaded);  
//trace(percentage);  
//trace(percframe);

if (percentage \>= 100) {  
gotoAndPlay(“main”,1);  
} else {  
with(\_root.bar) {  
\_xscale = percentage;  
}  
}

Now what I want to do is preload another .swf into an empty holder MC. This is the part I can’t seem to acomplish.

Do I need to put the preloader AS into the holder clip or into the .swf that’s being loaded? Should I use scenes? I’m really at a loss here. Any help would be greatly appreciated.

---

<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:** [September 27, 2002, 7:43pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/2 "2002-09-27T19:43:53Z")

</div>

This is a very common question. Load the movie into an mc called holder, for example, and use

\_root.holder.getBytesTotal();

\_root.holder - then the actions.

---

<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:** [September 27, 2002, 8:04pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/3 "2002-09-27T20:04:17Z")

</div>

Where does this script go frame, on the holder clip, or in the first frames of the .swf being loaded?

And by the way that’s the quickest and best response I’ve got from a forum. Thanx!

---

<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:** [September 27, 2002, 8:11pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/4 "2002-09-27T20:11:21Z")

</div>

So if I place it on “holder” it will getBytesLoaded(); for all .swf’s targeted to holder?

Now to show the progress it’s the same as my preloader?

---

<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:** [September 27, 2002, 8:16pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/5 "2002-09-27T20:16:17Z")

</div>

The code will go into the swf, that is loaded into holder.

In the swf in the first scene or frames where the preloader is, use

\_root.holder.getBytesLoaded.

And you’ll have to do this for each swf that you load, because as they load into holder, they’ll work out their own bytesLoaded, etc. by using \_root.holder (ie the clip they lie in).

---

<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:** [September 27, 2002, 8:35pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/6 "2002-09-27T20:35:50Z")

</div>

O.K. I’ve run into a little snag:

BTN AS:

on (release) {  
loadMovie(“cd.swf”, “\_root.holder”);  
}

The .swf that is being targeted an preloaded AS in a spereate scene:

is frame:  
total = \_root.getBytesTotal();  
loaded = \_root.getBytesLoaded();  
percentage = Math.floor((loaded/total)\*100);  
percframe = Math.floor(percentage/2);  
\_root.holder.getBytesLoaded();

2nd  
gotoAndPlay(1);

When I test the movie it displays 220 and then stops. The .swf never fully loads or displays. Where did I go wrong?

---

<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:** [September 27, 2002, 8:41pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/7 "2002-09-27T20:41:01Z")

</div>

Can you edit your post and click on disable smilies - there are some probs at the moments that cause code to turn into a smilie.

I’m looking at the rest of the code.

---

<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:** [September 27, 2002, 8:43pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/8 "2002-09-27T20:43:11Z")

</div>

If you’re loading into holder you need to use

```php

total = _root.holder.getBytesTotal();
loaded = _root.holder.getBytesLoaded();

and

_root.holder.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:** [September 27, 2002, 8:50pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/9 "2002-09-27T20:50:29Z")

</div>

That’s what I have now. It works fine when I test the movie being loaded, it displays the progress and loads. It just dosen’t seem to work when I try to load it into the ain movie.

It displays 220 loaded and stops.

---

<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:** [September 27, 2002, 8:51pm UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/10 "2002-09-27T20:51:33Z")

</div>

Nevermind (for know) I see my mistake.

---

<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:** [September 28, 2002, 3:12am UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/11 "2002-09-28T03:12:48Z")

</div>

Something still not quite right. Now when I test it it just loads the .swf without showing the preolader. It skips over it, seems like. I even cleared my cookies.

---

<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:** [September 28, 2002, 5:31am UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/12 "2002-09-28T05:31:18Z")

</div>

Everytime you test your preloader - you will have to clear your browser cache.

---

<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:** [September 28, 2002, 8:50am UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/13 "2002-09-28T08:50:54Z")

</div>

> Everytime you test your preloader - you will have to clear your browser cache.

Why don’t you use Web Speed Simulator (the name of the app says that all) from [xat.com](http://xat.com) ?  
You can test preloading, on various simulated modem speed.  
You can use it on file mode and… localhost mode (port 81)  
ehm… it’s trial I know… Just download 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:** [September 28, 2002, 9:19am UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/14 "2002-09-28T09:19:03Z")

</div>

I’ve heard about the low speed simulators. Never used them. Heard varying opinions about them.

---

<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:** [September 28, 2002, 11:08am UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/15 "2002-09-28T11:08:48Z")

</div>

It’s my everyday tool flex.  
Just try it to html pages containis swf…(!)  
You’ll see all kind of preloaders to work.

---

<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:** [September 28, 2002, 11:32am UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/16 "2002-09-28T11:32:18Z")

</div>

I’ll try it - only one way to find out if it really works, I suppose - have you got the url?

---

<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:** [September 28, 2002, 11:37am UTC](https://forum.kirupa.com/t/preloading-to-a-target-mc/6022/17 "2002-09-28T11:37:37Z")

</div>

[xat.com](http://xat.com)
