Drag only one button

Hi!
what is the right action script to drag a particular button without draging others. If I put the action script that I wrote below, it will let me to drag everything, even my background.
Thanks a lot!!!

–action script–

on (press) {
this.startDrag()
}
on (release) {
this.stopDrag()
}

Try this…

on (press) {
startDrag(this)
}
on (release) {
stopDrag()
}

PS: I am moving this thread to the Actionscript forum as this has nothing to do with HTML or Javascript and you posted it in the HTML/Javascript forum.

Thanks a lot! I will post in the right place next time!
Thanks again!

No problem. Glad I could help:)

I think you may find that the background is being dragged because the button is sitting on the main timeline (in which case this.startDrag() and startDrag(this) will both reference _root).

I’d suggest you place the button inside an instance of a movie clip: select the instance of the button, press F8 and choose Movie Clip. Then either this.startDrag() and startDrag(this) will work.

Ah yes, you are completely right there. For some reason that thought never popped into my head.

Thanks for the correction jsk.

Absolutely right jsk. When you define an on (something) event, and if you use this, you refer to the clip containing the button (the _root in this case).

In MX, there’s another way to solve this: declare a dynamic even handler in the timeline. For instance:

but.onPress=startDrag;

pom :asian: