mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 17:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,112 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.*;
|
||||
import flash.events.*;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFieldAutoSize;
|
||||
|
||||
public dynamic class SBAJOkPopup extends SBPopup
|
||||
{
|
||||
|
||||
protected var _messageText:TextField;
|
||||
|
||||
protected var _titleText:TextField;
|
||||
|
||||
protected var _skin:MovieClip;
|
||||
|
||||
protected var _content:MovieClip;
|
||||
|
||||
protected var _top:MovieClip;
|
||||
|
||||
protected var _mid:MovieClip;
|
||||
|
||||
protected var _bot:MovieClip;
|
||||
|
||||
private var _titleToMessageDifference:int = 5;
|
||||
|
||||
private var _btnTxtGap:int = 10;
|
||||
|
||||
private var _verticalOffset:int = 13;
|
||||
|
||||
private var _okBtn:MovieClip;
|
||||
|
||||
private var _okBtnCallback:Function;
|
||||
|
||||
public function SBAJOkPopup(init_parent:DisplayObjectContainer, init_message:String = null, init_title:String = null, okBtnCallback:Function = null, init_darken:Boolean = true, init_content:MovieClip = null, init_skin:MovieClip = null, autoOpen:Boolean = true, init_enabled:Boolean = true, init_modal:Boolean = false, init_draggable:Boolean = false, init_x:Number = undefined, init_y:Number = undefined, init_width:Number = undefined, init_height:Number = undefined, init_children:Array = null)
|
||||
{
|
||||
if(okBtnCallback != null)
|
||||
{
|
||||
this._okBtnCallback = okBtnCallback;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._okBtnCallback = this.onOkBtn;
|
||||
}
|
||||
this._skin = GETDEFINITIONBYNAME("BroadcastPopupSkin");
|
||||
this._content = GETDEFINITIONBYNAME("BroadcastPopupContent");
|
||||
this._top = this._skin.ba.t;
|
||||
this._mid = this._skin.ba.m;
|
||||
this._bot = this._skin.ba.b;
|
||||
this._okBtn = this._content.okBtn;
|
||||
this._okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this._okBtnCallback,false,0,true);
|
||||
this._messageText = this._content.text;
|
||||
this._titleText = this._content.titleTxt;
|
||||
this._messageText.autoSize = TextFieldAutoSize.CENTER;
|
||||
this._titleText.autoSize = TextFieldAutoSize.CENTER;
|
||||
this.setMessageText(init_message);
|
||||
if(Boolean(init_title))
|
||||
{
|
||||
this._titleText.text = init_title;
|
||||
}
|
||||
super(init_parent,this._skin,this._content,autoOpen,init_enabled,init_modal,init_draggable,init_darken,init_title,init_x,init_y,init_width,init_height,init_children);
|
||||
}
|
||||
|
||||
public static function destroyInParentChain(seekAndDestroy:DisplayObject) : void
|
||||
{
|
||||
while(Boolean(seekAndDestroy) && Boolean(seekAndDestroy != gMainFrame.stage) && !(seekAndDestroy is SBOkPopup))
|
||||
{
|
||||
seekAndDestroy = seekAndDestroy.parent;
|
||||
}
|
||||
if(seekAndDestroy is SBOkPopup)
|
||||
{
|
||||
SBOkPopup(seekAndDestroy).destroy();
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy() : void
|
||||
{
|
||||
this._okBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this._okBtnCallback);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
public function setMessageText(newText:String) : void
|
||||
{
|
||||
this._messageText.text = newText;
|
||||
this.resize();
|
||||
}
|
||||
|
||||
private function resize() : void
|
||||
{
|
||||
this._mid.height = Math.floor(this._messageText.height);
|
||||
this._mid.y = Math.floor(-(this._mid.height * 0.5));
|
||||
this._top.y = this._mid.y - this._top.height;
|
||||
this._bot.y = this._mid.y + this._mid.height;
|
||||
this._titleText.y = 0;
|
||||
this._messageText.y = this._titleText.height + this._titleToMessageDifference;
|
||||
this._okBtn.y = this._messageText.y + this._messageText.height + this._btnTxtGap + this._okBtn.height * 0.5;
|
||||
this._skin.c.height = this._titleText.height + this._titleToMessageDifference + this._messageText.height + this._btnTxtGap + this._okBtn.height;
|
||||
this._skin.c.y = -(this._skin.ba.height * 0.5) + this._verticalOffset;
|
||||
this._content.x = this._skin.c.x;
|
||||
this._content.y = this._skin.c.y;
|
||||
this._content.width = this._skin.c.width;
|
||||
this._content.height = this._skin.c.height;
|
||||
}
|
||||
|
||||
private function onOkBtn(evt:MouseEvent) : void
|
||||
{
|
||||
evt.stopPropagation();
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.text.TextField;
|
||||
|
||||
public dynamic class SBMessage extends SBPopup
|
||||
{
|
||||
|
||||
public var messageTxt:TextField = new TextField();
|
||||
|
||||
public function SBMessage(init_parent:DisplayObjectContainer, init_skin:MovieClip, init_message:String, autoOpen:Boolean = true, init_enabled:Boolean = true, init_modal:Boolean = false, init_draggable:Boolean = true, init_darken:Boolean = false, init_title:String = null, init_x:Number = undefined, init_y:Number = undefined, init_width:Number = undefined, init_height:Number = undefined, init_children:Array = null)
|
||||
{
|
||||
this.messageTxt.text = init_message;
|
||||
super(init_parent,init_skin,this.messageTxt,autoOpen,init_enabled,init_modal,init_draggable,init_darken,init_title,init_x,init_y,init_width,init_height,init_children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.*;
|
||||
import flash.events.*;
|
||||
import flash.ui.Keyboard;
|
||||
|
||||
public dynamic class SBOkPopup extends SBStandardPopup
|
||||
{
|
||||
|
||||
private var _okBtn:MovieClip;
|
||||
|
||||
private var _okBtnCallback:Function;
|
||||
|
||||
public function SBOkPopup(init_parent:DisplayObjectContainer, init_message:String = null, init_darken:Boolean = true, okBtnCallback:Function = null, autoOpen:Boolean = true, init_enabled:Boolean = true, init_modal:Boolean = false, init_draggable:Boolean = false, init_title:String = null, init_x:Number = undefined, init_y:Number = undefined, init_width:Number = undefined, init_height:Number = undefined, init_children:Array = null)
|
||||
{
|
||||
_verticalOffset = -20;
|
||||
_btnTxtGap = 6;
|
||||
_btnHeight = 44;
|
||||
if(okBtnCallback != null)
|
||||
{
|
||||
this._okBtnCallback = okBtnCallback;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._okBtnCallback = this.onOkBtn;
|
||||
}
|
||||
var skin:MovieClip = GETDEFINITIONBYNAME("OkPopupSkin");
|
||||
var content:MovieClip = GETDEFINITIONBYNAME("OkPopupContent");
|
||||
this._okBtn = content.okBtn;
|
||||
this._okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this._okBtnCallback,false,0,true);
|
||||
_resizeCallback = this.onResize;
|
||||
super(init_parent,init_message,init_darken,content,skin,autoOpen,init_enabled,init_modal,init_draggable,init_title,init_x,init_y,init_width,init_height,init_children);
|
||||
stage.addEventListener(KeyboardEvent.KEY_DOWN,this.handleOkKeyDown,false,0,true);
|
||||
}
|
||||
|
||||
public static function destroyInParentChain(seekAndDestroy:DisplayObject) : void
|
||||
{
|
||||
while(Boolean(seekAndDestroy) && Boolean(seekAndDestroy != gMainFrame.stage) && !(seekAndDestroy is SBOkPopup))
|
||||
{
|
||||
seekAndDestroy = seekAndDestroy.parent;
|
||||
}
|
||||
if(seekAndDestroy is SBOkPopup)
|
||||
{
|
||||
SBOkPopup(seekAndDestroy).destroy();
|
||||
}
|
||||
}
|
||||
|
||||
override public function destroy() : void
|
||||
{
|
||||
this._okBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this._okBtnCallback);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
private function onResize() : void
|
||||
{
|
||||
this._okBtn.y = _text.height + _btnTxtGap + 0.5 * _btnHeight;
|
||||
}
|
||||
|
||||
private function handleOkKeyDown(event:KeyboardEvent) : void
|
||||
{
|
||||
switch(event.keyCode)
|
||||
{
|
||||
case Keyboard.ENTER:
|
||||
case Keyboard.SPACE:
|
||||
this.onOkBtn(event);
|
||||
}
|
||||
}
|
||||
|
||||
private function onOkBtn(evt:Event) : void
|
||||
{
|
||||
evt.stopPropagation();
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.text.TextFieldAutoSize;
|
||||
import gui.DarkenManager;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public dynamic class SBParchmentPopup
|
||||
{
|
||||
|
||||
public static const TYPE_OK:int = 0;
|
||||
|
||||
public static const TYPE_YES_NO:int = 1;
|
||||
|
||||
public static const TYPE_CONTINUE_EXIT:int = 2;
|
||||
|
||||
public static const TYPE_CONTINUE_ONLY:int = 3;
|
||||
|
||||
private var _parent:DisplayObjectContainer;
|
||||
|
||||
private var _type:int;
|
||||
|
||||
private var _message:String;
|
||||
|
||||
private var _darken:Boolean;
|
||||
|
||||
private var _confirmCallback:Function;
|
||||
|
||||
private var _passback:Object;
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _popup:MovieClip;
|
||||
|
||||
public function SBParchmentPopup(init_parent:DisplayObjectContainer, init_type:int = 0, init_message:String = null, init_darken:Boolean = true, init_confirmCallback:Function = null, init_passbackObject:Object = null)
|
||||
{
|
||||
super();
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
this._parent = init_parent;
|
||||
this._type = init_type;
|
||||
this._message = init_message;
|
||||
this._darken = init_darken;
|
||||
this._confirmCallback = init_confirmCallback;
|
||||
this._passback = init_passbackObject;
|
||||
this._mediaHelper = new MediaHelper();
|
||||
this._mediaHelper.init(2106,this.onMediaLoaded);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
var idx:int = 0;
|
||||
if(Boolean(this._popup))
|
||||
{
|
||||
DarkenManager.unDarken(this._popup);
|
||||
if(Boolean(this._parent) && Boolean(this._popup.parent) && this._popup.parent == this._parent)
|
||||
{
|
||||
this._parent.removeChild(this._popup);
|
||||
}
|
||||
this._popup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
|
||||
switch(this._type)
|
||||
{
|
||||
case TYPE_CONTINUE_EXIT:
|
||||
this._popup.contBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
|
||||
this._popup.exitBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
|
||||
break;
|
||||
case TYPE_CONTINUE_ONLY:
|
||||
this._popup.contOnlyBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
|
||||
break;
|
||||
case TYPE_OK:
|
||||
this._popup.okBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
|
||||
break;
|
||||
case TYPE_YES_NO:
|
||||
this._popup.yesBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
|
||||
this._popup.noBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown);
|
||||
}
|
||||
idx = SBPopupManager.nonSBPopups.indexOf(this);
|
||||
if(idx >= 0)
|
||||
{
|
||||
SBPopupManager.nonSBPopups.splice(idx,1);
|
||||
}
|
||||
this._popup = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onMediaLoaded(img:MovieClip) : void
|
||||
{
|
||||
if(Boolean(img))
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
this._popup = MovieClip(img.getChildAt(0));
|
||||
this._mediaHelper.destroy();
|
||||
this._mediaHelper = null;
|
||||
switch(this._type)
|
||||
{
|
||||
case TYPE_CONTINUE_EXIT:
|
||||
this._popup.okBtn.visible = false;
|
||||
this._popup.yesBtn.visible = false;
|
||||
this._popup.noBtn.visible = false;
|
||||
this._popup.contOnlyBtn.visible = false;
|
||||
this._popup.contBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
|
||||
this._popup.exitBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
|
||||
break;
|
||||
case TYPE_CONTINUE_ONLY:
|
||||
this._popup.okBtn.visible = false;
|
||||
this._popup.yesBtn.visible = false;
|
||||
this._popup.noBtn.visible = false;
|
||||
this._popup.exitBtn.visible = false;
|
||||
this._popup.contBtn.visible = false;
|
||||
this._popup.contOnlyBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
|
||||
break;
|
||||
case TYPE_OK:
|
||||
this._popup.yesBtn.visible = false;
|
||||
this._popup.noBtn.visible = false;
|
||||
this._popup.contBtn.visible = false;
|
||||
this._popup.exitBtn.visible = false;
|
||||
this._popup.contOnlyBtn.visible = false;
|
||||
this._popup.okBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
|
||||
break;
|
||||
case TYPE_YES_NO:
|
||||
this._popup.okBtn.visible = false;
|
||||
this._popup.contBtn.visible = false;
|
||||
this._popup.exitBtn.visible = false;
|
||||
this._popup.contOnlyBtn.visible = false;
|
||||
this._popup.yesBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
|
||||
this._popup.noBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onBtnDown,false,0,true);
|
||||
}
|
||||
this._popup.txt.autoSize = TextFieldAutoSize.CENTER;
|
||||
this._popup.txt.text = this._message;
|
||||
with(this._popup.ba)
|
||||
{
|
||||
|
||||
m.height = Math.floor(_popup.txt.height) + 44 + 8;
|
||||
m.y = Math.floor(-(m.height * 0.5));
|
||||
t.y = m.y - t.height;
|
||||
b.y = m.y + m.height;
|
||||
_popup.txt.y = m.y + 4;
|
||||
_popup.yesBtn.y = m.y + _popup.txt.height + 13;
|
||||
_popup.noBtn.y = m.y + _popup.txt.height + 13;
|
||||
_popup.okBtn.y = m.y + _popup.txt.height + 9;
|
||||
_popup.contBtn.y = m.y + _popup.txt.height + 13;
|
||||
_popup.exitBtn.y = m.y + _popup.txt.height + 13;
|
||||
_popup.contOnlyBtn.y = m.y + _popup.txt.height + 13;
|
||||
}
|
||||
this._popup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup,false,0,true);
|
||||
this._popup.x = MainFrame.VIEW_WIDTH * 0.5;
|
||||
this._popup.y = MainFrame.VIEW_HEIGHT * 0.5;
|
||||
this._parent.addChild(this._popup);
|
||||
if(this._darken)
|
||||
{
|
||||
DarkenManager.darken(this._popup);
|
||||
}
|
||||
SBPopupManager.nonSBPopups.push(this);
|
||||
}
|
||||
}
|
||||
|
||||
private function onPopup(evt:MouseEvent) : void
|
||||
{
|
||||
evt.stopPropagation();
|
||||
}
|
||||
|
||||
private function onBtnDown(evt:MouseEvent) : void
|
||||
{
|
||||
var o:Object = null;
|
||||
evt.stopPropagation();
|
||||
if(this._confirmCallback != null)
|
||||
{
|
||||
o = {
|
||||
"status":evt.currentTarget == this._popup.contBtn || evt.currentTarget == this._popup.contOnlyBtn || evt.currentTarget == this._popup.yesBtn || evt.currentTarget == this._popup.okBtn,
|
||||
"passback":this._passback
|
||||
};
|
||||
this.destroy();
|
||||
this._confirmCallback(o);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiRadioButtonGroup;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public dynamic class SBPollPopup
|
||||
{
|
||||
|
||||
private static const POLL_POPUP_MEDIA_ID:int = 369;
|
||||
|
||||
private static const POLL_TY_POPUP_MEDIA_ID:int = 370;
|
||||
|
||||
private var _popupLayer:DisplayObjectContainer;
|
||||
|
||||
private var _tab:MovieClip;
|
||||
|
||||
private var _pollDef:Object;
|
||||
|
||||
private var _onVoteCallback:Function;
|
||||
|
||||
private var _onDoneCallback:Function;
|
||||
|
||||
private var _pollPopup:MovieClip;
|
||||
|
||||
private var _pollMediaHelper:MediaHelper;
|
||||
|
||||
private var _thankYouPopup:SBStandardTitlePopup;
|
||||
|
||||
private var _numOptions:int;
|
||||
|
||||
private var _randomizeOrder:Boolean;
|
||||
|
||||
private var _randOptionLookup:Array;
|
||||
|
||||
private var _answerSection:MovieClip;
|
||||
|
||||
private var _optionsGroup:GuiRadioButtonGroup;
|
||||
|
||||
public function SBPollPopup()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(initParent:DisplayObjectContainer, initTab:MovieClip, initOnVoteCallback:Function, initOnDoneCallback:Function, initRandomizeOrder:Boolean) : void
|
||||
{
|
||||
this._popupLayer = initParent;
|
||||
this._tab = initTab;
|
||||
this._onVoteCallback = initOnVoteCallback;
|
||||
this._onDoneCallback = initOnDoneCallback;
|
||||
this._randomizeOrder = initRandomizeOrder;
|
||||
this._pollDef = this._tab.def;
|
||||
this._randOptionLookup = [0,1,2,3,4];
|
||||
this._thankYouPopup = new SBStandardTitlePopup(this._popupLayer,LocalizationManager.translateIdOnly(14680),null,370,this._onDoneCallback,false);
|
||||
this._pollMediaHelper = new MediaHelper();
|
||||
this._pollMediaHelper.init(POLL_POPUP_MEDIA_ID,this.onMediaLoaded,true);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this._pollPopup.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onCloseBtnDown);
|
||||
this._pollPopup.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown);
|
||||
this._pollPopup = null;
|
||||
this._thankYouPopup.destroy();
|
||||
this._thankYouPopup = null;
|
||||
}
|
||||
|
||||
private function onMediaLoaded(img:MovieClip) : void
|
||||
{
|
||||
if(Boolean(img))
|
||||
{
|
||||
if(img.mediaHelper.id == POLL_POPUP_MEDIA_ID)
|
||||
{
|
||||
this._pollMediaHelper.destroy();
|
||||
this._pollMediaHelper = null;
|
||||
this._pollPopup = MovieClip(img.getChildAt(0));
|
||||
this.setUpPollPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setUpPollPopup() : void
|
||||
{
|
||||
this._pollPopup.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onCloseBtnDown,false,0,true);
|
||||
this._pollPopup.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopupDown,false,0,true);
|
||||
var text:String = this._pollDef.poll;
|
||||
var firstPipe:int = text.indexOf("|");
|
||||
this._pollPopup.bodyTxt.text = text.substring(0,firstPipe);
|
||||
var pollOptions:Array = text.substring(firstPipe + 1,text.length).split("|");
|
||||
if(this._randomizeOrder)
|
||||
{
|
||||
pollOptions = this.shuffleArray(pollOptions);
|
||||
}
|
||||
this._numOptions = pollOptions.length;
|
||||
this._pollPopup.titleTxt.text = this._pollDef.title;
|
||||
if(this._numOptions == 2)
|
||||
{
|
||||
this._answerSection = this._pollPopup.answer2;
|
||||
this._pollPopup.answer2.visible = true;
|
||||
this._pollPopup.answer3.visible = false;
|
||||
this._pollPopup.answer4.visible = false;
|
||||
this._pollPopup.answer5.visible = false;
|
||||
}
|
||||
else if(this._numOptions == 3)
|
||||
{
|
||||
this._answerSection = this._pollPopup.answer3;
|
||||
this._pollPopup.answer2.visible = false;
|
||||
this._pollPopup.answer3.visible = true;
|
||||
this._pollPopup.answer4.visible = false;
|
||||
this._pollPopup.answer5.visible = false;
|
||||
}
|
||||
else if(this._numOptions == 4)
|
||||
{
|
||||
this._answerSection = this._pollPopup.answer4;
|
||||
this._pollPopup.answer2.visible = false;
|
||||
this._pollPopup.answer3.visible = false;
|
||||
this._pollPopup.answer4.visible = true;
|
||||
this._pollPopup.answer5.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._answerSection = this._pollPopup.answer5;
|
||||
this._pollPopup.answer2.visible = false;
|
||||
this._pollPopup.answer3.visible = false;
|
||||
this._pollPopup.answer4.visible = false;
|
||||
this._pollPopup.answer5.visible = true;
|
||||
}
|
||||
this._optionsGroup = new GuiRadioButtonGroup(this._answerSection.options);
|
||||
this._answerSection.voteBtn.activateGrayState(true);
|
||||
this._answerSection.voteBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onVoteBtnDown,false,0,true);
|
||||
for(var i:int = 1; i < this._numOptions + 1; i++)
|
||||
{
|
||||
this._answerSection["answer" + i + "Txt"].text = pollOptions[i - 1];
|
||||
this._answerSection.options["option" + i].addEventListener(MouseEvent.MOUSE_DOWN,this.onOptionSelected,false,0,true);
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
this.open(this._pollPopup);
|
||||
}
|
||||
|
||||
private function shuffleArray(a:Array) : Array
|
||||
{
|
||||
var element:String = null;
|
||||
var i:int = 0;
|
||||
var rand:int = 0;
|
||||
var save:int = 0;
|
||||
var length:int = int(a.length);
|
||||
var shuffled:Array = a.slice();
|
||||
while(i < length)
|
||||
{
|
||||
element = shuffled[i];
|
||||
rand = Math.floor(Math.random() * length);
|
||||
if(i != rand)
|
||||
{
|
||||
shuffled[i] = shuffled[rand];
|
||||
shuffled[rand] = element;
|
||||
save = int(this._randOptionLookup[i]);
|
||||
this._randOptionLookup[i] = this._randOptionLookup[rand];
|
||||
this._randOptionLookup[rand] = save;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return shuffled;
|
||||
}
|
||||
|
||||
private function open(popup:MovieClip) : void
|
||||
{
|
||||
this._popupLayer.addChild(popup);
|
||||
popup.x = MainFrame.VIEW_WIDTH * 0.5;
|
||||
popup.y = MainFrame.VIEW_HEIGHT * 0.5;
|
||||
DarkenManager.darken(popup);
|
||||
popup.visible = true;
|
||||
}
|
||||
|
||||
private function close(popup:MovieClip) : void
|
||||
{
|
||||
popup.visible = false;
|
||||
DarkenManager.unDarken(popup);
|
||||
this._popupLayer.removeChild(popup);
|
||||
}
|
||||
|
||||
private function onVoteBtnDown(e:MouseEvent) : void
|
||||
{
|
||||
e.stopPropagation();
|
||||
if(!e.currentTarget.isGray)
|
||||
{
|
||||
if(this._onVoteCallback != null)
|
||||
{
|
||||
this._onVoteCallback(this._tab,this._randOptionLookup[this._optionsGroup.selected] + 1);
|
||||
}
|
||||
this.close(this._pollPopup);
|
||||
this._thankYouPopup.open();
|
||||
}
|
||||
}
|
||||
|
||||
private function onCloseBtnDown(e:MouseEvent) : void
|
||||
{
|
||||
e.stopPropagation();
|
||||
this.close(e.currentTarget.parent);
|
||||
this._onDoneCallback();
|
||||
}
|
||||
|
||||
private function onOptionSelected(e:MouseEvent) : void
|
||||
{
|
||||
e.stopPropagation();
|
||||
if(e.currentTarget == this._answerSection.options.option1)
|
||||
{
|
||||
this._answerSection.options.option1._circle.visible = true;
|
||||
}
|
||||
for(var i:int = 1; i < this._numOptions + 1; i++)
|
||||
{
|
||||
this._answerSection.options["option" + i].removeEventListener(MouseEvent.MOUSE_DOWN,this.onOptionSelected);
|
||||
}
|
||||
this._answerSection.voteBtn.activateGrayState(false);
|
||||
}
|
||||
|
||||
private function onPopupDown(e:MouseEvent) : void
|
||||
{
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,355 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public dynamic class SBPopup extends Sprite
|
||||
{
|
||||
|
||||
public var skin:SBPopupSkin;
|
||||
|
||||
public var content:DisplayObject;
|
||||
|
||||
public var popupFilters:Array;
|
||||
|
||||
public var _enabled:Boolean = true;
|
||||
|
||||
public var _selected:Boolean = true;
|
||||
|
||||
public var _modal:Boolean = false;
|
||||
|
||||
public var _darken:Boolean = false;
|
||||
|
||||
public var suppressMouseDown:Boolean = false;
|
||||
|
||||
public var closeCallback:Function;
|
||||
|
||||
public var restoreLastPos:Boolean = true;
|
||||
|
||||
public var lastPosX:Number;
|
||||
|
||||
public var lastPosY:Number;
|
||||
|
||||
public var draggable:Boolean = true;
|
||||
|
||||
public var soundsEnabled:Boolean = true;
|
||||
|
||||
public var bxClosesPopup:Boolean = true;
|
||||
|
||||
public function SBPopup(init_parent:DisplayObjectContainer, init_skin:MovieClip, init_content:DisplayObject, autoOpen:Boolean = true, init_enabled:Boolean = true, init_modal:Boolean = false, init_draggable:Boolean = false, init_darken:Boolean = false, init_title:String = null, init_x:Number = undefined, init_y:Number = undefined, init_width:Number = undefined, init_height:Number = undefined, init_filters:Array = null, init_children:Array = null)
|
||||
{
|
||||
super();
|
||||
this.skin = new SBPopupSkin(init_skin);
|
||||
this.addChild(this.skin.s);
|
||||
if(Boolean(init_content))
|
||||
{
|
||||
this.content = init_content;
|
||||
this.content.name = "content";
|
||||
this.content.x = this.skin.s["c"].x;
|
||||
this.content.y = this.skin.s["c"].y;
|
||||
this.content.width = this.skin.s["c"].width;
|
||||
this.content.height = this.skin.s["c"].height;
|
||||
this.skin.s.addChildAt(this.content,this.skin.s.getChildIndex(this.skin.s["c"]));
|
||||
}
|
||||
this.skin.s["c"].visible = false;
|
||||
if(Boolean(this.skin.s.getChildByName("bx")))
|
||||
{
|
||||
this.skin.s["bx"].addEventListener(MouseEvent.MOUSE_DOWN,this.bxHandler,false,0,true);
|
||||
}
|
||||
init_parent.addChild(this);
|
||||
this.visible = false;
|
||||
width = Boolean(init_width) ? init_width : this.skin.s.width;
|
||||
height = Boolean(init_height) ? init_height : this.skin.s.height;
|
||||
if(Boolean(parent.stage))
|
||||
{
|
||||
x = Boolean(init_x) ? init_x : MainFrame.VIEW_WIDTH * 0.5;
|
||||
y = Boolean(init_y) ? init_y : MainFrame.VIEW_HEIGHT * 0.5;
|
||||
}
|
||||
this.lastPosX = x;
|
||||
this.lastPosY = y;
|
||||
this.modal = init_modal;
|
||||
this.draggable = init_draggable;
|
||||
this.enabled = init_enabled;
|
||||
this.suppressMouseDown = false;
|
||||
this.popupFilters = init_filters;
|
||||
SBPopupManager.popups.push(this);
|
||||
if(init_darken)
|
||||
{
|
||||
this._darken = true;
|
||||
}
|
||||
if(autoOpen)
|
||||
{
|
||||
this.open();
|
||||
}
|
||||
}
|
||||
|
||||
public static function isChildOf(testParent:DisplayObjectContainer, stopParent:DisplayObjectContainer, testChild:DisplayObject) : Boolean
|
||||
{
|
||||
var c:DisplayObject = testChild;
|
||||
while(c != stopParent)
|
||||
{
|
||||
if(c == testParent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
c = c.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get darken() : Boolean
|
||||
{
|
||||
return this._darken;
|
||||
}
|
||||
|
||||
public function get selected() : Boolean
|
||||
{
|
||||
return this._selected;
|
||||
}
|
||||
|
||||
public function set selected(select:Boolean) : void
|
||||
{
|
||||
if(select)
|
||||
{
|
||||
}
|
||||
this._selected = select;
|
||||
}
|
||||
|
||||
public function get enabled() : Boolean
|
||||
{
|
||||
return this._enabled;
|
||||
}
|
||||
|
||||
public function set enabled(enable:Boolean) : void
|
||||
{
|
||||
if(enable)
|
||||
{
|
||||
mouseChildren = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseChildren = false;
|
||||
}
|
||||
this._enabled = enable;
|
||||
}
|
||||
|
||||
override public function set visible(make_visible:Boolean) : void
|
||||
{
|
||||
if(make_visible)
|
||||
{
|
||||
if(this._modal)
|
||||
{
|
||||
SBPopupManager.modalSBPopup = this;
|
||||
}
|
||||
if(this._darken && SBPopupManager.darken != null)
|
||||
{
|
||||
SBPopupManager.darken(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this._modal && SBPopupManager.modalSBPopup == this)
|
||||
{
|
||||
SBPopupManager.modalSBPopup = null;
|
||||
}
|
||||
if(!this._darken && SBPopupManager.lighten != null)
|
||||
{
|
||||
SBPopupManager.lighten(this);
|
||||
}
|
||||
}
|
||||
super.visible = make_visible;
|
||||
}
|
||||
|
||||
public function get modal() : Boolean
|
||||
{
|
||||
return Boolean(this._modal && visible);
|
||||
}
|
||||
|
||||
public function set modal(make_modal:Boolean) : void
|
||||
{
|
||||
if(make_modal)
|
||||
{
|
||||
if(visible)
|
||||
{
|
||||
if(Boolean(SBPopupManager.modalSBPopup) && Boolean(SBPopupManager.modalSBPopup != this) && SBPopupManager.modalSBPopup.modal)
|
||||
{
|
||||
throw new Error("Attempted to make two or more modal dialogs active at once!");
|
||||
}
|
||||
SBPopupManager.modalSBPopup = this;
|
||||
}
|
||||
}
|
||||
else if(SBPopupManager.modalSBPopup == this)
|
||||
{
|
||||
SBPopupManager.modalSBPopup = null;
|
||||
}
|
||||
this._modal = make_modal;
|
||||
}
|
||||
|
||||
public function addListeners() : void
|
||||
{
|
||||
addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDownHandler,false,0,true);
|
||||
addEventListener(MouseEvent.MOUSE_UP,this.mouseUpHandler,false,0,true);
|
||||
}
|
||||
|
||||
public function removeListeners() : void
|
||||
{
|
||||
removeEventListener(MouseEvent.MOUSE_DOWN,this.mouseDownHandler);
|
||||
removeEventListener(MouseEvent.MOUSE_UP,this.mouseUpHandler);
|
||||
}
|
||||
|
||||
public function open() : void
|
||||
{
|
||||
if(visible)
|
||||
{
|
||||
trace("WARNING: Tried to open an already opened popup... ignored...");
|
||||
return;
|
||||
}
|
||||
if(this._darken)
|
||||
{
|
||||
if(Boolean(SBPopupManager) && SBPopupManager.darken != null)
|
||||
{
|
||||
SBPopupManager.darken(this);
|
||||
}
|
||||
}
|
||||
this.addListeners();
|
||||
this.setFilters(this.popupFilters);
|
||||
if(Boolean(0))
|
||||
{
|
||||
x = this.lastPosX;
|
||||
y = this.lastPosY;
|
||||
}
|
||||
this.visible = true;
|
||||
if(Boolean(parent))
|
||||
{
|
||||
this.bringToFront();
|
||||
}
|
||||
if(this._modal)
|
||||
{
|
||||
SBPopupManager.modalSBPopup = this;
|
||||
}
|
||||
}
|
||||
|
||||
public function close() : void
|
||||
{
|
||||
if(!visible)
|
||||
{
|
||||
trace("WARNING: Tried to close an already closed popup... ignored...");
|
||||
return;
|
||||
}
|
||||
if(this._darken)
|
||||
{
|
||||
if(Boolean(SBPopupManager) && SBPopupManager.lighten != null)
|
||||
{
|
||||
SBPopupManager.lighten(this);
|
||||
}
|
||||
}
|
||||
this.removeListeners();
|
||||
this.setFilters([]);
|
||||
this.lastPosX = x;
|
||||
this.lastPosY = y;
|
||||
this.visible = false;
|
||||
if(this._modal)
|
||||
{
|
||||
if(SBPopupManager.modalSBPopup == this)
|
||||
{
|
||||
SBPopupManager.modalSBPopup = null;
|
||||
}
|
||||
}
|
||||
if(this.closeCallback != null)
|
||||
{
|
||||
this.closeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
if(visible)
|
||||
{
|
||||
this.close();
|
||||
}
|
||||
if(Boolean(this.skin) && Boolean(this.skin.s))
|
||||
{
|
||||
removeChild(this.skin.s);
|
||||
if(Boolean(this.content))
|
||||
{
|
||||
this.skin.s.removeChild(this.content);
|
||||
this.content = null;
|
||||
}
|
||||
this.skin.s = null;
|
||||
}
|
||||
this.closeCallback = null;
|
||||
if(Boolean(parent))
|
||||
{
|
||||
parent.removeChild(this);
|
||||
}
|
||||
var idx:int = SBPopupManager.popups.indexOf(this);
|
||||
if(idx > 0)
|
||||
{
|
||||
SBPopupManager.popups.splice(idx,1);
|
||||
}
|
||||
}
|
||||
|
||||
public function setFilters(newFilters:Array = null) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function bxHandler(m:MouseEvent) : void
|
||||
{
|
||||
m.stopPropagation();
|
||||
if(visible && this.bxClosesPopup)
|
||||
{
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
public function bringContentToFront() : void
|
||||
{
|
||||
this.skin.s.setChildIndex(this.content,this.skin.s.getChildIndex(this.skin.s["c"]));
|
||||
}
|
||||
|
||||
public function mouseDownHandler(m:MouseEvent) : void
|
||||
{
|
||||
m.stopPropagation();
|
||||
if(this.suppressMouseDown)
|
||||
{
|
||||
this.suppressMouseDown = false;
|
||||
return;
|
||||
}
|
||||
if(!(m.target is DisplayObject))
|
||||
{
|
||||
throw new Error("mouseDownHandler mouse event got a non-DisplayObject object!");
|
||||
}
|
||||
if(this.draggable && SBPopupManager.checkModalSBPopup(this,true) && (Boolean(SBPopup.isChildOf(this.skin.s["ba"],this,DisplayObject(m.target)) || m.target == this.content) || Boolean(this.content is DisplayObjectContainer && DisplayObjectContainer(this.content).getChildByName("titleDragBar") && m.target == this.content["titleDragBar"])))
|
||||
{
|
||||
startDrag();
|
||||
}
|
||||
}
|
||||
|
||||
public function bringToFront() : void
|
||||
{
|
||||
parent.setChildIndex(this,parent.numChildren - 1);
|
||||
}
|
||||
|
||||
public function mouseUpHandler(m:MouseEvent) : void
|
||||
{
|
||||
m.stopPropagation();
|
||||
if(!(m.target is DisplayObject))
|
||||
{
|
||||
throw new Error("mouseDownHandler mouse event got a non-DisplayObject object!");
|
||||
}
|
||||
if(this.draggable && SBPopupManager.checkModalSBPopup(this,false) && (Boolean(SBPopup.isChildOf(this.skin.s["ba"],this,DisplayObject(m.target)) || m.target == this.content) || Boolean(this.content is DisplayObjectContainer && DisplayObjectContainer(this.content).getChildByName("titleDragBar") && m.target == this.content["titleDragBar"])))
|
||||
{
|
||||
stopDrag();
|
||||
}
|
||||
}
|
||||
|
||||
public function get closeBtn() : MovieClip
|
||||
{
|
||||
return this.skin.s["bx"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.filters.*;
|
||||
|
||||
public class SBPopupManager
|
||||
{
|
||||
|
||||
public static var _selected:SBPopup;
|
||||
|
||||
public static var _modalSBPopup:SBPopup;
|
||||
|
||||
public static var _prevModalSBPopup:SBPopup;
|
||||
|
||||
public static var darken:Function;
|
||||
|
||||
public static var lighten:Function;
|
||||
|
||||
public static var popups:Array = [];
|
||||
|
||||
public static var nonSBPopups:Array = [];
|
||||
|
||||
public static var enabled:Boolean = true;
|
||||
|
||||
public function SBPopupManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function get selected() : SBPopup
|
||||
{
|
||||
return _selected;
|
||||
}
|
||||
|
||||
public static function set selected(select:SBPopup) : void
|
||||
{
|
||||
if(select.selected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
select.selected = true;
|
||||
_selected = select;
|
||||
}
|
||||
|
||||
public static function get modalSBPopup() : SBPopup
|
||||
{
|
||||
return _modalSBPopup;
|
||||
}
|
||||
|
||||
public static function set modalSBPopup(newModal:SBPopup) : void
|
||||
{
|
||||
var p:SBPopup = null;
|
||||
var tempPrev:SBPopup = null;
|
||||
for each(p in popups)
|
||||
{
|
||||
if(p != newModal)
|
||||
{
|
||||
p.enabled = newModal == null;
|
||||
}
|
||||
}
|
||||
tempPrev = _prevModalSBPopup;
|
||||
if(Boolean(newModal) && Boolean(_modalSBPopup) && newModal != _modalSBPopup)
|
||||
{
|
||||
_prevModalSBPopup = _modalSBPopup;
|
||||
}
|
||||
_modalSBPopup = newModal;
|
||||
if(_modalSBPopup == null && Boolean(tempPrev))
|
||||
{
|
||||
_modalSBPopup = tempPrev;
|
||||
_prevModalSBPopup = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkModalSBPopup(toCheck:SBPopup, down:Boolean) : Boolean
|
||||
{
|
||||
if(_modalSBPopup == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(_modalSBPopup != toCheck)
|
||||
{
|
||||
if(down)
|
||||
{
|
||||
_modalSBPopup.alpha = 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_modalSBPopup.alpha = 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getBlurFilter(blurAmountX:Number = 2, blurAmountY:Number = 2, blurQuality:int = 3) : BlurFilter
|
||||
{
|
||||
var blurFilter:BlurFilter = new BlurFilter();
|
||||
blurFilter.blurX = blurAmountX;
|
||||
blurFilter.blurY = blurAmountY;
|
||||
blurFilter.quality = blurQuality;
|
||||
return blurFilter;
|
||||
}
|
||||
|
||||
public static function getColorFilter(a:Number = 1, r:Number = 1, g:Number = 1, b:Number = 1) : ColorMatrixFilter
|
||||
{
|
||||
var colorMatrix:Array = new Array();
|
||||
colorMatrix = colorMatrix.concat([r,0,0,0,0]);
|
||||
colorMatrix = colorMatrix.concat([0,g,0,0,0]);
|
||||
colorMatrix = colorMatrix.concat([0,0,b,0,0]);
|
||||
colorMatrix = colorMatrix.concat([0,0,0,a,0]);
|
||||
return new ColorMatrixFilter(colorMatrix);
|
||||
}
|
||||
|
||||
public static function setAllPopupEffects(popupFilters:Array = null) : void
|
||||
{
|
||||
var p:SBPopup = null;
|
||||
for each(p in popups)
|
||||
{
|
||||
p.setFilters(popupFilters);
|
||||
}
|
||||
}
|
||||
|
||||
public static function setAllModalPopupEffects(popupFilters:Array = null) : void
|
||||
{
|
||||
var p:SBPopup = null;
|
||||
for each(p in popups)
|
||||
{
|
||||
if(p.modal)
|
||||
{
|
||||
p.setFilters(popupFilters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function closeAll() : void
|
||||
{
|
||||
var p:SBPopup = null;
|
||||
modalSBPopup = null;
|
||||
for each(p in popups)
|
||||
{
|
||||
if(p.visible)
|
||||
{
|
||||
p.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function destroyAll() : void
|
||||
{
|
||||
var p:SBPopup = null;
|
||||
modalSBPopup = null;
|
||||
for each(p in popups)
|
||||
{
|
||||
p.destroy();
|
||||
}
|
||||
while(popups.length > 0)
|
||||
{
|
||||
popups.pop();
|
||||
}
|
||||
}
|
||||
|
||||
public static function destroyNonSBPopups() : void
|
||||
{
|
||||
var p:Object = null;
|
||||
for each(p in nonSBPopups)
|
||||
{
|
||||
p.destroy();
|
||||
}
|
||||
while(nonSBPopups.length > 0)
|
||||
{
|
||||
nonSBPopups.pop();
|
||||
}
|
||||
}
|
||||
|
||||
public static function destroySpecificNonSBPopup(o:Object) : void
|
||||
{
|
||||
for(var i:int = 0; i < nonSBPopups.length; i++)
|
||||
{
|
||||
if(nonSBPopups[i] == o)
|
||||
{
|
||||
nonSBPopups.splice(i,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public dynamic class SBPopupSkin
|
||||
{
|
||||
|
||||
public var s:MovieClip;
|
||||
|
||||
public function SBPopupSkin(init_s:MovieClip)
|
||||
{
|
||||
super();
|
||||
this.s = init_s;
|
||||
if(!(Boolean(this.s["c"]) && Boolean(this.s["ba"])))
|
||||
{
|
||||
throw new Error("skin " + this.s.name + " is missing parts!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public class SBScreen
|
||||
{
|
||||
|
||||
public var screenClip:MovieClip;
|
||||
|
||||
public var parentWizard:SBWizard;
|
||||
|
||||
public var onEnterFromPrev:Function;
|
||||
|
||||
public var onEnterFromNext:Function;
|
||||
|
||||
public var onLeaveToPrev:Function;
|
||||
|
||||
public var onLeaveToNext:Function;
|
||||
|
||||
public var onPlay:Function;
|
||||
|
||||
public var onClose:Function;
|
||||
|
||||
public var updateScreen:Function;
|
||||
|
||||
public function SBScreen(initScreenClip:MovieClip, initParentWizard:SBWizard)
|
||||
{
|
||||
super();
|
||||
this.screenClip = initScreenClip;
|
||||
this.parentWizard = initParentWizard;
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this.screenClip = null;
|
||||
this.parentWizard = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.*;
|
||||
import flash.events.*;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFieldAutoSize;
|
||||
|
||||
public dynamic class SBStandardPopup extends SBPopup
|
||||
{
|
||||
|
||||
protected var _text:TextField;
|
||||
|
||||
protected var _skin:MovieClip;
|
||||
|
||||
protected var _content:MovieClip;
|
||||
|
||||
protected var _top:MovieClip;
|
||||
|
||||
protected var _mid:MovieClip;
|
||||
|
||||
protected var _bot:MovieClip;
|
||||
|
||||
protected var _verticalOffset:Number = 0;
|
||||
|
||||
protected var _btnTxtGap:Number = 0;
|
||||
|
||||
protected var _btnHeight:Number = 0;
|
||||
|
||||
protected var _resizeCallback:Function;
|
||||
|
||||
public function SBStandardPopup(init_parent:DisplayObjectContainer, init_message:String = null, init_darken:Boolean = true, init_content:MovieClip = null, init_skin:MovieClip = null, autoOpen:Boolean = true, init_enabled:Boolean = true, init_modal:Boolean = false, init_draggable:Boolean = false, init_title:String = null, init_x:Number = undefined, init_y:Number = undefined, init_width:Number = undefined, init_height:Number = undefined, init_children:Array = null)
|
||||
{
|
||||
if(Boolean(init_skin))
|
||||
{
|
||||
this._skin = init_skin;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._skin = GETDEFINITIONBYNAME("PopupSkin");
|
||||
}
|
||||
if(Boolean(init_content))
|
||||
{
|
||||
this._content = init_content;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._content = GETDEFINITIONBYNAME("PopupContent");
|
||||
}
|
||||
this._top = this._skin.ba.t;
|
||||
this._mid = this._skin.ba.m;
|
||||
this._bot = this._skin.ba.b;
|
||||
this._text = this._content.text;
|
||||
this._text.autoSize = TextFieldAutoSize.CENTER;
|
||||
if(Boolean(init_message))
|
||||
{
|
||||
this.setText(init_message);
|
||||
}
|
||||
super(init_parent,this._skin,this._content,autoOpen,init_enabled,init_modal,init_draggable,init_darken,init_title,init_x,init_y,init_width,init_height,init_children);
|
||||
}
|
||||
|
||||
public function setText(newText:String) : void
|
||||
{
|
||||
this._text.text = newText;
|
||||
this.resize();
|
||||
}
|
||||
|
||||
public function setHtmlText(newHtmlText:String) : void
|
||||
{
|
||||
this._text.htmlText = newHtmlText;
|
||||
this.resize();
|
||||
}
|
||||
|
||||
private function resize() : void
|
||||
{
|
||||
this._mid.height = Math.floor(this._text.height);
|
||||
this._mid.y = Math.floor(-(this._mid.height * 0.5) + this._verticalOffset);
|
||||
this._top.y = this._mid.y - this._top.height;
|
||||
this._bot.y = this._mid.y + this._mid.height;
|
||||
this._text.y = 0;
|
||||
this._skin.c.height = this._text.height + this._btnTxtGap + this._btnHeight;
|
||||
this._skin.c.y = this._mid.y;
|
||||
if(this._resizeCallback != null)
|
||||
{
|
||||
this._resizeCallback();
|
||||
}
|
||||
this._content.x = this._skin["c"].x;
|
||||
this._content.y = this._skin["c"].y;
|
||||
this._content.width = this._skin["c"].width;
|
||||
this._content.height = this._skin["c"].height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.text.TextFieldAutoSize;
|
||||
import gui.DarkenManager;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public dynamic class SBStandardTitlePopup
|
||||
{
|
||||
|
||||
public static const THANK_YOU_MEDIA_ID:int = 370;
|
||||
|
||||
private var _popupMediaHelper:MediaHelper;
|
||||
|
||||
private var _openWasCalled:Boolean;
|
||||
|
||||
protected var _loadedMC:MovieClip;
|
||||
|
||||
protected var _top:MovieClip;
|
||||
|
||||
protected var _mid:MovieClip;
|
||||
|
||||
protected var _bot:MovieClip;
|
||||
|
||||
public function SBStandardTitlePopup(init_parent:DisplayObjectContainer, init_message:String, init_title:String = null, init_mediaId:int = 370, init_closeCallback:Function = null, init_autoOpen:Boolean = true, init_darken:Boolean = true)
|
||||
{
|
||||
super();
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
this._popupMediaHelper = new MediaHelper();
|
||||
this._popupMediaHelper.init(init_mediaId,this.onMediaLoaded,{
|
||||
"parent":init_parent,
|
||||
"message":init_message,
|
||||
"title":init_title,
|
||||
"closeCallback":init_closeCallback,
|
||||
"autoOpen":init_autoOpen,
|
||||
"darken":init_darken
|
||||
});
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
DarkenManager.unDarken(this._loadedMC);
|
||||
this._loadedMC.passback.parent.removeChild(this._loadedMC);
|
||||
this._loadedMC.bx.removeEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
|
||||
this._loadedMC.removeEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
|
||||
this._loadedMC = null;
|
||||
this._top = null;
|
||||
this._mid = null;
|
||||
this._bot = null;
|
||||
this._openWasCalled = false;
|
||||
}
|
||||
|
||||
public function open() : void
|
||||
{
|
||||
if(Boolean(this._loadedMC))
|
||||
{
|
||||
this._loadedMC.visible = true;
|
||||
}
|
||||
if(Boolean(this._loadedMC.passback.darken))
|
||||
{
|
||||
DarkenManager.darken(this._loadedMC);
|
||||
}
|
||||
this._openWasCalled = true;
|
||||
}
|
||||
|
||||
public function close() : void
|
||||
{
|
||||
if(Boolean(this._loadedMC))
|
||||
{
|
||||
this._loadedMC.visible = false;
|
||||
}
|
||||
if(Boolean(this._loadedMC.passback.darken))
|
||||
{
|
||||
DarkenManager.unDarken(this._loadedMC);
|
||||
}
|
||||
}
|
||||
|
||||
private function onMediaLoaded(img:MovieClip) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(Boolean(img))
|
||||
{
|
||||
this._loadedMC = img.getChildAt(0) as MovieClip;
|
||||
this._popupMediaHelper.destroy();
|
||||
this._popupMediaHelper = null;
|
||||
this._loadedMC.x = MainFrame.VIEW_WIDTH * 0.5;
|
||||
this._loadedMC.y = MainFrame.VIEW_HEIGHT * 0.5;
|
||||
this._loadedMC.parent.parent.x = this._loadedMC.x;
|
||||
this._loadedMC.parent.parent.y = this._loadedMC.y;
|
||||
this._loadedMC.bx.addEventListener(MouseEvent.MOUSE_DOWN,this.onClose);
|
||||
this._loadedMC.addEventListener(MouseEvent.MOUSE_DOWN,this.onPopup);
|
||||
this._loadedMC.passback = this._loadedMC.parent["passback"];
|
||||
if(Boolean(this._loadedMC.passback.title))
|
||||
{
|
||||
this._loadedMC.titleTxt.text = this._loadedMC.passback.title;
|
||||
}
|
||||
if(Boolean(this._loadedMC.passback.message))
|
||||
{
|
||||
this._loadedMC.txt.bodyTxt.autoSize = TextFieldAutoSize.CENTER;
|
||||
this._loadedMC.txt.bodyTxt.text = this._loadedMC.passback.message;
|
||||
}
|
||||
this._top = this._loadedMC.ba.t;
|
||||
this._mid = this._loadedMC.ba.m;
|
||||
this._bot = this._loadedMC.ba.b;
|
||||
this.resize();
|
||||
if(!this._loadedMC.passback.autoOpen && !this._openWasCalled)
|
||||
{
|
||||
this._loadedMC.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.open();
|
||||
}
|
||||
this._loadedMC.passback.parent.addChild(this._loadedMC);
|
||||
}
|
||||
}
|
||||
|
||||
private function onClose(evt:MouseEvent) : void
|
||||
{
|
||||
evt.stopPropagation();
|
||||
if(Boolean(this._loadedMC.passback.closeCallback))
|
||||
{
|
||||
this._loadedMC.passback.closeCallback();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private function onPopup(evt:MouseEvent) : void
|
||||
{
|
||||
evt.stopPropagation();
|
||||
}
|
||||
|
||||
private function resize() : void
|
||||
{
|
||||
this._mid.height = Math.floor(this._loadedMC.txt.height);
|
||||
this._top.y = this._mid.y - this._mid.height * 0.5 - this._top.height * 0.5;
|
||||
this._bot.y = this._mid.y + this._mid.height * 0.5 + this._bot.height * 0.5;
|
||||
this._loadedMC.titleTxt.y = this._top.y - 23;
|
||||
this._loadedMC.bx.y = this._loadedMC.titleTxt.y;
|
||||
this._loadedMC.txt.y -= this._mid.height * 0.5 - 29;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
|
||||
public dynamic class SBStayLeavePopup extends SBStandardPopup
|
||||
{
|
||||
|
||||
private var _stayBtn:MovieClip;
|
||||
|
||||
private var _leaveBtn:MovieClip;
|
||||
|
||||
private var _confirmCallback:Function;
|
||||
|
||||
private var _passbackObject:Object;
|
||||
|
||||
public function SBStayLeavePopup(init_parent:DisplayObjectContainer, init_message:String = null, init_darken:Boolean = true, init_confirmCallback:Function = null, init_passbackObject:Object = null, autoOpen:Boolean = true, init_enabled:Boolean = true, init_modal:Boolean = false, init_draggable:Boolean = false, init_title:String = null, init_x:Number = undefined, init_y:Number = undefined, init_width:Number = undefined, init_height:Number = undefined, init_children:Array = null)
|
||||
{
|
||||
this._confirmCallback = init_confirmCallback;
|
||||
this._passbackObject = init_passbackObject;
|
||||
_verticalOffset = -20;
|
||||
_btnTxtGap = 6;
|
||||
_btnHeight = 44;
|
||||
var skin:MovieClip = GETDEFINITIONBYNAME("YesNoPopupSkin");
|
||||
var content:MovieClip = GETDEFINITIONBYNAME("LeaveStayPopupContent");
|
||||
this._stayBtn = content.stayBtn;
|
||||
this._leaveBtn = content.leaveBtn;
|
||||
this._stayBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onStayLeaveBtn,false,0,true);
|
||||
this._leaveBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onStayLeaveBtn,false,0,true);
|
||||
_resizeCallback = this.onResize;
|
||||
super(init_parent,init_message,init_darken,content,skin,autoOpen,init_enabled,init_modal,init_draggable,init_title,init_x,init_y,init_width,init_height,init_children);
|
||||
}
|
||||
|
||||
override public function destroy() : void
|
||||
{
|
||||
this._stayBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onStayLeaveBtn);
|
||||
this._leaveBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onStayLeaveBtn);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
private function onResize() : void
|
||||
{
|
||||
this._stayBtn.y = _text.height + _btnTxtGap + 0.5 * _btnHeight;
|
||||
this._leaveBtn.y = this._stayBtn.y;
|
||||
}
|
||||
|
||||
private function onStayLeaveBtn(evt:MouseEvent) : void
|
||||
{
|
||||
var o:Object = null;
|
||||
evt.stopPropagation();
|
||||
this.destroy();
|
||||
if(this._confirmCallback != null)
|
||||
{
|
||||
o = {
|
||||
"status":evt.currentTarget == this._leaveBtn,
|
||||
"passback":this._passbackObject
|
||||
};
|
||||
this._confirmCallback(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,276 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.MovieClip;
|
||||
|
||||
public class SBWizard
|
||||
{
|
||||
|
||||
public var screens:Array;
|
||||
|
||||
private var _step:int;
|
||||
|
||||
private var _useSeparateScreens:Boolean;
|
||||
|
||||
public var wizClip:MovieClip;
|
||||
|
||||
public var creationAssets:Object;
|
||||
|
||||
public function SBWizard()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(initWizClip:MovieClip, initAvatarCreationAssets:Object, initVisible:Boolean = true, initStep:int = 1, initScreens:Array = null, initEnabled:Boolean = true, useSeparateScreens:Boolean = false, isInWorld:Boolean = false) : void
|
||||
{
|
||||
var ifs:int = 0;
|
||||
var childOne:DisplayObject = null;
|
||||
var frameScreen:SBScreen = null;
|
||||
var ifa:int = 0;
|
||||
if(initWizClip == null)
|
||||
{
|
||||
throw new Error("invalid null initWizClip!");
|
||||
}
|
||||
this.wizClip = initWizClip;
|
||||
this.creationAssets = initAvatarCreationAssets;
|
||||
this._useSeparateScreens = useSeparateScreens;
|
||||
if(!initVisible && useSeparateScreens)
|
||||
{
|
||||
this.wizClip.visible = false;
|
||||
}
|
||||
var framesLength:int = useSeparateScreens == false ? int(initScreens.length) : this.wizClip.totalFrames;
|
||||
if(Boolean(initScreens))
|
||||
{
|
||||
this.screens = initScreens;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.screens = [];
|
||||
if(framesLength > 0)
|
||||
{
|
||||
for(ifs = 0; ifs < framesLength; ifs++)
|
||||
{
|
||||
this.wizClip.gotoAndStop(ifs + 1);
|
||||
if(this.wizClip.numChildren < 1)
|
||||
{
|
||||
throw new Error("SBWizard could not find any child SBScreen on frame:" + (ifs + 1) + "!");
|
||||
}
|
||||
childOne = this.wizClip.getChildAt(0);
|
||||
if(!(childOne is MovieClip))
|
||||
{
|
||||
throw new Error("SBWizard child was not a MovieClip for SBScreen on frame:" + (ifs + 1) + "!");
|
||||
}
|
||||
frameScreen = new SBScreen(childOne as MovieClip,this);
|
||||
if(!frameScreen)
|
||||
{
|
||||
throw new Error("SBWizard child SBScreen was null on frame:" + (ifs + 1) + "!");
|
||||
}
|
||||
frameScreen.screenClip.visible = false;
|
||||
this.screens.push(frameScreen);
|
||||
}
|
||||
if(this.screens.length != uint(framesLength))
|
||||
{
|
||||
throw new Error("SBWizard - Failed assertion: lengths must be equal- screens.length:" + this.screens.length + " uint(framesLength):" + uint(framesLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.wizClip.enabled = initEnabled;
|
||||
this.step = initStep;
|
||||
if(useSeparateScreens)
|
||||
{
|
||||
for(ifa = 0; ifa < framesLength; ifa++)
|
||||
{
|
||||
this.wizClip.addChild(this.screens[ifa].screenClip);
|
||||
}
|
||||
if(initStep > 0 && initStep <= framesLength)
|
||||
{
|
||||
this.screens[initStep - 1].screenClip.visible = true;
|
||||
}
|
||||
}
|
||||
this.wizClip.stop();
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
this.screens.splice(0,this.screens.length);
|
||||
this.screens = null;
|
||||
this.wizClip = null;
|
||||
}
|
||||
|
||||
public function get step() : int
|
||||
{
|
||||
return this._step;
|
||||
}
|
||||
|
||||
public function set step(setStep:int) : void
|
||||
{
|
||||
if(setStep == this._step)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.jumpToStep(setStep);
|
||||
}
|
||||
|
||||
public function get currScreen() : SBScreen
|
||||
{
|
||||
return this.screens[this._step - 1];
|
||||
}
|
||||
|
||||
public function get nextScreen() : SBScreen
|
||||
{
|
||||
if(Boolean(this.screens) && this._step <= this.screens.length - 1)
|
||||
{
|
||||
return this.screens[int(this._step)];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get prevScreen() : SBScreen
|
||||
{
|
||||
if(Boolean(this._step > 0) && Boolean(this.screens) && this.screens.length >= this._step)
|
||||
{
|
||||
return this.screens[int(this._step - 2)];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function jumpToStep(newStep:int) : void
|
||||
{
|
||||
var oldScr:SBScreen = null;
|
||||
var oldStepMoveFunc:Function = null;
|
||||
var newScr:SBScreen = null;
|
||||
var newStepMoveFunc:Function = null;
|
||||
if(!this.screens || newStep < 0 || newStep > this.screens.length + 1)
|
||||
{
|
||||
throw new Error("illegal wizard step:" + newStep + " screens:" + (Boolean(this.screens) ? this.screens.length : this.screens));
|
||||
}
|
||||
if(!this.wizClip.enabled || newStep == this._step)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var moveForward:Boolean = Boolean(newStep > this._step);
|
||||
if(this._step > 0 && this._step <= this.screens.length)
|
||||
{
|
||||
oldScr = this.screens[this._step - 1];
|
||||
if(this._useSeparateScreens)
|
||||
{
|
||||
oldScr.screenClip.visible = false;
|
||||
}
|
||||
oldStepMoveFunc = moveForward ? oldScr.onLeaveToNext : oldScr.onLeaveToPrev;
|
||||
if(oldStepMoveFunc != null)
|
||||
{
|
||||
if(!oldStepMoveFunc())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._step = newStep;
|
||||
if(newStep > 0 && newStep <= this.screens.length)
|
||||
{
|
||||
newScr = this.screens[newStep - 1];
|
||||
if(this._useSeparateScreens)
|
||||
{
|
||||
newScr.screenClip.visible = true;
|
||||
}
|
||||
newStepMoveFunc = moveForward ? newScr.onEnterFromPrev : newScr.onEnterFromNext;
|
||||
if(newStepMoveFunc != null)
|
||||
{
|
||||
newStepMoveFunc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function jumpToScreen(jumpScreen:SBScreen) : void
|
||||
{
|
||||
var screenIdx:int = this.screens.indexOf(jumpScreen);
|
||||
if(screenIdx >= 0)
|
||||
{
|
||||
this.jumpToStep(screenIdx + 1);
|
||||
return;
|
||||
}
|
||||
throw new Error("SBWizard jumpToScreen - screen:" + jumpScreen + " not found!");
|
||||
}
|
||||
|
||||
public function next() : void
|
||||
{
|
||||
this.jumpToStep(this._step + 1);
|
||||
}
|
||||
|
||||
public function prev() : void
|
||||
{
|
||||
this.jumpToStep(this._step - 1);
|
||||
}
|
||||
|
||||
public function onPlay() : void
|
||||
{
|
||||
this.currScreen.onPlay();
|
||||
}
|
||||
|
||||
public function onClose() : void
|
||||
{
|
||||
this.currScreen.onClose();
|
||||
this._step = 1;
|
||||
}
|
||||
|
||||
public function addScreen(addScreen:SBScreen, addStep:int = 0) : void
|
||||
{
|
||||
if(!this.screens)
|
||||
{
|
||||
throw new Error("Tried to addScreen on an uninitialized wizard!");
|
||||
}
|
||||
if(addStep == 0)
|
||||
{
|
||||
this.screens.push(addScreen);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(addStep < 0 || addStep > this.screens.length)
|
||||
{
|
||||
throw new Error("illegal step:" + addStep + " while trying to addScreen");
|
||||
}
|
||||
this.screens.splice(addStep - 1,0,addScreen);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeScreen(remStep:int = 0) : void
|
||||
{
|
||||
if(!this.screens || this.screens.length == 0)
|
||||
{
|
||||
throw new Error("Tried to removeScreen on an empty wizard!");
|
||||
}
|
||||
if(remStep == 0)
|
||||
{
|
||||
this.screens.pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(remStep < 0 || remStep > this.screens.length)
|
||||
{
|
||||
throw new Error("illegal step:" + remStep + " while trying to removeScreen");
|
||||
}
|
||||
this.screens.splice(remStep - 1,1);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateCurrScreen() : void
|
||||
{
|
||||
var currScr:SBScreen = this.currScreen;
|
||||
if(Boolean(currScr))
|
||||
{
|
||||
currScr.updateScreen(true);
|
||||
}
|
||||
var prevScr:SBScreen = this.prevScreen;
|
||||
if(Boolean(prevScr))
|
||||
{
|
||||
prevScr.updateScreen();
|
||||
}
|
||||
var nextScr:SBScreen = this.nextScreen;
|
||||
if(Boolean(nextScr))
|
||||
{
|
||||
nextScr.updateScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.sbi.popup
|
||||
{
|
||||
import flash.display.*;
|
||||
import flash.events.*;
|
||||
import flash.net.FileReference;
|
||||
import flash.ui.Keyboard;
|
||||
|
||||
public dynamic class SBYesNoPopup extends SBStandardPopup
|
||||
{
|
||||
|
||||
private var _yesBtn:MovieClip;
|
||||
|
||||
private var _noBtn:MovieClip;
|
||||
|
||||
private var _confirmCallback:Function;
|
||||
|
||||
private var _passbackObject:Object;
|
||||
|
||||
public function SBYesNoPopup(init_parent:DisplayObjectContainer, init_message:String = null, init_darken:Boolean = true, init_confirmCallback:Function = null, init_passbackObject:Object = null, autoOpen:Boolean = true, init_enabled:Boolean = true, init_modal:Boolean = false, init_draggable:Boolean = false, init_title:String = null, init_x:Number = undefined, init_y:Number = undefined, init_width:Number = undefined, init_height:Number = undefined, init_children:Array = null)
|
||||
{
|
||||
this._confirmCallback = init_confirmCallback;
|
||||
this._passbackObject = init_passbackObject;
|
||||
_verticalOffset = -20;
|
||||
_btnTxtGap = 6;
|
||||
_btnHeight = 44;
|
||||
var skin:MovieClip = GETDEFINITIONBYNAME("YesNoPopupSkin");
|
||||
var content:MovieClip = GETDEFINITIONBYNAME("YesNoPopupContent");
|
||||
this._yesBtn = content.yesBtn;
|
||||
this._noBtn = content.noBtn;
|
||||
this._yesBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onYesNoBtn,false,0,true);
|
||||
this._noBtn.addEventListener(MouseEvent.MOUSE_DOWN,this.onYesNoBtn,false,0,true);
|
||||
_resizeCallback = this.onResize;
|
||||
super(init_parent,init_message,init_darken,content,skin,autoOpen,init_enabled,init_modal,init_draggable,init_title,init_x,init_y,init_width,init_height,init_children);
|
||||
stage.addEventListener(KeyboardEvent.KEY_DOWN,this.handleYesNoKeyDown,false,0,true);
|
||||
}
|
||||
|
||||
override public function destroy() : void
|
||||
{
|
||||
if(Boolean(stage))
|
||||
{
|
||||
stage.removeEventListener(KeyboardEvent.KEY_DOWN,this.handleYesNoKeyDown);
|
||||
}
|
||||
this._yesBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onYesNoBtn);
|
||||
this._noBtn.removeEventListener(MouseEvent.MOUSE_DOWN,this.onYesNoBtn);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
private function onResize() : void
|
||||
{
|
||||
this._yesBtn.y = _text.height + _btnTxtGap + 0.5 * _btnHeight;
|
||||
this._noBtn.y = this._yesBtn.y;
|
||||
}
|
||||
|
||||
private function handleYesNoKeyDown(event:KeyboardEvent) : void
|
||||
{
|
||||
switch(event.keyCode)
|
||||
{
|
||||
case Keyboard.ENTER:
|
||||
case Keyboard.SPACE:
|
||||
event.stopPropagation();
|
||||
this.handleYesNo(true);
|
||||
break;
|
||||
case Keyboard.BACKSPACE:
|
||||
case Keyboard.DELETE:
|
||||
case Keyboard.ESCAPE:
|
||||
event.stopPropagation();
|
||||
this.handleYesNo(false);
|
||||
}
|
||||
}
|
||||
|
||||
private function onYesNoBtn(evt:MouseEvent) : void
|
||||
{
|
||||
evt.stopPropagation();
|
||||
this.handleYesNo(evt.currentTarget == this._yesBtn);
|
||||
}
|
||||
|
||||
private function handleYesNo(onYes:Boolean) : void
|
||||
{
|
||||
var fileRef:FileReference = null;
|
||||
var o:Object = null;
|
||||
this.destroy();
|
||||
if(Boolean(onYes) && Boolean(this._passbackObject) && this._passbackObject.hasOwnProperty("FileReference"))
|
||||
{
|
||||
fileRef = new FileReference();
|
||||
fileRef.save(this._passbackObject.ImageData,this._passbackObject.SaveName);
|
||||
}
|
||||
if(this._confirmCallback != null)
|
||||
{
|
||||
o = {
|
||||
"status":onYes,
|
||||
"passback":this._passbackObject
|
||||
};
|
||||
this._confirmCallback(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user