// Richard Caceres, rcaceres {at} ucla.edu // DMA 199 // $Id: ImageIG3.as,v 380.1 2008-01-30 18:11:35-08 - - $ // $Date: 2008-01-30 18:11:35-08 $ package { import flash.display.Sprite; import flash.display.Loader; import flash.events.*; import flash.net.*; import fl.transitions.*; import fl.transitions.easing.*; public class ImageIG3 extends Sprite { var url_str:String; var isLoaded:Boolean = false; var isBeingLoaded:Boolean = false; var obj_width, obj_height; var fadetween:Tween; var dimtween:Tween; public function ImageIG3 (_url:String, _width, _height) { url_str = _url; obj_width = _width; obj_height = _height; this.alpha = .2; loadImage(); } public function loadImage ():void { trace ("loadImage: "+url_str); if (isLoaded == false && isBeingLoaded == false) { var loader:Loader = new Loader(); loader.load (new URLRequest(url_str)); loader.contentLoaderInfo.addEventListener (Event.COMPLETE, handleLoadComplete); isBeingLoaded = true; addChild(loader); } else { this.fadeIn(); } } public function handleLoadComplete (e:Event) { //trace ("handleComplete: "+e); isBeingLoaded = false; isLoaded = true; //this.width = this.obj_width; //this.height = this.obj_height; this.fadeIn(); } public function fadeIn ():void { //fadetween = new Tween (this, "y", Regular.easeOut, 0, this.y, 30); } public function fadeOut ():void { fadetween = new Tween (this, "alpha", Regular.easeOut, this.alpha, 0, 30); } public function focus ():void { dimtween = new Tween (this, "alpha", Regular.easeOut, this.alpha, 1, 2, true); } public function unfocus ():void { if (this.alpha > .2) dimtween = new Tween (this, "alpha", Regular.easeOut, this.alpha, .2, 2, true); } // GET AND SET VARIABLES // - Actionscript has the feature to officially create get and set methods // which then appear to be simple parameters. // example way to access these: trace(foo.centerX); or foo.centerX = 10; public function get centerX():int { return x + width/2.0; } public function set centerX(val:int) { x = val - (width/2.0); } } }