A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Using Tweener to tween property of class

  1. #1
    Senior Member
    Join Date
    Nov 2005
    Location
    Milan
    Posts
    119

    resolved [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!

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    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*anglePertime:0.5});

    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Senior Member
    Join Date
    Nov 2005
    Location
    Milan
    Posts
    119
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center