Adding a variable number to a mc path

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


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.

:slight_smile:

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?

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 . :slight_smile: :slight_smile: