Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Engaged ,
Nov 07, 2013 Nov 07, 2013

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!

TOPICS
ActionScript
3.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Nov 11, 2013 Nov 11, 2013

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

...
Translate
Community Expert ,
Nov 07, 2013 Nov 07, 2013

use:

import fl.transitions.Tween;

import fl.transitions.easing.*;

import fl.transitions.TweenEvent;

var rCW:Tween;

b_rotate_CW.addEventListener(MouseEvent.CLICK, rotateCW);

function rotateCW(event:MouseEvent):void

{

rCW = new Tween(Object(this).parent.module, "rotatation", Strong.easeOut, 0, Object(this).parent.module.rotation+90, .5, true);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 11, 2013 Nov 11, 2013

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 11, 2013 Nov 11, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines