-
[RESOLVED] Using Tweener to tween property of class
I've got a property,
var angleX:Number;
declared right after my class declaration (therefore available to each function in the class). How do I go about tweening this value with Tweener? Specifically, I'm trying to do it in a mouse press event but am stumped by the object i need to pass - the keyword "this" isn't working.
protected function moveRight(e:Event):void
{
dest++;
trace(angleX); //traces ok
Tweener.addTween(this, {angleX:dest*anglePer, time:0.5});
}
How do I tell Tweener that the variable belongs to the class?
Thanks in advance!
-
The param needs to be visible publicly (you're telling tweener to tell "this" what to do - so Tweener needs to see the var) - so set up an accessor pair:
PHP Code:
public function get _angleX():Number{
return angleX;
}
public function set _angleX(n:Number):void{
angleX = n;
}
protected function moveRight(e:Event):void{
dest++;
trace(angleX); //traces ok
Tweener.addTween(this, {_angleX:dest*anglePer, time:0.5});
}
Please use [php] or [code] tags, and mark your threads resolved 8)
-
Brilliant. Thanks a million. I never really got why I needed get and set functions (except to make debugging easier), now it all makes perfect sense.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|