# Putting variables instead of names

**URL:** https://forum.kirupa.com/t/putting-variables-instead-of-names/58888
**Category:** Uncategorized
**Created:** [July 26, 2004, 9:13pm UTC](https://forum.kirupa.com/t/putting-variables-instead-of-names/58888 "2004-07-26T21:13:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mad\_man](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@mad\_man](https://forum.kirupa.com/u/mad_man)
#### Post date: [July 26, 2004, 9:13pm UTC](https://forum.kirupa.com/t/putting-variables-instead-of-names/58888/1 "2004-07-26T21:13:05Z")

</div>

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

\_root.varname.\_x=33;

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

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 26, 2004, 9:28pm UTC](https://forum.kirupa.com/t/putting-variables-instead-of-names/58888/2 "2004-07-26T21:28:07Z")

</div>

varname=“mov1”  
\_root[varname].\_x=33;

or  
varname="mov1"  
eval(varname).\_x=33;

by the way: use the board’s search function

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 26, 2004, 9:50pm UTC](https://forum.kirupa.com/t/putting-variables-instead-of-names/58888/3 "2004-07-26T21:50:30Z")

</div>

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.

on(press){  
i = i + 1;  
mcname=“star”+i;  
duplicateMovieClip (\_root.star, mcname, i);

\_root[mcname].endx = this.\_x;  
\_root[mcname].endy = this.\_y;  
\_root[mcname].inLocation = false;  
\_root[mcname].id=i;  
\_global.inLocation\*=false;

\_root[mcname].onEnterFrame = function(){

if(!inLocation[id]){  
speed = 3;  
x = this.endx - this.\_x;  
y = this.endy - this.\_y;  
yrate = y/x;  
xrate= 1;  
isBehind=false;  
if (this.endx \< this.\_x){  
yrate=-yrate;  
xrate=-xrate;  
isBehind=true;  
}  
this.\_x += xrate_speed;  
this.\_y += yrate_speed;  
}  
if ((this.endx \< this.\_x)&&(isBehind==false)){  
\_global.inLocation[id]=true;  
}  
}  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 26, 2004, 10:17pm UTC](https://forum.kirupa.com/t/putting-variables-instead-of-names/58888/4 "2004-07-26T22:17:36Z")

</div>

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

```auto

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;
	}
}

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 26, 2004, 10:29pm UTC](https://forum.kirupa.com/t/putting-variables-instead-of-names/58888/5 "2004-07-26T22:29:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 26, 2004, 10:31pm UTC](https://forum.kirupa.com/t/putting-variables-instead-of-names/58888/6 "2004-07-26T22:31:30Z")

</div>

okay, i’ll try what i can do 😉
