# createEmptyMovieClip--level help

**URL:** <https://forum.kirupa.com/t/createemptymovieclip-level-help/7027>\
**Category:** flash\
**Created:** [October 22, 2002, 11:56am UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027 "2002-10-22T11:56:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![webEuphoria](https://avatars.discourse-cdn.com/v4/letter/w/b77776/32.png) [@webEuphoria](https://forum.kirupa.com/u/webEuphoria)\
**Post date:** [October 22, 2002, 11:56am UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/1 "2002-10-22T11:56:00Z")

</div>

Here is my loop:

puppycount = new LoadVars();  
puppycount.load(“puppycount.txt”);  
puppycount.onLoad=function(){  
count=this.count;  
count=parseInt(count);  
for (i=1; i\<=count; i++) {  
\_root.createEmptyMovieClip(“puppyholder”+i, i);  
\_root[“puppyholder”+i].\_x=i\*100;  
\_root[“puppyholder”+i].\_y=100;  
loadMovie(“puppy”+i+".jpg",\_root[“puppyholder”+i]);

}

}

it works, but when I click on another button in my movie each movieClip that this script created remains above everything else??  
Something to do with the levels. I don not under stand this. How can this be fixed. Please be very specific this is confusing to me.

thank you

---

<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:** [October 22, 2002, 12:48pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/2 "2002-10-22T12:48:26Z")

</div>

I think you should try removeMovieClip(target) action on button event to remove those clips which you had created by createMovieClip() .

Ranish

---

<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:** [October 22, 2002, 1:09pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/3 "2002-10-22T13:09:59Z")

</div>

Well, what do you want your button to do exactly? Remove the clips? Put them behind something?..

pom :cowboy:

---

<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:** [October 22, 2002, 1:47pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/4 "2002-10-22T13:47:47Z")

</div>

Here is my test link:

[http://www.geocities.com/adsparrow/](http://www.geocities.com/adsparrow/)

I want the created movieclips to only be in the puppies button.  
The puppies button plays the movieClip that the script is in.  
see what I mean?

p.s. I took the script out for posting this because it freezes on geocities.

---

<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:** [October 22, 2002, 2:50pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/5 "2002-10-22T14:50:40Z")

</div>

I don’t understand, sorry.

\>I want the created movieclips to only be in the puppies button.  
What do you mean in the button??

\>The puppies button plays the movieClip that the script is in.  
Plays which movie clip? And where’s the script?

---

<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:** [October 22, 2002, 3:08pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/6 "2002-10-22T15:08:23Z")

</div>

When the user clicks the “puppies” button the movie goes to and plays 11 frames starting at frame 84 of the main timeline. In these frames is a movieClip called “puppies” and in “puppies” is a movieClip called “slider”. The script…

puppycount = new LoadVars();  
puppycount.load(“puppycount.txt”);  
puppycount.onLoad=function(){  
count=this.count;  
count=parseInt(count);  
for (i=1; i\<=count; i++) {  
\_root.createEmptyMovieClip(“puppyholder”+i, i);  
\_root[“puppyholder”+i].\_x=i\*100;  
\_root[“puppyholder”+i].\_y=100;  
loadMovie(“puppy”+i+".jpg",\_root[“puppyholder”+i]);

}

}

…is in frame 1 of “slider”. I guess my question is what does \_root do exactly. When I put:

this.createEmptyMovieClip(“puppyholder”+i, i);

instead of:

\_root.createEmptyMovieClip(“puppyholder”+i, i);

the created movieClips are not visible when I click on the other buttons but the loop does not work it only loads the last picture.

However with \_root, once I click on the “puppies” button the created movieClips are always there even after I click on other buttons.

Seems like I am not creating emptyMovieClips in the movieClip “slider” but rather on the main stage, is that the case? If so how do I fix 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:** [October 22, 2002, 3:28pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/7 "2002-10-22T15:28:36Z")

</div>

this -\> you create in the current object (here is it a loadVars object, I don’t know if it will work…)  
\_root -\> you create in the \_root

So I guess your code should look like

```auto
for (i=1; i<=count; i++) {
  mc=this.createEmptyMovieClip("puppyholder"+i, i);
  mc._x=i*100;
  mc._y=100;
  mc.loadMovie("puppy"+i+".jpg");
}

```

Another solution could be to create a clip in the \_root that will hold all the clips that you create. That way, when you need it, you create it, and when you don’t need it anymore, you just destroy it.

```auto
puppycount = new LoadVars();
puppycount.load("puppycount.txt");
puppycount.onLoad=function(){
  count=this.count;
  count=parseInt(count);
  _root.createEmptyMovieClip("container",-1);
  for (i=1; i<=count; i++) {
    mc=_root.container.createEmptyMovieClip("puppyholder"+i, i);
    mc._x=i*100;
    mc._y=100;
    loadMovie("puppy"+i+".jpg",mc);
  }
}

```

pom :asian:

---

<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:** [October 22, 2002, 4:20pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/8 "2002-10-22T16:20:03Z")

</div>

Nice…your second suggestion worked thank you. I hate to bother you but you seem to give me the most help.

I’ve attached the .fla. and I will also attach the puppycount.txt and the jpgs in other posts

There are a couple of things I was wondering:

1. do you know how to make the puppy movieClips fade in with the rest of the blue rectangle when the user clicks on “puppies”?..test movie to see what I mean.

2. do you know how I can resize these puppy pics in the loop, so they will all be the same size?

3. If I click on the “puppies” button it shows the created movieclips, but if I click on it again they go away, can this be fixed?

Thank you for all your 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:** [October 22, 2002, 4:22pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/9 "2002-10-22T16:22:20Z")

</div>

I attached the fla., why don’t I see 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:** [October 22, 2002, 4:37pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/10 "2002-10-22T16:37:40Z")

</div>

the fla is too large…is there another way I can send it to you??

---

<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:** [October 22, 2002, 4:53pm UTC](https://forum.kirupa.com/t/createemptymovieclip-level-help/7027/11 "2002-10-22T16:53:40Z")

</div>

I’m sorry, policy of the house. ☹ But if someone else wants to check your fla…

From what I understood, you want to load the pictures and have them fade in, right? Well, supra wrote the code for it in the gallery tutorial. check it, everything’s there.

pom :asian:
