Jump to content

dragging causes ALL objects to drag


iyeru42

Recommended Posts

How do I fix this problem? My button has the following AS, but when I click the button and drag it around, EVERYTHING ELSE drags with it. How can I prevent that from happening. I don't think I need to give you a FLA for this, since it's solely actionscript issues.

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

I can't set lockcenter to true, otherwise the button will move off to the side of the stage, rather than me grasping onto it with the mouse. Edit: I can convert the button to a movieclip to fix this problem, but I'll have to do this for every one of them (IE: I'll have 10 library items, 5 for the buttons, 5 for the movieclips.) That's not very welcoming.

Link to comment
Share on other sites

It sounds like the buttons are contained in another movie clip and you are setting the drag on the entire movie clip instead of just on the button. So it's not solely an actionscript issue.
It actually was. when referencing to "this" it means the stage of the current place the button is in. When you have the button in another object (IE: A Movieclip) everything inside that movieclip is also moved at the same rate you move the button. However, when you do this...
startDrag (instanceOfButton);

where you have set the instance (in the properties window of that button) to instanceOfButton, then the button will only start dragging itself.

Link to comment
Share on other sites

You can use this if you structure the code like so:
buttonInstance.onPress = function() {		startDrag (this);}

I guess, but it looks a bit bulkier to me. Especially with the function() thing there.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...