LinkButtonCustom
This class allows you to make the background of a LinkButton transparent. There are times when having the background is fine, but other times you would rather it not be there and have it appear link and HTML link. This class does just that
transparent(bool:Boolean):void
Hide or show the LinkButton background
transparent():Boolean
Returns true or false if LinkButton background is transparent.
- Class version:
- 1.0
- Last Updated:
- July 3, 2009
- Requires:
- Actionscript 3
- Download:
- http://freerksen.googlecode.com/files/flex_linkbuttoncustom.zip
LinkButtonCustom.as Source:
package com.witheringtree.controls { import com.witheringtree.skins.LinkButtonSkin; import mx.controls.LinkButton; /** * Extension of the Event class to allow you to pass parameters to the event handlers. */ public class LinkButtonCustom extends LinkButton { private var _transparent:Boolean = false; /** * Constructor. */ public function LinkButtonCustom() { super(); transparency(); } /** * @private * Sets the backgrond transparent or not. */ private function transparency():void { if(_transparent) { this.setStyle("downSkin", LinkButtonSkin as Class); this.setStyle("overSkin", LinkButtonSkin as Class); this.setStyle("upSkin", LinkButtonSkin as Class); } else { this.setStyle("downSkin", null as Class); this.setStyle("overSkin", null as Class); this.setStyle("upSkin", null as Class); } } /** * Make the background of the button transparent. * * @param bool Boolean value to specify if the background show be transparent or not. * * @default false */ public function set transparent(bool:Boolean):void { this._transparent = bool; transparency(); } /** * Returns true if background is transparent */ public function get transparent():Boolean { return this._transparent; } } }
LinkButtonSkin.as Source:
package com.witheringtree.skins { import mx.core.EdgeMetrics; import mx.skins.Border; public class LinkButtonSkin extends Border { public function LinkButtonSkin() { super(); } override public function get borderMetrics():EdgeMetrics { return EdgeMetrics.EMPTY; } override protected function updateDisplayList(w:Number, h:Number):void { super.updateDisplayList(w, h); var cornerRadius:Number = getStyle("cornerRadius"); graphics.clear(); switch(name) { case "upSkin": { break; } case "overSkin": { break; } case "downSkin": { break; } case "disabledSkin": { drawRoundRect(0, 0, w, h, cornerRadius, 0, 0); break; } } } } }
Usage:
var lb:LinkButtonCustom = new LinkButtonCustom(); lb.transparent = true; lb.label = "My Button" this.addChild(lb);
There are no comments