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:
#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:
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:
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:
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:
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