Click to See Complete Forum and Search --> : Drag and Rotate
possum3
01-04-2006, 08:41 PM
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?
blanius
01-04-2006, 11:06 PM
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
}
}
}
blanius
01-04-2006, 11:08 PM
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.
possum3
01-05-2006, 12:21 AM
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
possum3
01-06-2006, 12:23 AM
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.
Chris_Seahorn
01-06-2006, 01:50 AM
Attachment cleared. Resolved.
possum3
01-06-2006, 11:58 AM
Thank you for your help Chris.
Chris_Seahorn
01-06-2006, 12:12 PM
Bret did all the work....I just gave it a spin ;)
blanius
01-08-2006, 10:17 PM
Sorry did that in a hurry then was out of town for a few days.
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.