attachMovie question

here’s my question:

I have 4 buttons on the stage which, when pressed, attaches one of 4 movieClips to an emptyClip on the stage. EG:
pressing button 2 runs this script:

emptyClip.attachMovie(“movieClip2”, “movieClip2”, 0);

What I want to do is be able to trace the name of the clip that is attached to emptyClip at the time of pressing another button on the stage, like a confirmation button that traces, for example, that “movieClip2” is the final selection.

I can only get “_name” to return the name of the emptyClip

I hope this makes sense!

if i’m not mistaken… u want to show a text is’nt it??

Hi,
Not sure if this will give you want you want, but try it:
[AS]trace(emptyClip._name-1);[/AS]

essentially if you put your trace on the button,(say button3)that code should give you the result of what the previous button did ? !!!

Let me know

SteveD

I’m not sure what u mean… What I ultimately want to do is to store the users selected movieClip name (the one attached to emptyClip) to a database when they hit the “confirm” button…

Hi,
Sorry I thought you was trying to trace the previously loaded clip, the code I posted will not work anyway, so back to the drawing board.
A quick and dirty way would be to do this :
On your main timeline declare a var, something like :
var count =0;
In your movie clips that are being loaded into the empty clip, put in the first frame
[AS]_root.count=1;[/AS]
and so on, so that each mc increases the var by one.
Then on the next ( or perhaps the last frame of your movie, write some if else statements like:
[AS]if(count==1){
save clip1;
} else if (count==2){
save clip2[/AS]

and so on, obviously the save clip bit needs to be changed to whatever code you are using when the confirm button is hit.

Cheers

SteveD

You could simply place the following code on the first frame of each movie clip you are loading

_root.vName=“someClipImAttaching”;

Short of that easy method… there is a more complex way using a “for in” loop to get it. If you don’t like the first suggestion let me know and I’ll describe the “for in” method.

Thanks SteveD & David,

The SteveD idea works great. It’s for a prototype of a site, so quick and dirty is good enough for now.

Cheers & thanks for the quick response.

Hi Tezza,
Glad it helped, Davids method is identical, he’s just using a string instead of a numeric, but essentially it would work the same.
Also, he’s right, a for…loop would probably be more efficient, but if you only have four clips to worry about it doesn’t make a lot of difference

Cheers

SteveD

Yep, I see what you mean, I’ll keep David’s method in mind if it gets a little complex…

Cheers

Terry