A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Really Simple yet Complicated Question:

  1. #1
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870

    Really Simple yet Complicated Question:

    How to make complicated tweenings in ActionScript?

    Say if I got a arrow MC with instance name : myTweenObject
    How do I make the arrow, (start with pointing upwards) twist 90 degrees CW in 30 frames, then twist 180 degrees AntiCW in 80 frames, then expand itself by 30%???
    I know how to animate but how to continuesly animate something by AS?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    heres one way:

    Code:
    //we want arrow to rotate 90 degrees in 30 frames which means in one frame we want it to rotate 90/30 = 3 degrees, hence:
    var cwSpeed:Number = 3;
    
    //we want arrow to rotate 180 degrees in 80 frames which means in one frame we want it to rotate 180/80 = 2.25 degrees hence:
    var acwSpeed:Number = -2.25;
    
    
    var expansionSpeed:Number = 1;
    var speed:Number = cwSpeed;
    var expand:Boolean = false;
    
    _root.onEnterFrame = rotate;
    
    function rotate() {
    	//clockwise first
    	myTweenObject._rotation += speed;
    	if (myTweenObject._rotation == 90) {
    		speed = acwSpeed;
    	}
    	if (myTweenObject._rotation == -90) {
    		//now we dont want it to rotate so set speed to zero
    		speed = 0;
    		expand = true;
    	}
    	if (expand) {
    		myTweenObject._xscale = myTweenObject._yscale += expansionSpeed;
    		if (myTweenObject._xscale == 130) {
    			delete this.onEnterFrame;
    		}
    	}
    }
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Good one thanks!
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

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