home *** CD-ROM | disk | FTP | other *** search
- package com.generationk.zinc
- {
- import com.greensock.TweenMax;
- import com.greensock.plugins.AutoAlphaPlugin;
- import com.greensock.plugins.TweenPlugin;
- import flash.display.DisplayObject;
- import flash.display.GradientType;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import flash.geom.Matrix;
- import flash.text.AntiAliasType;
- import flash.text.TextField;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFormat;
-
- public class Window extends Sprite
- {
- public static var CANCEL:String = "cancel";
-
- private var _closeButton:CloseButton;
-
- private var _colors:Array;
-
- private var _textsTF:TextField;
-
- private var _closelabel:String;
-
- private var windowholder:Sprite;
-
- private var _cornerRadius:int;
-
- private var closebutton:Button;
-
- private var cancelbutton:DisplayObject;
-
- private var bglayer:Sprite;
-
- private var _height:Number;
-
- private var _width:Number;
-
- private var _background:Sprite;
-
- private var _title:String;
-
- private var _alpha:int;
-
- private var _texts:String;
-
- private var _linkedId:String;
-
- private var _cancellabel:String;
-
- private var _label:TextField;
-
- public function Window(param1:Number, param2:Number, param3:String, param4:String, param5:String, param6:String)
- {
- super();
- TweenPlugin.activate([AutoAlphaPlugin]);
- _closelabel = param6;
- _cancellabel = param5;
- _width = param1;
- _height = param2;
- _title = param3;
- _texts = param4;
- addEventListener(Event.ADDED_TO_STAGE,init);
- }
-
- private function init(param1:Event) : void
- {
- drawBGLayer();
- windowholder = new Sprite();
- addChild(windowholder);
- drawBackground();
- addCloseButton();
- addButtons();
- addTitle(_title);
- addText();
- arrange();
- }
-
- private function drawBackground() : void
- {
- _background = new Sprite();
- _cornerRadius = 10;
- _colors = [15856113,11776947];
- _alpha = 0.5;
- var _loc1_:String = GradientType.LINEAR;
- var _loc2_:Matrix = new Matrix();
- _loc2_.createGradientBox(_width,_height,Math.PI / 2,0,0);
- trace("_width " + _width);
- _background.graphics.beginGradientFill(_loc1_,_colors,[100,100],[0,255],_loc2_);
- _background.graphics.drawRoundRect(0,0,_width,_height,_cornerRadius,_cornerRadius);
- _background.graphics.endFill();
- windowholder.addChild(_background);
- }
-
- public function get linkedId() : String
- {
- return _linkedId;
- }
-
- private function addButtons() : void
- {
- closebutton = new Button(_closelabel);
- windowholder.addChild(closebutton);
- closebutton.addEventListener(MouseEvent.CLICK,close);
- cancelbutton = new Button(_cancellabel);
- windowholder.addChild(cancelbutton);
- cancelbutton.addEventListener(MouseEvent.CLICK,hide);
- }
-
- private function arrange() : void
- {
- windowholder.x = Math.round(stage.stageWidth / 2);
- windowholder.y = Math.round(stage.stageHeight / 2);
- _background.x = Math.round(-(_background.width / 2));
- _background.y = Math.round(-(_background.height / 2));
- _closeButton.x = _background.x + _background.width - 10;
- _closeButton.y = _background.y + 10;
- _label.x = _background.x + 20;
- _label.y = _background.y + 20;
- closebutton.y = _background.y + _background.height - closebutton.height - 18;
- cancelbutton.y = closebutton.y;
- closebutton.x = _background.x + 22;
- cancelbutton.x = closebutton.x + closebutton.width + 10;
- _textsTF.x = Math.round(_background.x + 20);
- _textsTF.y = Math.round(_background.y + _background.height / 2 - _textsTF.height / 2);
- bglayer.graphics.clear();
- bglayer.graphics.beginFill(0,0.4);
- bglayer.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
- bglayer.graphics.endFill();
- }
-
- public function set title(param1:String) : void
- {
- var _loc2_:TextFormat = new TextFormat();
- _loc2_.color = 1668518;
- _loc2_.font = new BOLD().fontName;
- _loc2_.size = 18;
- _label.text = param1;
- _label.setTextFormat(_loc2_);
- }
-
- public function get windowWidth() : Number
- {
- return _width;
- }
-
- public function get windowHeight() : Number
- {
- return _height;
- }
-
- private function addTitle(param1:String) : void
- {
- var _loc2_:TextFormat = new TextFormat();
- _loc2_.color = 1668518;
- _loc2_.font = new BOLD().fontName;
- _loc2_.bold = true;
- _loc2_.size = 18;
- _label = new TextField();
- _label.autoSize = TextFieldAutoSize.LEFT;
- _label.antiAliasType = AntiAliasType.ADVANCED;
- _label.embedFonts = true;
- _label.selectable = false;
- _label.text = param1;
- _label.setTextFormat(_loc2_);
- windowholder.addChild(_label);
- }
-
- public function hide(param1:MouseEvent = null) : void
- {
- dispatchEvent(new Event(CANCEL));
- TweenMax.to(bglayer,0,{"autoAlpha":0});
- TweenMax.to(windowholder,0.25,{
- "autoAlpha":0,
- "scaleX":0.8,
- "scaleY":0.8
- });
- }
-
- private function drawBGLayer() : void
- {
- bglayer = new Sprite();
- bglayer.graphics.beginFill(0,0.4);
- bglayer.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
- bglayer.graphics.endFill();
- addChild(bglayer);
- }
-
- public function hideDirect() : void
- {
- TweenMax.to(bglayer,0,{"autoAlpha":0});
- TweenMax.to(windowholder,0,{
- "autoAlpha":0,
- "scaleX":0.8,
- "scaleY":0.8
- });
- }
-
- private function addCloseButton() : void
- {
- _closeButton = new CloseButton();
- _closeButton.addEventListener(MouseEvent.CLICK,hide);
- windowholder.addChild(_closeButton);
- }
-
- public function onResize() : void
- {
- arrange();
- }
-
- private function addText() : void
- {
- var _loc1_:TextFormat = new TextFormat();
- _loc1_.color = 0;
- _loc1_.font = new BOLD().fontName;
- _loc1_.bold = true;
- _loc1_.size = 14;
- _textsTF = new TextField();
- _textsTF.antiAliasType = AntiAliasType.ADVANCED;
- _textsTF.autoSize = TextFieldAutoSize.LEFT;
- _textsTF.embedFonts = true;
- _textsTF.selectable = false;
- _textsTF.text = _texts;
- _textsTF.setTextFormat(_loc1_);
- windowholder.addChild(_textsTF);
- arrange();
- }
-
- private function close(param1:MouseEvent) : void
- {
- dispatchEvent(new Event(Event.CLOSE));
- hide();
- }
-
- public function show() : void
- {
- TweenMax.to(bglayer,0,{"autoAlpha":1});
- windowholder.scaleX = 0.8;
- windowholder.scaleY = 0.8;
- TweenMax.to(windowholder,0.25,{
- "autoAlpha":1,
- "scaleX":1,
- "scaleY":1
- });
- }
- }
- }
-
-