Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple instances of a movieclip flash 5 1

Status
Not open for further replies.

irate

Programmer
Jan 29, 2001
92
GB
i have a one frame with the following actionscript to add movies to the stage

countMovOnStage = countMovOnStage + 1;
_root.attachMovie("astermov", "astermov"+countMovOnStage, countMovOnStage);


so when i test this movie it just adds a load of move clips to the stage over and over.

But lets say i wanted to randomly chage the movieclips attributes like so:


sessionNumber = Math.round(Math.random()*5+1);
this._x += sessionNumber;
this._y += sessionNumber;
this._xscale += sessionNumber;
this._yscale += sessionNumber;
this._rotation += sessionNumber;


how do i reference all the created movie clips?

something like this maybe?

"astermov"+countMovOnStage._x += sessionNumber;

can anyone help?
Or if you have a better way of doing what i want?
I just want movie clips to be created at different sives and colours and to fly off the screen in random directions...

thanks in advance
 
You're pretty much there already...

Here are two ways to do what you want:

_root["astermov"+countMovOnStage]._x=sessionNumber

or

eval("astermov"+countMovOnStage)._x=sessionNumber

Paths to the clips you create are the major problem with using them, therefore you might find yourself doing things like...

eval("_root.astermov etc

or

_parent["asterMov etc

Both methods work well, apparently "eval" is very slightly quicker but I think the other, array-type, method is easier to read and use (and it's less typing!) so I tend to go with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top