Drag And Drop
Enviado por pargasi • 13 de Agosto de 2013 • 3.837 Palabras (16 Páginas) • 477 Visitas
function dragSetup(clip, targ) {
clip.targetok = false;
clip.onPress = function() {
if(!this.targetok)
{
this.startDrag();
this.swapDepths(getNextHighestDepth());
this.beingDragged=true;
}
};
clip.onRelease =function () {
this.stopDrag();
this.beingDragged=false;
if (this._droptarget==targ._target) {
this.onTarget = true;
this.targetok=true;
this.useHandCursor=false;
this.gotoAndStop("ok");
this.badTarget = false;
}
else {
this.onTarget = false;
this.gotoAndStop("bad");
}
};
clip.onReleaseOutside=function () {
this.stopDrag();
this.beingDragged=false;
if (this._droptarget==targ._target) {
this.onTarget = true;
this.targetok = true;
this.useHandCursor=false;
this.gotoAndStop("ok");
} else {
this.onTarget = false;
this.gotoAndStop("bad");
}
};
//the variables below will store the clips starting position
clip.myHomeX = clip._x;
clip.myHomeY = clip._y;
//the variables below will store the clips end position
clip.myFinalX = targ._x+targ._width/2-clip._width/2;
clip.myFinalY = targ._y+targ._height/2-clip._height/4;
clip.onEnterFrame = function() {
//all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
// then move the MC back to its original starting point (with a smooth motion)"
if (!this.beingDragged && !this.onTarget) {
this._x -= (this._x-this.myHomeX)/5;
this._y -= (this._y-this.myHomeY)/5;
//if the circle is dropped on any part of the target it slides to the center of the target
} else if (!this.beingDragged && this.onTarget) {
this._x -= (this._x-this.myFinalX)/5;
this._y -= (this._y-this.myFinalY)/5;
};
};
}
dragSetup(text1, target1);
dragSetup(text2, target2);
dragSetup(text3, target3);
function dragSetup(clip, targ) {
clip.targetok = false;
clip.onPress = function() {
if(!this.targetok)
{
this.startDrag();
this.swapDepths(getNextHighestDepth());
this.beingDragged=true;
}
};
clip.onRelease =function () {
this.stopDrag();
this.beingDragged=false;
if (this._droptarget==targ._target) {
this.onTarget = true;
this.targetok=true;
this.useHandCursor=false;
this.gotoAndStop("ok");
this.badTarget = false;
}
else {
this.onTarget = false;
this.gotoAndStop("bad");
}
};
clip.onReleaseOutside=function () {
this.stopDrag();
this.beingDragged=false;
if (this._droptarget==targ._target) {
this.onTarget = true;
this.targetok = true;
this.useHandCursor=false;
this.gotoAndStop("ok");
} else {
this.onTarget = false;
this.gotoAndStop("bad");
}
};
//the variables below will store the clips starting position
clip.myHomeX = clip._x;
clip.myHomeY = clip._y;
//the variables below will store the clips end position
clip.myFinalX = targ._x+targ._width/2-clip._width/2;
clip.myFinalY = targ._y+targ._height/2-clip._height/4;
clip.onEnterFrame = function() {
//all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
// then move the MC back to its original starting point (with a smooth motion)"
if (!this.beingDragged && !this.onTarget) {
this._x -= (this._x-this.myHomeX)/5;
this._y -= (this._y-this.myHomeY)/5;
//if the circle is dropped on any part of the target it slides to the center of the target
} else if (!this.beingDragged && this.onTarget) {
this._x -= (this._x-this.myFinalX)/5;
this._y -= (this._y-this.myFinalY)/5;
};
};
}
dragSetup(text1, target1);
dragSetup(text2, target2);
dragSetup(text3, target3);
function dragSetup(clip, targ) {
clip.targetok = false;
clip.onPress = function() {
if(!this.targetok)
{
this.startDrag();
this.swapDepths(getNextHighestDepth());
this.beingDragged=true;
}
};
clip.onRelease =function () {
this.stopDrag();
this.beingDragged=false;
if (this._droptarget==targ._target) {
this.onTarget = true;
this.targetok=true;
this.useHandCursor=false;
this.gotoAndStop("ok");
this.badTarget = false;
}
else {
this.onTarget = false;
this.gotoAndStop("bad");
}
};
clip.onReleaseOutside=function () {
this.stopDrag();
this.beingDragged=false;
if (this._droptarget==targ._target) {
this.onTarget = true;
this.targetok = true;
this.useHandCursor=false;
this.gotoAndStop("ok");
} else {
this.onTarget = false;
this.gotoAndStop("bad");
}
};
//the variables below will store the clips starting position
clip.myHomeX = clip._x;
clip.myHomeY = clip._y;
//the variables below will store the clips end position
clip.myFinalX = targ._x+targ._width/2-clip._width/2;
clip.myFinalY = targ._y+targ._height/2-clip._height/4;
clip.onEnterFrame = function() {
//all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
// then move the MC back to its original starting point (with a smooth motion)"
if (!this.beingDragged && !this.onTarget) {
this._x -= (this._x-this.myHomeX)/5;
this._y -= (this._y-this.myHomeY)/5;
//if the circle is dropped on any part of the target it slides to the center of the target
} else if (!this.beingDragged && this.onTarget) {
...