Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Stack overflow when override set rotation()

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.



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

Hi greensock,


thank you for your answer. Meanwhile i have added a wrapper around the object to be animated, which solves the problem of having a wrong registration point.




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.