Section 1
//ShellDialog (dialog.ShellDialog)
package dialog {
import flash.events.*;
import util.*;
import flash.text.*;
import flash.display.*;
import flash.utils.*;
public class ShellDialog extends Sprite {
var ox;// = 0
var _sw;// = 0
var _intransition;// = false
var slideCounter;// = 0
var _transDir;// = 0
var _sh;// = 0
var _palette;
var dSlideCoords;
var closeBtn;
var topOffset;// = 0
var onCancel;
var slideCounterMax;// = 5
var titleField;
var transEndCallback;
var transProgCallback;
var _inputLock;// = false
var appearCounter;
var backing;
public var fixedCoords;// = null
var oSlideCoords;
var textPadH;// = 12
var oy;// = 0
var textPadV;// = 12
var closeFunction;
public static var textFieldUtilClass;
public static var managerClass;
public function ShellDialog(){
textPadH = 12;
textPadV = 12;
topOffset = 0;
_sw = 0;
_sh = 0;
_intransition = false;
_transDir = 0;
_inputLock = false;
fixedCoords = null;
ox = 0;
oy = 0;
slideCounter = 0;
slideCounterMax = 5;
super();
_palette = getPalette();
addBacking();
addEventListener(KeyboardEvent.KEY_DOWN, textInputHandler);
}
function addCloseButton(cancelCallbackFunc){
var btnClass:*;
var bnds:*;
var cancelCallbackFunc = cancelCallbackFunc;
btnClass = getDefinitionByName("noticeCloseBtn");
closeBtn = addChild(new (btnClass));
bnds = this.getBounds(this);
closeBtn.x = (Math.round(((bnds.x + bnds.width) - 19)) - 0.5);
closeBtn.y = (Math.round((bnds.y + 9)) - 0.5);
onCancel = function (evtObj){
cancelCallbackFunc();
};
closeBtn.addEventListener("mouseDown", onCancel);
closeBtn.buttonMode = true;
}
function centerPlacement(sw, sh){
var bnds:*;
bnds = this.getBounds(this);
if (fixedCoords != null){
x = (fixedCoords.x + Math.round((-(((bnds.width / 2) + bnds.x)) * scaleX)));
y = (fixedCoords.y + Math.round((-(((bnds.height / 2) + bnds.y)) * scaleY)));
} else {
x = (ox + Math.round(((sw / 2) - (((bnds.width / 2) + bnds.x) * scaleX))));
y = (oy + Math.round(((sh / 2) - (((bnds.height / 2) + bnds.y) * scaleY))));
};
}
public function slideTo(dx, dy){
slideCounter = 0;
oSlideCoords = {x:ox, y:ox};
dSlideCoords = {x:dx, y:dy};
addEventListener("enterFrame", doSlide);
}
function getTextField(txt, size=18, fontString="Myriad Pro", advancedAlias=true){
return (textFieldUtilClass.getTextField(txt, size, _palette.text, fontString, advancedAlias));
}
function addTitleField(txt){
titleField = addChild(getTextField(txt, 27, "Avant Garde Gothic Itc T Bold"));
titleField.textColor = 0;
titleField.alpha = 0.5;
titleField.y = (titleField.y - (titleField.textHeight + 14));
topOffset = 8;
}
function onReturn(){
}
public function drawInputFrame(ix, iy, iw, ih, cornerR=null){
var g:*;
var vPad:*;
var hPad:*;
if (cornerR == null){
cornerR = (ih / 3);
};
g = backing.graphics;
g.beginFill(0);
vPad = 3;
hPad = 3;
g.drawRoundRect(((ix - hPad) - 2), ((iy - vPad) - 1), (iw + (hPad * 2)), (ih + (vPad * 2)), cornerR, cornerR);
g.beginFill(0xFFFFFF);
vPad = 2;
hPad = 2;
g.drawRoundRect(((ix - hPad) - 2), ((iy - vPad) - 1), (iw + (hPad * 2)), (ih + (vPad * 2)), cornerR, cornerR);
}
public function slideBack(){
var tempCoords:*;
slideCounter = 0;
tempCoords = oSlideCoords;
oSlideCoords = dSlideCoords;
dSlideCoords = tempCoords;
addEventListener("enterFrame", doSlide);
}
function getPalette(){
return ({bg:0xFFFFFF, edge:0xCCCCCC, text:0});
}
function doSlide(e){
var slideFrac:*;
slideCounter++;
slideFrac = ShellCurves.easeOut(ShellCurves.scurve((slideCounter / slideCounterMax)));
setPos(((oSlideCoords.x * (1 - slideFrac)) + (dSlideCoords.x * slideFrac)), ((oSlideCoords.y * (1 - slideFrac)) + (dSlideCoords.y * slideFrac)));
centerPlacement(_sw, _sh);
if (slideCounter == slideCounterMax){
removeEventListener("enterFrame", doSlide);
};
}
function doDisappear(frac, callback){
scaleX = frac;
scaleY = frac;
if (frac == 1){
_intransition = false;
lockInput(_inputLock);
callback(this);
};
}
function onEscape(){
}
public function lockInput(boo){
var allowInput:*;
_inputLock = boo;
allowInput = ((!(boo)) && (!(_intransition)));
mouseChildren = allowInput;
mouseEnabled = allowInput;
}
function drawRect(g, bnds, ox, oy){
g.drawRoundRect(((bnds.x - textPadH) + ox), (((bnds.y - textPadV) + topOffset) + oy), (bnds.width + (textPadH * 2)), ((bnds.height + (textPadV * 2)) - topOffset), 25, 25);
}
public function updateStageSize(sw, sh){
_sw = sw;
_sh = sh;
centerPlacement(sw, sh);
}
function onClose(){
if (closeFunction != undefined){
closeFunction();
};
}
public function appear(callback){
transProgCallback = callback;
_intransition = true;
_transDir = 1;
lockInput(_inputLock);
appearCounter = new ShellCounter(5);
addEventListener("enterFrame", onFrame);
setAppear(0);
}
public function setPos(xOff, yOff){
ox = xOff;
oy = yOff;
}
function setAppear(frac){
scaleX = frac;
scaleY = frac;
alpha = frac;
}
function onAppearComplete(){
}
public function closeMe(evtObj=null){
onClose();
managerClass.removeWindow(this);
}
function drawBacking(){
var g:*;
var bnds:*;
g = backing.graphics;
bnds = this.getBounds(this);
g.beginFill(0, 0.5);
drawRect(g, bnds, 0, 6);
g.beginFill(_palette.edge);
drawRect(g, bnds, 0, 2);
g.beginFill(_palette.bg);
drawRect(g, bnds, 0, 0);
}
function addBacking(){
backing = addChild(new Sprite());
}
public function disappear(callback){
_intransition = true;
_transDir = -1;
transEndCallback = callback;
}
function onFrame(evtObj){
var frac:*;
if (_intransition){
appearCounter.step(_transDir);
frac = appearCounter.getFrac();
setAppear(ShellCurves.easeOut(frac));
transProgCallback(this);
if ((((frac == 1)) || ((frac == 0)))){
_intransition = false;
_transDir = 0;
lockInput(_inputLock);
if (transEndCallback != null){
transEndCallback(this);
transEndCallback = null;
};
onAppearComplete();
};
};
}
public function cleanUp(){
if (((!((closeBtn == null))) && (!((onCancel == null))))){
removeEventListener("mouseDown", onCancel);
};
removeEventListener("enterFrame", onFrame);
removeEventListener(KeyboardEvent.KEY_DOWN, textInputHandler);
removeEventListener("enterFrame", doSlide);
}
function textInputHandler(event:KeyboardEvent):void{
if (event.keyCode == 13){
onReturn();
};
if (event.keyCode == 27){
onEscape();
};
}
}
}//package dialog
Section 2
//ShellNotice (dialog.ShellNotice)
package dialog {
import flash.events.*;
import flash.text.*;
import flash.display.*;
import flash.utils.*;
public class ShellNotice extends ShellDialog {
var tf;
var _hasCloseButton;
public function ShellNotice(txtString, rtnFunc=null, clickAnywhereToClose=true, hasCloseButton=true){
var btnClass:*;
var bnds:*;
super();
_hasCloseButton = hasCloseButton;
textPadH = 24;
if (clickAnywhereToClose){
backing.addEventListener("mouseDown", closeMe);
backing.buttonMode = true;
};
closeFunction = rtnFunc;
addContent(txtString, clickAnywhereToClose);
drawBacking();
if (hasCloseButton){
btnClass = getDefinitionByName("noticeCloseBtn");
closeBtn = addChild(new (btnClass));
bnds = this.getBounds(this);
closeBtn.x = (Math.round(((bnds.x + bnds.width) - 21)) + 0.5);
closeBtn.y = (Math.round(((bnds.y + 8) + 0.5)) + 0.5);
if (!clickAnywhereToClose){
closeBtn.addEventListener("mouseDown", closeMe);
closeBtn.buttonMode = true;
} else {
closeBtn.mouseEnabled = false;
};
};
}
override function getPalette(){
return ({bg:0xFFFFFF, text:0x444444});
}
override function onEscape(){
closeMe();
}
function addContent(txtString, disableTextClip){
var fmt:TextFormat;
var myCSS:StyleSheet;
var hPad:*;
var vPad:*;
tf = addChild(new TextField());
tf.wordWrap = true;
tf.selectable = false;
tf.antiAliasType = AntiAliasType.ADVANCED;
fmt = new TextFormat("Myriad Pro Semibold");
fmt.size = 16;
fmt.leading = 5;
fmt.kerning = true;
fmt.align = "center";
tf.embedFonts = true;
tf.textColor = _palette.text;
tf.width = 999;
tf.height = 999;
tf.mouseEnabled = !(disableTextClip);
tf.htmlText = txtString;
tf.setTextFormat(fmt);
tf.multiline = true;
myCSS = new StyleSheet();
myCSS.setStyle("a:link", {color:"#000000", textDecoration:"underline"});
tf.styleSheet = myCSS;
hPad = 5;
vPad = 4;
tf.autoSize = TextFieldAutoSize.CENTER;
tf.width = ((tf.textWidth + hPad) + 2);
tf.height = ((tf.textHeight + vPad) + 2);
}
override function drawBacking(){
var g:*;
var bnds:*;
g = backing.graphics;
bnds = this.getBounds(this);
if (_hasCloseButton){
bnds.x = (bnds.x + 6);
};
g.beginFill(0, 0.2);
drawRect(g, bnds, 0, 3);
g.beginFill(_palette.bg);
drawRect(g, bnds, 0, 0);
}
override function onReturn(){
closeMe();
}
override public function cleanUp(){
removeEventListener("mouseDown", closeMe);
super.cleanUp();
}
}
}//package dialog
Section 3
//ShellTextFieldUtil (dialog.ShellTextFieldUtil)
package dialog {
import flash.text.*;
import flash.display.*;
public class ShellTextFieldUtil {
public function ShellTextFieldUtil(){
super();
}
public static function getTextField(txt, size=18, colr=0xFFFFFF, fontString="Myriad Pro", advancedAlias=true){
var tf:*;
var fmt:TextFormat;
tf = new TextField();
tf.mouseEnabled = false;
tf.wordWrap = false;
tf.selectable = false;
if (advancedAlias){
tf.antiAliasType = AntiAliasType.ADVANCED;
};
fmt = new TextFormat(fontString);
fmt.kerning = true;
fmt.size = size;
fmt.leading = 5;
tf.textColor = colr;
tf.embedFonts = true;
tf.text = txt;
tf.setTextFormat(fmt);
tf.width = (tf.textWidth + 5);
tf.height = (tf.textHeight + 5);
return (tf);
}
}
}//package dialog
Section 4
//ShellCounter (util.ShellCounter)
package util {
public class ShellCounter {
public var wrap;
public var currVal;
public var maxVal;
public function ShellCounter(maxCount, currCount=0, doWrap=false){
super();
maxVal = maxCount;
currVal = currCount;
wrap = doWrap;
}
public function get isComplete(){
return ((currVal == maxVal));
}
public function getFrac(){
return ((currVal / maxVal));
}
public function step(dir=1){
setCount((currVal + dir));
}
public function setCount(num){
if (num < 0){
num = 0;
};
if (num > maxVal){
num = (wrap) ? (currVal - maxVal) : maxVal;
};
currVal = num;
}
public function booStep(boo){
step((boo) ? 1 : -1);
}
public function setFrac(frac){
currVal = (frac * maxVal);
}
public function reset(newMaxVal=null){
currVal = 0;
if (newMaxVal != null){
maxVal = newMaxVal;
};
}
public function getCount(){
return (currVal);
}
}
}//package util
Section 5
//ShellCurves (util.ShellCurves)
package util {
public class ShellCurves {
public function ShellCurves(){
super();
}
public static function easeOut(num){
return (Math.sin(((num * Math.PI) / 2)));
}
public static function easeIn(num){
return ((1 - Math.sin((((1 - num) * Math.PI) / 2))));
}
public static function zenoEaseOut(t, factor=1){
return (((t == 1)) ? 1 : (((-(Math.pow(2, (-10 * t))) + 1) * factor) + (t * (1 - factor))));
}
public static function zenoScurve(t, factor=1){
return (((t)<0.5) ? (zenoEaseIn((t * 2), factor) / 2) : (0.5 + (zenoEaseOut(((t - 0.5) * 2), factor) / 2)));
}
public static function quadEaseOut(num){
num = (num / 1);
return ((-(num) * (num - 2)));
}
public static function quadEaseIn(num){
num = (num / 1);
return ((num * num));
}
public static function quadScurve(t){
return (((t)<0.5) ? (quadEaseIn((t * 2)) * 0.5) : (0.5 + (0.5 * quadEaseOut(((t - 0.5) * 2)))));
}
public static function scurve(num){
return (((-(Math.cos((num * Math.PI))) + 1) / 2));
}
public static function zenoEaseIn(t, factor=1){
return (((t == 0)) ? 0 : ((Math.pow(2, (10 * (t - 1))) * factor) + (t * (1 - factor))));
}
}
}//package util
Section 6
//LoadingWheel (LoadingWheel)
package {
import flash.events.*;
import util.*;
import flash.display.*;
public class LoadingWheel extends Sprite {
var calleeArr;
var _isFadingIn;// = false
var spinRate;// = 0.098174770424681
public var wheel:loadingWheelDisc;
var darknessFrac;// = 0.666666666666667
var spinVal;// = 0
var appearCounter;
public var onDisappearCallback;
public function LoadingWheel(){
darknessFrac = (2 / 3);
spinVal = 0;
spinRate = (Math.PI / 32);
_isFadingIn = false;
super();
appearCounter = new ShellCounter(90);
calleeArr = [];
visible = false;
}
public function appear(id){
if (calleeArr.indexOf(id) == -1){
calleeArr.push(id);
};
_isFadingIn = true;
addEventListener("enterFrame", onFrame);
}
public function setMaxTime(val){
appearCounter.maxVal = val;
}
public function disappear(id){
if (calleeArr.indexOf(id) != -1){
calleeArr.splice(calleeArr.indexOf(id), 1);
};
if (calleeArr.length == 0){
_isFadingIn = false;
};
}
function onFrame(evtObj){
var rawFrac:*;
var frac:*;
appearCounter.booStep(_isFadingIn);
rawFrac = appearCounter.getFrac();
frac = ((rawFrac - darknessFrac) / (1 - darknessFrac));
if (frac > 0){
visible = true;
alpha = frac;
spinVal = (spinVal + spinRate);
if (spinVal > Math.PI){
spinVal = (spinVal - (Math.PI * 2));
};
wheel.rotation = ((spinVal / Math.PI) * 180);
} else {
visible = false;
if ((((rawFrac == 0)) && (!(_isFadingIn)))){
removeEventListener("enterFrame", onFrame);
if (onDisappearCallback != null){
onDisappearCallback();
};
};
};
}
public function setDarknessFrac(val){
darknessFrac = val;
}
public function disable(){
removeEventListener("enterFrame", onFrame);
}
}
}//package
Section 7
//loadingWheelDisc (loadingWheelDisc)
package {
import flash.display.*;
public dynamic class loadingWheelDisc extends Sprite {
public function loadingWheelDisc(){
super();
}
}
}//package
Section 8
//MyriadProSemiBold (MyriadProSemiBold)
package {
import flash.text.*;
public dynamic class MyriadProSemiBold extends Font {
public function MyriadProSemiBold(){
super();
}
}
}//package
Section 9
//noticeCloseBtn (noticeCloseBtn)
package {
import flash.display.*;
public dynamic class noticeCloseBtn extends Sprite {
public function noticeCloseBtn(){
super();
}
}
}//package
Section 10
//SendAndLoader (SendAndLoader)
package {
import flash.events.*;
import shell.*;
import flash.xml.*;
import flash.net.*;
import flash.ui.*;
public class SendAndLoader {
static var id = 0;
public static var loadingClip;
public function SendAndLoader(url, onLoadedCallback, errorHandlerCallback, urlVariableObj=null){
var myId:*;
var loader:URLLoader;
var reekwest:*;
var onLoaded:*;
var onError:*;
var url = url;
var onLoadedCallback = onLoadedCallback;
var errorHandlerCallback = errorHandlerCallback;
var urlVariableObj = urlVariableObj;
super();
myId = ("SendAndLoader" + id++);
loader = new URLLoader();
reekwest = new URLRequest(url);
reekwest.method = URLRequestMethod.POST;
reekwest.data = urlVariableObj;
onLoaded = function (e){
Shell.addLogText(("SUCCESS " + e));
onLoadedCallback(e);
loadingClip.disappear(myId);
};
onError = function (e){
Shell.addLogText(("ERROR " + e));
errorHandlerCallback(e);
loadingClip.disappear(myId);
};
configureListeners(loader, onLoaded, onError);
loadingClip.appear(myId);
Shell.addLogText(("TRY TO LOAD " + url));
loader.load(reekwest);
}
private function configureListeners(dispatcher:IEventDispatcher, onLoadCallback, onError):void{
var onStatusEvt:*;
var dispatcher = dispatcher;
var onLoadCallback = onLoadCallback;
var onError = onError;
dispatcher.addEventListener(Event.COMPLETE, onLoadCallback);
onStatusEvt = function (e){
Shell.addLogText(("STATUS " + e));
};
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, onError);
dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
dispatcher.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onError);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, onStatusEvt);
}
}
}//package
Section 11
//Shell (Shell)
package {
import flash.events.*;
import util.*;
import dialog.*;
import flash.text.*;
import flash.display.*;
import flash.xml.*;
import flash.net.*;
import flash.ui.*;
import flash.system.*;
public class Shell extends Sprite {
var appConfigData;
var loadFailCount;// = 0
var loadingWheelClip;
var errorEmail;// = "errors@windosill.com"
var managerUrl;
var noticeY;// = -300
var modalLayer;
var enableRoomWarp;// = false
var baseErrorString;// = "Windosill is having trouble connecting to the server.
Please make sure you are connected to the internet.
Click this message to try again."
var refailErrorString;// = "Windosill still can't connect to the server.
The server may be temporarily down.
Visit <a href='http://status.windosill.com'>status.windosill.com</a> for system status."
var badXmlMessage;
var baseUrl;
public function Shell(){
var spliceTestArr:*;
var rootContextMenu:*;
enableRoomWarp = false;
errorEmail = "errors@windosill.com";
baseErrorString = "Windosill is having trouble connecting to the server.\rPlease make sure you are connected to the internet.\rClick this message to try again.";
refailErrorString = "Windosill still can't connect to the server.\rThe server may be temporarily down.\rVisit <a href='http://status.windosill.com'>status.windosill.com</a> for system status.";
badXmlMessage = (("XML is malformed!\rPlease send an email to\r" + errorEmail) + ".");
loadFailCount = 0;
noticeY = -300;
super();
spliceTestArr = [1];
spliceTestArr.splice(-1, 1);
rootContextMenu = new ContextMenu();
rootContextMenu.hideBuiltInItems();
this.contextMenu = rootContextMenu;
loadingWheelClip = addChild(new LoadingWheel());
SwfLoader.loadingClip = loadingWheelClip;
SendAndLoader.loadingClip = loadingWheelClip;
ShellModalManager.stageRef = stage;
ShellModalManager.stageWidth = stage.stageWidth;
ShellModalManager.stageHeight = stage.stageHeight;
ShellModalManager.modalLayer = this;
ShellDialog.textFieldUtilClass = ShellTextFieldUtil;
ShellDialog.managerClass = this;
loadConfigXml(configXmlAddress);
stage.stageFocusRect = false;
loadingWheelClip.x = Math.round((stage.stageWidth / 2));
loadingWheelClip.y = Math.round((stage.stageHeight - 16));
}
function onLoadErrorCallback(resumeCallBack, evt=null){
loadFailCount++;
if (loadFailCount >= 2){
displayNotice(refailErrorString, null, false, true);
} else {
displayNotice(baseErrorString, resumeCallBack);
};
}
function onConfigXmlLoaded(e){
var rtnXml:*;
var configXml:*;
var manager:*;
var managerUrl:*;
var e = e;
rtnXml = e.target.data;
loadFailCount = 0;
configXml = new XML(rtnXml);
//unresolved jump
var _slot1 = e;
displayNotice(badXmlMessage);
return;
baseUrl = (configXml.server.@url + configXml.build.@path);
Security.allowDomain(baseUrl);
manager = configXml.manager.@file;
managerUrl = (baseUrl + manager);
appConfigData = configXml.applicationData;
new SwfLoader(managerUrl, onRoomManagerLoadComplete, onLoadErrorCallback);
}
function errorHandler(evt):void{
loadFailCount++;
onLoadErrorCallback(reloadConfigXml, evt);
}
function loadConfigXml(xmlAddress){
var variables:URLVariables;
variables = new URLVariables();
variables.shellVersion = shellVersion;
new SendAndLoader(xmlAddress, onConfigXmlLoaded, errorHandler, variables);
}
function displayNotice(noticeText, callBack=null, clickable=true, hasCloseButton=true){
var notice:*;
notice = new ShellNotice(noticeText, callBack, clickable, hasCloseButton);
ShellModalManager.addWindow(notice);
noticeY = (noticeY + 150);
return (notice);
}
function get shellVersion(){
return ("localTesting");
}
public function removeWindow(obj){
ShellModalManager.removeWindow(obj);
}
function get isBrowser(){
return (false);
}
function get configXmlAddress(){
return ("http://windosill.com/config/getConfig.php");
}
function onRoomManagerLoadComplete(clip){
addChild(clip);
modalLayer = addChild(new Sprite());
clip.init(baseUrl, appConfigData, loadingWheelClip, modalLayer, false, isBrowser);
if (enableRoomWarp){
clip.enableRoomWarp = true;
};
setChildIndex(modalLayer, (numChildren - 1));
setChildIndex(loadingWheelClip, (numChildren - 1));
}
function reloadConfigXml(){
loadConfigXml(configXmlAddress);
}
private function configureListeners(dispatcher:IEventDispatcher, onLoadCallback, onFailCallback):void{
dispatcher.addEventListener(Event.COMPLETE, onLoadCallback);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, onFailCallback);
}
public static function addLogText(txt){
trace(("LOG: " + txt));
}
}
}//package
Section 12
//Shell_Browser (Shell_Browser)
package {
import flash.system.*;
public class Shell_Browser extends Shell {
public function Shell_Browser(){
super();
Security.allowDomain("windosill.com");
Security.allowDomain("files.windosill.com");
Security.allowDomain("vectorpark.com");
}
override function get shellVersion(){
return ("public_1");
}
override function get isBrowser(){
return (true);
}
}
}//package
Section 13
//Shell_Browser_Mochi (Shell_Browser_Mochi)
package {
public class Shell_Browser_Mochi extends Shell_Browser {
public function Shell_Browser_Mochi(){
super();
}
override function get shellVersion(){
return ("public_1_mochi");
}
}
}//package
Section 14
//ShellModalManager (ShellModalManager)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class ShellModalManager {
public static var modalLayer;
public static var stageHeight;
public static var stageWidth;
public static var stageRef;
static var modalWindows = [];
public function ShellModalManager(){
super();
}
static function onMouseUpEvt(evtObj){
if (modalWindows.length > 0){
if (getQualifiedClassName(stageRef.focus).split(":").pop() != "TextField"){
stageRef.focus = modalWindows[(modalWindows.length - 1)];
};
};
}
public static function addWindow(windowObj){
modalWindows.push(windowObj);
modalLayer.addChild(windowObj);
windowObj.updateStageSize(stageWidth, stageHeight);
windowObj.appear(onWindowAppearProg);
stageRef.focus = windowObj;
modalLayer.stage.addEventListener("mouseUp", onMouseUpEvt);
}
public static function removeWindow(windowObj){
windowObj.disappear(destroyWindow);
}
static function destroyWindow(windowObj){
modalWindows.splice(modalWindows.indexOf(windowObj), 1);
windowObj.cleanUp();
modalLayer.removeChild(windowObj);
if (modalWindows.length > 0){
stageRef.focus = modalWindows[(modalWindows.length - 1)];
};
}
public static function updateStageSize(sw, sh){
var window:*;
stageWidth = sw;
stageHeight = sh;
for each (window in modalWindows) {
window.updateStageSize(stageWidth, stageHeight);
};
}
static function onWindowAppearProg(windowObj){
windowObj.updateStageSize(stageWidth, stageHeight);
}
}
}//package
Section 15
//SwfLoader (SwfLoader)
package {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.net.*;
import flash.system.*;
public class SwfLoader {
var tryLoad;
var loader;
static var id = 0;
public static var loadingClip;
public function SwfLoader(url, onComplete, onErrorCallback){
var myId:*;
var request:URLRequest;
var onSwfLoaded:*;
var onError:*;
var url = url;
var onComplete = onComplete;
var onErrorCallback = onErrorCallback;
super();
myId = ("SwfLoader" + id);
request = new URLRequest(url);
loader = new Loader();
onSwfLoaded = function (e){
Shell.addLogText(("SUCCESS " + e));
loadingClip.disappear(myId);
onComplete(loader.content);
};
onError = function (e){
Shell.addLogText(("ERROR " + e));
loadingClip.disappear(myId);
onErrorCallback(tryLoad, e);
};
tryLoad = function (){
var addedDefinitions:LoaderContext;
Shell.addLogText(("LOADING " + url));
loadingClip.appear(myId);
addedDefinitions = new LoaderContext();
addedDefinitions.applicationDomain = ApplicationDomain.currentDomain;
loader.load(request, addedDefinitions);
};
configureErrorListeners(loader, onSwfLoaded, onError);
tryLoad();
}
private function configureErrorListeners(loader, onSwfLoaded, onError):void{
var loadInfo:*;
loadInfo = loader.contentLoaderInfo;
loadInfo.addEventListener(Event.COMPLETE, onSwfLoaded);
loadInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
loadInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
loadInfo.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onError);
}
}
}//package