Groups | Blog | Home
all groups > flash actionscript > november 2006 >

flash actionscript : Drag Drop and Rotate Multiple Objects


Jeff Hight
11/2/2006 7:45:30 PM
I have 3 objects on the stage that I need to be able to individually drag and
rotate. I've managed to get this to work
with one of the objects using the arrow keys left and right to rotate the
object. I then tried to set a variable that would
rotate the different objects but can't seem to get that to work out. Any help
at all, as usual would be GREATLY appreciated!

Thanks in advance,
Jeff
kglad
11/2/2006 7:56:15 PM
if your variable contains that name of the movieclip that you want to rotate,
there should be no problem short of faulty programming. does your variable
contain the name of the movieclip that's to be rotated? if so, show your code.
Jeff Hight
11/2/2006 8:09:01 PM
Thanks for your reply Kglad
Here's the code, for what it's worth...

on(press) {
_root.object="box1"
this.startDrag();
}

on(release) {
this.stopDrag();
}

on(keyPress "<left>") {
_root.object._rotation += 2;
}
on(keyPress "<right>") {
_root.object._rotation -= 2;
}

As soon as I change it from this._rotation to the variable name, it kills
it....

jH
kglad
11/2/2006 8:14:01 PM
if you use a string to designate your object to be rotated you must help flash convert that string to an object. you can use array notation:

Jeff Hight
11/2/2006 8:25:49 PM
Thanks again for getting back to me so quick Kglad,
I tried both examples and the darn thing still won't rotate...
Jeff Hight
11/2/2006 8:29:15 PM
kglad
11/2/2006 8:37:45 PM
ooops. this is a little awkward but you should use:



on(press) {
_root.object="box1"
this.startDrag();
}

on(release) {
this.stopDrag();
}

on(keyPress "<left>") {
_root[_root.object]._rotation += 2;
}
on(keyPress "<right>") {
_root[_root.object]._rotation -= 2;
}

// or better

on(press) {
_root.object=_root.box1
this.startDrag();
}

on(release) {
this.stopDrag();
}

on(keyPress "<left>") {
_root.object._rotation += 2;
}
on(keyPress "<right>") {
_root.object._rotation -= 2;
}
AddThis Social Bookmark Button