Hey, i’m trying to get a box to drag (it’s a button within a movieclip), but my code just ends up dragging the whole stage, and i don’t know what i’m doing wrong. :-\
The code is:
on (press) {
startDrag ("");
}
on (release) {
stopDrag ();
}
I tried putting the name of the button instance in the “”, but that just makes the code do nothing.
i don’t understand what you mean by dragging the whole stage but I will explain how to get the object to drag.
Firstly you can drag only a movieclip so if u want to drag a button, create a button, then create a movieclip and from the library
(Ctrl + L) drag the button onto the movieclip. then go to the main movie time line and drag the movie clip from the library onto the stage and give it an instance name in the instance dialogue box. then right click on the mc and click on the edit. then right click on the button and click on actions and give the following actions
on (press) {
startDrag ("/instance name of the movieclip");
}
on (release) {
stopDrag ();
}
hey,
i tried converting the thing to a movieclip, and output says this:
Symbol=news, Layer=dragger, Frame=1: Line 1: Mouse events are permitted only for button instances
on (press) {
Symbol=news, Layer=dragger, Frame=1: Line 4: Mouse events are permitted only for button instances
on (release) {
So i converted it to a button again, and left “” blank, and it ends up dragging everything. What i mean about the ‘whole stage’ is that i have the button on top of a graphic (the bg), and it drags the background as well as the thing it’s supposed to be dragging.
Here’s the code i put on the button, with the button instance named:
on (press) {
startDrag (“dragger”);
}
on (release) {
stopDrag ();
}
…dragger being the button instance. I tried that before i posted for the first time, nothing’s working… Basically, the only way i get anything to drag, is if i have it as a button, and leave “” blank.
I would post the .fla, but it is Flash MX, so Flash 5 won’t be able to read it. If you use MX, let me know, I will post the .fla here for you in a .zip file.
There are no instance names for buttons!! (Haven’t I said that already?:P)
If you want to drag anything, you have to target a movie clip. In this case, ‘this’. It works, I’ve just tested it (if you a button inside a movie clip, of course).
*Originally posted by natalia *
**hey,
i tried converting the thing to a movieclip, and output says this:
Symbol=news, Layer=dragger, Frame=1: Line 1: Mouse events are permitted only for button instances
on (press) {
Symbol=news, Layer=dragger, Frame=1: Line 4: Mouse events are permitted only for button instances
on (release) {
So i converted it to a button again, and left “” blank, and it ends up dragging everything. **
OK, there is the problem. Let take this back from the beginning:
You have a graphic, you turn it into a button, and give it the code
on (press) {startDrag (this);}
For the moment, this refers to the _root (the parent of the button) so it won’t work.
Now turn your button into a movie clip (F8) and that’s it!
okay, now i’m hopelessly confused. all i wanted to do was to make this little box drag…
i can’t do button instances on flash 5.
if i make it into a movieclip, i can’t use the ‘on’ code in the actionscript box because i need an ‘onclip’ code. With the ‘onclip’, it doesn’t drag.