createEmptyMovieClip--level help

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

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

Ranish

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

pom :cowboy:

Here is my test link:

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.

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?

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?

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

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.

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:

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

I attached the fla., why don’t I see it??

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

I’m sorry, policy of the house. :frowning: 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: