Chat LIVE With Programming Experts! There Are 23 Online Right Now...

 

Code Snippets

  

ActionScript Source Code


Welcome to Dream.In.Code
Become an Expert!

Join 244,058 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,405 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: 5,115

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!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month