Jump to content
Search Community

rotationX followed by transformMatrix:{rotation}

BladePoint test
Moderator Tag

Recommended Posts

I have a rectangular sprite that I want to turn in 2 dimensions so it looks like a card. It begins with rotationX:90 so you only see the edge and tweens to rotationX:0 so its flat. Then I want it to rotate it 180 degress using transformMatrix so it's nice and smooth.

 

TweenLite.from(card, 2, {rotationX:90, onComplete:rotateCard});

 

function rotateCard():void {

 

TweenMax.from(card, 2, {transformMatrix:{rotation:180});

}

 

That kicks up this error though:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at com.greensock.plugins::TransformMatrixPlugin/onInitTween()

at com.greensock::TweenLite/init()

at com.greensock::TweenMax/init()

at com.greensock::TweenMax/renderTime()

at com.greensock.core::SimpleTimeline/renderTime()

at com.greensock::TweenLite$/updateAll()

 

I read that you can't combine transformMatrix tweens with other transform property tweens so that is probably why. I'm trying to find a way around it though. Here's what I have come up with.

 

1. After the rotationX, remove card and replace it with a duplicate card in the exact same spot and apply the transformMatrix rotation to the duplicate card.

2. Just use the regular rotation instead of the transformMatrix rotation.

3. Kill the rotationX tween after it's done so it doesn't interfere with the transformMatrix rotation. I couldn't get this to work though.

 

Any other ideas?

Link to comment
Share on other sites

I believe the problem has to do with the fact that when you apply ANY 3D property to a DisplayObject (rotationX, rotationY, or z), it suddenly makes the transform.matrix null and populates the transform.matrix3D instead. Therefore, when you were trying to do a transformMatrix tween (which relies on the transform.matrix data), it was null. The solution is to simply set the DisplayObject's transform.matrix3D = null. So do that right before you do your regular transformMatrix rotation. Does that help?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...