How to get the position of the movieclip after dragging by mouse

I have code like
on (press) {
startDrag(screen);
}

on (release) {
stopDrag();
x_value1=_root.screen._x;
y_value1=_root.screen._y;
trace(x_value1);
trace(y_value1);

}

But I found after dragging, x_value1 and y_value1 are always the initial value. So what is the right way to record the position then? thanks in advance !

I used

[AS]
on (press) {
startDrag(_root.screen);
}

on (release) {
stopDrag();
x_value1=_root.screen._x;
y_value1=_root.screen._y;
trace(x_value1);
trace(y_value1);

}[/AS]

and it worked fine for me …

Thanks for that _root.screen.

Actually, I want to record different position of movieclip when the button is clicked.

There are two buttons as front, back. I would like to when the front button is clicked. Drag the movieclip and record its position, then when I pressed the front button again, the position should still be there.

So I have something for the movieclip like
on (press) {
startDrag(_root.screen);
}

on (release) {
stopDrag();
}

onClipEvent (mouseUp) {

switch (state) {
case 1 :
	x_value1 = _root.screen._x;
	y_value1 = _root.screen._y;
	trace(_root.x_value1);
	trace(_root.y_value1);
	break;
case 2 :
	x_value2 = _root.screen._x;
	y_value2 = _root.screen._y;
	trace(_root.x_value2);
	trace(_root.y_value2);
	
	break;

}

Then for the front button,
on (release)
{
_root.screen._x=x_value1;
_root.screen._y=y_value1;

}
for the back button,

on (release)
{
_root.screen._x=x_value1;
_root.screen._y=y_value1;

}

But every time, when I click the front button again, the movieclip is at the initial position but not the position where I dragged.

What should I modify then. Do u have some good suggestion. Thanks much in advance!!

I don’t get it :hair: Can you please explain more ?

Hello, it is like this,

input textfield output textfieldinMovieclip

                                           front_btn       back_btn

When I click the front_btn, I write the text and drag it by mouse. And after I click the front_btn again, the output textfield should still stay there.

for the movieclip
on (press) {
startDrag(_root.screen);
}

on (release) {

if(_root.state==1) {
	
	x_value1 = _root.screen._x;
	y_value1 = _root.screen._y;
	trace(_root.x_value1);
	trace(_root.y_value1);
	stopDrag();
	
}
else if(_root.state==2) {
	stopDrag();
	x_value2 = _root.screen._x;
	y_value2 = _root.screen._y;
	trace(_root.x_value2);
	trace(_root.y_value2);
}

}

And for the front button, I have
on (release)
{
_root.state =1;
_root.screen._x=_root.x_value1;
_root.screen._y=_root.y_value1;
}

for the back button I have
on (release)
{
_root.state =2;
_root.screen._x=_root.x_value2;
_root.screen._y=_root.y_value2;
}

But again, the trace output of the _x and _y value are the initial value. What should I do then ? Am I made myself clear? Thanks !

No, I still don’t get it. I’m so confused !

What’s with the textfields !? Two minutes ago it was a screen !
What is the back button supposed to do ?
What should be written inside the two boxes ?
Which text should you drag ?

Please provide the FLA so I can have a look and maybe understand what you mean.

You can try to input data when different button is clicked, e.g when front is clicked, or when back is clicked. You will see that the position of the screen is the same no matter what I dragged.

I don’t get what you are trying to accomplish here at all. Really, I don’t. Sorry man, but I am unable to help you.

Thanks anyway!

i don’t understand why you want to have a front and a back button, but have a look at my example. maybe this is in the lines of what you are looking for.

Thanks indeed for your code. That is much helpful! I do appreciate. Although it is not exactly the same, it gives me idea about that. Thanks again! Regards!