Accessing a movieclip with string variable as name

I have a button called px (p1 - p8). When you press it I want to call a function that returns the x position of globalWrapper.px (p1 - p8) (different movieClips).

So I tried:


p1.addEventListener(MouseEvent.MOUSE_UP, buttonMouseUp);
...
p8.addEventListener(MouseEvent.MOUSE_UP, buttonMouseUp);

function buttonMouseUp(event:MouseEvent):void{
	var targetP:String = 'globalWrapper.'+event.target.name;
	var end:MovieClip = targetP;
	
	trace(end.x);
	
}


But obviously this does not work as I am trying to change the variable type.
Anyone know how to do this correctly?