This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Flash Site Design > April 2006 > drag and drop with swapdepth problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author drag and drop with swapdepth problem
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




tralfaz

2006-04-03, 3:29 am


"digit" <jidesign@hotmail.com> wrote in message news:e0q0ct$sed$1@forums.macromedia.com...
>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


Try also the macromedia.flash.actionscript forum. It would be better for your question since this forum doesn't get much use.
tralfaz




Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews