How do I tween a variable with TweenLite?
-
22-10-2019 - |
Question
package
{
import com.greensock.TweenLite;
import flash.display.Sprite;
public class TweenTest extends Sprite
{
private var _test:Number = 10;
public function TweenTest()
{
TweenLite.to(this,1,{_test:200});
}
}
}
I get the error #1069: Property _test not found for TweenTest… I also tried this example which does not work for me: http://www.snorkl.tv/2010/09/how-to-tween-a-variable-with-flash-and-tweenlite/
Solution
TweenLite can only affect public properties of a class. Making _text
public or creating an public getter should sort it out.
OTHER TIPS
This is definitely possible by simply making your variable public.
You can also do something like:
var arr:Array = [0];
TweenLite.to(arr, 1, {endArray: [10], onUpdate: output});
function output():void
{
trace (arr[0]);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow