-
import mx.events.EventDispatcher;
-
import mx.utils.Delegate;
-
import com.mosesSupposes.fuse.Fuse;
-
import com.mosesSupposes.fuse.FuseFMP;
-
import com.mosesSupposes.fuse.PennerEasing;
-
-
/**
-
* @author Matt Przybylski [http://www.reintroducing.com]
-
* @version 1.0
-
*/
-
-
class com.reintroducing.ui.GlowButton extends MovieClip
-
{
-
//- PRIVATE VARIABLES -------------------------------------------------------------------------------------
-
-
private var dispatchEvent:Function;
-
-
private var _fuse:Fuse;
-
private var _id:Number;
-
private var _startBlur:Number;
-
private var _endBlur:Number;
-
private var _active:Boolean;
-
-
//- PUBLIC VARIABLES --------------------------------------------------------------------------------------
-
-
public static var DEFAULT_NAME:String = "com.reintroducing.ui.GlowButton";
-
-
public var addEventListener:Function;
-
public var removeEventListener:Function;
-
-
// instances
-
public var title_txt:TextField;
-
-
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
-
-
public function GlowButton()
-
{
-
super();
-
-
EventDispatcher.initialize(this);
-
-
this.onLoad = Delegate.create(this, init);
-
}
-
-
//- PRIVATE METHODS ---------------------------------------------------------------------------------------
-
-
private function init():Void
-
{
-
this.initButtonEvents();
-
}
-
-
/**
-
* Adds the events to the button
-
*/
-
private function initButtonEvents():Void
-
{
-
this.onRollOver = Delegate.create(this, doRollOver);
-
this.onRollOut = Delegate.create(this, doRollOut);
-
this.onRelease = Delegate.create(this, doRelease);
-
}
-
-
/**
-
* Clears the button of events
-
*/
-
private function killButtonEvents():Void
-
{
-
this.onRollOver = null;
-
this.onRollOut = null;
-
this.onRelease = null;
-
}
-
-
/**
-
* onRollOver
-
*/
-
private function doRollOver():Void
-
{
-
this._fuse = new Fuse({target: this, Glow_blur: this._endBlur, Glow_alpha: 1, Glow_strength: 2, time: .35, ease: PennerEasing.easeOutSine});
-
this._fuse.start();
-
}
-
-
/**
-
* onRollOut
-
*/
-
private function doRollOut():Void
-
{
-
this._fuse = new Fuse({target: this, Glow_blur: this._startBlur, Glow_alpha: .5, Glow_strength: 2, time: .35, ease: PennerEasing.easeOutSine});
-
this._fuse.start();
-
}
-
-
/**
-
* onRelease
-
*/
-
private function doRelease():Void
-
{
-
this.dispatchEvent({type: "onGlowButtonClicked", target: this});
-
}
-
-
//- PUBLIC METHODS ----------------------------------------------------------------------------------------
-
-
/**
-
* Sets the properties of the button
-
*/
-
public function create($title:String, $id:Number, $color:Number, $startBlur:Number, $endBlur:Number):Void
-
{
-
this.title_txt.text = $title;
-
this._id = $id;
-
this._startBlur = $startBlur;
-
this._endBlur = $endBlur;
-
-
FuseFMP.writeFilter(this, "Glow", {color: $color, blur: this._startBlur, alpha: .5, strength: 2});
-
}
-
-
/**
-
* Enables the button
-
*/
-
public function setEnabled():Void
-
{
-
this.initButtonEvents();
-
-
this.enabled = true;
-
this._active = true;
-
-
this._fuse = new Fuse({target: this, alpha: 100, Glow_blur: this._startBlur, Glow_alpha: .5, Glow_strength: 2, time: .35, ease: PennerEasing.easeOutSine});
-
this._fuse.start();
-
}
-
-
/**
-
* Disables the button
-
*/
-
public function setDisabled():Void
-
{
-
this.killButtonEvents();
-
-
this.enabled = false;
-
this._active = false;
-
-
this._fuse = new Fuse({target: this, alpha: 50, Glow_blur: 0, Glow_alpha: 0, Glow_strength: 0, time: .35, ease: PennerEasing.easeOutSine});
-
this._fuse.start();
-
}
-
-
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
-
-
-
-
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
-
-
public function get id():Number
-
{
-
return this._id;
-
}
-
-
public function set id($val:Number):Void
-
{
-
this._id = $val;
-
}
-
-
public function get active():Boolean
-
{
-
return this._active;
-
}
-
-
public function set active($val:Boolean):Void
-
{
-
this._active = $val;
-
}
-
-
//- HELPERS -----------------------------------------------------------------------------------------------
-
-
public function toString():String
-
{
-
return "com.reintroducing.ui.GlowButton";
-
}
-
-
//- END CLASS ---------------------------------------------------------------------------------------------
-
}