A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: smoothness

Hybrid View

  1. #1
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    One more cool tween to add to this thread, so I can point people to it for future reference.

    A spring-effect in which the button is scaled with a spring-like motion. Here's the script:

    Code:
    onClipEvent (load) {
    	this.speed = 0;   // current tween velocity
    	this.tScale = 100; // target scale
    	this.stiffness = .3;
    	// (from 0-1 or so) spring stiffness - large numbers make the spring 'stiffer'
    	this.damping = .8;
    	// (from 0-1) affects rate of decay - lower numbers make spring settle faster
    }
    
    // spring animation code
    onClipEvent (enterFrame) {
    	var ds = this.tScale - this._xscale;
    	this.speed  += ds*this.stiffness;
    	this.speed *= this.damping;
    	this._xscale += this.speed;
    	this._yscale += this.speed;
    }
    
    // we set the desired xcales/yscale here
    on (rollOver) {
    	this.tScale = 120;
    }
    on (rollOut) {
    	this.tScale = 100;
    }
    And a sample FLA file demonstrating the effect is enclosed.
    Attached Files Attached Files

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