Code Snippets

  

ActionScript Source Code


Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,102 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,142 people online right now. Registration is fast and FREE... Join Now!





MovieClip.alphaTo

make a movie clip alpha dynamically using this cool proto

Submitted By: reyco1
Actions:
Rating:
Views: 4,252

Language: ActionScript

Last Modified: April 4, 2005
Instructions: you know the drill, plug the proto on to the first frame of your movie. an example of the usage is in the script

Snippet


  1. MovieClip.prototype.alphaTo = function(targetAlpha, speed) {
  2.      this.onEnterFrame = function() {
  3.           alphaDifference = Math.abs(this._alpha-targetAlpha);
  4.           if (this._alpha>targetAlpha) {
  5.                this._alpha -= alphaDifference/speed;
  6.           } else if (this._alpha<targetAlpha) {
  7.                this._alpha += alphaDifference/speed;
  8.           } else if (this._alpha == targetAlpha) {
  9.                delete this.onEnterFrame;
  10.           }
  11.      };
  12. };
  13. //
  14. /////////////usage////////////////////////
  15. ////myImage.alphaTo(targetAlpha, speed)///
  16. //////////////////////////////////////////
  17. //
  18. myButton.onRelease = function() {
  19.      _root.myImage.alphaTo(0, 4);
  20. };

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month