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

3D Rotation Inconsistent Between Motion Editor & AS3 (CS4)

Explorer ,
Nov 20, 2008 Nov 20, 2008

Copy link to clipboard

Copied

I'm trying to access the rotationY property in code to determine the current state of a movie clip that has its rotationY animated in the motion editor. What I'm seeing is that the value of the property reported in a trace stmt is different than the value shown in the motion editor.

In the motion editor I created a tween from rotationY=0 at frame 0 to rotationY=353 at the last frame. I've added the attached code to get the value of rotationY at every frame.

What I see is that the rotation does not increase steadily from 0 to 353. Instead it increases from 0 to 90 and then decreases back to 0 and then goes negative to -90 at which point the absolute values decrease toward 0. This seems like a bug. The rotation of the object is visibly different during the 0 to 90 deg. phase than it is from the 90 to 0 phase yet the numerical values are the same. And if I set the rotation of the object in code instead of the motion editor, rotations from 90 to 180 correspond to the phase reported by the trace statement as 90 to 0. Something doesn't make sense about this inconsistent behavior.

David Salahi
TOPICS
ActionScript

Views

803

Translate

Translate

Report

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

Explorer , Nov 22, 2008 Nov 22, 2008
Colin,
Thanks for the explanation!

I'll have to rethink my approach. What I'm trying to do seems like it should be simple but I haven't yet found a way to do it. I'm trying to have a two-sided movie clip with different photos on each side. When it rotates I want the different photos to be visible based on which side is turned toward the viewer. But Flash doesn't do true 3D so it's not possible to construct a true two-sided object. As far as I can tell. some workaround is necessary. My thought w...

Votes

Translate

Translate
LEGEND ,
Nov 22, 2008 Nov 22, 2008

Copy link to clipboard

Copied

Welcome to 3D! An object rotated in any way you like, could have gotten into that state in more than one way. Imagine a 90 degree X rotation, you can also get there with a -90 X rotation along with a 180 Y and Z rotation.

Put differently, try this:

function frameListener(evt:Event):void {
trace(mc.rotationY,mc.rotationX,mc.rotationZ);
}

I don't know what thought process it goes through to decide that you really did an XYZ rotation and not just the Y rotation you thought you did, but the numbers are still correct, even it they're not convenient.


Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2008 Nov 22, 2008

Copy link to clipboard

Copied

Colin,
Thanks for the explanation!

I'll have to rethink my approach. What I'm trying to do seems like it should be simple but I haven't yet found a way to do it. I'm trying to have a two-sided movie clip with different photos on each side. When it rotates I want the different photos to be visible based on which side is turned toward the viewer. But Flash doesn't do true 3D so it's not possible to construct a true two-sided object. As far as I can tell. some workaround is necessary. My thought was to check the current rotation in an enterFrame listener and set the visibility of one or the other. But now, I can see that won't work. Any suggestions?

Dave

Votes

Translate

Translate

Report

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
LEGEND ,
Nov 22, 2008 Nov 22, 2008

Copy link to clipboard

Copied

With a movieclip that has two frames and a stop action, try this:

mc.addEventListener("enterFrame", frameListener);

function frameListener(evt:Event):void {
var f:int=1;
if (mc.rotationX>0) {
f=2;
}
mc.gotoAndStop(f);
}


ps. Of course you would want the two frames to be different in order to see that it's doing something!


Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2008 Nov 22, 2008

Copy link to clipboard

Copied

Hi Colin,
Thanks for the suggestion. I'm not sure if your code snippet would work to achieve what I'm trying to accomplish. The effect I'm after is to simulate a rotating two-sided photo. When the front side is toward the viewer, the front-side photo would be visible and vice-versa.

But as I was thinking about your original reply I realized that my original approach ought to work if I just just examine the rotation of all three axes. Various combinations of rotation along the three axes will produce a photo that is displaying either its front or its back. I just need to work through the various permutations to get the ranges of x/y/z rotations that indicate a forward-facing object vs. a backward-facing object.

I'll continue with that approach. Thanks again!

Dave

Votes

Translate

Translate

Report

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
LEGEND ,
Nov 22, 2008 Nov 22, 2008

Copy link to clipboard

Copied

My sample code does do exactly what you're talking about. By looking at the X rotation you can tell whether the front or back is towards you, because as your Y rotation changes, the X flips between 180 and 0.


Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2008 Nov 22, 2008

Copy link to clipboard

Copied

Right, your code does do that as long as only rotationY is animated (which is what I had mentioned in my original post). However, I need it to work in the general case where rotation is being animated about any or all of the axes. I think I'll have to look at all three axes to do that.

Cheers,
Dave

Votes

Translate

Translate

Report

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
New Here ,
Jan 09, 2009 Jan 09, 2009

Copy link to clipboard

Copied

Double sided clips in Flash Player 10:

http://blog.soulwire.co.uk/flash/actionscript-3/two-sided-planes-in-flash-player-10/

That might help you out?

Votes

Translate

Translate

Report

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
New Here ,
Jan 09, 2009 Jan 09, 2009

Copy link to clipboard

Copied

Double sided clips in Flash Player 10:

http://blog.soulwire.co.uk/flash/actionscript-3/two-sided-planes-in-flash-player-10/

That might help you out?

Votes

Translate

Translate

Report

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
Explorer ,
Jan 09, 2009 Jan 09, 2009

Copy link to clipboard

Copied

LATEST
soulwire,
This looks like exactly what I was looking for! And your PaperSprite class is a very nicely written tutorial.
Thanks!
Dave

Votes

Translate

Translate

Report

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