# Adding a variable number to a mc path

**URL:** <https://forum.kirupa.com/t/adding-a-variable-number-to-a-mc-path/7972>\
**Category:** Uncategorized\
**Created:** [November 11, 2002, 6:03pm UTC](https://forum.kirupa.com/t/adding-a-variable-number-to-a-mc-path/7972 "2002-11-11T18:03:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chapster](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chapster](https://forum.kirupa.com/u/chapster)\
**Post date:** [November 11, 2002, 6:03pm UTC](https://forum.kirupa.com/t/adding-a-variable-number-to-a-mc-path/7972/1 "2002-11-11T18:03:53Z")

</div>

I extarcted a number that I want to add on to a instance name to find the x of that mc

```auto

function checkHomePos() {
	if (_root.pannelDrag) {
		this.whatPanel = _root.currentPanelView;
		n = Number(this.whatPanel.substring(1));
	
		this.homeX=_root["bgP"+n]._x;
			trace("BGP :" +_root["bgP"+n]);
		trace("N :"+n);
		trace("HOMEX :" +this.homeX);
	}
}
_root.createEmptyMovieClip("menuChecker1", _root.depth++);
menuChecker1.onEnterFrame = checkHomePos;

```

Ok I have a variable [COLOR=red]n[/COLOR] which holds a number. Now I want to find the x position of the mc [COLOR=red]bgPn[/COLOR]  
All my bgP clips are named bgP1 to bgP20 so I want to be able to us the number in [COLOR=red]n[/COLOR] to add on to the end of bgP so it will represent the bgP clip I need.

🙂

---

<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:** [November 12, 2002, 12:00am UTC](https://forum.kirupa.com/t/adding-a-variable-number-to-a-mc-path/7972/2 "2002-11-12T00:00:53Z")

</div>

Hmm… but you already used the correct syntax for such things…

\_root[“bgP”+n]

or this[“bgP”+n]

or perhaps I missed what you were asking?

---

<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:** [November 12, 2002, 12:15am UTC](https://forum.kirupa.com/t/adding-a-variable-number-to-a-mc-path/7972/3 "2002-11-12T00:15:53Z")

</div>

Ok I was not sure if I had the right syntax but now that you say I am right. I found an error on my stupidity I was calling it from the \_root when it is inside a mc on the root. But it took you to tell me I was using the right syntax for me to study it more thanks. I am stupid sometimes but don’t tell me I am thanks . 🙂 🙂
