A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Drag and Rotate

  1. #1
    Junior Member
    Join Date
    Sep 2005
    Posts
    27

    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?

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    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
    }
    }
    }

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    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.

  4. #4
    Junior Member
    Join Date
    Sep 2005
    Posts
    27
    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

  5. #5
    Junior Member
    Join Date
    Sep 2005
    Posts
    27
    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.
    Attached Files Attached Files

  6. #6

  7. #7
    Junior Member
    Join Date
    Sep 2005
    Posts
    27
    Thank you for your help Chris.

  8. #8

  9. #9
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Sorry did that in a hurry then was out of town for a few days.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center