Putting variables instead of names

hello, if i have mc duplicated or an object instance name thats stored inside a variable how can i call it?
for ex:

_root.mov1._x = 53;

What if i want instead of mov1 a variable name. lets say randomname is a var and it holds the name of a duplicated object with a name i dont know since its random.

now how can i call it just like the example above cause i tried


but it thought varname was an instance name instead of var.

Sorry i am new to AS and help will be appreciated.



by the way: use the board’s search function

ok i dont get why this doesnt work. for some reason the mc’s dont stop moving. once they reach center they keep on just moving in the middle of the button. help needed plz.

i = i + 1;
duplicateMovieClip (_root.star, mcname, i);

_root[mcname].endx = this._x;
_root[mcname].endy = this._y;
_root[mcname].inLocation = false;

_root[mcname].onEnterFrame = function(){

speed = 3;
x = this.endx - this._x;
y = this.endy - this._y;
yrate = y/x;
xrate= 1;
if (this.endx < this._x){
this._x += xratespeed;
this._y += yrate
if ((this.endx < this._x)&&(isBehind==false)){

what was wrong with yesterdays code? because your new code is to complicated for the things you want… try this:

on (press) {
	i = i+1;
	mcname = "star"+i;
	duplicateMovieClip(_root.star, mcname, i);
	_root[mcname].endx = _root.btnname._x;
	_root[mcname].endy = _root.btnname._y;
	_root[mcname].onEnterFrame = function() {
		speed = 10;
		x = this.endx - this._x;
		this._x += x/speed;
		y = this.endy - this._y;
		this._y += y/speed;

well i like ur code but i want it to keep a constant speed instead of slowing down.

okay, i’ll try what i can do :wink: