We Recommend

Accelerated C# 2008 Accelerated C# 2008
This book is both a rapid tutorial and a permanent reference. You’ll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start?


Posted By

chrisaiv on 02/20/07


Tagged

MovieClipLoader FadeAlphaIn


Versions (?)


Who likes this?

7 people have marked this snippet as a favorite

Hirmine
juliecutey
gasface
arala22
digitalifer
ninedaysoff
mrjthethird


AS2: Dynamically load image + FadeAlphaIn


Published in: ActionScript 


This is a quick way to fade in an image while it is dynamically loading. MovieClipLoader is a powerful class that can also show loading progress and load completion so it's worth looking into if you need something more powerful.

  1. /************************
  2. Import Classes
  3. ************************/
  4. import mx.transitions.Tween;
  5. import mx.transitions.easing.*;
  6. /************************
  7. Fade in JPG
  8. ************************/
  9. MovieClip.prototype.FadeAlpha = function(url:String, direction:String) {
  10. //A. You can either fade "IN" or "OUT"
  11. if (direction == "IN")
  12. {
  13. //B. MovieClipLoader is far more powerful than loadMovie()
  14. var mcLoader:MovieClipLoader = new MovieClipLoader();
  15. mcLoader.loadClip(url, this);
  16. var tw:Tween = new Tween(this, "_alpha", Strong.easeOut, 0, 100, 50, false);
  17. } else
  18. {
  19. var tw:Tween = new Tween(this, "_alpha", Strong.easeOut, 100, 0, 50, false);
  20. }
  21. };
  22. //Create a new MovieClip, load .JPG, and FadeIN
  23. var container_mc:MovieClip = this.createEmptyMovieClip("container_mc", this.getNextHighestDepth());
  24. container_mc.FadeAlpha("http://capefeare.com/ralphdrip_small.gif", "IN");

Report this snippet 

You need to login to post a comment.