Drag n' drop problems (script inside)

[font=Arial]Hi all!

I have a problem with my drageable object when the users drag the object outside the limit of the Flash stage in a HTML page. It seem like it lose it’s _.x and ._y coordonates. It will followed the cursor when it returns to the stage but it can be drop anywhere on the stage after that.

Anybody have a solution to how I could detect when the piece is going outside the stage and make it return to its original place?

Here’s the script on my object :

on (press) {
this.startX = this._x;
this.startY = this._y;
this.startDrag();
}
on (release) {
this.stopDrag();
if (getProperty("/b", _droptarget) eq “/b1”) {
this._x = eval(this._droptarget)._x+0;
this._y = eval(this._droptarget)._y;
} else {
this._x = this.startX;
this._y = this.startY;
}
}

Here’s the Flash movie in question : [/font][font=Tahoma][color=#004477]Drag Drop Flash Movie[/color][/font]

[font=Arial]Do you have a better way to script an drag n’ drop object that doesnt need absolute positioning?

Thanks,
Eric Lanteigne [/font]

instead of just

this.startDrag();

put:

this.startDrag(true, 10, 10, 10, 10),

the numbers go in order (left, top, right bottom)

It constrains where you can drag your movie clip to on the stage,

You will have to adjust your numbers, I just put 10 for all of them in this example. Hope this helps.

Thank you!

Eric

you say you think it’s losing it’s _x and _y vars when the mouse is off of the flash movie… that is exactly what is happening :slight_smile:

I still have some questions :slight_smile: :

EDIT : It’s weird, if I set the first parameter to true, when I click on my MC, there’s an offset with my cursor. Is there a way to get rid of that mouse/MC offset? If I use false, everything work fine except if I drop my MC on another MC. The cursor still have the focus on the MC and moving it, it can be dropped anywhere. :S

Why does my MC still get outside the stage but only from the left position? The others border works fine but the left positioning is not working when I put 0 for value.

If my Flash movie is 750x270 and I want a 10 px margin from everyside, what are the value parameter, I should use? It seem like wider MC still goes outside. Does it have anything to do with the rotating point (center) of my MC? All my MC are not the same size.

Thanks,
Eric

could you upload the fla? it would be easier to see what’s going on if you did. thanks

[www.ericlanteigne.ca/1-3-9 (750x270).fla](http://www.ericlanteigne.ca/1-3-9 (750x270).fla)

Another link : http://www10.brinkster.com/EricLanteigne/1-3-9%20(750x270).fla

Can somebody help me :slight_smile:

Thanks,
Eric

It won’t let me access the file. I don’t know if it is my computer or not. Is anybody else able to access this file??

It must be Brinkster causing this problem :frowning: Wait i’m gonna create a page for downloading it.

Fixed : http://www10.brinkster.com/EricLanteigne/1-3-9.html

My biggest problem now is when my MC is dragged over another draggeable MC or over an already placed MC in my table.