PDA

View Full Version : drag only one button



wa ha ha ha ha
September 19th, 2002, 11:55 AM
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()
}

lostinbeta
September 19th, 2002, 12:02 PM
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.

wa ha ha ha ha
September 19th, 2002, 12:15 PM
Thanks a lot! I will post in the right place next time!
Thanks again!

lostinbeta
September 19th, 2002, 12:21 PM
No problem. Glad I could help:)

jsk
September 19th, 2002, 12:55 PM
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.

lostinbeta
September 19th, 2002, 01:06 PM
Ah yes, you are completely right there. For some reason that thought never popped into my head.

Thanks for the correction jsk.

pom
September 19th, 2002, 01:31 PM
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: