Jump to content
GreenSock

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

Tween Object

Recommended Posts

Hi is there anyway to tween a non native flash property with tweenLite.

I want to use an object to hold a property called specialRotation for example and I want to update that property using tweenlite.to, how can I achieve.

 

I tried using a getter and setter but that didn't work.

 

var obj:Object = new Object();
private function get specialRotation():Number
{
return obj.specialRotation;
}

private function set specialRotation(value:Number):void
{
obj.specialRotation = value;
}

TweenLite.to(obj, 1, {specialRotation:90, onUpdate:onUpdateTest } );

private function onUpdateTest():void
{
trace("working = "+specialRotation);
}

Link to comment
Share on other sites

Absolutely - I do it all the time. TweenLite/Max will tween ANY numeric property of ANY object.

 

var obj:Object = new Object();
obj.specialRotation = 0;

TweenLite.to(obj, 2, {specialRotation:100, onUpdate:onUpdateTest});

function onUpdateTest():void {
   trace("specialRotation: " + obj.specialRotation);
}

 

If your object is an instance of a custom class, you could use a getter/setter to do special stuff whenever the tweening value gets updated. Or just use an onUpdate like above.

 

Enjoy.

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