Jump to content
Search Community

Stack overflow when override set rotation()

rivella50 test
Moderator Tag

Recommended Posts

Hi there,

 

for a game i use LinePath2D to animate objects over defined paths, where autorotate is enabled. The problem is that the rotation happens

around the registration point and this looks very unnatural in my case.

Now i tried different ways to change the rotation behaviour to use e.g. the center of the SpriteVisualElement objects as rotation points.

For this i have found approaches on the web to rotate an object around another point than the registration point, where they do all work

without the use of LinePath2D and TweenMax.to(..), but with them i always run in a Stack overflow error when running the test app.

Also i had to override the set rotation() function for the SpriteVisualElement extension class that will animate the objects for being able

to change the rotation behaviour, when LinePath2D->renderObjectAt() tries to set the new angle value:

 

override public function set rotation(value:Number):void {
  rotator.setRegistrationPoint(new Point(this.x + this.width/2, this.y + this.height/2));
  rotator.rotation = value;
}

 

Using Rotator class (http://code.google.com/p/barteksplaygro ... Rotator.as) is one approach

to change the rotation point.

Does someone know why i always run into that sort of errors and if yes, how can i solve this problem ?

 

Thanks for any help.

Bests

valley

Link to comment
Share on other sites

It's very difficult to troubleshoot without seeing your code or the error in context. Please post a simple FLA that clearly demonstrates the problem. It almost sounds like you're calling the "rotation" setter from inside of itself which would definitely cause a stack overflow (infinite recursion).

 

By the way, is there any reason why you don't just change your object's registration point instead of trying to use these workarounds? In other words, why not just build your object so that its registration point is exactly where you want it to be in terms of rotation? Or wrap your objects in a container and offset their x/y values accordingly and then make the container follow the path.

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...