Click, animate rotation of Object by +90° via AS3?

I have a button that will rotate an object in its parent by 90 degrees every time its clicked:
b_rotate_CW.addEventListener(MouseEvent.CLICK, rotateCW);
function rotateCW(event:MouseEvent):void
Object(this).parent.module.rotation += 90;
Which is fine, but I think it would be a nice touch if the object's rotation were animated.
I tried this:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
b_rotate_CW.addEventListener(MouseEvent.CLICK, rotateCW);
function rotateCW(event:MouseEvent):void
var rCW:Tween = new Tween(Object(this).parent.module, "rotate", Strong.easeOut, 0, +90, .5, true);
... but it does nothing at all, I am guessing that "rotate" is a property option, I can find no documentation for that, only x, y, their scale and alpha.
I'm sure this has been done by many, can anyone offer a helpful clue as to how this function would be properly coded?
Thanks!

Thats brilliant, I tweaked it a little; replaced the 0 with the current angle of the clip) and now it works perfectly:
var rCW:Tween;
b_rotate_CW.addEventListener(MouseEvent.CLICK, rotateCW);
function rotateCW(event:MouseEvent):void
rCW = new Tween(Object(this).parent.module, "rotation", Strong.easeOut, Object(this).parent.module.rotation, Object(this).parent.module.rotation+90, .5, true);
Who would have known you could use a target path in place of a value?
Where can everyone learn AS3 as you know it?
Thank you again for your immense help!

Similar Messages

  • Problem in moving Rotated Shape object

    Hi All,
    I want to move the rotated shape object based on the mouse movement
    m able to move the object which is not rotated, but m facing the problem when i move the rotated object its moving position is not correct . I am expecting to maintain both shape objects movement is same, i mean if i did mouse movement to right rotated object moves upwards and normal object moves towards right insted of moving both r moving towards to right.
    Pls help me
    the following code is m using to moving the object
    The one which in red color is not rotated and the one which is in black color has rotated.
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.Shape;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.geom.AffineTransform;
    import java.awt.geom.Point2D;
    import java.awt.geom.Rectangle2D;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import com.clinapps.LDPConstants;
    public class MoveRotatedObj extends JFrame
         public MoveRotatedObj()
              JPanel pane = new Dorairaj();
              add(pane);
         public static void main(String[] args)
              MoveRotatedObj f = new MoveRotatedObj();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setSize(400, 400);
              f.setLocation(200, 200);
              f.setVisible(true);
         static class Dorairaj extends JPanel
              implements
                   MouseListener,
                   MouseMotionListener
              Shape o = null;
              Rectangle2D rect = new Rectangle2D.Double(
                   10, 10, 100, 100);
              Graphics2D g2 = null;
              boolean flag = true;
              int x=10,y=10,x1, y1, x2, y2;
              AffineTransform af = new AffineTransform();
              AffineTransform originalAt = new AffineTransform();
              int origin = 0;
              public Dorairaj()
                   addMouseListener(this);
                   addMouseMotionListener(this);
              protected void paintComponent(Graphics g)
                   super.paintComponent(g);
                   g2 = (Graphics2D) g;
                   g2.draw(new Rectangle2D.Double(0,0,500,500));
                   g2.translate(origin, origin);
                   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
                   rect = new Rectangle2D.Double(
                        x, y, 150, 100);
                   g2.setColor(Color.RED);
                   g2.draw(rect);
                   g2.setColor(Color.black);
                   originalAt = g2.getTransform();
                   g2.rotate(Math.toRadians(270), 200, 200);               
                   g2.draw(rect);
                   g2.setTransform(originalAt);
              * Invoked when a mouse button has been pressed on a component.
              public void mousePressed(MouseEvent e)
                   e.translatePoint(-origin, -origin);
                   x1 = e.getX();
                   y1 = e.getY();
              public void mouseDragged(MouseEvent e)
                   x2 = e.getX();
                   y2 = e.getY();
                   x = x + x2 - x1;
                   y = y + y2 - y1;
                   x1 = x2;
                   y1 = y2;
                   repaint();
              public void mouseMoved(MouseEvent e)
              * Invoked when the mouse button has been clicked (pressed and released)
              * on a component.
              public void mouseClicked(MouseEvent e)
                   repaint();
              * Invoked when a mouse button has been released on a component.
              public void mouseReleased(MouseEvent e)
              * Invoked when the mouse enters a component.
              public void mouseEntered(MouseEvent e)
              * Invoked when the mouse exits a component.
              public void mouseExited(MouseEvent e)
    Edited by: DoraiRaj on Sep 16, 2009 12:51 PM
    Edited by: DoraiRaj on Sep 16, 2009 1:00 PM
    Edited by: DoraiRaj on Sep 16, 2009 1:07 PM

    Thanks for replay and suggestion morgalr,
    I mean MoveRotatedObj1 is MoveRotatedObj only jsut m maintaing a copy on my system like MoveRotatedObj1.
    finally i solved my problem like this ,
    Is this correct approach m followinig or not pls let me know .
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.Shape;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.geom.AffineTransform;
    import java.awt.geom.Point2D;
    import java.awt.geom.Rectangle2D;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import com.clinapps.LDPConstants;
    public class MoveRotatedObj extends JFrame
    public MoveRotatedObj()
      JPanel pane = new Dorairaj();
      add(pane);
    public static void main(String[] args)
      MoveRotatedObj f = new MoveRotatedObj();
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.setSize(400, 400);
      f.setLocation(200, 200);
      f.setVisible(true);
    static class Dorairaj extends JPanel
      implements
       MouseListener,
       MouseMotionListener
      Shape o = null;
      Rectangle2D rect = new Rectangle2D.Double(
       10, 10, 100, 100);
      Rectangle2D rect1 = new Rectangle2D.Double(
       10, 10, 100, 100);
      Graphics2D g2 = null;
      boolean flag = true;
      double lx, ly;
      int x = 10, y = 10, x1, y1, x2, y2;
      int l = 20, m = 20;
      int angle = 270;
      AffineTransform af = new AffineTransform();
      AffineTransform originalAt = new AffineTransform();
      int origin = 0;
      public Dorairaj()
       addMouseListener(this);
       addMouseMotionListener(this);
      protected void paintComponent(Graphics g)
       super.paintComponent(g);
       g2 = (Graphics2D) g;
       g2.draw(new Rectangle2D.Double(
        0, 0, 500, 500));
       g2.translate(origin, origin);
       g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
        RenderingHints.VALUE_ANTIALIAS_ON);
       rect = new Rectangle2D.Double(
        x, y, 150, 100);
       g2.setColor(Color.RED);
       g2.draw(rect);
       rect1 = new Rectangle2D.Double(
        l, m, 150, 100);
       g2.setColor(Color.black);
       originalAt = g2.getTransform();
       g2.rotate(Math.toRadians(angle), 200, 200);
       g2.draw(rect1);
       g2.setTransform(originalAt);
      public void mousePressed(MouseEvent e)
       e.translatePoint(-origin, -origin);
       x1 = e.getX();
       y1 = e.getY();
      public void mouseDragged(MouseEvent e)
       boolean left, right, up, bottm;
       int dx, dy;
       left = right = up = bottm = false;
       x2 = e.getX();
       y2 = e.getY();
       dx = x2 - x1;
       dy = y2 - y1;
       x = x + dx;
       y = y + dy;
       up = dy < 0;
       bottm = dy > 0;
       left = dx < 0;
       right = dx > 0;
       if (left || right)
        // b += dx;
        m += dx;
       if (up || bottm)
        // a -= dy;
        l -= dy;
       x1 = x2;
       y1 = y2;
       repaint();
      public void mouseMoved(MouseEvent e)
      public void mouseClicked(MouseEvent e)
       repaint();
      public void mouseReleased(MouseEvent e)
      public void mouseEntered(MouseEvent e)
      public void mouseExited(MouseEvent e)
    }

  • In Macromedia Flash8 we had an option insert timeline effects rotate. Do we have any option to rotate an object in Adobe Flash cs5 and above

    in Macromedia Flash8 we had an option insert>timeline effects>rotate. Do we have any option to rotate an object in Adobe Flash cs5 and above.

    You can also use the following:
    1 Select the object to rotate > Right Click > Create Motion Tween.
    2 Click on the last frame of the Motion tween and choose the desired Rotation settings from Properties panel.

  • How do I embed a pdf document into an existing pdf so that the user double clicks on the pdf object within the pdf and it opens? i've looked everywhere on various forums and tried attachments - but still not working. Thanks

    I've tried various methods but to no avail. I have a pdf document and within the pdf I'd like to embed a couple pdf documents so that all the user has to do is double click on the pdf object inside the pdf and it opens in a new window. I've tried using attachments to do it and linking it...but to no avail. Anyone know how to do? I'm using Acrobat Pro Version 11. Thanks

    The "embed" feature common to MS Office applications is not applicable to PDF (for the why and wherefore of PDF get comfortable and read the ISO Standard for PDF - ISO 32000-1:2008).
    You can insert other PDF files' pages into any given PDF.
    You can attach files of supported formats to a PDF (of course a PDF is supported).
    You cannot "embed". So, nothing is broken.
    Be well...

  • Rotate a Object Around Center Axis

    Hey peoples, new to flash here.  I'm using CS3 with ActionScript 3.0.  What I want is simple, and I've done some searching but nothing that can get me the right results.  I'm going to post a link that does exactly what I want:
    http://www.newgrounds.com/dump/item/d25a3dd46f2ff49f2ec892c425cbbd1e
    This rotates the circular object around a center point in a way that you can distort the object yet is still remains turning in a circular motion.  A simple motion tween rotating the image will only work if the object is perfectly round, so distorting the object to make it more straight or curved won't work with a simple tween.  I want to do exactly what is happening here (with my own object), is there some AS3 behind the scenes here making this turn on a center point??  Thanks for the help

    Yes, but I still don't know what you mean by the parent child relationship.  Lets say I use a simple rotate line like:
    objectname.rotation = 360;
    That should spin it, but how do I spin it correctly if the object is skewed like in the bottom right picture of my example?

  • Thought I knew Adobe...but can't figure out how to rotate an object in AdobeMUSE. Help?

    I can't figure out how to rotate an object in Adobe Muse. I want an object to be half a bubble off plumb.

    Hi ,
    You can rotate an object in Muse by using the Transform toolbar and selecting the rotation angle. Please refer to this screenshot :- http://prntscr.com/52vtux
    However, if you want to create a circular looking object , then all you need to do is, set the corners as Rounded, Make the Height and Width Equal and then increase the corner radius. This would give you the desired result.
    Please refer to this screenshot :- http://prntscr.com/52vu9n
    Hope this helps
    Regards,
    Rohit Nair 

  • CS6 - Is it possible to rotate multiple objects independent of one another?

    CS6 - Is it possible to rotate multiple objects independent of one another? In other words selecting say 9 object in a grid then rotating the all 30 degrees on their own axis.

    I forgot Transform > Again won't rotate each layer about its own centre.
    It can be done, though. Record an Action of a layer being rotated and followed by Opt+] or Alt+] to target next layer. It should look like the screenshot below. Use it by first running it on the lowest target layer in the stack then running however many more times is required.

  • Swinging/Rotating an object in AE 5.5

    Hi all,
    I have a question about something that I am trying to achieve in AE5,5.
    I have a clip that I would like to 'rotate' into the frame and was wondering how I could do this. If I might explain:
    If you can imagine the action of a clapperboard, you might have an idea of the effect I'm trying to attain.Essentially, I'd like the clip to start offscreen on the right hand side of the frame, At this point, the clip would be rotated 90 degree clockwise. Over the a next couple of seconds, I'd like it to 'crash' down into the frame, rotating around the lower, right corner so that it ends up filling the frame and the correct way up :-). I thought it would be fairly easy to do this with a few adjustments around the anchor points but I seem to be having no luck as whenever I move the anchor point, the entire clip seems to move rather than just adjusting the point at which I'd like it to rotate.
    What am I missing??
    Any help would be greatly appreciated.
    Many thanks,
    Sean

    :-) Ah, I've been rumbled!! To be honest, I come from a straight video editing background and am just starting to get to grips with AE. I have just cracked open the Classroom-In-A-Book this week and (naively) thought that it might be something I could achieve simply by changing the anchor point from which to rotate the object around.  Seems like I was slightly off track - maybe I should have perservered with the book before I tried!
    Many thanks for the replies - I will certainly have a look at the blog post you mentioned and will see how I get on. From what I've seen so far, AE looks like it's going to be keep me occupied for many, many months to come. I'm looking forward to it!
    thanks again,
    Sean

  • Right clicking on a flash object causes all flash objects to crash

    whenever I attempt to right click on a flash movie or other flash based object the flash plugin crashes and takes all flash objects including those in other tabs with it. There does not seem to be any other problems with the plugin just that it crashes when an attempt is made to right click on any flash object.

    Try to create a new profile as a test to check if your current profile is causing the problems.
    See "Creating a profile":
    *https://support.mozilla.org/kb/profile-manager-create-and-remove-firefox-profiles
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Profile_issues
    If the new profile works then you can transfer some files from an existing profile to the new profile, but be cautious not to copy corrupted files to avoid carrying over the problem.
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox
    You can check for problems with current Flash plugin versions and try these:
    *disable a possible RealPlayer Browser Record Plugin extension for Firefox and update the RealPlayer if installed
    *disable protected mode in the Flash plugin (Flash 11.3+ on Windows Vista and later)
    *disable hardware acceleration in the Flash plugin
    *http://kb.mozillazine.org/Flash#Troubleshooting

  • Clicking on Touch Tracks object won't re-open Touch Tracks window

    Hey Everyone,
    If I create a Touch Tracks object in the Environment, a new Touch Tracks window appears. If I close that window and then double-click on the newly created Touch Tracks object to re-open the Touch Tracks window (like the manual tells me to), the window will not re-open. I'm on day three of trying to figure this out. Double-clicking on all other objects in the "All Objects" layer of the Environment works (takes you to where the clicked object exists in a different layer or whatever is supposed to happen). But double-clicking on this specific object does nothing.
    Also, if double-clicking just won't work, does anyone know a different way to re-open the Touch Tracks window?
    Thanks!

    I have the same problem as well with an itouch that I purchased for my niece. The first one I bought, the apps never worked after I downloaded and some songs wouldn't play either. So last Monday I exchanged it and got a new one. The apps worked on this one along with the music until she unwrapped it Christmas morning (about 4 days). Now the app will flash up then quickly return to the home screen. I also received a touch for Christmas and put the apps on mine and so far am NOT having that problem, so I don't think it's a computer problem. I scheduled a support call with apple but it will be January 4th before they can get to me! If anyone can help, it would be greatly appreciated!

  • Illustrator shuts down when I click drag on an object.

    It doesn't matter if I open the file in another version... It doesn't matter if I copy out the content and paste into a new file... Illustrator continues to shut down when I click drag on an object. Is this a keyboard issue? Or a program issue? or a combination?
    I have plenty of memory on my computer.

    After being on Adobe Chat support all morning, we uninstalled and reinstalled the program (outside of the cloud -as re-installing from the cloud produced the same error in the software).
    When having this issue, it did not matter what object was selected and moved. It did not matter what file I was in. It did not matter if I created a new file.

  • Difficulty rotating ms3d object in java 3d

    I've created a few ms3d objects and have managed to successfully load them into my J3d program.
    I'm trying now to rotate this object through user interaction.
    I will start by just getting the object to rotate first and then add the keyboard interaction.
    Is it possible to rotate these objects, and does anybody have any link suggestions
    Thanks

    I've created a few ms3d objects and have managed to successfully load them into my J3d program.
    I'm trying now to rotate this object through user interaction.
    I will start by just getting the object to rotate first and then add the keyboard interaction.
    Is it possible to rotate these objects, and does anybody have any link suggestions
    Thanks

  • Rotate and stop rotating an object

    Hi
    I want to rotate an object using the arrows on the keyboard when the mouse is over the object and it should not be possible to rotate the object when the mouse is not on the object.
    I know how to rotate the object, when the mouse is over the object, but when I put the mouse outside the object I can still rotate the object. How do I make the rotation stop?
    square1.addEventListener(MouseEvent.MOUSE_OVER, around);
    square1.addEventListener(MouseEvent.MOUSE_OUT, normal);
    function around(e:MouseEvent):void {
    stage.addEventListener(KeyboardEvent.KEY_DOWN, rotate);
    function rotate(event:KeyboardEvent):void {
    switch (event.keyCode)
    case Keyboard.RIGHT:
    square1.rotation += 90;
    break;
    case Keyboard.LEFT:
    square1.rotation -=90;
    break;
    function normal(e:MouseEvent):void {
         trace("The object should not be rotating");
    Thanks

    use:
    square1.addEventListener(MouseEvent.MOUSE_OVER, around);
    square1.addEventListener(MouseEvent.MOUSE_OUT, normal);
    function around(e:MouseEvent):void {
    stage.addEventListener(KeyboardEvent.KEY_DOWN, rotate);
    function rotate(event:KeyboardEvent):void {
    switch (event.keyCode)
    case Keyboard.RIGHT:
    square1.rotation += 90;
    break;
    case Keyboard.LEFT:
    square1.rotation -=90;
    break;
    function normal(e:MouseEvent):void {
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, rotate);

  • Javascript function to rotate an object around its axis

    Hello,
    I wonder if it is possible to rotate an object around its axis (eg 45 ° rotation)?
    I want to make this rotation with a button and a Javascript code!
    Is it possible? if so, have a track for me to start?
    thank you

    Possible, yes - but you will need some basic knowledge of how 3D matrix transformations work if you want to do anything complex.
    The code to rotate a node in a 3D scene by 45 degrees on the X axis is
    myNode.transform.rotateAboutXInPlace(Math.PI/4)

  • Rotating an object about a specific point!

    Hello Guys!
    Have a new Problem!
    I want to rotate an object about a specific point. But up to now i only can rotate something about the x,y,z axis!
    Is this possible to rotate a scene about the point 1,1,1?
         Transform3D rotation = new Transform3D();
         rotation.setRotation(new AxisAngle4d(-x, -y, 0,((Math.PI / 2) - angle)));
    I don't handle it with Alpha because i needn't an animation!
    Please help me!
    Quh

    Hello,
    to rotate an Object A about the Point P you have to do the following:
    1. Get the Transform T which transforms P to Point (0,0,0)
    2. Apply T on A
    3. Rotate A (around (0,0,0))
    4. Transform A with the inverse of T
    leha23.

Maybe you are looking for