Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,360 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,217 people online right now. Registration is fast and FREE... Join Now!




Actionscript to rotate an object

 
Reply to this topicStart new topic

Actionscript to rotate an object

Hamish++
post 30 Sep, 2008 - 10:23 AM
Post #1


New D.I.C Head

*
Joined: 30 Sep, 2008
Posts: 4

Hi I'm new here smile.gif

I'm looking for the code to rotate an object (a movieclip) 90 deg (clockwise) when alt-clicked.

So far I have code to click an drag each object which works fine like this:


CODE
s1.onPress=function(){
startDrag(this);
}
s1.onRelease=s1.onReleaseOutside=function(){
stopDrag();
}


I'm making a Tangram game btw

This post has been edited by Hamish++: 30 Sep, 2008 - 10:30 AM
User is offlineProfile CardPM

Go to the top of the page

DilutedImage
post 30 Sep, 2008 - 10:44 AM
Post #2


D.I.C Addict

Group Icon
Joined: 20 Nov, 2006
Posts: 642



Thanked 6 times

Dream Kudos: 25
My Contributions


You'll need a Key listener to monitor the key, and then use the rotation property to change the Movie Clip's rotation.

That's about all the help I can offer though, since you've not posted any code relevant to your question.

User is offlineProfile CardPM

Go to the top of the page

Hamish++
post 30 Sep, 2008 - 10:48 AM
Post #3


New D.I.C Head

*
Joined: 30 Sep, 2008
Posts: 4

I haven't posted any relevant code because I haven't written any yet.

Where do I find a key listener? Sorry I'm very new to Flash MX.
User is offlineProfile CardPM

Go to the top of the page

DilutedImage
post 30 Sep, 2008 - 11:24 PM
Post #4


D.I.C Addict

Group Icon
Joined: 20 Nov, 2006
Posts: 642



Thanked 6 times

Dream Kudos: 25
My Contributions


Well, rules prohibit any code being provided without an attempt on your part first. Sorry.

In AS3 you'd create listeners for the "KeyboardEvent" class. In AS2 you'd create listeners for the "Key" class. Information on both, including good examples, can be found in the Help documentation.
User is offlineProfile CardPM

Go to the top of the page

Hamish++
post 1 Oct, 2008 - 05:16 AM
Post #5


New D.I.C Head

*
Joined: 30 Sep, 2008
Posts: 4

OK I have tried something else. I put the following code into each movieclip but it doesn't do anything.

CODE
onClipEvent(enterFrame){
if (hitTest( _root._xmouse, _root._ymouse, true)) {
if(key.isDown(18))this._rotation+=90;
}
}


Is the solution as simple as this or do I have to go and create a keylistener and classes for the shapes and all that? I'd rather keep things as simple as needed.

I'm using Flash MX 2004

This post has been edited by Hamish++: 1 Oct, 2008 - 05:17 AM
User is offlineProfile CardPM

Go to the top of the page

Hamish++
post 1 Oct, 2008 - 01:34 PM
Post #6


New D.I.C Head

*
Joined: 30 Sep, 2008
Posts: 4

It's OK I found out a way.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 04:34AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month