# \_x in AS for dynamic instance name

**URL:** <https://forum.kirupa.com/t/-x-in-as-for-dynamic-instance-name/86123>\
**Category:** flash\
**Created:** [April 10, 2005, 11:58am UTC](https://forum.kirupa.com/t/-x-in-as-for-dynamic-instance-name/86123 "2005-04-10T11:58:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![3pinter](https://avatars.discourse-cdn.com/v4/letter/3/9de053/32.png) [@3pinter](https://forum.kirupa.com/u/3pinter)\
**Post date:** [April 10, 2005, 11:58am UTC](https://forum.kirupa.com/t/-x-in-as-for-dynamic-instance-name/86123/1 "2005-04-10T11:58:22Z")

</div>

Oke, I couldn’t find anything about this one…

I have a number of mc’s on my mainstage. About ten each named target1, target2 etc.

I have a target problem. I wrote a prototype where I check if a dragged picture (piece1, piece2) is above target1 then… etc.etc.

Working just fine because I stated the coordinates of the image1 etc.  
While it’s a prototype I thought why not use the \_x of image1 … instead of saying what the \_X coordinate is…

Get it so far?  
No? this is the prototype I’m talking about…

```auto

// Jigsaw puzzle V1.0 design by www.fromthemill.nl
MovieClip.prototype.jigsaw = function(ocx, ocy, ncx, ncy, pic) {
	// ocx = original coordinate x ncx = new coordinate x pic = piecenumber
	this.onPress = function() {
		_root.i++;
		startDrag(this);
		this.swapDepths(i);
		lines.swapDepths(i+1);
	};
	this.onRelease = function() {
		stopDrag();
		var item = "target"+pic;
// item: target is the instance name, pic is declared in my prototype
		if (this._droptarget == item) {
			this._x = item._x;
			this._y = item._y;
		} else {
			this._x = ocx;
			this._y = ocy;
		}
		delete this.onEnterframe;
	};
};
piece1.jigsaw(189, 74, 1);
// so I only state the original x & y coordinates and the piece number

```

Problem: How to ‘target’ in AS1 the \_x of a " “target”+pic " ???

😏
