all groups > flash actionscript > september 2005 >
You're in the

flash actionscript

group:

Set instance name using Actionscript


Re: Set instance name using Actionscript greenwire
9/24/2005 12:00:00 AM
flash actionscript:
i guess you'd do something along these lines:

createEmptyMovieClip("mc_001", 1);
mc_001.loadMovie("somemovie.swf");

you'd then duplicate it like this
mc_001.duplicateMovieClip("mc_002", 1);

youd probably want to use an array to manage 50 instances.


Re: Set instance name using Actionscript Cetrez
9/24/2005 12:00:00 AM
ok, I'll give that a try... thanks a bunch.

Here's another question:

I've got a string and a variable(number) called 'counter' that I want to
combine to an instance name.
For example I want to target a button with the instance name "btn5" and I
typed the following line:

var btnTarget = "btn" + counter;

which returns the string "btn5", that I want to use


and then:

this.btnTarget.onRelease = function() {
etc.....


but that doesn't work for me
any ideas or hints?
Re: Set instance name using Actionscript Rothrock
9/24/2005 12:00:00 AM
Or you could have the clip(s) in your library set to export for actionscript.
Then you could use the attachMovie method. Do it in a loop:

var numClips=50;
for(var i=0;i<numClips;i++){
this.attachMovie("myLibraryClip","myNewName"+i,100+i,[{initobject}]);
}

The initobject is an optional thing. If you aren't going to use it then don't
inclure the part after the final comma and before the closing right
parenthesis. Of course each clip will be stacked on top of the others so you
won't see them all. If you need help with that post back and we can work it out.

Of course check out the movieclip class in the help files.
Re: Set instance name using Actionscript Rothrock
9/24/2005 12:00:00 AM
Oh and here is for your second questions

this["btn"+counter].onRelease=function(){}

Re: Set instance name using Actionscript Cetrez
9/24/2005 12:00:00 AM
Thanks a lot guys.

Set instance name using Actionscript Cetrez
9/24/2005 10:42:17 AM
Hi all

Would appreciate if someone could help me with a problem I've got:


Let's say I've got 50 instances of a MC on my stage, without any instance
names.
What I want to do is to give each of these MCs an instance names, for example:
mc_001, mc_002 etc.
Is this possible using actionscript?

Maybe it would be easier if I were to duplicate and put the MCs on the stage
using actionscript instead, and at the same time apply them with an instance
name. But I don't know how to set an instance name using actionscript.


Any help would be highly appreciated
Thanks
Re: Set instance name using Actionscript Travise Newbury
9/24/2005 11:27:03 AM
"Cetrez" <webforumsuser@macromedia.com> said:
[quoted text, click to view]

Not the way I believe you are thinking.

[quoted text, click to view]

Use createEmptyMovieClip. The second parameter is the instance name.


--
AddThis Social Bookmark Button