home *** CD-ROM | disk | FTP | other *** search
- package com.generationk.zinc
- {
- import flash.display.Sprite;
- import flash.events.MouseEvent;
- import flash.text.AntiAliasType;
- import flash.text.TextField;
- import flash.text.TextFormat;
-
- public class Button extends Sprite
- {
- private var _border:Rect;
-
- private var _background:GradientRectangle;
-
- private var _backgroundHL:GradientRectangle;
-
- private var _label:TextField;
-
- private var _overlay:Rect;
-
- public function Button(param1:String)
- {
- super();
- buttonMode = true;
- drawBorder();
- drawBackground();
- addLabel(param1);
- mouseChildren = false;
- addEventListener(MouseEvent.MOUSE_OVER,onOver);
- addEventListener(MouseEvent.MOUSE_OUT,onOut);
- }
-
- private function onOver(param1:MouseEvent) : void
- {
- _backgroundHL.visible = true;
- _background.visible = false;
- }
-
- public function set activate(param1:Boolean) : void
- {
- if(!param1)
- {
- _overlay.alpha = 0.5;
- _background.alpha = 0.5;
- removeEventListener(MouseEvent.MOUSE_OVER,onOver);
- removeEventListener(MouseEvent.MOUSE_OUT,onOut);
- buttonMode = false;
- }
- else
- {
- addEventListener(MouseEvent.MOUSE_OVER,onOver);
- addEventListener(MouseEvent.MOUSE_OUT,onOut);
- _background.alpha = 1;
- _overlay.alpha = 1;
- buttonMode = true;
- }
- }
-
- private function addLabel(param1:String) : void
- {
- var _loc2_:TextFormat = new TextFormat();
- _loc2_.color = 3355443;
- _loc2_.font = new BOLD().fontName;
- _loc2_.bold = true;
- _loc2_.size = 14;
- _label = new TextField();
- _label.antiAliasType = AntiAliasType.ADVANCED;
- _label.embedFonts = true;
- _label.selectable = false;
- _label.x = 10;
- _label.text = param1;
- _label.setTextFormat(_loc2_);
- _label.width = _label.textWidth + 5;
- _label.height = _label.textHeight + 5;
- addChild(_label);
- _border.draw(Math.round(_label.textWidth + 22),25);
- _background.draw(_border.width - 2,23);
- _backgroundHL.draw(_border.width - 2,23);
- _label.x = _background.width / 2 - _label.textWidth / 2 - 2;
- _label.y = _background.height / 2 - _label.textHeight / 2;
- addOverlay();
- }
-
- private function onOut(param1:MouseEvent) : void
- {
- _backgroundHL.visible = false;
- _background.visible = true;
- }
-
- private function drawBorder() : void
- {
- _border = new Rect(0,0,6710886);
- addChild(_border);
- }
-
- private function drawBackground() : void
- {
- _backgroundHL = new GradientRectangle(0,0,[13560825,6527413]);
- _backgroundHL.x = _backgroundHL.y = 1;
- _backgroundHL.visible = false;
- addChild(_backgroundHL);
- _background = new GradientRectangle(0,0,[15921906,11776947]);
- _background.x = _background.y = 1;
- addChild(_background);
- }
-
- public function set title(param1:String) : void
- {
- var _loc2_:TextFormat = new TextFormat();
- _loc2_.color = 3355443;
- _loc2_.font = new BOLD().fontName;
- _loc2_.bold = true;
- _loc2_.size = 14;
- _label.text = param1;
- _label.setTextFormat(_loc2_);
- _label.width = _label.textWidth + 5;
- _label.height = _label.textHeight + 5;
- _border.draw(Math.round(_label.textWidth + 22),25);
- _background.draw(_border.width - 2,23);
- _backgroundHL.draw(_border.width - 2,23);
- _label.x = _background.width / 2 - _label.textWidth / 2 - 2;
- _label.y = _background.height / 2 - _label.textHeight / 2;
- _overlay.draw(_border.width,_border.height);
- }
-
- private function addOverlay() : void
- {
- _overlay = new Rect(_border.width,_border.height,6710886,0,false,0);
- addChild(_overlay);
- }
- }
- }
-
-