Here's some code:
In the class itself, I have to override the rollover and rollout so I can remove the drop shadow to give a different dynamic effect. Also, I have to override the updateDisplayList because the disabled buttons shouldn't have a drop shadow (again, just for fun).
/**Class**/
package com.studioNorth.skins{
import flash.display.DisplayObject;
import flash.events.MouseEvent;
import flash.filters.DropShadowFilter;
import mx.controls.Button;
import mx.core.IUITextField;
import mx.core.UITextField;
public class CustomButtonTextDropShadow extends Button{
private var ds:DropShadowFilter; //This could be public so users could access and change it or any other variable
public function CustomButtonTextDropShadow(){
super();
ds = new DropShadowFilter(1);
}
override protected function rollOverHandler(event:MouseEvent):void{
textField.filters = null;
super.rollOverHandler(event);
}
override protected function rollOutHandler(event:MouseEvent):void{
super.rollOutHandler(event);
if(enabled)
textField.filters = [ds];
}
override protected function createChildren():void{
if (!textField){
textField = IUITextField(createInFontContext(UITextField));
textField.filters = [ds];
textField.styleName = this;
addChild(DisplayObject(textField));
}
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if(!this.enabled){
textField.filters = null;
}
}
}
}
/**Main App**/
before mouse over:

during mouse over:

that simple!
No comments:
Post a Comment