-
Drag and Rotate
I have made a puzzle that contains seven pieces. Each piece has been converted to a movie clip to allow for dragging. Each piece has been assigned a corresponding number key that will rotate the piece fortyfive degrees. Is there a way I can 'shift click' to rotate a puzzle piece instead of assigning an individual key to each piece?
-
I would think you could. You should be able to tell if the mouse is over a MC or track which MC is "selected" and then the key action could use this info to know which piece to rotate.
mc1.onMouseDown=function(){
mc1.selected=true;
txt1.text=mc1.selected
}
mc1.onMouseUp=function(){
mc1.selected=false;
txt1.text=mc1.selected
}
myListener=new Object()
Key.addListener(myListener);
myListener.onKeyDown=function(){
if (Key.isDown(Key.Space)) {
txt1.text="space"
if (mc1.selected){
mc1._rotation+=45
}
}
}
-
I think there's a better way though. It seems to me that you should be able to prototype a broadcast to all movieClips that send a reference that you could listen for and then look to see if Space is down. I don't have time to figure out the code for that at the moment.
-
Thank you Bret! I will try using your example. I had been reading about functions but it hasn't filtered down to where it makes sense yet. Thanks
-
1 Attachment(s)
I did try the above script using two movieclips. Both clips rotate at the same time. I am not able to select just one clip to rotate. If I hold down the spacebar and click both clips rotate. If I hold the mouse down and press the spacebar both clips rotate. I have found more information to read. I may not find what I need but I have learned a few things in the meantime.
-
Attachment cleared. Resolved.
-
Thank you for your help Chris.
-
Bret did all the work....I just gave it a spin ;)
-
Sorry did that in a hurry then was out of town for a few days.