| digit 2006-04-02, 10:29 pm |
| I am trying to create a drag and drop with the line trail effect and also
using swapdepths so when you drag a circle to the other circle, it will
detect that it's always in front.
But I must be doing something wrong because the circle and lines moving
randomly whenever I drop the circle to the other circles.
You can have a look at the prototype from the link below:
http://users.tpg.com.au/jidesign/test/test2b.html
---> Scripts as below:
//frame 1 - main timeline
keys = 10;
//to create the line trail effect, connecting dots
key1.onEnterFrame = function () {
clear();
lineStyle(1, 0xFFAF00);
moveTo(495, 80);
lineTo(key1._x, key1._y);
moveTo(628, 80);
lineTo(key2._x, key2._y);
moveTo(565, 170);
lineTo(key3._x, key3._y);
}
//Key1 ================================================ (key 1 is circle 1)
key1.onPress=function(){
this.startDrag();
this.swapDepths(_root.keys);
++_root.keys;
}
key1.onRelease=function(){
this.stopDrag();
if (this.hitTest(key2)){
this._x=key2._x;
this._y=key2._y;
gotoAndStop("green");}
else if (this.hitTest(key3)){
this._x=key3._x;
this._y=key3._y;
gotoAndStop("red");}
else {
this._x=495; //+12 of the actual coordinate
this._y=80;
}
}
//Key2 ================================================
key2.onPress=function(){
this.startDrag();
this.swapDepths(_root.keys);
++_root.keys;
}
key2.onRelease=function(){
this.stopDrag();
if (this.hitTest(key1)){
this._x=key1._x;
this._y=key1._y;
gotoAndStop("green");}
else if (this.hitTest(key3)){
this._x=key3._x;
this._y=key3._y;
gotoAndStop("red");}
else {
this._x=628; //+12 of the actual coordinate
this._y=80;
}
}
//Key3 ================================================
key3.onPress=function(){
this.startDrag();
this.swapDepths(_root.keys);
++_root.keys;
}
key3.onRelease=function(){
this.stopDrag();
if (this.hitTest(key1)){
this._x=key1._x;
this._y=key1._y;
gotoAndStop("green");}
else if (this.hitTest(key2)){
this._x=key2._x;
this._y=key2._y;
gotoAndStop("red");}
else {
this._x=565; //+12 of the actual coordinate
this._y=170;
}
}
thanks in advance
|