# \[FMX04\]Turning while dragging + var wont work

**URL:** <https://forum.kirupa.com/t/fmx04-turning-while-dragging-var-wont-work/146369>\
**Category:** Uncategorized\
**Created:** [April 30, 2005, 3:09pm UTC](https://forum.kirupa.com/t/fmx04-turning-while-dragging-var-wont-work/146369 "2005-04-30T15:09:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr\_DJ](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mr_dj/32/1282_2.png) [@Mr\_DJ](https://forum.kirupa.com/u/Mr_DJ)\
**Post date:** [April 30, 2005, 3:09pm UTC](https://forum.kirupa.com/t/fmx04-turning-while-dragging-var-wont-work/146369/1 "2005-04-30T15:09:56Z")

</div>

**Hi all,**

Just jumped into the forums cause i have a problem that i cnnot solve my self.  
I’m trying to make a movie within you need to drag + turn pieces and place them on the good place… sofar sogood. :rolleyes:  
\*\*  
I attached the file so it will work easyier. p.s. you can turn the pieces while dragging with ENTER\*\*

Currently i have 2 pieces, _Part 1_ and _Part 2_. The have to be droped at _Droptarget 1 and 2_. Part 1 is an square and does not need to be turned. Part 2 is an triangle that has too be turned 90 degrees.

**When testinmg the file make sure you have set Keyboard Shortcuts OFF!**

These are the codes of part 1 and 2 these are the codes of the BUTTONs inside the MOVIECLIPs:

```auto
#Part1:
on (press) {
	this.x = getProperty(this, _x);
	this.y = getProperty(this, _y);
	this.rotation = getProperty(this, _rotation);
	if (this.right == false) {
		_root.id = "drag2";
		startDrag(this, true);
	}
}
on (release) {
	_root.id = "drop";
	stopDrag();
if (eval(this._droptarget) == _root.droptarget01 && (this._rotation == 0 || this._rotation == 90 || this._rotation == 180 || this._rotation == -90)) {
		this._x = _root.droptarget01._x;
		this._y = _root.droptarget01._y;
		this.right = true;
	}
}

#Part2:
on (press) {
	this.x = getProperty(this, _x);
	this.y = getProperty(this, _y);
	this.rotation = getProperty(this, _rotation);
	if (this.right == false) {
		_root.id = "drag1";
		startDrag(this, true);
	} else {
		_root.id = "drag1";
		_root.correct -1;
		startDrag(this, true);
	}
}
on (release) {
	_root.id = "drop";
	stopDrag();
	if (eval(this._droptarget) == _root.droptarget02 && this._rotation == 0) {
		this._x = _root.droptarget02._x;
		this._y = _root.droptarget02._y;
		this.right = true;
		_root.correct +1;
	}

```

as you can see in part1:

```auto
 if (eval(this._droptarget) == _root.droptarget01 && (this._rotation == 0 || this._rotation == 90 || this._rotation == 180 || this._rotation == -90))

```

will make sure that it snaps to pos. when it is VISUALLY good turned. I don’t know why in part 2 the code is:

```auto
 if (eval(this._droptarget) == _root.droptarget02 && this._rotation == 0) {

```

cause it works only when i turn the triangle 90 degrees… :mad:

however these are the codes of the movieclips surrounding part 1 and 2:

```auto
onClipEvent (load) {
	this.right = false;
}

```

so the var right is false for each object (thats why \_root. is not used)  
At frame one from the movie there is this code:

```auto
var correct = 0;
var id = "drop";
listenForKey_obj = new Object();
listenForKey_obj.onKeyDown = function() {
	if (Key.getCode() == 13 && _root.id == "drag1") {
		_root.Part1._rotation += 45;
	} else if (Key.getCode() == 13 && _root.id == "drag2") {
		_root.Part2._rotation += 45;
	}
};
Key.addListener(listenForKey_obj);
stop();
if (_root.correct == 1) {
	gotoAndPlay(2) }

```

The questions: 1.Why is _if (\_root.correct == 1) {  
gotoAndPlay(2) }_ not working?  
2.how dus my turn thing WORKS?

I hope you can answer soon cause i need this at the morning of 1 MAY 2005… srr to bother you guys (and girls)

Mr.DJ
