Section 1
//Character (com.king.ludo.characters.Character)
package com.king.ludo.characters {
import com.king.ludo.*;
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import gs.*;
import com.king.ludo.utils.*;
import flash.utils.*;
import com.midasplayer.avatar.*;
import com.king.ludo.data.*;
import flash.filters.*;
import gs.easing.*;
public class Character extends Sprite implements Tickable {
private var _animState:String;
private var _glowFilter:GlowFilter;
private var _angleOffset:int;// = 0
private var _isSelected:Boolean;
private var _moveFinishedListener:Function;
public var id:int;
public var isInGoal:Boolean;// = false
public var initAngle:int;
public var ownerId:int;
public var isInPlay:Boolean;// = false
private var _glowSin:Number;// = 0
private var _bitmap:Bitmap;
private var _frm:int;// = 1
private var _bitmaps:Array;
private var _currentPosId:int;// = -1
private var _movePath:Array;
private static const ANIM_STATUS_STOP:String = "stop";
private static const FRM_FALL_2:int = 29;
private static const FRM_KNUFF_1:int = 30;
private static const FRM_KNUFF_2:int = 40;
private static const ANIM_STATUS_FALL:String = "fall";
private static const ANIM_STATUS_KNUFF:String = "knuff";
private static const ANIM_STATUS_NULL:String = "null";
private static const ANIM_STATUS_START_RUN:String = "start_run";
private static const ANIM_STATUS_RUN:String = "run";
public static const FRM_OFFSET_D:int = 0;
public static const FRM_OFFSET_L:int = 40;
private static const FRM_RUN_1:int = 1;
private static const FRM_RUN_2:int = 12;
public static const FRM_OFFSET_R:int = 80;
public static const FRM_OFFSET_U:int = 120;
private static const FRM_STOP_1:int = 18;
private static const FRM_STOP_2:int = 20;
private static const FRM_START_1:int = 13;
private static const FRM_START_2:int = 16;
private static const FRM_FALL_1:int = 21;
private static var totalChars:int = 0;
public function Character(ownerId:int){
super();
id = totalChars;
totalChars++;
this.ownerId = ownerId;
var shadow:Bitmap = new Bitmap(BitmapDispenser.getBitmapData("char_shadow"));
shadow.x = (-(shadow.width) / 2);
shadow.y = (-(shadow.height) / 2);
addChild(shadow);
_glowFilter = new GlowFilter(0xFFFFFF, 0.5, 8, 8);
_bitmaps = CharacterManager.getGfxForCharacter(ownerId);
_bitmap = new Bitmap();
_bitmap.x = -28;
_bitmap.y = -72;
addChild(_bitmap);
_animState = "stop";
_frm = FRM_STOP_2;
forceFrameUpdate();
hitArea = new Sprite();
hitArea.graphics.beginFill(0, 0.5);
hitArea.graphics.drawRect(-13, -55, 30, 60);
hitArea.visible = false;
buttonMode = true;
mouseChildren = false;
addEventListener(MouseEvent.MOUSE_UP, selectChar, false, 0, true);
Game.getInstance().projection.addToUpdateList(this);
Game.getInstance().projection.addToSortList(this);
CharacterManager.addCharacter(this);
}
public function destroy():void{
Game.getInstance().projection.removeFromUpdateList(this);
Game.getInstance().projection.removeFromSortList(this);
CharacterManager.removeCharacter(this);
if (parent){
parent.removeChild(this);
};
}
public function getCurrentPosId():int{
return (_currentPosId);
}
public function setAngle(angleOffset:int):void{
_frm = (_frm - _angleOffset);
_angleOffset = angleOffset;
_frm = (_frm + _angleOffset);
if (_angleOffset == FRM_OFFSET_D){
_bitmap.x = -26;
_bitmap.y = -68;
} else {
if (_angleOffset == FRM_OFFSET_L){
_bitmap.x = -28;
_bitmap.y = -68;
} else {
if (_angleOffset == FRM_OFFSET_R){
_bitmap.x = -28;
_bitmap.y = -72;
} else {
_bitmap.x = -34;
_bitmap.y = -70;
};
};
};
forceFrameUpdate();
}
public function tick():void{
var val:Number;
if (((getSelectable()) && (!(_isSelected)))){
_glowSin = (_glowSin + 0.2);
val = Math.sin(_glowSin);
_glowFilter.blurX = (4 + (val * 4));
_glowFilter.blurY = (4 + (val * 4));
_bitmap.filters = [_glowFilter];
_bitmap.transform.colorTransform = new ColorTransform((1.4 + (val * 0.4)), (1.4 + (val * 0.4)), (1.4 + (val * 0.4)));
};
if (_animState == ANIM_STATUS_RUN){
if (_movePath != null){
_bitmap.bitmapData = _bitmaps[_frm];
if (_frm < (_angleOffset + FRM_RUN_2)){
_frm++;
} else {
_frm = (_angleOffset + FRM_RUN_1);
};
};
} else {
if (_animState == ANIM_STATUS_STOP){
if (_frm < (FRM_STOP_2 + _angleOffset)){
_bitmap.bitmapData = _bitmaps[_frm];
_frm++;
};
} else {
if (_animState == ANIM_STATUS_START_RUN){
if (_frm < (FRM_START_2 + _angleOffset)){
_bitmap.bitmapData = _bitmaps[_frm];
_frm++;
} else {
animRun();
};
} else {
if (_animState == ANIM_STATUS_FALL){
if (_frm < (FRM_FALL_2 + _angleOffset)){
_bitmap.bitmapData = _bitmaps[_frm];
_frm++;
} else {
fadeDownThenUp(0);
setTimeout(moveToPool, 500);
setTimeout(animStop, 500);
_animState = ANIM_STATUS_NULL;
};
} else {
if (_animState == ANIM_STATUS_KNUFF){
if (_frm < (FRM_KNUFF_2 + _angleOffset)){
_bitmap.bitmapData = _bitmaps[_frm];
_frm++;
} else {
animStop();
setAngle(_angleOffset);
};
};
};
};
};
};
}
public function setCurrentPosId(posId:int):void{
_currentPosId = posId;
}
private function animKnuff():void{
_frm = (FRM_KNUFF_1 + _angleOffset);
_animState = ANIM_STATUS_KNUFF;
_bitmap.x = (_bitmap.x + -60);
_bitmap.y = (_bitmap.y + -14);
forceFrameUpdate();
setTimeout(postKnuffCorrection, 350);
Main.getInstance().soundManager.getByClass(Main.getInstance().SndKnuff, "snd_knuff").play(0.35);
}
public function moveToPathPos(posId:int):void{
var rnd:Number;
var snd:Class;
var id:int;
var charsAtPos:Array;
var pos:Point;
var victim:Character;
if (posId == -1){
posId = Positions.MAX_POS_ID;
};
if (!isInPlay){
Players.getPlayer(ownerId).getHappy();
Main.getInstance().soundManager.getByClass(Main.getInstance().SndYippie, "snd_yippie").play(0.35);
} else {
Main.getInstance().soundManager.getByClass(Main.getInstance().SndWalkLoop, "snd_walk_loop").loop(0.35);
};
isInPlay = true;
if (_currentPosId != -1){
moveFromTo(_currentPosId, posId);
rnd = Math.random();
if (rnd > 0.66){
id = (1 + (Math.random() * 5));
if (id == 1){
snd = Main.getInstance().SndHappy1;
} else {
if (id == 2){
snd = Main.getInstance().SndHappy2;
} else {
if (id == 3){
snd = Main.getInstance().SndHappy3;
} else {
if (id == 4){
snd = Main.getInstance().SndHappy4;
} else {
snd = Main.getInstance().SndHappy5;
};
};
};
};
Main.getInstance().soundManager.getByClass(snd, ("snd_happy" + id)).play(0.25);
};
} else {
charsAtPos = CharacterManager.getCharactersByPositionId(posId);
if (charsAtPos.length > 0){
victim = charsAtPos[0];
victim.fall();
Players.getPlayer(victim.ownerId).knockedDown++;
Players.getPlayer(ownerId).knuffs++;
};
Players.getPlayer(ownerId).playerPanel.setAvatarMood(AvatarMood.MOOD_HAPPY);
pos = Positions.getPathPos(posId);
setTimeout(setPosition, 500, pos);
fadeDownThenUp(0);
_currentPosId = posId;
animStop();
if (_moveFinishedListener != null){
_moveFinishedListener(this);
};
};
}
private function forceFrameUpdate():void{
_bitmap.bitmapData = _bitmaps[_frm];
}
private function setPosition(pos:Point):void{
x = pos.x;
y = pos.y;
}
private function animStop():void{
_frm = (FRM_STOP_1 + _angleOffset);
_animState = ANIM_STATUS_STOP;
}
public function setMoveFinishedListener(f:Function):void{
_moveFinishedListener = f;
}
private function animRun():void{
_frm = (FRM_STOP_1 + _angleOffset);
_animState = ANIM_STATUS_RUN;
}
public function deSelectChar():void{
_isSelected = false;
_glowFilter.blurX = 8;
_glowFilter.blurY = 8;
_bitmap.filters = [];
_bitmap.transform.colorTransform = new ColorTransform();
}
private function onArrivedAtPos():void{
var charsAtPos:Array;
var tId:int;
var p:Point;
var angle:Number;
var off:int;
var victim:Character;
if (_movePath.length > 0){
tId = _movePath[0];
_movePath.shift();
if (tId > (Positions.MAX_POS_ID + 1)){
if (!isInGoal){
Main.getInstance().soundManager.getByClass(Main.getInstance().SndYippie, "snd_yippie").play(0.35);
Players.getPlayer(ownerId).playerPanel.setAvatarMood(AvatarMood.MOOD_HAPPY);
};
isInGoal = true;
};
p = Positions.getPathPos(tId);
angle = MathExtra.getAngleBetweenPoints(new Point(x, y), p);
if ((((angle > 0)) && ((angle < 90)))){
setAngle(FRM_OFFSET_R);
} else {
if ((((angle > 90)) && ((angle < 180)))){
setAngle(FRM_OFFSET_D);
} else {
if ((((angle > -90)) && ((angle < 0)))){
setAngle(FRM_OFFSET_U);
} else {
setAngle(FRM_OFFSET_L);
};
};
};
charsAtPos = CharacterManager.getCharactersByPositionId(tId);
off = 0;
if (charsAtPos.length > 0){
if (_movePath.length > 0){
off = 12;
} else {
victim = charsAtPos[0];
victim.fall();
Players.getPlayer(victim.ownerId).knockedDown++;
Players.getPlayer(ownerId).knuffs++;
animKnuff();
};
};
_currentPosId = tId;
setTimeout(onArrivedAtPos, 350);
TweenLite.to(this, 0.35, {x:(p.x + (off * 0.3333)), y:(p.y - off), ease:Linear.easeNone});
} else {
if (_moveFinishedListener != null){
_moveFinishedListener(this);
};
Main.getInstance().soundManager.getByClass(Main.getInstance().SndWalkLoop, "snd_walk_loop").stop();
animStop();
_movePath = null;
};
//unresolved jump
var _slot1 = e;
Debug.print(((("Error in " + onArrivedAtPos) + ": ") + _slot1), "ff2020");
}
public function setSelectable(b:Boolean):void{
if (b){
addChild(hitArea);
} else {
if (hitArea.parent){
hitArea.parent.removeChild(hitArea);
};
_bitmap.filters = [];
_bitmap.transform.colorTransform = new ColorTransform();
_isSelected = false;
};
}
public function getSelectable():Boolean{
return (!((hitArea.parent == null)));
}
private function moveToPool():void{
var isOccupied:Boolean;
var j:int;
var char:Character;
var p:Point;
var pool:Array = Positions.getPoolPosForPlayer(ownerId);
var a:Array = CharacterManager.getCharactersByOwner(ownerId);
var i:int;
while (i < pool.length) {
isOccupied = false;
j = 0;
while (j < a.length) {
char = a[j];
p = new Point(char.x, char.y);
if (Point.distance(p, Point(pool[i])) < 3){
isOccupied = true;
};
j++;
};
if (!isOccupied){
break;
};
i++;
};
var pos:Point = pool[i];
x = pos.x;
y = pos.y;
setAngle(initAngle);
_frm = (FRM_STOP_2 + _angleOffset);
forceFrameUpdate();
}
private function postKnuffCorrection():void{
_bitmap.x = (_bitmap.x + 60);
_bitmap.y = (_bitmap.y + 14);
setAngle(_angleOffset);
}
private function selectChar(e:MouseEvent):void{
_glowFilter.blurX = 8;
_glowFilter.blurY = 8;
_bitmap.filters = [_glowFilter];
_bitmap.transform.colorTransform = new ColorTransform(1.45, 1.45, 1.45);
_isSelected = true;
Input.setSelectedChar(this);
Main.getInstance().soundManager.getByClass(Main.getInstance().SndMark, "snd_mark").play(0.35);
}
private function moveFromTo(fromId:int, toId:int):void{
var dist:int;
var i:int;
if (isInGoal){
_movePath = [];
dist = (toId - fromId);
i = 0;
while (i < dist) {
_movePath.push(((fromId + i) + 1));
i++;
};
} else {
_movePath = Positions.createPath(fromId, toId, ownerId);
};
animStartRun();
onArrivedAtPos();
}
private function animStartRun():void{
_frm = (FRM_START_1 + _angleOffset);
_animState = ANIM_STATUS_START_RUN;
}
private function fall():void{
_bitmap.x = (_bitmap.x + -60);
_bitmap.y = (_bitmap.y + -14);
_frm = (FRM_FALL_1 + _angleOffset);
_animState = ANIM_STATUS_FALL;
isInPlay = false;
_currentPosId = -1;
Main.getInstance().soundManager.getByClass(Main.getInstance().SndFall, "snd_fall").play(0.35);
}
private function fadeDownThenUp(delay:Number):void{
TweenLite.to(this, 0.5, {alpha:0, scaleX:0.8, scaleY:0.8, overwrite:0, delay:delay});
TweenLite.to(this, 0.5, {alpha:1, scaleX:1, scaleY:1, delay:(0.5 + delay), overwrite:0});
}
}
}//package com.king.ludo.characters
Section 2
//CharacterManager (com.king.ludo.characters.CharacterManager)
package com.king.ludo.characters {
import flash.display.*;
import com.king.ludo.utils.*;
import flash.utils.*;
public class CharacterManager {
public static const GREEN:int = 1;
public static const BLUE:int = 0;
public static const RED:int = 3;
public static const YELLOW:int = 2;
private static var _bitmapsG:Array = [];
private static var _bitmapsR:Array = [];
private static var _characters:Array = [];
private static var _callBack:Function;
private static var _bitmapsY:Array = [];
private static var _movieClip:MovieClip;
private static var _frm:int;
private static var _time:int;
private static var _bitmapsB:Array = [];
public function CharacterManager(){
super();
}
public static function getGfxForCharacter(color:int):Array{
if (color == BLUE){
return (_bitmapsB);
};
if (color == GREEN){
return (_bitmapsG);
};
if (color == RED){
return (_bitmapsR);
};
if (color == YELLOW){
return (_bitmapsY);
};
return (null);
}
public static function removeCharacter(char:Character):void{
var i:int;
while (i < _characters.length) {
if (char == _characters[i]){
_characters.splice(i, 1);
return;
};
i++;
};
}
public static function getCharactersInPoolByOwner(ownId:int):Array{
var char:Character;
var collection:Array = [];
var i:int;
while (i < _characters.length) {
char = _characters[i];
if ((((char.ownerId == ownId)) && (!(char.isInPlay)))){
collection.push(char);
};
i++;
};
return (collection);
}
public static function addCharacter(char:Character):void{
_characters.push(char);
}
public static function getCharactersByPositionId(posId:int):Array{
var char:Character;
var collection:Array = [];
var i:int;
while (i < _characters.length) {
char = _characters[i];
if (char.getCurrentPosId() == posId){
collection.push(char);
};
i++;
};
return (collection);
}
public static function getCharactersByOwner(ownId:int):Array{
var char:Character;
var collection:Array = [];
var i:int;
while (i < _characters.length) {
char = _characters[i];
if (char.ownerId == ownId){
collection.push(char);
};
i++;
};
return (collection);
}
public static function getCharacters():Array{
return (_characters);
}
public static function getCharacterById(id:int):Character{
var char:Character;
var i:int;
while (i < _characters.length) {
char = _characters[i];
if (char.id == id){
return (char);
};
i++;
};
Debug.print(("CharacterManager.getCharacterById() char not found, id: " + id), "ff3333");
return (null);
}
public static function getCharactersInPlayByOwner(ownId:int):Array{
var char:Character;
var collection:Array = [];
var i:int;
while (i < _characters.length) {
char = _characters[i];
if ((((char.ownerId == ownId)) && (char.isInPlay))){
collection.push(char);
};
i++;
};
return (collection);
}
private static function drawBitmap():void{
var bmd:BitmapData;
if ((((_movieClip.width > 0)) && ((_movieClip.height > 0)))){
bmd = new BitmapData(_movieClip.width, _movieClip.height, true, 0x555555);
bmd.draw(_movieClip);
if (_frm <= 160){
_bitmapsB.push(bmd);
} else {
if (_frm <= 320){
_bitmapsG.push(bmd);
} else {
if (_frm <= 480){
_bitmapsR.push(bmd);
} else {
_bitmapsY.push(bmd);
};
};
};
};
if (_frm < _movieClip.totalFrames){
_frm++;
_movieClip.gotoAndStop(_frm);
if ((_frm % 30) == 0){
setTimeout(drawBitmap, 65);
} else {
setTimeout(drawBitmap, 0);
};
} else {
Debug.print(((("CharacterManager.generateBitmaps() finished time: " + (getTimer() - _time)) + "ms totalFrames: ") + _movieClip.totalFrames));
_movieClip = null;
if (_callBack != null){
_callBack();
};
};
}
public static function generateBitmaps(movieClip:MovieClip, callback:Function):void{
_movieClip = movieClip;
_frm = 1;
_time = getTimer();
_callBack = callback;
_bitmapsB.push(null);
_bitmapsG.push(null);
_bitmapsR.push(null);
_bitmapsY.push(null);
drawBitmap();
}
}
}//package com.king.ludo.characters
Section 3
//Client (com.king.ludo.comm.Client)
package com.king.ludo.comm {
public class Client {
public var isPlayer:Boolean;
public var avatarSlot:int;
public var avatar:String;
public var name:String;
public var id:int;
public var playerId:int;
public var isConnected:Boolean;
public function Client(id:Number, name:String, avatar:String){
super();
this.id = id;
this.name = name;
this.avatar = avatar;
playerId = (id + 1);
isPlayer = false;
isConnected = true;
}
}
}//package com.king.ludo.comm
Section 4
//CommCallback (com.king.ludo.comm.CommCallback)
package com.king.ludo.comm {
public interface CommCallback {
function clientAccepted(:Client):void;
function startGame():void;
function clientDisconnected(_arg1:Number, _arg2:Number):void;
function localDisconnect():void;
function connecting():void;
function gameCommand(:String):void;
function log(:String):void;
function unableToConnect():void;
function clientConnected(:Client):void;
}
}//package com.king.ludo.comm
Section 5
//Communicator (com.king.ludo.comm.Communicator)
package com.king.ludo.comm {
import flash.events.*;
import com.king.ludo.utils.*;
import flash.system.*;
import flash.utils.*;
import flash.net.*;
public class Communicator {
private var pauseQueue:Array;
protected var callback:CommCallback;
public var numPlayers:int;// = 0
private var delayQueue:Array;
private var lastPingTime:Number;// = -1
private var connectionEstablished:Boolean;// = false
protected var connectString:String;
protected var pingTime:Number;// = 4
private var magic:String;
protected var socket:XMLSocket;
private var pauseDepth:int;// = 0
private var slotId:String;
private var isConnected:Boolean;// = false
private static var FAKE_LAG:int = 0;
public function Communicator(callback:CommCallback=null){
pauseQueue = new Array();
super();
delayQueue = new Array();
this.callback = callback;
}
public function handleCommand(str:String):void{
var id:Number;
var username:String;
var i:int;
var avatar:String;
var remainingPlayers:Number;
var time:Number;
if ((((str.indexOf("STM") < 0)) && ((str.indexOf("AIM") < 0)))){
Debug.print(str, "ffffdd");
};
var cmd:Array = str.split(" ");
if (cmd[0] == "SCA"){
id = new Number(cmd[1]);
username = cmd[2];
i = 3;
while (username.charAt((username.length - 1)) != "\"") {
var _temp1 = i;
i = (i + 1);
username = (username + (" " + cmd[_temp1]));
};
var _temp2 = i;
i = (i + 1);
avatar = cmd[_temp2];
while (avatar.charAt((avatar.length - 1)) != "\"") {
var _temp3 = i;
i = (i + 1);
avatar = (avatar + (" " + cmd[_temp3]));
};
var _temp4 = i;
i = (i + 1);
numPlayers = parseInt(cmd[_temp4]);
username = username.substring(1, (username.length - 1));
avatar = avatar.substring(1, (avatar.length - 1));
callback.clientAccepted(new Client(id, username, avatar));
isConnected = true;
} else {
if (cmd[0] == "SAC"){
id = new Number(cmd[1]);
username = cmd[2];
i = 3;
while (username.charAt((username.length - 1)) != "\"") {
var _temp5 = i;
i = (i + 1);
username = (username + (" " + cmd[_temp5]));
};
avatar = cmd[i];
username = username.substring(1, (username.length - 1));
avatar = avatar.substring(1, (avatar.length - 1));
callback.clientConnected(new Client(id, username, avatar));
} else {
if (cmd[0] == "SCD"){
id = new Number(cmd[1]);
remainingPlayers = new Number(cmd[2]);
callback.clientDisconnected(id, remainingPlayers);
} else {
if (cmd[0] == "SSG"){
callback.startGame();
} else {
if (cmd[0] == "STM"){
time = new Number(cmd[1]);
} else {
callback.gameCommand(str);
};
};
};
};
};
}
public function log(str:String):void{
Debug.print(("Communicator.log() " + str), "ffffdd");
}
public function connected():void{
sendData(((("CCC " + slotId) + " ") + magic));
}
public function onConnect(e:Event):void{
connectionEstablished = true;
connected();
}
public function sendData(cmd:String):void{
var o:Object;
var cmd = cmd;
if (!connectionEstablished){
return;
};
if (FAKE_LAG > 0){
o = new Object();
o.time = (getTimer() + int(((Math.random() * Math.random()) * FAKE_LAG)));
o.cmd = cmd;
delayQueue.push(o);
} else {
socket.send(cmd);
//unresolved jump
var _slot1 = e;
log(((("ERROR: " + _slot1) + ", ") + typeof(_slot1)));
localDisconnect();
};
}
public function cmdReceived(str:String):void{
if ((((pauseDepth > 0)) && ((str.indexOf("S") == 0)))){
pauseQueue.push(str);
return;
};
handleCommand(str);
}
public function unableToConnect():void{
disconnected();
callback.unableToConnect();
}
public function onClose(e:Event):void{
Debug.print("socket event onClose", "ff3333");
localDisconnect();
}
public function disconnected():void{
isConnected = false;
connectionEstablished = false;
}
public function pause():void{
pauseDepth++;
}
public function tick():void{
var now:uint;
if ((((FAKE_LAG > 0)) && ((delayQueue.length > 0)))){
for (;delayQueue[0].time < getTimer();delayQueue.splice(0, 1)) {
socket.send(delayQueue[0].cmd);
continue;
var _slot1 = e;
log(((("ERROR: " + _slot1) + ", ") + typeof(_slot1)));
localDisconnect();
};
};
if (isConnected){
now = getTimer();
while ((now - lastPingTime) > 7000) {
lastPingTime = (lastPingTime + 7000);
sendData("CTM");
};
};
}
public function catchIOError(event:IOErrorEvent):void{
log(("IOERROR: " + event));
unableToConnect();
}
public function securityError(e:Event):void{
log(("securityError: " + e));
unableToConnect();
}
public function disconnect():void{
socket.close();
isConnected = false;
connectionEstablished = false;
}
public function localDisconnect():void{
disconnected();
callback.localDisconnect();
}
public function onData(e:DataEvent):void{
cmdReceived(e.data);
}
public function connect(serverIp:String, serverPort:int, slotId:String, magic:String):void{
var serverIp = serverIp;
var serverPort = serverPort;
var slotId = slotId;
var magic = magic;
Security.loadPolicyFile((("http://" + serverIp) + "/crossdomain.xml"));
this.connectString = ((serverIp + ":") + serverPort);
this.slotId = slotId;
this.magic = magic;
socket = new XMLSocket();
callback.connecting();
socket.addEventListener(Event.CONNECT, onConnect);
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityError);
socket.addEventListener(DataEvent.DATA, onData);
socket.addEventListener(Event.CLOSE, onClose);
socket.addEventListener(IOErrorEvent.IO_ERROR, catchIOError);
log((("connecting to " + connectString) + "..."));
socket.connect(serverIp, serverPort);
//unresolved jump
var _slot1 = e;
log(("ERROR: " + _slot1));
unableToConnect();
}
public function resume():void{
var i:int;
pauseDepth--;
if (pauseDepth <= 0){
i = 0;
while (i < pauseQueue.length) {
handleCommand(pauseQueue[i]);
i++;
};
pauseQueue = new Array();
};
}
}
}//package com.king.ludo.comm
Section 6
//GameData (com.king.ludo.comm.GameData)
package com.king.ludo.comm {
public class GameData {
public var port:int;
public var gameType:String;
public var magic:String;
public var textMappings:Object;
public var hostName:String;
public var randomSeed:int;
public var slotId:String;
public function GameData(){
super();
}
}
}//package com.king.ludo.comm
Section 7
//GameDataParser (com.king.ludo.comm.GameDataParser)
package com.king.ludo.comm {
import com.king.ludo.utils.*;
import flash.xml.*;
public class GameDataParser {
public static var textMappings:Object;
public function GameDataParser(){
super();
}
public static function parseGameData(gameData:String):GameData{
var result:GameData = new GameData();
var gameDataXml:XMLDocument = new XMLDocument(gameData);
textMappings = new Object();
result.textMappings = textMappings;
var cn:Array = gameDataXml.firstChild.childNodes;
var randomSeed:int = parseInt(gameDataXml.firstChild.attributes.randomseed);
result.randomSeed = randomSeed;
var i:int;
while (i < cn.length) {
if (cn[i].nodeName == "id"){
};
if (cn[i].nodeName == "game"){
result.gameType = new String(cn[i].attributes.type);
Debug.print(("gameType " + result.gameType), "ffffaa");
};
if (cn[i].nodeName == "multiplayer"){
result.hostName = cn[i].attributes.hostname.toString();
result.port = parseInt(cn[i].attributes.port);
result.slotId = cn[i].attributes.slotid.toString();
result.magic = cn[i].attributes.magic.toString();
Debug.print(((("host:\t\t " + result.hostName) + ":") + result.port), "ffffaa");
Debug.print(("slotId:\t " + result.slotId), "ffffaa");
Debug.print(("magic:\t\t " + result.magic), "ffffaa");
};
if (cn[i].nodeName == "text"){
if ((((cn[i].firstChild == null)) || ((cn[i].firstChild == undefined)))){
textMappings[cn[i].attributes.id] = (("[xx" + cn[i].attributes.id) + "xx]");
} else {
textMappings[cn[i].attributes.id] = new String(cn[i].firstChild.nodeValue);
};
TextMappings.set(cn[i].attributes.id, textMappings[cn[i].attributes.id]);
};
i++;
};
return (result);
}
}
}//package com.king.ludo.comm
Section 8
//TextMappings (com.king.ludo.comm.TextMappings)
package com.king.ludo.comm {
public class TextMappings {
public static var mappings:Object = new Object();
public function TextMappings(){
super();
}
public static function set(str:String, val:String):void{
mappings[str] = val;
}
public static function get(str:String):String{
if (mappings[str] == null){
return ((("[" + str) + "]"));
};
return (mappings[str]);
}
}
}//package com.king.ludo.comm
Section 9
//BitmapDispenser (com.king.ludo.data.BitmapDispenser)
package com.king.ludo.data {
import flash.display.*;
import com.king.ludo.utils.*;
import flash.utils.*;
public class BitmapDispenser {
private static var _movieClip:MovieClip;
private static var _callBack:Function;
private static var _bitmaps:Dictionary;
private static var _frm:int;
private static var _time:int;
private static var _this:BitmapDispenser;
public function BitmapDispenser(){
super();
}
public static function generateBitmaps(movieClip:MovieClip, callback:Function):void{
_this = new (BitmapDispenser);
_bitmaps = new Dictionary();
_movieClip = movieClip;
_frm = 1;
_time = getTimer();
_callBack = callback;
drawBitmap();
}
private static function drawBitmap():void{
var bmd:BitmapData = new BitmapData(_movieClip.width, _movieClip.height, true, 0x555555);
bmd.draw(_movieClip);
_bitmaps[_movieClip.currentLabel] = bmd;
if (_frm < _movieClip.totalFrames){
_frm++;
_movieClip.gotoAndStop(_frm);
setTimeout(drawBitmap, 1);
} else {
Debug.print(((("BitmapDispenser.generateBitmaps() finished time: " + (getTimer() - _time)) + "ms totalFrames: ") + _movieClip.totalFrames));
_movieClip = null;
if (_callBack != null){
_callBack();
};
};
}
public static function getBitmapData(id:String):BitmapData{
if (_bitmaps == null){
return (null);
};
return (((_bitmaps[id])!=null) ? _bitmaps[id] : _bitmaps["err_not_found"]);
}
}
}//package com.king.ludo.data
Section 10
//Positions (com.king.ludo.data.Positions)
package com.king.ludo.data {
import com.king.ludo.*;
import flash.geom.*;
import com.king.ludo.utils.*;
public class Positions {
public static const MAX_POS_ID:int = 39;
private static var dicePositions:Array;
private static var positions:Array;
private static var endPositions:Array;
private static var startPositions:Array;
private static var pos:Boolean = generatePositions();
public function Positions(){
super();
}
public static function getPoolPosForPlayer(playerId:int):Array{
return (startPositions[playerId]);
}
public static function createPath(fromId:int, toId:int, playerId:int):Array{
var i:int;
var j:int;
var movePath:Array = [];
var step:int = fromId;
var stepsLeft:int = Game.latestDiceValue;
var endpos:int = getEndPosForPlayer(playerId);
Debug.print(("stepsLeft start : " + stepsLeft));
var isAlreadyAtEndPos = (step == endpos);
if (toId < 50){
toId = (toId % (MAX_POS_ID + 1));
};
i = 0;
while (i < 99) {
step++;
stepsLeft--;
step = (step % (MAX_POS_ID + 1));
if (!isAlreadyAtEndPos){
movePath.push(step);
} else {
stepsLeft++;
};
if ((((step == endpos)) || (isAlreadyAtEndPos))){
Debug.print(("stepsLeft end : " + stepsLeft));
j = 0;
while (j < stepsLeft) {
movePath.push(getGoalPosForPlayer(playerId)[j]);
if (j == 3){
break;
};
j++;
};
break;
};
if (step == toId){
break;
};
i++;
};
return (movePath);
}
private static function setupFixedPositions():void{
positions = [];
positions[0] = new Point(529, 381);
positions[1] = new Point(496, 397);
positions[2] = new Point(465, 383);
positions[3] = new Point(434, 364);
positions[4] = new Point(406, 349);
positions[5] = new Point(374, 332);
positions[6] = new Point(349, 349);
positions[7] = new Point(317, 367);
positions[8] = new Point(286, 383);
positions[9] = new Point(261, 398);
positions[10] = new Point(226, 383);
positions[11] = new Point(194, 364);
positions[12] = new Point(219, 344);
positions[13] = new Point(253, 327);
positions[14] = new Point(280, 313);
positions[15] = new Point(309, 296);
positions[16] = new Point(286, 277);
positions[17] = new Point(253, 258);
positions[18] = new Point(224, 242);
positions[19] = new Point(194, 224);
positions[20] = new Point(222, 206);
positions[21] = new Point(0xFF, 189);
positions[22] = new Point(289, 205);
positions[23] = new Point(323, 220);
positions[24] = new Point(347, 240);
positions[25] = new Point(373, 254);
positions[26] = new Point(403, 240);
positions[27] = new Point(434, 220);
positions[28] = new Point(468, 206);
positions[29] = new Point(493, 188);
positions[30] = new Point(526, 204);
positions[31] = new Point(555, 224);
positions[32] = new Point(531, 242);
positions[33] = new Point(502, 259);
positions[34] = new Point(469, 273);
positions[35] = new Point(446, 297);
positions[36] = new Point(469, 307);
positions[37] = new Point(500, 328);
positions[38] = new Point(529, 342);
positions[39] = new Point(560, 364);
var pl1:Array = [];
pl1[0] = new Point(398, 412);
pl1[1] = new Point(355, 412);
pl1[2] = new Point(352, 440);
pl1[3] = new Point(401, 441);
var pl2:Array = [];
pl2[0] = new Point(132, 258);
pl2[1] = new Point(122, 283);
pl2[2] = new Point(75, 276);
pl2[3] = new Point(94, 249);
var pl3:Array = [];
pl3[0] = new Point(414, 112);
pl3[1] = new Point(374, 134);
pl3[2] = new Point(340, 113);
pl3[3] = new Point(374, 90);
var pl4:Array = [];
pl4[0] = new Point(610, 261);
pl4[1] = new Point(658, 249);
pl4[2] = new Point(676, 275);
pl4[3] = new Point(630, 289);
startPositions = [pl1, pl2, pl3, pl4];
positions[50] = new Point(496, 364);
positions[51] = new Point(466, 345);
positions[52] = new Point(438, 328);
positions[53] = new Point(406, 309);
positions[54] = new Point(0xFF, 364);
positions[55] = new Point(284, 346);
positions[56] = new Point(315, 329);
positions[57] = new Point(344, 312);
positions[58] = new Point(0xFF, 223);
positions[59] = new Point(283, 239);
positions[60] = new Point(314, 0x0101);
positions[61] = new Point(345, 274);
positions[62] = new Point(497, 224);
positions[63] = new Point(469, 240);
positions[64] = new Point(437, 259);
positions[65] = new Point(407, 276);
var pl1e:Array = [];
pl1e[0] = 50;
pl1e[1] = 51;
pl1e[2] = 52;
pl1e[3] = 53;
var pl2e:Array = [];
pl2e[0] = 54;
pl2e[1] = 55;
pl2e[2] = 56;
pl2e[3] = 57;
var pl3e:Array = [];
pl3e[0] = 58;
pl3e[1] = 59;
pl3e[2] = 60;
pl3e[3] = 61;
var pl4e:Array = [];
pl4e[0] = 62;
pl4e[1] = 63;
pl4e[2] = 64;
pl4e[3] = 65;
endPositions = [pl1e, pl2e, pl3e, pl4e];
dicePositions = [];
dicePositions[0] = new Point(298, 417);
dicePositions[1] = new Point(195, 297);
dicePositions[2] = new Point(457, 170);
dicePositions[3] = new Point(527, 294);
}
public static function getPathLength():int{
return (positions.length);
}
public static function getStartPosForPlayer(playerId:int):int{
if (playerId == 0){
return (1);
};
if (playerId == 1){
return (11);
};
if (playerId == 2){
return (21);
};
return (31);
}
public static function getEndPosForPlayer(playerId:int):int{
return ((getStartPosForPlayer(playerId) - 1));
}
private static function generatePositions():Boolean{
setupFixedPositions();
return (true);
}
public static function getPathPos(id:int):Point{
return (positions[id]);
}
public static function getDicePosForPlayer(playerId:int):Point{
return (dicePositions[playerId]);
}
public static function cloneArray(a:Array):Array{
var clone:Array = [];
var i:int;
while (i < a.length) {
clone[i] = a[i];
i++;
};
return (clone);
}
public static function getGoalPosForPlayer(playerId:int):Array{
return (endPositions[playerId]);
}
}
}//package com.king.ludo.data
Section 11
//Dice (com.king.ludo.dice.Dice)
package com.king.ludo.dice {
import com.king.ludo.*;
import flash.events.*;
import flash.display.*;
import mx.events.*;
import com.king.ludo.utils.*;
import flash.utils.*;
public class Dice extends MovieClip {
private var vertices:Array;
private var _enabled:Boolean;// = false
private var _79879582Side5:Class;
private var _79879578Side1:Class;
private var _79879579Side2:Class;
public var shadow:Sprite;
private var _1819712192Shadow:Class;
private var _79879583Side6:Class;
private var texCoords:Array;
private var faces:Array;
public var diceHolder:MovieClip;
private var _79879580Side3:Class;
private var startTime:Number;// = -1000000
private var _79879581Side4:Class;
private var oRotX:Number;// = 0
private var oRotY:Number;// = 0
private var oRotZ:Number;// = 0
private var tRotX:Number;// = 0
private var tRotY:Number;
private var tRotZ:Number;// = 0
public function Dice(){
var tokens:Array;
var x:Number;
var y:Number;
var z:Number;
var u:Number;
var v:Number;
var face:Face;
var j:int;
var tokens2:Array;
var vertexIndex:int;
var texCoordIndex:int;
_79879578Side1 = Dice_Side1;
_79879579Side2 = Dice_Side2;
_79879580Side3 = Dice_Side3;
_79879581Side4 = Dice_Side4;
_79879582Side5 = Dice_Side5;
_79879583Side6 = Dice_Side6;
_1819712192Shadow = Dice_Shadow;
vertices = new Array();
faces = new Array();
texCoords = new Array();
tRotY = ((Math.random() * Math.PI) * 2);
super();
shadow = (new Shadow() as Sprite);
addChild(shadow);
diceHolder = new MovieClip();
addChild(diceHolder);
var currentSide = 1;
var lines:Array = TriangleObj.DATA.toString().split("\r\n");
var i:int;
while (i < lines.length) {
tokens = lines[i].split(" ");
if (tokens[0] == "v"){
x = parseFloat(tokens[1]);
y = parseFloat(tokens[2]);
z = parseFloat(tokens[3]);
vertices.push(new Vertex(x, y, z));
} else {
if (tokens[0] == "vt"){
u = parseFloat(tokens[1]);
v = parseFloat(tokens[2]);
texCoords.push(new Vertex(u, v, 0));
} else {
if (tokens[0] == "side"){
currentSide = parseInt(tokens[1]);
} else {
if (tokens[0] == "f"){
face = new Face(this, currentSide);
j = 1;
while (j < tokens.length) {
tokens2 = tokens[j].split("/");
vertexIndex = (parseInt(tokens2[0]) - 1);
texCoordIndex = (parseInt(tokens2[1]) - 1);
face.addVertex(vertices[vertexIndex], texCoords[texCoordIndex]);
j++;
};
faces.push(face);
};
};
};
};
i++;
};
normalizeVertices();
buttonMode = true;
useHandCursor = true;
mouseEnabled = true;
addEventListener(MouseEvent.CLICK, sendRoll, false, 0, true);
setEnabled(false);
x = -100;
}
public function set Shadow(value:Class):void{
var oldValue:Object = this._1819712192Shadow;
if (oldValue !== value){
this._1819712192Shadow = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "Shadow", oldValue, value));
};
}
public function get Side1():Class{
return (this._79879578Side1);
}
public function get Side2():Class{
return (this._79879579Side2);
}
public function get Side3():Class{
return (this._79879580Side3);
}
public function get Side6():Class{
return (this._79879583Side6);
}
public function tick():void{
diceHolder.graphics.clear();
diceHolder.graphics.lineStyle(0, 0xFF00FF, 1);
var yRot:Number = ((35.264 / 180) * Math.PI);
var tt:Number = ((getTimer() - startTime) / 500);
if (tt > 1){
tt = 1;
};
var tt2:Number = (tt * 1.6);
var h:Number = (Math.sin((((Math.sqrt(tt2) * 0.15) + (tt2 * 0.85)) * Math.PI)) * 100);
if (tt2 > 1){
tt2--;
tt2 = (tt2 / 0.6);
h = (Math.sin((((Math.sqrt(tt2) * 0.15) + (tt2 * 0.85)) * Math.PI)) * 20);
};
var i:int;
while (i < vertices.length) {
vertices[i].reset();
vertices[i].rotX((oRotX + ((tRotX - oRotX) * tt)));
vertices[i].rotZ((oRotZ + ((tRotZ - oRotZ) * tt)));
vertices[i].rotY((oRotY + ((tRotY - oRotY) * tt)));
vertices[i].rotX(yRot);
vertices[i].xp = (vertices[i].x * 16);
vertices[i].yp = (((vertices[i].y * 16) - 16) - h);
vertices[i].zp = (vertices[i].z * 16);
i++;
};
if (shadow != null){
shadow.alpha = (0.5 - (h / 400));
shadow.scaleX = (shadow.scaleY = (0.9 - (h / 200)));
};
i = 0;
while (i < faces.length) {
faces[i].render(diceHolder.graphics);
i++;
};
}
public function sendRoll(e:MouseEvent):void{
if (!_enabled){
return;
};
var result:int = advanceRandom();
Comm.getInstance().sendDice(Players.getSelf().id, result);
LudoEvents.onUserDice(Players.getSelf().id, result);
}
public function normalizeVertices():void{
var x:Number;
var y:Number;
var z:Number;
var x0:Number = vertices[0].x;
var x1:Number = vertices[0].x;
var y0:Number = vertices[0].y;
var y1:Number = vertices[0].y;
var z0:Number = vertices[0].z;
var z1:Number = vertices[0].z;
var i = 1;
while (i < vertices.length) {
if (vertices[i].x < x0){
x0 = vertices[i].x;
};
if (vertices[i].x > x1){
x1 = vertices[i].x;
};
if (vertices[i].y < y0){
y0 = vertices[i].y;
};
if (vertices[i].y > y1){
y1 = vertices[i].y;
};
if (vertices[i].z < z0){
z0 = vertices[i].z;
};
if (vertices[i].z > z1){
z1 = vertices[i].z;
};
i++;
};
i = 0;
while (i < vertices.length) {
x = ((vertices[i].x - x0) / (x1 - x0));
y = ((vertices[i].y - y0) / (y1 - y0));
z = ((vertices[i].z - z0) / (z1 - z0));
vertices[i].setPos(((x * 2) - 1), ((y * 2) - 1), ((z * 2) - 1));
i++;
};
}
public function get Side5():Class{
return (this._79879582Side5);
}
public function set Side1(value:Class):void{
var oldValue:Object = this._79879578Side1;
if (oldValue !== value){
this._79879578Side1 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "Side1", oldValue, value));
};
}
public function get Side4():Class{
return (this._79879581Side4);
}
public function set Side3(value:Class):void{
var oldValue:Object = this._79879580Side3;
if (oldValue !== value){
this._79879580Side3 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "Side3", oldValue, value));
};
}
public function set Side5(value:Class):void{
var oldValue:Object = this._79879582Side5;
if (oldValue !== value){
this._79879582Side5 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "Side5", oldValue, value));
};
}
public function set Side2(value:Class):void{
var oldValue:Object = this._79879579Side2;
if (oldValue !== value){
this._79879579Side2 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "Side2", oldValue, value));
};
}
public function set Side6(value:Class):void{
var oldValue:Object = this._79879583Side6;
if (oldValue !== value){
this._79879583Side6 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "Side6", oldValue, value));
};
}
public function set Side4(value:Class):void{
var oldValue:Object = this._79879581Side4;
if (oldValue !== value){
this._79879581Side4 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "Side4", oldValue, value));
};
}
public function get Shadow():Class{
return (this._1819712192Shadow);
}
public function advanceRandom():int{
return ((Main.random.nextInt(6) + 1));
}
public function advanceTime(e:Event):void{
tick();
}
public function roll(face:int):void{
var i:Number;
startTime = getTimer();
oRotX = tRotX;
oRotY = tRotY;
oRotZ = tRotZ;
tRotX = 0;
tRotY = ((Math.random() * Math.PI) * 2);
tRotZ = 0;
if (face == 2){
tRotZ = (-(Math.PI) / 2);
};
if (face == 3){
tRotX = (-(Math.PI) / 2);
};
if (face == 4){
tRotX = (Math.PI / 2);
};
if (face == 5){
tRotZ = (Math.PI / 2);
};
if (face == 6){
tRotX = Math.PI;
};
while ((oRotX - tRotX) < -(Math.PI)) {
oRotX = (oRotX + (Math.PI * 2));
};
while ((oRotY - tRotY) < -(Math.PI)) {
oRotY = (oRotY + (Math.PI * 2));
};
while ((oRotZ - tRotZ) < -(Math.PI)) {
oRotZ = (oRotZ + (Math.PI * 2));
};
while ((oRotX - tRotX) >= Math.PI) {
oRotX = (oRotX - (Math.PI * 2));
};
while ((oRotY - tRotY) >= Math.PI) {
oRotY = (oRotY - (Math.PI * 2));
};
while ((oRotZ - tRotZ) >= Math.PI) {
oRotZ = (oRotZ - (Math.PI * 2));
};
if ((((oRotX == tRotX)) && ((oRotZ == tRotZ)))){
i = int((Math.random() * 4));
if (i == 0){
oRotX = (oRotX - (Math.PI * 2));
} else {
if (i == 1){
oRotX = (oRotX + (Math.PI * 2));
} else {
if (i == 2){
oRotZ = (oRotZ - (Math.PI * 2));
} else {
oRotZ = (oRotZ + (Math.PI * 2));
};
};
};
};
}
public function setEnabled(b:Boolean):void{
Debug.print((("Dice.enabled(" + b) + ") "));
buttonMode = b;
_enabled = b;
}
}
}//package com.king.ludo.dice
Section 12
//Dice_Shadow (com.king.ludo.dice.Dice_Shadow)
package com.king.ludo.dice {
import flash.display.*;
import mx.core.*;
public class Dice_Shadow extends SpriteAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo.dice
Section 13
//Dice_Side1 (com.king.ludo.dice.Dice_Side1)
package com.king.ludo.dice {
import flash.display.*;
import mx.core.*;
public class Dice_Side1 extends BitmapAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo.dice
Section 14
//Dice_Side2 (com.king.ludo.dice.Dice_Side2)
package com.king.ludo.dice {
import flash.display.*;
import mx.core.*;
public class Dice_Side2 extends BitmapAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo.dice
Section 15
//Dice_Side3 (com.king.ludo.dice.Dice_Side3)
package com.king.ludo.dice {
import flash.display.*;
import mx.core.*;
public class Dice_Side3 extends BitmapAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo.dice
Section 16
//Dice_Side4 (com.king.ludo.dice.Dice_Side4)
package com.king.ludo.dice {
import flash.display.*;
import mx.core.*;
public class Dice_Side4 extends BitmapAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo.dice
Section 17
//Dice_Side5 (com.king.ludo.dice.Dice_Side5)
package com.king.ludo.dice {
import flash.display.*;
import mx.core.*;
public class Dice_Side5 extends BitmapAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo.dice
Section 18
//Dice_Side6 (com.king.ludo.dice.Dice_Side6)
package com.king.ludo.dice {
import flash.display.*;
import mx.core.*;
public class Dice_Side6 extends BitmapAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo.dice
Section 19
//Face (com.king.ludo.dice.Face)
package com.king.ludo.dice {
import flash.display.*;
import flash.geom.*;
public class Face {
public var t:Array;
public var v:Array;
private var texMat:Matrix;
private var bitmap:BitmapData;
public function Face(dice:Dice, side:int){
super();
v = new Array();
t = new Array();
if (side == 1){
bitmap = (new dice.Side1() as Bitmap).bitmapData;
};
if (side == 2){
bitmap = (new dice.Side2() as Bitmap).bitmapData;
};
if (side == 3){
bitmap = (new dice.Side3() as Bitmap).bitmapData;
};
if (side == 4){
bitmap = (new dice.Side4() as Bitmap).bitmapData;
};
if (side == 5){
bitmap = (new dice.Side5() as Bitmap).bitmapData;
};
if (side == 6){
bitmap = (new dice.Side6() as Bitmap).bitmapData;
};
}
public function addVertex(vertex:Vertex, texCoord:Vertex):void{
v.push(vertex);
t.push(texCoord);
}
public function render(g:Graphics):void{
var matrix:Matrix;
var xa1:Number;
var ya1:Number;
var za1:Number;
var xa2:Number;
var ya2:Number;
var za2:Number;
var xn:Number;
var yn:Number;
var zn:Number;
var nd:Number;
var d:Number;
var i:int;
var xt:Number;
var yt:Number;
var xt2:Number;
var yt2:Number;
var xl:Number = 0;
var yl:Number = 0.7;
var zl:Number = 1;
var ld:Number = Math.sqrt((((xl * xl) + (yl * yl)) + (zl * zl)));
xl = (xl / ld);
yl = (yl / ld);
zl = (zl / ld);
var i0:int;
var i1 = 1;
var i2 = 2;
if (v.length >= 6){
i1 = (i1 * 2);
i2 = (i2 * 2);
};
var d0:int = (((((v[i1].yp - v[i0].yp) / (v[i1].xp - v[i0].xp)) - ((v[i2].yp - v[i0].yp) / (v[i2].xp - v[i0].xp))))<0) ? 1 : 0;
var d1:int = (((v[i0].xp <= v[i1].xp))==(v[i0].xp > v[i2].xp)) ? 1 : 0;
if ((d0 ^ d1) != 1){
if (texMat == null){
texMat = new Matrix();
xt = (t[i1].xp - t[i0].xp);
yt = (t[i1].yp - t[i0].yp);
xt2 = (t[i2].xp - t[i0].xp);
yt2 = (t[i2].yp - t[i0].yp);
texMat = new Matrix(xt, yt, xt2, yt2, t[i0].xp, t[i0].yp);
texMat.scale(64, 64);
texMat.invert();
};
matrix = texMat.clone();
xa1 = (v[i1].xp - v[i0].xp);
ya1 = (v[i1].yp - v[i0].yp);
za1 = (v[i1].zp - v[i0].zp);
xa2 = (v[i2].xp - v[i0].xp);
ya2 = (v[i2].yp - v[i0].yp);
za2 = (v[i2].zp - v[i0].zp);
matrix.concat(new Matrix(xa1, ya1, xa2, ya2, v[i0].xp, v[i0].yp));
xn = ((ya1 * za2) - (za1 * ya2));
yn = ((za1 * xa2) - (xa1 * za2));
zn = ((xa1 * ya2) - (ya1 * xa2));
nd = Math.sqrt((((xn * xn) + (yn * yn)) + (zn * zn)));
xn = (xn / nd);
yn = (yn / nd);
zn = (zn / nd);
d = (((1 - (xn * xl)) + (yn * yl)) + (zn * zl));
if (d < 0){
d = 0;
};
if (d > 1){
d = 1;
};
d = (d * 0.5);
g.lineStyle();
if (bitmap != null){
g.beginBitmapFill(bitmap, matrix, true, true);
} else {
g.beginFill(0xFF8000, 1);
};
g.moveTo(v[i0].xp, v[i0].yp);
i = 1;
while (i < v.length) {
g.lineTo(v[i].xp, v[i].yp);
i++;
};
g.endFill();
g.beginFill(0, d);
g.moveTo(v[i0].xp, v[i0].yp);
i = 1;
while (i < v.length) {
g.lineTo(v[i].xp, v[i].yp);
i++;
};
g.endFill();
};
}
}
}//package com.king.ludo.dice
Section 20
//TriangleObj (com.king.ludo.dice.TriangleObj)
package com.king.ludo.dice {
public class TriangleObj {
public static var DATA:XML = <data>
v 8.744486 14.626059 4.958852
v 8.744486 18.602651 8.935445
v 4.767894 14.626059 8.935445
v 4.591406 14.626059 -9.344843
v 8.744486 18.779140 -9.344843
v 8.744486 14.626059 -5.191762
v -5.559207 14.626059 8.935445
v -9.535802 18.602654 8.935445
v -9.535802 14.626059 4.958851
v -5.344264 32.906347 8.935445
v -9.535802 32.906347 4.743907
v -9.535802 28.714809 8.935445
v 8.744486 28.714810 8.935445
v 8.744486 32.906347 4.743908
v 4.552948 32.906347 8.935445
v -9.535802 14.626059 -5.191762
v -9.535802 18.779140 -9.344843
v -5.382723 14.626059 -9.344843
v -9.535802 32.906347 -4.976818
v -5.167776 32.906347 -9.344843
v -9.535802 28.538322 -9.344843
v 8.744486 28.538322 -9.344843
v 4.376462 32.906347 -9.344843
v 8.744486 32.906347 -4.976817
vt 1.000000 0.217535
vt 1.000000 1.000000
vt 0.782466 1.000000
vt 0.782465 0.000000
vt 0.217535 1.000000
vt 1.000000 0.782465
vt 1.000000 0.217535
vt 0.782465 1.000000
vt 1.000000 0.782465
vt 1.000000 0.229293
vt 0.770707 0.000000
vt 0.782465 0.000000
vt 0.000000 0.782465
vt 0.770707 1.000000
vt 1.000000 0.770707
vt 0.000000 0.770707
vt 0.229293 1.000000
vt 1.000000 0.227189
vt 0.238947 0.000000
vt 0.000000 0.238947
vt 0.772811 0.000000
vt 0.772811 1.000000
vt 0.000000 0.761053
vt 0.238948 1.000000
vt -0.000000 0.772811
vt 0.227189 1.000000
vt -0.000000 1.000000
vt -0.000000 0.000000
vt 0.227189 0.000000
vt -0.000000 0.227189
vt 1.000000 0.000000
vt 1.000000 0.238947
vt 1.000000 0.000000
vt 0.000000 0.229293
vt 0.000000 0.000000
vt 0.229293 0.000000
vt 1.000000 0.772811
vt 0.229293 1.000000
vt 1.000000 0.772811
vt 0.761053 0.000000
vt 0.772811 1.000000
vt 0.000000 0.238947
vt 0.761053 1.000000
vt 0.238947 0.000000
vt 0.000000 0.217535
vt 0.000000 1.000000
vt 0.217535 0.000000
vt 0.772811 0.000000
vt 0.229293 0.000000
vt -0.000000 0.229293
vt 0.000000 0.770707
vt 0.238947 1.000000
vt 1.000000 0.761053
vt -0.000000 0.761053
vt 1.000000 1.000000
vt 1.000000 0.227189
side 2
f 1/2/1 2/3/2 3/6/3
side 3
f 4/25/4 5/26/5 6/27/6
side 4
f 7/7/7 8/12/8 9/33/9
side 6
f 10/34/10 11/35/11 12/36/12
f 13/38/13 14/46/14 15/51/15
side 3
f 16/28/16 17/29/17 18/30/18
f 19/31/19 20/32/20 21/40/21
f 22/43/22 23/53/23 24/55/24
f 5/26/5 4/25/4 18/30/18 17/29/17 21/40/21 20/32/20 23/53/23 22/43/22
side 6
f 24/24/24 23/23/23 20/20/20 19/19/19 11/11/11 10/10/10 15/15/15 14/14/14
side 5
f 12/17/12 11/16/11 19/42/19 21/44/21 17/21/17 16/18/16 9/9/9 8/8/8
side 2
f 6/37/6 5/22/5 22/52/22 24/54/24 14/50/14 13/49/13 2/4/2 1/1/1
side 1
f 16/48/16 18/56/18 4/39/4 6/41/6 1/5/1 3/13/3 7/45/7 9/47/9
side 4
f 10/34/10 12/36/12 8/12/8 7/7/7 3/6/3 2/3/2 13/38/13 15/51/15
</data>
;
public function TriangleObj(){
super();
}
}
}//package com.king.ludo.dice
Section 21
//Vertex (com.king.ludo.dice.Vertex)
package com.king.ludo.dice {
public class Vertex {
public var zp:Number;
public var zo:Number;
public var yo:Number;
public var xo:Number;
public var x:Number;
public var y:Number;
public var z:Number;
public var yp:Number;
public var xp:Number;
public function Vertex(x:Number, y:Number, z:Number){
super();
xp = (this.xo = (this.x = x));
yp = (this.yo = (this.y = y));
zp = (this.zo = (this.z = z));
}
public function setPos(x:Number, y:Number, z:Number):void{
xo = (this.x = x);
yo = (this.y = y);
zo = (this.z = z);
}
public function rotX(a:Number):void{
var sin:Number = Math.sin(a);
var cos:Number = Math.cos(a);
var yy:Number = ((y * cos) - (z * sin));
var zz:Number = ((y * sin) + (z * cos));
this.y = yy;
this.z = zz;
}
public function rotY(a:Number):void{
var sin:Number = Math.sin(a);
var cos:Number = Math.cos(a);
var xx:Number = ((x * cos) - (z * sin));
var zz:Number = ((x * sin) + (z * cos));
this.x = xx;
this.z = zz;
}
public function reset():void{
x = xo;
y = yo;
z = zo;
}
public function rotZ(a:Number):void{
var sin:Number = Math.sin(a);
var cos:Number = Math.cos(a);
var xx:Number = ((x * cos) - (y * sin));
var yy:Number = ((x * sin) + (y * cos));
this.x = xx;
this.y = yy;
}
}
}//package com.king.ludo.dice
Section 22
//FlowerDispenser (com.king.ludo.fx.FlowerDispenser)
package com.king.ludo.fx {
import flash.events.*;
import flash.display.*;
import mx.events.*;
import flash.utils.*;
public class FlowerDispenser extends MovieClip {
private var lastTime:int;// = 0
private var _2051326894FlowerRainFlowerClass:Class;
private static var MS_BETWEEN_FLOWERS:int = 200;
public function FlowerDispenser(){
_2051326894FlowerRainFlowerClass = FlowerDispenser_FlowerRainFlowerClass;
super();
lastTime = getTimer();
addEventListener(Event.ENTER_FRAME, advanceTime);
advanceTime(null);
}
public function set FlowerRainFlowerClass(value:Class):void{
var oldValue:Object = this._2051326894FlowerRainFlowerClass;
if (oldValue !== value){
this._2051326894FlowerRainFlowerClass = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "FlowerRainFlowerClass", oldValue, value));
};
}
public function get FlowerRainFlowerClass():Class{
return (this._2051326894FlowerRainFlowerClass);
}
public function advanceTime(e:Event):void{
var now:int = getTimer();
while ((now - lastTime) > MS_BETWEEN_FLOWERS) {
addChild(new FlowerRainFlower((new FlowerRainFlowerClass() as MovieClip)));
lastTime = (lastTime + MS_BETWEEN_FLOWERS);
};
}
}
}//package com.king.ludo.fx
Section 23
//FlowerDispenser_FlowerRainFlowerClass (com.king.ludo.fx.FlowerDispenser_FlowerRainFlowerClass)
package com.king.ludo.fx {
import flash.display.*;
import mx.core.*;
public class FlowerDispenser_FlowerRainFlowerClass extends MovieClipAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo.fx
Section 24
//FlowerRainFlower (com.king.ludo.fx.FlowerRainFlower)
package com.king.ludo.fx {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class FlowerRainFlower extends MovieClip {
private var swayOffs:Number;// = 0
private var spinSpeed:Number;// = 0
private var xStart:int;// = 0
private var swaySpeed:Number;// = 0
private var rotateSpeed:Number;// = 0
private var spinStart:Number;// = 0
private var startTime:int;// = 0
private var fallSpeed:Number;// = 0
private var type:int;// = 0
private var sway:Number;// = 0
private var mc:MovieClip;
public function FlowerRainFlower(mc:MovieClip, timeOffs:int=0){
super();
this.mc = mc;
startTime = (getTimer() - timeOffs);
type = int((Math.random() * 4));
xStart = ((Math.random() * 854) - 50);
y = -1000;
fallSpeed = ((((Math.random() + Math.random()) - 1) * 0.6) + 1);
swaySpeed = ((((Math.random() + Math.random()) - 1) * 0.6) + 1);
rotateSpeed = ((((Math.random() + Math.random()) - 1) * 0.6) + 1);
sway = ((((Math.random() + Math.random()) - 1) * 0.2) + 1);
swayOffs = ((Math.random() * Math.PI) * 2);
spinStart = (Math.random() * 360);
spinSpeed = ((Math.random() - Math.random()) * 5);
addChild(mc);
scaleX = (scaleY = (((fallSpeed - 1) * 0.2) + 1));
addEventListener(Event.ENTER_FRAME, advanceTime);
}
public function advanceTime(e:Event):void{
var t:Number = (getTimer() - startTime);
rotation = (spinStart + ((spinSpeed * t) / 1000));
var rot:Number = ((((t * 1) / 1000) * swaySpeed) + swayOffs);
x = (xStart + ((Math.sin(rot) * 32) * sway));
y = ((((t * fallSpeed) / 20) + ((Math.cos((rot * 2)) * 16) * sway)) - 60);
if (y > (600 + 60)){
removeEventListener(Event.ENTER_FRAME, advanceTime);
parent.removeChild(this);
};
var frame:int = (((int((((t * 12) / 1000) * rotateSpeed)) % 12) + 1) + (type * 20));
mc.gotoAndStop(frame);
}
}
}//package com.king.ludo.fx
Section 25
//BasicButton (com.king.ludo.gui.BasicButton)
package com.king.ludo.gui {
import flash.events.*;
import flash.display.*;
import flash.filters.*;
public class BasicButton extends Sprite {
protected var _enabled:Boolean;
protected var _callBack:Function;
protected var _mouseIsDown:Boolean;// = false
protected var _label:StdLabel;
public function BasicButton(){
super();
mouseChildren = false;
_label = new StdLabel();
addChild(_label);
}
protected function onMouseDown(e:Event):void{
drawMain("down");
_mouseIsDown = true;
}
protected function onMouseUp(e:Event):void{
drawMain("over");
if (((!((_callBack == null))) && (_mouseIsDown))){
_callBack(this);
};
_mouseIsDown = false;
}
public function draw():void{
graphics.clear();
graphics.beginFill(0, 0.2);
graphics.drawRoundRect(0, 0, 100, 20, 10, 10);
_label.x = ((100 / 2) - (_label.width / 2));
_label.y = ((20 / 2) - (_label.height / 2));
drawMain("idle");
}
public function setActive(bool:Boolean=true, func:Function=null):void{
if (bool){
if (!hasEventListener(MouseEvent.MOUSE_UP)){
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver, false, 0, true);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp, false, 0, true);
};
if (func != null){
_callBack = func;
};
_enabled = true;
alpha = 1;
} else {
removeEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
_enabled = false;
alpha = 0.4;
};
buttonMode = bool;
}
protected function onMouseOut(e:Event):void{
drawMain("idle");
_mouseIsDown = false;
}
protected function onMouseOver(e:Event):void{
drawMain("over");
}
protected function drawMain(state:String):void{
if (state == "over"){
filters = [new GlowFilter(0, 1, 4, 4, 1)];
} else {
filters = [];
};
}
public function getLabel():StdLabel{
return (_label);
}
}
}//package com.king.ludo.gui
Section 26
//BitmapButton (com.king.ludo.gui.BitmapButton)
package com.king.ludo.gui {
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
public class BitmapButton extends BasicButton {
private var _bitmap:Bitmap;
public function BitmapButton(){
super();
}
public function setBitmap(b:BitmapData):void{
if (_bitmap == null){
_bitmap = new Bitmap(b);
addChild(_bitmap);
} else {
_bitmap.bitmapData = b;
};
}
override public function draw():void{
}
override protected function drawMain(state:String):void{
if (state == "over"){
filters = [new GlowFilter(0, 1, 4, 4, 1)];
transform.colorTransform = new ColorTransform(1.15, 1.15, 1.15);
} else {
filters = [];
transform.colorTransform = new ColorTransform();
};
}
}
}//package com.king.ludo.gui
Section 27
//ChatBubble (com.king.ludo.gui.ChatBubble)
package com.king.ludo.gui {
import flash.display.*;
import flash.text.*;
import gs.*;
import flash.utils.*;
import com.king.ludo.data.*;
import mx.effects.easing.*;
public class ChatBubble extends Sprite {
public function ChatBubble(msg:String, flip:Boolean){
super();
var b:Bitmap = new Bitmap(BitmapDispenser.getBitmapData("speech_bubble"));
var tf:StdLabel = new StdLabel(StdLabel.font1, 11, 0x333333);
tf.autoSize = TextFieldAutoSize.NONE;
tf.multiline = true;
tf.wordWrap = true;
tf.width = 160;
tf.height = 50;
tf.x = 31;
tf.y = 9;
tf.text = msg;
addChild(b);
addChild(tf);
mouseEnabled = false;
tf.mouseEnabled = false;
if (flip){
} else {
b.scaleX = -1;
tf.x = (tf.x - 214);
};
}
public function destroy():void{
if (parent){
parent.removeChild(this);
};
}
public function hide():void{
TweenLite.to(this, 1, {alpha:0.1, onComplete:destroy});
}
public function show():void{
alpha = 0.1;
scaleX = 0.4;
scaleY = 0.4;
TweenLite.to(this, 0.6, {alpha:1, scaleX:1, scaleY:1, ease:Elastic.easeOut});
setTimeout(hide, 5000);
}
}
}//package com.king.ludo.gui
Section 28
//ChatInput (com.king.ludo.gui.ChatInput)
package com.king.ludo.gui {
import com.king.ludo.*;
import flash.events.*;
import flash.display.*;
import flash.text.*;
import com.king.ludo.data.*;
import flash.filters.*;
import flash.ui.*;
public class ChatInput extends Sprite {
private var _inputField:StdLabel;
private var _chatSend:Sprite;
public function ChatInput(){
super();
graphics.lineStyle(1, 0, 0.75);
graphics.beginFill(0, 0.25);
graphics.drawRect(0, 0, 603, 20);
_inputField = new StdLabel(StdLabel.font1, 12, 0xFFFFFF);
_inputField.autoSize = TextFieldAutoSize.NONE;
_inputField.width = 600;
_inputField.height = 20;
_inputField.type = TextFieldType.INPUT;
_inputField.selectable = true;
_inputField.filters = [new GlowFilter(0, 0.75, 6, 6)];
_inputField.x = 2;
_inputField.y = 2;
addChild(_inputField);
_chatSend = new Sprite();
var bitm:Bitmap = new Bitmap(BitmapDispenser.getBitmapData("chat_send"));
_chatSend.addChild(bitm);
_chatSend.x = ((675 - 57) - 10);
_chatSend.y = -2;
_chatSend.addEventListener(MouseEvent.CLICK, send, false, 0, true);
_chatSend.buttonMode = true;
_chatSend.mouseChildren = false;
addChild(_chatSend);
Main.getInstance().stage.addEventListener(KeyboardEvent.KEY_DOWN, onKey, false, 0, true);
}
private function onKey(e:KeyboardEvent):void{
if (e.keyCode == Keyboard.ENTER){
send();
};
if (_inputField.text.length > 80){
_inputField.text = _inputField.text.substr(0, 80);
};
}
private function send(e:Event=null):void{
if (_inputField.text.length > 0){
Main.getInstance().comm.sendChatMsg(_inputField.text);
Players.getSelf().playerPanel.showChatMsg(_inputField.text);
_inputField.text = "";
};
}
}
}//package com.king.ludo.gui
Section 29
//DebugWindow (com.king.ludo.gui.DebugWindow)
package com.king.ludo.gui {
import com.king.ludo.*;
import flash.events.*;
import flash.display.*;
import flash.text.*;
import com.king.ludo.utils.*;
import flash.system.*;
public class DebugWindow extends Sprite {
private var _tf:TextField;
private var _text:Array;
public function DebugWindow(){
_text = [];
super();
var f:TextFormat = new TextFormat();
f.size = 9;
f.font = "Verdana";
_tf = new TextField();
_tf.wordWrap = true;
_tf.multiline = true;
_tf.x = 5;
_tf.y = 15;
_tf.width = (325 + 150);
_tf.height = 460;
_tf.defaultTextFormat = f;
_tf.textColor = 0xAAAAAA;
addChild(_tf);
graphics.lineStyle(1, 0, 1);
graphics.beginFill(0, 0.6);
graphics.drawRect(0, 0, 330, 460);
var top:Sprite = new Sprite();
top.graphics.lineStyle(1, 0, 1);
top.graphics.beginFill(0xCCCCCC, 0.75);
top.graphics.drawRect(0, 0, 330, 10);
top.buttonMode = true;
addChild(top);
top.addEventListener(MouseEvent.MOUSE_DOWN, onClicked, false, 0, true);
top.addEventListener(MouseEvent.MOUSE_UP, onReleased, false, 0, true);
var copy:Sprite = new Sprite();
copy.x = 310;
copy.y = 0;
copy.graphics.lineStyle(1, 0, 1);
copy.graphics.beginFill(0xFFFFFF);
copy.graphics.drawRect(0, 0, 20, 10);
copy.buttonMode = true;
copy.addEventListener(MouseEvent.MOUSE_DOWN, copyText, false, 0, true);
addChild(copy);
}
private function copyText(e:MouseEvent):void{
var outputString:String = "";
var i:int;
while (i < _text.length) {
outputString = (outputString + (_text[i] + "\n"));
i++;
};
System.setClipboard(outputString);
print("DebugWindow.copyText() content copied to clipboard", null);
}
private function onReleased(e:MouseEvent):void{
stopDrag();
}
public function print(msg:String, color:String):void{
var str:String;
if (color != null){
if (color.toLowerCase() == "ff3333"){
Main.getInstance().addChild(this);
};
};
msg.split("<").join("{");
msg.split(">").join("}");
var now:Date = new Date();
var timeString:String = ((((now.getHours() + ":") + Formatter.addZero(now.getMinutes())) + ":") + Formatter.addZero(now.getSeconds()));
if (color != null){
str = (((((("<b>" + timeString) + " - </b><font color=\"#") + color) + "\">") + msg) + "</font>");
} else {
str = ((("<b>" + timeString) + " - </b>") + msg);
};
_text.push(str);
if (_tf.numLines > 32){
_text.shift();
};
var outputString:String = "";
var i:int;
while (i < _text.length) {
outputString = (outputString + (_text[i] + "\n"));
i++;
};
_tf.htmlText = outputString;
}
private function onClicked(e:MouseEvent):void{
startDrag();
}
}
}//package com.king.ludo.gui
Section 30
//MoveMarker (com.king.ludo.gui.MoveMarker)
package com.king.ludo.gui {
import com.king.ludo.*;
import flash.display.*;
import flash.geom.*;
import com.king.ludo.data.*;
import flash.filters.*;
public class MoveMarker extends Sprite implements Tickable {
private var _glowFilter:GlowFilter;
private var _arrow:Bitmap;
public var positionId:int;
private var _glowSin:Number;// = 0
private var _arrowContainer:Sprite;
private var _sin:Number;// = 0
public function MoveMarker(){
super();
var bitmap:Bitmap = new Bitmap(BitmapDispenser.getBitmapData("marker"));
bitmap.x = (-(bitmap.width) / 2);
bitmap.y = (-(bitmap.height) / 2);
addChild(bitmap);
buttonMode = true;
_arrow = new Bitmap(BitmapDispenser.getBitmapData("big_arrow"));
_arrow.x = (-(_arrow.width) * 0.4);
_arrow.y = (-(_arrow.height) - 25);
_arrowContainer = new Sprite();
_arrowContainer.buttonMode = true;
_arrowContainer.addChild(_arrow);
_glowFilter = new GlowFilter(0xFFFFFF, 0.75, 8, 8);
}
public function getArrow():Sprite{
return (_arrowContainer);
}
public function tick():void{
_arrowContainer.visible = visible;
if (!visible){
return;
};
_arrowContainer.x = x;
_arrowContainer.y = (y + 5);
_arrow.x = (-(_arrow.width) * 0.4);
_arrow.y = ((-(_arrow.height) - 25) + (Math.sin(_sin) * 4));
_sin = (_sin + 0.1);
_glowSin = (_glowSin + 0.2);
var val:Number = Math.sin(_glowSin);
_glowFilter.blurX = (4 + (val * 4));
_glowFilter.blurY = (4 + (val * 4));
_arrow.filters = [_glowFilter];
_arrow.transform.colorTransform = new ColorTransform((1 + (val * 0.3)), (1 + (val * 0.3)), (1 + (val * 0.3)));
}
}
}//package com.king.ludo.gui
Section 31
//PlayerPanel (com.king.ludo.gui.PlayerPanel)
package com.king.ludo.gui {
import com.king.ludo.*;
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.king.ludo.utils.*;
import flash.utils.*;
import com.midasplayer.avatar.*;
import com.king.ludo.data.*;
import flash.filters.*;
public class PlayerPanel extends Sprite {
private var _player:Player;
private var _turnStartedOn:int;
private var _flipAvatar:Boolean;
private var _moodDelay:uint;
private var _progressFlower:Bitmap;
private var _avatarMood:String;// = "neutral"
private var _totalTurnTime:int;
private var _progressBitmaps:Array;
private var _lbl:StdLabel;
private var _avatar;
private static var _positions:Array = [new Point(100, 85), new Point(100, 5), new Point(-100, 5), new Point(-100, 85)];
public function PlayerPanel(player:Player){
var bId:String;
_progressBitmaps = [];
super();
_player = player;
_flipAvatar = (player.id < 2);
_lbl = new StdLabel(StdLabel.font1, 16, 0);
_lbl.filters = [new GlowFilter(0xFFFFFF, 1, 4, 4, 10)];
_lbl.text = player.name;
_lbl.x = (_flipAvatar) ? -20 : (-(_lbl.width) + 20);
_lbl.y = 60;
var i:int;
while (i < 7) {
bId = ((("time_" + player.id) + "_") + i);
_progressBitmaps.push(BitmapDispenser.getBitmapData(bId));
i++;
};
_progressFlower = new Bitmap();
_progressFlower.x = (_positions[player.id].x - (96 / 2));
_progressFlower.y = (_positions[player.id].y - (96 / 2));
addChild(_progressFlower);
addChild(_lbl);
setActive(false);
setProgress(0);
}
public function getFlowerPos():Point{
return (new Point(((x + _progressFlower.x) + (96 / 2)), ((y + _progressFlower.y) + (96 / 2))));
}
public function setActive(b:Boolean):void{
if (b){
_progressFlower.alpha = 1;
} else {
_progressFlower.alpha = 0.5;
setProgress(0);
};
}
public function showChatMsg(msg:String):void{
var bubble:ChatBubble = new ChatBubble(msg, _flipAvatar);
bubble.x = (_flipAvatar) ? 40 : -40;
bubble.y = 25;
bubble.show();
addChild(bubble);
}
public function setAvatarNeutral():void{
setAvatarMood(AvatarMood.MOOD_NEUTRAL);
}
public function setProgress(n:Number):void{
if (n < 0){
n = 0;
};
if (n > 1){
n = 1;
};
var bitm:int = (6 - Math.round((6 * n)));
_progressFlower.bitmapData = _progressBitmaps[bitm];
}
public function setAvatarMood(mood:String):void{
if (_avatarMood != mood){
_avatarMood = mood;
_avatar.setMood(mood);
};
clearTimeout(_moodDelay);
if (mood != AvatarMood.MOOD_NEUTRAL){
_moodDelay = setTimeout(setAvatarNeutral, 2500);
};
}
public function createAvatar(event:Event):void{
var av:DisplayObject;
var event = event;
_avatar = event.target.content.getAvatar(_player.avatar);
//unresolved jump
var _slot1 = e1;
Debug.print(((((("createAvatar() : " + _slot1.errorID) + " ") + _slot1.message) + " ") + _slot1.name), "ff3333");
av = (_avatar as Sprite);
av.scaleX = (_flipAvatar) ? -0.75 : 0.75;
av.scaleY = 0.75;
av.x = (_flipAvatar) ? (_avatar.getWidth() / 2) : (-(_avatar.getWidth()) / 2);
av.y = (-(_avatar.getHeight()) * 0.4);
av.filters = [new GlowFilter(0xFFFFFF, 1, 6, 6, 10)];
addChild(av);
//unresolved jump
var _slot1 = e2;
Debug.print(("createAvatar() : " + _slot1.toString()), "ff3333");
}
}
}//package com.king.ludo.gui
Section 32
//PopupMsg (com.king.ludo.gui.PopupMsg)
package com.king.ludo.gui {
import com.king.ludo.*;
import flash.events.*;
import flash.display.*;
import com.king.ludo.comm.*;
import flash.text.*;
import gs.*;
import flash.utils.*;
import com.king.ludo.data.*;
import flash.filters.*;
public class PopupMsg extends Sprite {
public var closable:Boolean;// = true
private static var msgId:int = 0;
private static var _lastPopup:PopupMsg;
public function PopupMsg(msgStr:String="NOW I AM TESTING MULTILINE FUNCTIONALITY NOW I AM TESTING MULTILINE FUNCTIONALITY NOW I AM TESTING MULTILINE FUNCTIONALITY NOW I AM TESTING MULTILINE FUNCTIONALITY NOW I AM TESTING MULTILINE FUNCTIONALITY ", closeIn:int=0){
super();
var b:Bitmap = new Bitmap(BitmapDispenser.getBitmapData("info_frame"));
addChild(b);
var msg:StdLabel = new StdLabel(StdLabel.font1, 16, 0xFFFFFF, false);
var f:TextFormat = msg.defaultTextFormat;
f.align = TextFormatAlign.CENTER;
f.bold = true;
msg.defaultTextFormat = f;
msg.autoSize = TextFieldAutoSize.NONE;
msg.width = 480;
msg.height = 400;
msg.multiline = true;
msg.wordWrap = true;
msg.text = msgStr;
msg.x = 140;
msg.y = 175;
msg.filters = [new GlowFilter(0, 0.75, 4, 4)];
addChild(msg);
addEventListener(MouseEvent.CLICK, close, false, 0, true);
alpha = 0;
TweenLite.to(this, 0.5, {alpha:1});
if (closeIn > 0){
setTimeout(close, closeIn, null);
};
}
public function addDisplayObject(d:DisplayObject, xp:Number, yp:Number):void{
addChildAt(d, 1);
d.x = xp;
d.y = yp;
}
public function drawPlayersStats():void{
var i:int;
var column:StdLabel;
var p:Player;
var values:Object;
var j:int;
var playerLbl:StdLabel;
var xpos = 150;
var ypos = 220;
var columnNames:Array = ["game_over_player", "game_over_chars_in_nest", "game_over_pushes", "game_over_6_rolls", "game_over_knocked_down"];
i = 0;
while (i < 5) {
column = new StdLabel(StdLabel.font1, 12, 0xFFFFFF);
column.filters = [new GlowFilter(0, 0.75, 4, 4)];
column.text = TextMappings.get(columnNames[i]);
column.x = (xpos + (i * 100));
column.y = ypos;
addChild(column);
i++;
};
ypos = (ypos + 20);
var result:Array = [];
i = 0;
while (i < Players.getNumPlayers()) {
p = Players.getPlayer(i);
values = {v0:p.name, v1:p.charsInGoal, v2:p.knuffs, v3:p.sixRolls, v4:p.knockedDown};
result.push(values);
i++;
};
result.sortOn("v1", Array.NUMERIC);
result.reverse();
i = 0;
while (i < result.length) {
j = 0;
while (j < 5) {
playerLbl = new StdLabel(StdLabel.font1, 12, 0xFFFFFF);
playerLbl.filters = [new GlowFilter(0, 0.75, 4, 4)];
playerLbl.text = ("" + result[i][("v" + j)]);
playerLbl.x = (xpos + (j * 100));
playerLbl.y = ypos;
addChild(playerLbl);
j++;
};
ypos = (ypos + 20);
i++;
};
}
public function close(e:MouseEvent):void{
if (!closable){
return;
};
if (parent){
parent.removeChild(this);
};
msgId--;
_lastPopup = null;
}
}
}//package com.king.ludo.gui
Section 33
//ShortMessage (com.king.ludo.gui.ShortMessage)
package com.king.ludo.gui {
import flash.display.*;
import gs.*;
import flash.filters.*;
public class ShortMessage extends Sprite {
private var _lbl:StdLabel;
public function ShortMessage(msg:String){
super();
var size:int = (74 - msg.length);
_lbl = new StdLabel(StdLabel.font1, size, 0xFFFFFF);
_lbl.filters = [new GlowFilter(356568, 1, 4, 4, 3), new GlowFilter(0, 1, 6, 6, 1)];
_lbl.text = msg;
_lbl.x = (-(_lbl.width) / 2);
_lbl.y = (-(_lbl.height) / 2);
mouseEnabled = false;
_lbl.mouseEnabled = false;
addChild(_lbl);
}
public function destroy():void{
if (parent){
parent.removeChild(this);
};
}
public function hide():void{
TweenLite.to(this, 1, {alpha:0.1, scaleX:0.9, scaleY:0.9, overwrite:0, onComplete:destroy});
}
public function show(hideAfter:Boolean=true):void{
alpha = 0.1;
scaleX = 0.4;
scaleY = 0.4;
rotation = (-10 + (Math.random() * 20));
if (hideAfter){
TweenLite.to(this, 0.75, {alpha:1, scaleX:1, scaleY:1, overwrite:0, onComplete:hide});
} else {
TweenLite.to(this, 0.75, {alpha:1, scaleX:1, scaleY:1, overwrite:0});
};
}
}
}//package com.king.ludo.gui
Section 34
//StdLabel (com.king.ludo.gui.StdLabel)
package com.king.ludo.gui {
import flash.text.*;
public class StdLabel extends TextField {
public static const font1:String = "Verdana";
public static const font2:String = "AvantGarde";
public function StdLabel(font:String="Verdana", size:int=10, color:uint=0, performAutoSize:Boolean=true){
super();
var f:TextFormat = new TextFormat();
f.font = font;
f.size = size;
f.color = color;
embedFonts = true;
defaultTextFormat = f;
selectable = false;
if (performAutoSize){
autoSize = TextFieldAutoSize.LEFT;
};
}
}
}//package com.king.ludo.gui
Section 35
//Debug (com.king.ludo.utils.Debug)
package com.king.ludo.utils {
import com.king.ludo.gui.*;
import flash.system.*;
import flash.external.*;
public class Debug {
public static var enabled:Boolean = false;
public static var debugWindow:DebugWindow;
public static var useExternal:Boolean = false;
public function Debug(){
super();
}
public static function printMem():void{
print((("MEM: " + (System.totalMemory / 1000000).toFixed(2)) + "mb"));
}
public static function printCapabilities():void{
print(("Capabilities.serverString: " + Capabilities.serverString), "AAAAFF");
}
public static function print(msg:String, color:String=null):void{
if (!enabled){
return;
};
if (useExternal){
if (color == null){
ExternalInterface.call("jsPrintDebug", msg);
} else {
ExternalInterface.call("jsPrintDebug", msg, color);
};
};
if (debugWindow != null){
debugWindow.print(msg, color);
};
}
}
}//package com.king.ludo.utils
Section 36
//Formatter (com.king.ludo.utils.Formatter)
package com.king.ludo.utils {
import flash.text.*;
public class Formatter {
public static var HOURS_PER_DAY:int = 8;
public function Formatter(){
super();
}
public static function formatDateNoTime(d:Date):String{
return (((((d.getFullYear() + "-") + addZero((d.getMonth() + 1))) + "-") + addZero(d.getDate())));
}
public static function formatTime(n:Number):String{
return ("");
}
public static function shortenTextByLetters(str:String, letters:int):String{
return ("");
}
public static function formatDate(d:Date):String{
return (((((((((d.getFullYear() + "-") + addZero((d.getMonth() + 1))) + "-") + addZero(d.getDate())) + " ") + addZero(d.getHours())) + ":") + addZero(d.getMinutes())));
}
public static function shortenTextByPixels(tf:TextField, allowedLength:int):String{
return ("");
}
public static function addZero(n:Number):String{
return (((n < 10)) ? ("0" + n) : ("" + n));
}
public static function formatDuration(hours:int):String{
var d:int = (hours / HOURS_PER_DAY);
var h:int = (hours - (d * HOURS_PER_DAY));
return ((((d + "d ") + h) + "h"));
}
}
}//package com.king.ludo.utils
Section 37
//Integer64 (com.king.ludo.utils.Integer64)
package com.king.ludo.utils {
public class Integer64 {
private var p:Array;
private var r:Array;
private var s:Array;
public function Integer64(lowInt){
super();
r = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]];
p = [0, 0, 0, 0, 0];
s = [0, 0, 0];
if (lowInt){
merge(lowInt);
};
}
public function binaryShiftRight(step:Number):void{
var i:Number;
var j:Number;
var f:Number = ((step / 15) >> 0);
var rs:Number = (step - (f * 15));
var l:Number = (p.length - 1);
while (l > 0) {
i = 0;
while (i < f) {
p[i] = p[(i + 1)];
i++;
};
var _temp1 = l;
l = (l - 1);
var _local7 = _temp1;
p[_local7] = 0;
};
if (rs > 0){
j = 0;
while (j < rs) {
shr();
j++;
};
};
}
public function mul32(value:Number):void{
mul64(new Integer64(value));
}
public function add32(num:Number):void{
var c:Number = 0;
var l:Number = (num & 32767);
num = (num >> 15);
var h:Number = (num & 32767);
num = (num >> 15);
var vh:Number = (num & 3);
c = (c + (p[0] + l));
p[0] = (c & 32767);
c = (c >> 15);
c = (c + (p[1] + h));
p[1] = (c & 32767);
c = (c >> 15);
c = (c + (p[2] + vh));
p[2] = (c & 32767);
}
public function binaryShiftLeft(step:Number):void{
var i:int;
while (i < step) {
shl();
i++;
};
}
public function mul64(o:Integer64):void{
var ai:Number;
var c:Number = 0;
var i:int;
while (i < 5) {
ai = o.p[i];
c = (ai * p[0]);
r[i][0] = (c & 32767);
c = (c >> 15);
c = (c + (ai * p[1]));
r[i][1] = (c & 32767);
c = (c >> 15);
c = (c + (ai * p[2]));
r[i][2] = (c & 32767);
c = (c >> 15);
c = (c + (ai * p[3]));
r[i][3] = (c & 32767);
c = (c >> 15);
c = (c + (ai * p[4]));
r[i][4] = (c & 32767);
i++;
};
c = r[0][0];
p[0] = (c & 32767);
c = (c >> 15);
c = (c + (r[0][1] + r[1][0]));
p[1] = (c & 32767);
c = (c >> 15);
c = (c + ((r[0][2] + r[1][1]) + r[2][0]));
p[2] = (c & 32767);
c = (c >> 15);
c = (c + (((r[0][3] + r[1][2]) + r[2][1]) + r[3][0]));
p[3] = (c & 32767);
c = (c >> 15);
c = (c + ((((r[0][4] + r[1][3]) + r[2][2]) + r[3][1]) + r[4][0]));
p[4] = (c & 7);
}
private function shr():void{
var msb:Number = 0;
var la:Number = 0;
var i:int = (p.length - 1);
while (i >= 0) {
msb = ((p[i] & 1) << 14);
p[i] = (p[i] >> 1);
p[i] = ((p[i] | la) & 32767);
i--;
la = msb;
};
}
public function init32(n:Number):void{
p[0] = (n & 32767);
n = (n >>> 15);
p[1] = (n & 32767);
n = (n >>> 15);
p[2] = (n & 3);
p[3] = 0;
p[4] = 0;
}
public function init(v:Integer64):void{
var i:int;
while (i < p.length) {
p[i] = v.p[i];
i++;
};
}
private function merge(a:Number):Number{
var i:int;
while (i < 3) {
p[i] = (p[i] + (a & 32767));
a = (a >>> 15);
i++;
};
return (a);
}
public function binaryNot(o:Integer64):void{
p[0] = (p[0] ^ o.p[0]);
p[1] = (p[1] ^ o.p[1]);
p[2] = (p[2] ^ o.p[2]);
p[3] = (p[3] ^ o.p[3]);
p[4] = (p[4] ^ o.p[4]);
}
public function get lsb():Number{
return (((p[0] | (p[1] << 15)) | ((p[2] & 3) << 30)));
}
public function get msb():Number{
return (((((p[2] >> 2) | ((p[3] << 15) >> 2)) | ((p[4] << (15 * 2)) >> 2)) & 2147483647));
}
public function mulu32(num:Number):void{
var ai:Number;
var c:Number = 0;
s[0] = (num & 32767);
num = (num >>> 15);
s[1] = (num & 32767);
num = (num >>> 15);
s[2] = (num & 3);
var i:int;
while (i < 3) {
ai = s[i];
c = (ai * p[0]);
r[i][0] = (c & 32767);
c = (c >> 15);
c = (c + (ai * p[1]));
r[i][1] = (c & 32767);
c = (c >> 15);
c = (c + (ai * p[2]));
r[i][2] = (c & 3);
i++;
};
c = r[0][0];
p[0] = (c & 32767);
c = (c >> 15);
c = (c + (r[0][1] + r[1][0]));
p[1] = (c & 32767);
c = (c >> 15);
c = (c + ((r[0][2] + r[1][1]) + r[2][0]));
p[2] = (c & 3);
p[3] = 0;
p[4] = 0;
}
private function shl():void{
var msb:Number = 0;
var la:Number = 0;
var i:int;
var j:int = p.length;
while (i < j) {
msb = ((p[i] & 0x4000) >> 14);
p[i] = (p[i] << 1);
p[i] = ((p[i] | la) & 32767);
i++;
la = msb;
};
}
public function add64(o:Integer64):void{
var c:Number = 0;
var l:Number = 1;
var i:Number = 0;
while ((((l < p.length)) && (!((o.p[i] == 0))))) {
l++;
};
i = 0;
while (i < l) {
c = (c + (p[i] + o.p[i]));
p[i] = (c & 32767);
c = (c >> 15);
i++;
};
}
}
}//package com.king.ludo.utils
Section 38
//MathExtra (com.king.ludo.utils.MathExtra)
package com.king.ludo.utils {
import flash.geom.*;
public class MathExtra {
public function MathExtra(){
super();
}
public static function degreesToRads(d:Number):Number{
return ((d * (Math.PI / 180)));
}
public static function roundInt(n:Number, size:int):int{
var n1:int = Math.round((n / size));
return ((n1 * size));
}
public static function radsToDegrees(r:Number):Number{
return ((r * (180 / Math.PI)));
}
public static function getDistanceBetweenPoints(p1:Point, p2:Point):Number{
return (Point.distance(p1, p2));
}
public static function getPointByAngleAndDistance(dist:Number, angle:Number, orgPoint:Point=null):Point{
if (orgPoint == null){
orgPoint = new Point(0, 0);
};
angle = degreesToRads(angle);
var x:Number = (Math.cos(angle) * dist);
var y:Number = (Math.sin(angle) * dist);
return (new Point((x + orgPoint.x), (y + orgPoint.y)));
}
public static function getAngleBetweenPoints(p1:Point, p2:Point):Number{
return (((Math.atan2((p2.y - p1.y), (p2.x - p1.x)) * 180) / Math.PI));
}
}
}//package com.king.ludo.utils
Section 39
//Random (com.king.ludo.utils.Random)
package com.king.ludo.utils {
import flash.utils.*;
public class Random {
private var mta:Array;
private var mti:Number;
private var lastSeed:Number;
private static var MATRIX_A:Number = 2567483615;
private static var UPPER_MASK:Number = 2147483648;
private static var LOWER_MASK:Number = 2147483647;
private static var M:Number = 397;
private static var N:Number = 624;
private static var mag01:Array = [0, 2567483615];
public function Random(aSeed:Number){
super();
mta = new Array(N);
mti = (N + 1);
if (aSeed){
init_genrand(aSeed);
};
}
private function init_genrand(s:Number):void{
s = int(s);
var tBegin:int = getTimer();
lastSeed = s;
mta[0] = s;
var sts:Number = s;
var pt:Integer64 = new Integer64(null);
var n:Number = N;
mti = 1;
while (mti < n) {
pt.init32(((sts >>> 30) ^ sts));
pt.mulu32(1812433253);
sts = (mta[mti] = int((pt.lsb + mti)));
mti++;
};
var tEnd:uint = getTimer();
}
public function nextFloat():Number{
return ((next(24) / (1 << 24)));
}
public function nextDouble():Number{
return ((next(24) / (1 << 24)));
}
public function get seed():Number{
return (lastSeed);
}
public function next(bits:Number):Number{
if (bits < 32){
return ((genrand_int32() & ((1 << bits) - 1)));
};
return (genrand_int32());
}
public function set seed(s:Number):void{
init_genrand(s);
}
public function nextInt(n:Number):Number{
return (((genrand_int32() & 2147483647) % n));
}
private function genrand_int32():Number{
var m:Number;
var um:Number;
var lm:Number;
var lmag01:Array;
var tBegin:int;
var kk:Number;
var kk1:Number;
var kk2:Number;
var tEnd:int;
var n:Number = N;
var y:Number = 0;
if (mti >= n){
if (mti == (n + 1)){
init_genrand(5489);
};
m = M;
um = UPPER_MASK;
lm = LOWER_MASK;
lmag01 = mag01;
tBegin = getTimer();
kk = 0;
kk1 = (n - m);
kk2 = (m - n);
kk = 0;
while (kk < kk1) {
y = ((mta[kk] & um) | (mta[(kk + 1)] & lm));
mta[kk] = ((mta[(kk + m)] ^ (y >>> 1)) ^ lmag01[(y & 1)]);
kk++;
};
kk1 = (n - 1);
while (kk < kk1) {
y = ((mta[kk] & um) | (mta[(kk + 1)] & lm));
mta[kk] = ((mta[(kk + kk2)] ^ (y >>> 1)) ^ lmag01[(y & 1)]);
kk++;
};
y = ((mta[(n - 1)] & um) | (mta[0] & lm));
mta[(n - 1)] = ((mta[(m - 1)] ^ (y >>> 1)) ^ lmag01[(y & 1)]);
mti = 0;
tEnd = getTimer();
};
y = mta[mti++];
y = (y ^ (y >>> 11));
y = (y ^ ((y << 7) & 2636928640));
y = (y ^ ((y << 15) & 4022730752));
y = (y ^ (y >>> 18));
return (y);
}
}
}//package com.king.ludo.utils
Section 40
//Comm (com.king.ludo.Comm)
package com.king.ludo {
import com.king.ludo.gui.*;
import com.king.ludo.comm.*;
import com.king.ludo.utils.*;
import flash.utils.*;
public class Comm implements CommCallback {
public var communicator:Communicator;
public var mayDisconnect:Boolean;// = false
private var cmdQueue:Array;
private var pauseCount:int;// = 0
private static var _this:Comm;
public function Comm(){
cmdQueue = new Array();
super();
_this = this;
communicator = new Communicator(this);
}
public function gameCommand(cmd:String):void{
var i:int;
var clientId:int;
var cmds:Array = cmd.split(" ");
var msg:String = "";
if (cmds[0] == "MSG"){
msg = "";
i = 1;
while (i < cmds.length) {
if (i > 1){
msg = (msg + " ");
};
msg = (msg + cmds[i]);
i++;
};
cmds = msg.split(",");
clientId = parseInt(cmds[0]);
msg = "";
i = 1;
while (i < cmds.length) {
if (i > 1){
msg = (msg + ",");
};
msg = (msg + cmds[i]);
i++;
};
Players.getPlayer(clientId).playerPanel.showChatMsg(msg);
} else {
if (cmds[0].indexOf("T") == 0){
clientId = parseInt(cmds[1]);
if (cmds[0] == "TCT"){
msg = "";
i = 2;
while (i < cmds.length) {
if (i > 2){
msg = (msg + " ");
};
msg = (msg + cmds[i]);
i++;
};
Players.getPlayer(clientId).playerPanel.showChatMsg(msg);
} else {
if (cmds[0] == "TOP"){
Debug.print(("Comm.gameCommand() log : " + cmd), "ddddff");
};
};
} else {
if (pauseCount > 0){
cmdQueue.push(cmds);
} else {
handle(cmds);
};
};
};
}
public function broadcast(str:String):void{
communicator.sendData(str);
}
public function unableToConnect():void{
Debug.print("Comm.Unable to connect..", "ff3333");
}
public function log(str:String):void{
Debug.print(("Comm: " + str), "ffffaa");
}
public function clientConnected(client:Client):void{
Debug.print(((((("Comm.Client connected.." + client.id) + " , ") + client.name) + " , ") + client.avatarSlot), "ffffaa");
Players.addPlayer(new Player(client.id, client.name, client.avatar));
}
public function sendGameOver(winnerId:int):void{
send(("LGO " + winnerId));
}
public function resume():void{
communicator.resume();
pauseCount--;
if (pauseCount == 0){
handleAllQueued();
};
}
public function init(server:String, port:int, slotId:String, magic:String):void{
communicator.connect(server, port, slotId, magic);
}
public function sendMove(charId:int, pathId:int):void{
send(((("LMO " + charId) + " ") + pathId));
}
public function sendRandomSeed():void{
Debug.print((("Comm.startGame() send: " + "SRS ") + Main.getInstance().parsedGameData.randomSeed));
send(("SRS " + Main.getInstance().parsedGameData.randomSeed));
}
public function sendDice(playerId:int, result:int):void{
send(((("LDI " + playerId) + " ") + result));
}
public function send(str:String):void{
if (!Game.getInstance().isGameStopped()){
communicator.sendData(str);
};
}
public function clientAccepted(client:Client):void{
Debug.print(((("Comm.Client accepted.. you are: " + client.id) + " ") + client.name), "ffffaa");
Players.addPlayer(new Player(client.id, client.name, client.avatar));
Players.setSelfId(client.id);
communicator.sendData("CIR");
}
public function sendForfeit():void{
send("LFG");
}
public function tick():void{
communicator.tick();
}
public function sendMovesFinished():void{
send("LMF");
}
public function clientDisconnected(playerNum:Number, remainingPlayers:Number):void{
Debug.print(((("Comm.Client disconnected.. player:" + playerNum) + " , remaining: ") + remainingPlayers), "ff3333");
Players.playerLeft(playerNum);
}
public function localDisconnect():void{
if (mayDisconnect){
return;
};
Debug.print("Comm.Local disconnect..", "ff3333");
Players.getSelf().score = 10;
var pop:PopupMsg = new PopupMsg(TextMappings.get("disconnected_text"));
Main.getInstance().addChild(pop);
pop.closable;
Game.getInstance().stopGame();
setTimeout(Main.getInstance().gameQuit, 5000);
}
private function handle(cmds:Array):void{
var i:int;
var playerId:int;
var diceResult:int;
var charId:int;
var pathId:int;
var winnerId:int;
var pop:PopupMsg;
var cmd:String = cmds[0];
if (cmd != "AIM"){
Debug.print(("Comm.handle(): " + cmd), "ffffaa");
};
if (cmd == "LSG"){
LudoEvents.onAllUsersConnected();
send("LSG resp");
} else {
if (cmd == "LST"){
playerId = parseInt(cmds[1]);
LudoEvents.onTurnStart(playerId);
send("LST resp");
} else {
if (cmd == "LDI"){
playerId = parseInt(cmds[1]);
diceResult = parseInt(cmds[2]);
Debug.print(("dice result: " + diceResult));
LudoEvents.onUserDice(playerId, diceResult);
} else {
if (cmd == "LET"){
LudoEvents.onTurnEnd();
send("LET resp");
} else {
if (cmd == "LMO"){
charId = parseInt(cmds[1]);
pathId = parseInt(cmds[2]);
LudoEvents.onUserMoved(charId, pathId);
} else {
if (cmd == "LEG"){
winnerId = parseInt(cmds[1]);
Main.getInstance().gameOver(winnerId);
} else {
if (cmd == "LFG"){
playerId = parseInt(cmds[1]);
Players.playerLeft(playerId);
} else {
if (cmd == "MSA"){
setTimeout(Main.getInstance().maybeShowAd, 800);
} else {
if (cmd == "SAG"){
pop = new PopupMsg(TextMappings.get("abort_game"));
Main.getInstance().addChild(pop);
setTimeout(Main.getInstance().gameQuit, 3000);
};
};
};
};
};
};
};
};
};
}
private function handleAllQueued():void{
var i:int;
while (i < cmdQueue.length) {
handle(cmdQueue[i]);
i++;
};
cmdQueue = new Array();
}
public function sendChatMsg(msg:String):void{
send(((("MSG " + Players.getSelf().id) + ",") + msg));
Debug.print(("Comm.sendChatMsg() " + msg));
}
public function connecting():void{
Debug.print("Comm.Connecting..", "ffffaa");
}
public function startGame():void{
Debug.print("Comm.Startgame()..", "ffffaa");
}
public function pause():void{
communicator.pause();
pauseCount++;
}
public static function getInstance():Comm{
return (_this);
}
}
}//package com.king.ludo
Section 41
//Config (com.king.ludo.Config)
package com.king.ludo {
import com.king.ludo.utils.*;
import flash.system.*;
public class Config {
public static const ROOT_LOAD_PATH:String = "";
public static const SECURE_ROOT_LOAD_PATH:String = "";
public function Config(){
super();
}
public static function checkEnviroment():void{
Debug.print(("Config.checkEnviroment() : " + Capabilities.playerType), "33FF55");
}
}
}//package com.king.ludo
Section 42
//Game (com.king.ludo.Game)
package com.king.ludo {
import flash.events.*;
import com.king.ludo.gui.*;
import flash.display.*;
import flash.geom.*;
import com.king.ludo.comm.*;
import com.king.ludo.characters.*;
import gs.*;
import com.king.ludo.utils.*;
import com.king.ludo.dice.*;
import flash.system.*;
import flash.utils.*;
import com.king.ludo.data.*;
public class Game extends Sprite implements LudoListener {
private var _dice:Dice;
private var _thisPlayersTurn:int;// = 0
private var _waitingMsg:ShortMessage;
private var _turnId:int;// = 0
private var _turnAllowedTime:int;// = 0
private var _hasCharacterInPlay:Boolean;// = false
private var _gameHasStarted:Boolean;// = false
private var _gameStopped:Boolean;// = false
private var _turnStartedOn:int;// = -1
public var projection:Projection;
private var _chatInput:ChatInput;
private var _autoPlay:Boolean;// = false
private var _readyBtnPressed:Boolean;// = false
private var _diceThrown:Boolean;// = false
private var _players:Players;
private var _readyButton:BitmapButton;
private var _diceThrows:int;// = 0
private var _timesTimedOut:int;// = 0
private static const ALLOW_INFINITE_AUTOPLAY:Boolean = false;
public static var currentPlayer:int;
public static var latestDiceValue:int;
private static var _this:Game;
public function Game(){
super();
_this = this;
}
private function onTimeout():void{
_turnStartedOn = -1;
if (currentPlayer == Players.getSelf().id){
_timesTimedOut++;
if (_timesTimedOut > 3){
Main.getInstance().forfeitGame();
} else {
autoPlayTurn();
};
};
}
public function onUserMoved(charId:int, pathId:int):void{
var char:Character;
if (((Main.getInstance().hasGameEnded()) || (_gameStopped))){
return;
};
_diceThrown = false;
if ((((charId > -1)) && ((pathId > -1)))){
char = CharacterManager.getCharacterById(charId);
if (char.ownerId == Players.getSelf().id){
_hasCharacterInPlay = true;
};
};
if (currentPlayer == Players.getSelf().id){
enableCharacters(false);
Debug.print(((((((((("Game.onUserMoved(" + charId) + ",") + pathId) + ") ") + _thisPlayersTurn) + " ") + _diceThrows) + " ") + _hasCharacterInPlay), "886666");
if ((((latestDiceValue == 6)) || ((((((_thisPlayersTurn == 1)) && ((_diceThrows < 3)))) && (!(_hasCharacterInPlay)))))){
if (char != null){
char.setMoveFinishedListener(onCharMoveFinishedEnableDice);
} else {
_dice.setEnabled(true);
};
addTime((10 * 1000));
} else {
_turnStartedOn = -1;
if (char != null){
char.setMoveFinishedListener(onCharMoveFinished);
} else {
setTimeout(onCharMoveFinished, 500, null);
};
Debug.print((((("Game.onUserMoved(" + charId) + ",") + pathId) + ")"));
};
} else {
if (latestDiceValue == 6){
addTime((10 * 1000));
};
};
if (char != null){
char.moveToPathPos(pathId);
};
}
private function addTime(time:int):void{
_turnAllowedTime = (_turnAllowedTime + time);
}
public function init():void{
LudoEvents.addListener(this);
Input.init();
_players = new Players();
projection = new Projection();
_dice = new Dice();
projection.addToSortList(_dice);
var background:Bitmap = new Bitmap(BitmapDispenser.getBitmapData("main_board"));
addChild(background);
addChild(projection);
addChild(_players);
addEventListener(Event.ENTER_FRAME, tick, false, 0, true);
_chatInput = new ChatInput();
_chatInput.x = 5;
_chatInput.y = (Main.H - 25);
addChild(_chatInput);
_waitingMsg = new ShortMessage(TextMappings.get("waiting_for_opponents"));
_waitingMsg.scaleX = (_waitingMsg.scaleY = 0.75);
_waitingMsg.x = (Main.W / 2);
_waitingMsg.y = (Main.H / 2);
_readyButton = new BitmapButton();
_readyButton.setBitmap(BitmapDispenser.getBitmapData("btn_ready"));
_readyButton.x = ((Main.W / 2) - (_readyButton.width / 2));
_readyButton.y = ((Main.H / 2) - (_readyButton.height / 2));
_readyButton.setActive(true, onReadyButtonPressed);
var btnLbl:StdLabel = new StdLabel(StdLabel.font1, 14);
btnLbl.text = TextMappings.get("btn_ready");
btnLbl.x = ((_readyButton.width / 2) - (btnLbl.width / 2));
btnLbl.y = 5;
_readyButton.addChild(btnLbl);
TweenLite.to(_dice, 0.5, {x:-100, y:-100});
}
private function removeReadyButton():void{
if (_readyButton.parent){
_readyButton.parent.removeChild(_readyButton);
};
}
public function stopGame():void{
_gameStopped = true;
_turnStartedOn = -1;
enableCharacters(false);
_dice.setEnabled(false);
projection.moveMarker.visible = false;
Players.removeTimeSparkle();
}
public function onUserDice(userId:int, result:int):void{
var movable:int;
var charsInPool:Array;
var char:Character;
if (((Main.getInstance().hasGameEnded()) || (_gameStopped))){
return;
};
_dice.roll(result);
_diceThrows++;
_diceThrown = true;
latestDiceValue = result;
if (result == 6){
Main.getInstance().soundManager.getByClass(Main.getInstance().SndSix, "snd_six").play(0.35);
Players.getPlayer(currentPlayer).sixRolls++;
};
if (currentPlayer == Players.getSelf().id){
if (((!(_autoPlay)) || (ALLOW_INFINITE_AUTOPLAY))){
_timesTimedOut = 0;
};
movable = enableCharacters(true);
_dice.setEnabled(false);
if ((((result == 1)) || ((result == 6)))){
charsInPool = CharacterManager.getCharactersInPoolByOwner(currentPlayer);
if (charsInPool.length > 0){
char = charsInPool[0];
Input.setSelectedChar(char, Positions.getStartPosForPlayer(currentPlayer));
} else {
if (movable == 0){
setTimeout(LudoEvents.onUserMoved, 300, -1, -1);
};
};
} else {
if (movable == 0){
setTimeout(LudoEvents.onUserMoved, 300, -1, -1);
};
};
if (_autoPlay){
autoPlayTurn2();
};
} else {
_dice.advanceRandom();
};
}
public function tick(e:Event):void{
var timeLeft:int;
projection.tick();
_dice.tick();
if ((((_turnStartedOn > 0)) && ((currentPlayer > -1)))){
timeLeft = ((_turnStartedOn + _turnAllowedTime) - getTimer());
Players.getPlayer(currentPlayer).playerPanel.setProgress((timeLeft / _turnAllowedTime));
if (timeLeft < 0){
onTimeout();
};
};
}
private function autoPlayTurn():void{
Debug.print("Game.autoPlayTurn()");
_autoPlay = true;
if (_diceThrown){
autoPlayTurn2();
} else {
_dice.sendRoll(null);
};
}
private function autoPlayTurn2():void{
var i:int;
Debug.print("Game.autoPlayTurn2()");
var chars:Array = CharacterManager.getCharactersByOwner(currentPlayer);
var charFound:Boolean;
var char:Character = Input.getSelectedChar();
var bestPos = -999;
if (((!((char == null))) && (char.getSelectable()))){
charFound = true;
} else {
i = 0;
while (i < chars.length) {
if (((chars[i].getSelectable()) && ((chars[i].getCurrentPosId() >= bestPos)))){
bestPos = chars[i].getCurrentPosId();
char = chars[i];
charFound = true;
};
i++;
};
};
if (((charFound) && (!((char == null))))){
Input.autoPlay(char);
} else {
Main.getInstance().comm.sendMovesFinished();
};
}
private function hasAnyPlayerWon():Boolean{
var player:Player;
var chars:Array;
var j:int;
var won:Boolean;
var i:int;
while (i < Players.getNumPlayers()) {
player = Players.getPlayer(i);
chars = CharacterManager.getCharactersByOwner(player.id);
player.charsInGoal = 0;
j = 0;
while (j < chars.length) {
if (Character(chars[j]).isInGoal){
player.charsInGoal++;
};
j++;
};
if (player.charsInGoal == 4){
won = true;
};
i++;
};
return (won);
}
public function onUserDisconnected(userId:int):void{
}
public function onGameEnd(winnerId:int):void{
}
public function onTurnEnd():void{
var player:Player;
var chars:Array;
var j:int;
if (currentPlayer == Players.getSelf().id){
enableCharacters(false);
_turnStartedOn = -1;
};
var i:int;
while (i < Players.getNumPlayers()) {
player = Players.getPlayer(i);
chars = CharacterManager.getCharactersByOwner(player.id);
player.charsInGoal = 0;
j = 0;
while (j < chars.length) {
if (Character(chars[j]).isInGoal){
player.charsInGoal++;
};
j++;
};
player.score = (player.charsInGoal * 100);
if (player.charsInGoal == 4){
Debug.print((("===== Player has won! " + player.name) + " ======"), "ffffff");
Main.getInstance().comm.sendGameOver(player.id);
stopGame();
};
i++;
};
currentPlayer = -1;
}
private function onCharMoveFinishedEnableDice(char:Character):void{
if (hasAnyPlayerWon()){
onCharMoveFinished(char);
return;
};
_dice.setEnabled(true);
if (char != null){
char.setMoveFinishedListener(null);
};
if (_autoPlay){
setTimeout(autoPlayTurn, 1000);
};
}
public function onAllUsersConnected():void{
var pl:Player;
var pos:Array;
var j:int;
var char:Character;
var p:Point;
var angles:Array = [Character.FRM_OFFSET_L, Character.FRM_OFFSET_U, Character.FRM_OFFSET_R, Character.FRM_OFFSET_D];
var i:int;
while (i < Players.getNumPlayers()) {
pl = Players.getPlayer(i);
pos = Positions.getPoolPosForPlayer(pl.id);
j = 0;
while (j < pos.length) {
char = new Character(pl.id);
char.initAngle = angles[i];
char.setAngle(angles[i]);
p = pos[j];
char.x = p.x;
char.y = p.y;
j++;
};
i++;
};
if (!_gameHasStarted){
fscommand("gameStart", "");
_waitingMsg.hide();
_waitingMsg = null;
_gameHasStarted = true;
removeReadyButton();
};
}
public function onTurnStart(turnOwnerId:int):void{
if (((Main.getInstance().hasGameEnded()) || (_gameStopped))){
return;
};
Main.getInstance().onTurnStart(turnOwnerId);
_autoPlay = false;
_diceThrown = false;
currentPlayer = turnOwnerId;
_diceThrows = 0;
_turnId++;
_turnStartedOn = getTimer();
_turnAllowedTime = 0;
addTime((10 * 1000));
if (currentPlayer == Players.getSelf().id){
_dice.setEnabled(true);
_thisPlayersTurn++;
Main.getInstance().soundManager.getByClass(Main.getInstance().SndYourTurn, "snd_your_turn").play(0.35);
};
TweenLite.to(_dice, 0.5, {x:Positions.getDicePosForPlayer(currentPlayer).x, y:Positions.getDicePosForPlayer(currentPlayer).y});
Debug.print(("Game.onTurnStart() NEW TURN turnOwnerId: " + currentPlayer), "33ff99");
var msg:ShortMessage = new ShortMessage(TextMappings.get("new_turn").split("{0}").join(Players.getPlayer(currentPlayer).name));
msg.x = (Main.W / 2);
msg.y = (Main.H / 2);
msg.show();
addChild(msg);
}
private function enableCharacters(b:Boolean):int{
var char:Character;
var a:Array;
Debug.print((("Game.enableCharacters(" + b) + ") "));
var chars:Array = CharacterManager.getCharactersByOwner(currentPlayer);
var movableChars:int;
var i:int;
while (i < chars.length) {
char = chars[i];
if (b){
a = Input.testMove(char);
if (a[0]){
if (((((char.isInPlay) || ((latestDiceValue == 1)))) || ((latestDiceValue == 6)))){
char.setSelectable(true);
movableChars++;
};
};
} else {
char.setSelectable(false);
};
i++;
};
return (movableChars);
}
private function onCharMoveFinished(char:Character):void{
if (char != null){
char.setMoveFinishedListener(null);
};
setTimeout(Main.getInstance().comm.sendMovesFinished, 500);
}
public function isGameStopped():Boolean{
return (_gameStopped);
}
public function showReadyButton():void{
addChild(_readyButton);
setTimeout(onReadyButtonPressed, (20 * 1000), null);
}
private function onReadyButtonPressed(b:BasicButton):void{
if (_readyBtnPressed){
return;
};
_readyBtnPressed = true;
Main.getInstance().comm.sendRandomSeed();
addChild(_waitingMsg);
_waitingMsg.alpha = 0;
TweenLite.to(_waitingMsg, 0.75, {alpha:1, delay:1});
removeReadyButton();
}
public static function getInstance():Game{
return (_this);
}
}
}//package com.king.ludo
Section 43
//Input (com.king.ludo.Input)
package com.king.ludo {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.king.ludo.characters.*;
import com.king.ludo.utils.*;
import flash.utils.*;
import com.king.ludo.data.*;
public class Input {
private static var _moveEnabled:Boolean = false;
private static var _char:Character;
public function Input(){
super();
}
public static function autoPlay(char:Character):void{
Debug.print(("Input.autoPlay() char: " + char));
var pos = -1;
if (!char.isInPlay){
pos = Positions.getStartPosForPlayer(char.ownerId);
};
setSelectedChar(char, pos);
setTimeout(moveChar, 500, null);
}
public static function getSelectedChar():Character{
return (_char);
}
private static function setMoveEnabled(b:Boolean):void{
_moveEnabled = b;
}
public static function init():void{
}
public static function testMove(char:Character, specTargetPos:int=-1):Array{
var i:int;
var targetPosId:int;
var endpos:Array;
var contains:Boolean;
var path:Array;
var charAtPos:Character;
var movePossible:Boolean;
if (char.isInGoal){
endpos = Positions.getGoalPosForPlayer(char.ownerId);
targetPosId = (char.getCurrentPosId() + Game.latestDiceValue);
contains = false;
i = 0;
while (i < endpos.length) {
if (targetPosId == endpos[i]){
contains = true;
};
i++;
};
movePossible = contains;
} else {
if (!char.isInPlay){
targetPosId = Positions.getStartPosForPlayer(char.ownerId);
} else {
if (specTargetPos == -1){
targetPosId = (char.getCurrentPosId() + Game.latestDiceValue);
path = Positions.createPath(char.getCurrentPosId(), targetPosId, char.ownerId);
targetPosId = path[(path.length - 1)];
if (path.length < Game.latestDiceValue){
movePossible = false;
};
} else {
targetPosId = specTargetPos;
};
};
};
var chars:Array = CharacterManager.getCharactersByPositionId(targetPosId);
i = 0;
while (i < chars.length) {
charAtPos = chars[i];
if (charAtPos.ownerId == char.ownerId){
movePossible = false;
};
i++;
};
return ([movePossible, targetPosId]);
}
public static function setSelectedChar(char:Character, specTargetPos:int=-1):Boolean{
setMoveEnabled(false);
if (_char != null){
_char.deSelectChar();
_char = null;
};
_char = char;
Debug.print(("Input.setSelectedChar() _char = " + char), "ffffff");
var a:Array = testMove(char, specTargetPos);
var movePossible:Boolean = a[0];
var targetPosId:int = a[1];
var targetPos:Point = Positions.getPathPos(targetPosId);
if (movePossible){
Game.getInstance().projection.moveMarker.x = targetPos.x;
Game.getInstance().projection.moveMarker.y = targetPos.y;
Game.getInstance().projection.moveMarker.positionId = targetPosId;
Game.getInstance().projection.moveMarker.visible = true;
setTimeout(setMoveEnabled, 50, true);
return (true);
};
Game.getInstance().projection.moveMarker.visible = false;
return (false);
}
private static function moveChar(e:MouseEvent):void{
Debug.print("Input.moveChar() ", "ffffff");
if (_char == null){
Debug.print("Input.moveChar() _char == null", "ffff00");
return;
};
if (!_moveEnabled){
Debug.print("Input.moveChar() !_moveEnabled", "ffff00");
return;
};
LudoEvents.onUserMoved(_char.id, Game.getInstance().projection.moveMarker.positionId);
Comm.getInstance().sendMove(_char.id, Game.getInstance().projection.moveMarker.positionId);
Game.getInstance().projection.moveMarker.visible = false;
Main.getInstance().soundManager.getByClass(Main.getInstance().SndClick, "snd_click").play(0.35);
_char.deSelectChar();
_char.setSelectable(false);
_char = null;
setMoveEnabled(false);
}
public static function initMouseDown(clickObj:Sprite):void{
clickObj.addEventListener(MouseEvent.MOUSE_UP, moveChar, false, 0, true);
}
}
}//package com.king.ludo
Section 44
//LudoEvents (com.king.ludo.LudoEvents)
package com.king.ludo {
import com.king.ludo.utils.*;
public class LudoEvents {
private static var _listeners:Array = [];
private static var _diceThrows:int = 0;
public function LudoEvents(){
super();
}
public static function onAllUsersConnected():void{
Debug.print("LudoEvents.onAllUsersConnected()", "ffffff");
var i:int;
while (i < _listeners.length) {
_listeners[i].onAllUsersConnected();
i++;
};
}
public static function onUserDisconnected(userId:int):void{
Debug.print("LudoEvents.onUserDisconnected()", "ffffff");
var i:int;
while (i < _listeners.length) {
_listeners[i].onUserDisconnected(userId);
i++;
};
}
public static function onUserMoved(charId:int, pathId:int):void{
Debug.print((((("LudoEvents.onUserMoved(" + charId) + ", ") + pathId) + ")"), "ffffff");
var i:int;
while (i < _listeners.length) {
_listeners[i].onUserMoved(charId, pathId);
i++;
};
}
public static function onGameEnd():void{
Debug.print("LudoEvents.onGameEnd()", "ffffff");
var i:int;
while (i < _listeners.length) {
_listeners[i].onGameEnd();
i++;
};
}
public static function onTurnStart(turnOwnerId:int):void{
Debug.print((("LudoEvents.onTurnStart(" + turnOwnerId) + ")"), "ffffff");
var i:int;
while (i < _listeners.length) {
_listeners[i].onTurnStart(turnOwnerId);
i++;
};
}
public static function onUserDice(userId:int, result:int):void{
_diceThrows++;
Debug.print(((((("LudoEvents.onUserDice(" + userId) + ", ") + result) + ") id:") + _diceThrows), "ffffff");
var i:int;
while (i < _listeners.length) {
_listeners[i].onUserDice(userId, result);
i++;
};
}
public static function addListener(l:LudoListener):void{
_listeners.push(l);
}
public static function onTurnEnd():void{
Debug.print("LudoEvents.onTurnEnd()", "ffffff");
var i:int;
while (i < _listeners.length) {
_listeners[i].onTurnEnd();
i++;
};
}
}
}//package com.king.ludo
Section 45
//LudoListener (com.king.ludo.LudoListener)
package com.king.ludo {
public interface LudoListener {
function onUserDice(_arg1:int, _arg2:int):void;
function onAllUsersConnected():void;
function onUserDisconnected(:int):void;
function onTurnStart(:int):void;
function onUserMoved(_arg1:int, _arg2:int):void;
function onGameEnd(:int):void;
function onTurnEnd():void;
}
}//package com.king.ludo
Section 46
//Main (com.king.ludo.Main)
package com.king.ludo {
import flash.events.*;
import com.king.ludo.gui.*;
import flash.display.*;
import com.king.ludo.comm.*;
import com.midasplayer.sound.*;
import com.king.ludo.characters.*;
import mx.events.*;
import com.king.ludo.utils.*;
import flash.system.*;
import flash.utils.*;
import com.king.ludo.fx.*;
import com.king.ludo.data.*;
import flash.filters.*;
import flash.external.*;
public class Main extends MovieClip {
private var _725850624SndGameEnd:Class;
private var _2118823195LudoGfx:Class;
public var comm:Comm;
private var _402865052SndFall:Class;
private var _548873220SndHappy3:Class;
private var _soundBtn:BitmapButton;
private var _introScreen:PopupMsg;
private var _adNotice:MovieClip;
private var _548873221SndHappy2:Class;
private var _quitBtn:BitmapButton;
private var _2015806707Verdana:Class;
private var _musicBtn:BitmapButton;
private var _548873218SndHappy5:Class;
private var _53848086FlowerRainFlower:Class;
private var _60924857SndYourTurn:Class;
private var _548873222SndHappy1:Class;
private var _debugWindow:DebugWindow;
private var _402656330SndMark:Class;
private var _399251107SndIntro:Class;
private var _gameEnded:Boolean;// = false
private var gameShowing:Boolean;// = true
private var _1065750646SndWalkLoop:Class;
private var _1786245893AdNotice:Class;
private var _548873219SndHappy4:Class;
private var shouldHide:Boolean;// = false
private var _393639359SndClick:Class;
public var soundManager:SoundManager;
private var _1814098215SndSix:Class;
private var _loadingAnim:MovieClip;
public var gameData:String;
private var _gameQuit:Boolean;// = false
private var _88003004LudoTimeSparkleGfx:Class;
private var _1278905424CharacterGfx:Class;
public var musicManager:SoundManager;
private var _402672755SndLoop:Class;
private var _greyGame:Bitmap;
private var _54789931SndYippie:Class;
private var _game:Game;
private var _afterintroDone:Boolean;// = false
private var _401098729SndKnuff:Class;
public var parsedGameData:GameData;
private var adsShowing:Boolean;// = false
public static var random:Random;
public static var H:int = 600;
private static var _this:Main;
public static var isHost:Boolean;
public static var W:int = 755;
public static var tick:uint = 0;
public function Main(){
_2118823195LudoGfx = Main_LudoGfx;
_1278905424CharacterGfx = Main_CharacterGfx;
_88003004LudoTimeSparkleGfx = Main_LudoTimeSparkleGfx;
_2015806707Verdana = Main_Verdana;
_53848086FlowerRainFlower = Main_FlowerRainFlower;
_1786245893AdNotice = Main_AdNotice;
_399251107SndIntro = Main_SndIntro;
_402672755SndLoop = Main_SndLoop;
_725850624SndGameEnd = Main_SndGameEnd;
_402656330SndMark = Main_SndMark;
_393639359SndClick = Main_SndClick;
_60924857SndYourTurn = Main_SndYourTurn;
_1814098215SndSix = Main_SndSix;
_54789931SndYippie = Main_SndYippie;
_1065750646SndWalkLoop = Main_SndWalkLoop;
_402865052SndFall = Main_SndFall;
_401098729SndKnuff = Main_SndKnuff;
_548873222SndHappy1 = Main_SndHappy1;
_548873221SndHappy2 = Main_SndHappy2;
_548873220SndHappy3 = Main_SndHappy3;
_548873219SndHappy4 = Main_SndHappy4;
_548873218SndHappy5 = Main_SndHappy5;
super();
_this = this;
Debug.enabled = false;
if (Debug.enabled){
_debugWindow = new DebugWindow();
Debug.debugWindow = _debugWindow;
_debugWindow.x = (W - 25);
_debugWindow.y = 25;
addChild(_debugWindow);
};
Debug.print("Main.init() entry point ", "33FF55");
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.LEFT;
_loadingAnim = (new LudoTimeSparkleGfx() as MovieClip);
_loadingAnim.blendMode = BlendMode.ADD;
_loadingAnim.x = ((W / 2) - (_loadingAnim.width / 2));
_loadingAnim.y = ((H / 2) - (_loadingAnim.height / 2));
addChild(_loadingAnim);
stage.quality = StageQuality.LOW;
init();
}
public function get SndHappy2():Class{
return (this._548873221SndHappy2);
}
public function set SndHappy1(value:Class):void{
var oldValue:Object = this._548873222SndHappy1;
if (oldValue !== value){
this._548873222SndHappy1 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndHappy1", oldValue, value));
};
}
public function get SndHappy4():Class{
return (this._548873219SndHappy4);
}
public function forfeitGame():void{
if (_gameEnded){
return;
};
Players.getSelf().score = 10;
comm.sendForfeit();
}
public function gameOver(winnerId:int):void{
var msgString:String;
if (_gameEnded){
return;
};
_gameEnded = true;
_game.stopGame();
Players.removeTimeSparkle();
if (winnerId > -1){
if (Players.getNumPlayersOnline() > 1){
msgString = TextMappings.get("game_over_winner").split("{0}").join(Players.getPlayer(winnerId).name);
} else {
msgString = TextMappings.get("game_over_winner_walkover").split("{0}").join(Players.getPlayer(winnerId).name);
};
if (Players.getPlayer(winnerId).score < 200){
Players.getPlayer(winnerId).score = 200;
};
} else {
msgString = TextMappings.get("you_have_forfeited");
};
var pop:PopupMsg = new PopupMsg(msgString);
if (winnerId > -1){
pop.addDisplayObject(new Bitmap(BitmapDispenser.getBitmapData(("winner_" + winnerId))), 270, 330);
pop.drawPlayersStats();
};
pop.closable = false;
addChild(new FlowerDispenser());
addChild(pop);
fscommand("gameEnd", ("" + Players.getSelf().score));
setTimeout(gameQuit, (15 * 1000));
setTimeout(makeClosable, (2 * 1000), pop);
musicManager.getByClass(Main.getInstance().SndLoop, "snd_loop").stop();
musicManager.getByClass(Main.getInstance().SndGameEnd, "snd_game_end").play(0.25);
comm.mayDisconnect = true;
}
public function get SndHappy1():Class{
return (this._548873222SndHappy1);
}
public function get SndHappy3():Class{
return (this._548873220SndHappy3);
}
public function get SndHappy5():Class{
return (this._548873218SndHappy5);
}
public function set SndFall(value:Class):void{
var oldValue:Object = this._402865052SndFall;
if (oldValue !== value){
this._402865052SndFall = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndFall", oldValue, value));
};
}
public function showAd():void{
adsShowing = true;
if (musicManager.enabled){
musicManager.fadeTo(0, 100);
};
}
public function set SndHappy4(value:Class):void{
var oldValue:Object = this._548873219SndHappy4;
if (oldValue !== value){
this._548873219SndHappy4 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndHappy4", oldValue, value));
};
}
public function set SndHappy5(value:Class):void{
var oldValue:Object = this._548873218SndHappy5;
if (oldValue !== value){
this._548873218SndHappy5 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndHappy5", oldValue, value));
};
}
public function set SndLoop(value:Class):void{
var oldValue:Object = this._402672755SndLoop;
if (oldValue !== value){
this._402672755SndLoop = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndLoop", oldValue, value));
};
}
public function destroyGame():void{
_this = null;
}
private function init2():void{
var oa:Object;
Config.checkEnviroment();
comm = new Comm();
if (((!((Capabilities.playerType == "External"))) && (!((Capabilities.playerType == "StandAlone"))))){
oa = ExternalInterface.call("getGameData");
if ((((oa == null)) || (!(oa.success)))){
Debug.print("getGameData returned null", "ff3333");
} else {
gameData = oa.message;
};
};
if (gameData != null){
parsedGameData = GameDataParser.parseGameData(gameData);
comm.init(parsedGameData.hostName, parsedGameData.port, parsedGameData.slotId, parsedGameData.magic);
} else {
parsedGameData = new GameData();
parsedGameData.randomSeed = int((Math.random() * 9999));
Debug.print("gameData is null!", "ff3333");
};
random = new Random(parsedGameData.randomSeed);
soundManager = new SoundManager();
musicManager = new SoundManager();
_game = new Game();
_game.init();
addEventListener(Event.ENTER_FRAME, onUpdate, false, 0, true);
init3();
}
private function init3():void{
var gfx:MovieClip = (new CharacterGfx() as MovieClip);
CharacterManager.generateBitmaps(gfx, init4);
}
private function init4(e:Event=null):void{
var lobbyWindowId:uint;
stage.quality = StageQuality.HIGH;
_loadingAnim.stop();
if (_loadingAnim.parent){
_loadingAnim.parent.removeChild(_loadingAnim);
};
_loadingAnim = null;
stage.frameRate = 50;
ExternalInterface.addCallback("onUserEvent", onUserEvent);
var rv:Object = ExternalInterface.call("getParentMovieId");
if (((!((rv == null))) && (rv.success))){
lobbyWindowId = uint(rv.value);
ExternalInterface.call("addListener", "user", lobbyWindowId);
};
addChild(_game);
if (Debug.enabled){
addChild(_debugWindow);
};
var xpos:int = ((W - 36) - 1);
var ypos:int = (H - 34);
_quitBtn = new BitmapButton();
_quitBtn.setBitmap(BitmapDispenser.getBitmapData("btn_exit"));
_quitBtn.setActive(true, onQuitBtn);
_quitBtn.x = xpos;
_quitBtn.y = ypos;
xpos = (xpos - 35);
_soundBtn = new BitmapButton();
_soundBtn.setBitmap(BitmapDispenser.getBitmapData("btn_sound_on"));
_soundBtn.setActive(true, onSoundBtn);
_soundBtn.x = xpos;
_soundBtn.y = ypos;
xpos = (xpos - 35);
_musicBtn = new BitmapButton();
_musicBtn.setBitmap(BitmapDispenser.getBitmapData("btn_music_on"));
_musicBtn.setActive(true, onMusicBtn);
_musicBtn.x = xpos;
_musicBtn.y = ypos;
_introScreen = new PopupMsg(TextMappings.get("intro_text"));
_introScreen.addEventListener(MouseEvent.CLICK, doAfterIntro, false, 0, true);
addChild(_introScreen);
addChild(_musicBtn);
addChild(_soundBtn);
addChild(_quitBtn);
musicManager.getByClass(Main.getInstance().SndIntro, "snd_intro").play(0.25);
setTimeout(doAfterIntro, (20 * 1000));
_adNotice = (new AdNotice() as MovieClip);
_adNotice.gotoAndStop(1);
_adNotice.textLabel.text = TextMappings.get("wait_for_ads");
}
private function init():void{
var gfx:MovieClip = (new LudoGfx() as MovieClip);
BitmapDispenser.generateBitmaps(gfx, init2);
}
public function get SndGameEnd():Class{
return (this._725850624SndGameEnd);
}
public function set SndHappy2(value:Class):void{
var oldValue:Object = this._548873221SndHappy2;
if (oldValue !== value){
this._548873221SndHappy2 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndHappy2", oldValue, value));
};
}
public function set SndIntro(value:Class):void{
var oldValue:Object = this._399251107SndIntro;
if (oldValue !== value){
this._399251107SndIntro = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndIntro", oldValue, value));
};
}
public function set Verdana(value:Class):void{
var oldValue:Object = this._2015806707Verdana;
if (oldValue !== value){
this._2015806707Verdana = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "Verdana", oldValue, value));
};
}
public function get LudoTimeSparkleGfx():Class{
return (this._88003004LudoTimeSparkleGfx);
}
public function hideGame():void{
if (!shouldHide){
return;
};
if (musicManager.enabled){
musicManager.fadeTo(0, 100);
};
gameShowing = false;
var bmd:BitmapData = new BitmapData(W, H, false, 0);
bmd.draw(_game);
_greyGame = new Bitmap(bmd);
var filter1:BlurFilter = new BlurFilter(8, 8, BitmapFilterQuality.MEDIUM);
var filter2:ColorMatrixFilter = new ColorMatrixFilter();
var alphaIdentity:Array = [0, 0, 0, 1, 0];
var l:Number = 0.8;
var br:Number = 0.6;
var colmatrix:Array = new Array();
colmatrix = colmatrix.concat([(((0.3 * l) + (1 - l)) * br), ((0.59 * l) * br), ((0.11 * l) * br), 0, 0]);
colmatrix = colmatrix.concat([((0.3 * l) * br), (((0.59 * l) + (1 - l)) * br), ((0.11 * l) * br), 0, 0]);
colmatrix = colmatrix.concat([((0.3 * l) * br), ((0.59 * l) * br), (((0.11 * l) + (1 - l)) * br), 0, 0]);
colmatrix = colmatrix.concat(alphaIdentity);
filter2.matrix = colmatrix;
_greyGame.filters = [filter1, filter2];
addChild(_greyGame);
removeChild(_game);
addChild(_adNotice);
}
public function set SndGameEnd(value:Class):void{
var oldValue:Object = this._725850624SndGameEnd;
if (oldValue !== value){
this._725850624SndGameEnd = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndGameEnd", oldValue, value));
};
}
public function set CharacterGfx(value:Class):void{
var oldValue:Object = this._1278905424CharacterGfx;
if (oldValue !== value){
this._1278905424CharacterGfx = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "CharacterGfx", oldValue, value));
};
}
public function revealHiddenGame():void{
shouldHide = false;
if (musicManager.enabled){
musicManager.fadeTo(1, 100);
};
if (!gameShowing){
gameShowing = true;
if (_greyGame){
if (_greyGame.parent){
_greyGame.parent.removeChild(_greyGame);
};
_greyGame.bitmapData.dispose();
};
_greyGame = null;
addChildAt(_game, 0);
removeChild(_adNotice);
};
}
public function get SndFall():Class{
return (this._402865052SndFall);
}
public function set SndMark(value:Class):void{
var oldValue:Object = this._402656330SndMark;
if (oldValue !== value){
this._402656330SndMark = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndMark", oldValue, value));
};
}
public function hasGameEnded():Boolean{
return (_gameEnded);
}
public function get SndWalkLoop():Class{
return (this._1065750646SndWalkLoop);
}
private function onUserEvent(evt:String):void{
var evtXML:XML = new XML(evt);
var cmd:String = evtXML.command;
Debug.print(((("Main.onUserEvent() cmd: " + cmd) + " evt: ") + evt), "ffffff");
if (cmd == "adStart"){
showAd();
} else {
if (cmd == "adDone"){
stopShowingAd();
};
};
}
public function gameQuit(e:Event=null):void{
if (_gameQuit){
return;
};
Debug.print("Main.gameQuit()");
_gameQuit = true;
fscommand("gameQuit", "");
}
public function set SndClick(value:Class):void{
var oldValue:Object = this._393639359SndClick;
if (oldValue !== value){
this._393639359SndClick = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndClick", oldValue, value));
};
}
public function set SndYourTurn(value:Class):void{
var oldValue:Object = this._60924857SndYourTurn;
if (oldValue !== value){
this._60924857SndYourTurn = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndYourTurn", oldValue, value));
};
}
public function get SndLoop():Class{
return (this._402672755SndLoop);
}
public function get SndIntro():Class{
return (this._399251107SndIntro);
}
private function onUpdate(e:Event):void{
comm.tick();
soundManager.update();
musicManager.update();
}
public function maybeShowAd():void{
Debug.print("Main.maybeShowAd()");
fscommand("showAd");
setTimeout(hideGame, (1 * 1000));
shouldHide = true;
}
public function get SndMark():Class{
return (this._402656330SndMark);
}
public function get CharacterGfx():Class{
return (this._1278905424CharacterGfx);
}
public function get SndYourTurn():Class{
return (this._60924857SndYourTurn);
}
private function onQuitBtn(b:BasicButton):void{
forfeitGame();
}
public function get SndClick():Class{
return (this._393639359SndClick);
}
public function set LudoTimeSparkleGfx(value:Class):void{
var oldValue:Object = this._88003004LudoTimeSparkleGfx;
if (oldValue !== value){
this._88003004LudoTimeSparkleGfx = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "LudoTimeSparkleGfx", oldValue, value));
};
}
public function onTurnStart(turnOwnerId:int):void{
revealHiddenGame();
}
public function set LudoGfx(value:Class):void{
var oldValue:Object = this._2118823195LudoGfx;
if (oldValue !== value){
this._2118823195LudoGfx = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "LudoGfx", oldValue, value));
};
}
private function onSoundBtn(b:BasicButton):void{
if (soundManager.enabled){
soundManager.enabled = false;
soundManager.setVolume(0);
_soundBtn.setBitmap(BitmapDispenser.getBitmapData("btn_sound_off"));
} else {
soundManager.enabled = true;
soundManager.setVolume(1);
_soundBtn.setBitmap(BitmapDispenser.getBitmapData("btn_sound_on"));
};
}
public function set FlowerRainFlower(value:Class):void{
var oldValue:Object = this._53848086FlowerRainFlower;
if (oldValue !== value){
this._53848086FlowerRainFlower = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "FlowerRainFlower", oldValue, value));
};
}
public function get SndYippie():Class{
return (this._54789931SndYippie);
}
public function get SndSix():Class{
return (this._1814098215SndSix);
}
private function doAfterIntro(e:Event=null):void{
if (_afterintroDone){
return;
};
_afterintroDone = true;
musicManager.getByClass(Main.getInstance().SndIntro, "snd_intro").stop();
musicManager.getByClass(Main.getInstance().SndLoop, "snd_loop").loop(0.25);
_introScreen.close(null);
_introScreen = null;
_game.showReadyButton();
}
public function set SndSix(value:Class):void{
var oldValue:Object = this._1814098215SndSix;
if (oldValue !== value){
this._1814098215SndSix = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndSix", oldValue, value));
};
}
public function set SndKnuff(value:Class):void{
var oldValue:Object = this._401098729SndKnuff;
if (oldValue !== value){
this._401098729SndKnuff = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndKnuff", oldValue, value));
};
}
public function set SndYippie(value:Class):void{
var oldValue:Object = this._54789931SndYippie;
if (oldValue !== value){
this._54789931SndYippie = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndYippie", oldValue, value));
};
}
public function get LudoGfx():Class{
return (this._2118823195LudoGfx);
}
public function stopShowingAd():void{
if (adsShowing){
revealHiddenGame();
};
comm.send("LAD");
adsShowing = false;
}
public function set SndWalkLoop(value:Class):void{
var oldValue:Object = this._1065750646SndWalkLoop;
if (oldValue !== value){
this._1065750646SndWalkLoop = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndWalkLoop", oldValue, value));
};
}
public function get SndKnuff():Class{
return (this._401098729SndKnuff);
}
public function get FlowerRainFlower():Class{
return (this._53848086FlowerRainFlower);
}
public function get Verdana():Class{
return (this._2015806707Verdana);
}
private function onMusicBtn(b:BasicButton):void{
if (musicManager.enabled){
musicManager.enabled = false;
musicManager.setVolume(0);
_musicBtn.setBitmap(BitmapDispenser.getBitmapData("btn_music_off"));
} else {
musicManager.enabled = true;
musicManager.setVolume(1);
_musicBtn.setBitmap(BitmapDispenser.getBitmapData("btn_music_on"));
};
}
public function set SndHappy3(value:Class):void{
var oldValue:Object = this._548873220SndHappy3;
if (oldValue !== value){
this._548873220SndHappy3 = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "SndHappy3", oldValue, value));
};
}
public function get AdNotice():Class{
return (this._1786245893AdNotice);
}
private function makeClosable(pop:PopupMsg):void{
pop.closable = true;
pop.addEventListener(MouseEvent.CLICK, gameQuit, false, 0, true);
pop.buttonMode = true;
}
public function set AdNotice(value:Class):void{
var oldValue:Object = this._1786245893AdNotice;
if (oldValue !== value){
this._1786245893AdNotice = value;
this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "AdNotice", oldValue, value));
};
}
public static function getInstance():Main{
return (_this);
}
}
}//package com.king.ludo
Section 47
//Main_AdNotice (com.king.ludo.Main_AdNotice)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_AdNotice extends MovieClipAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 48
//Main_CharacterGfx (com.king.ludo.Main_CharacterGfx)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_CharacterGfx extends MovieClipAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 49
//Main_FlowerRainFlower (com.king.ludo.Main_FlowerRainFlower)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_FlowerRainFlower extends MovieClipAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 50
//Main_LudoGfx (com.king.ludo.Main_LudoGfx)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_LudoGfx extends MovieClipAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 51
//Main_LudoTimeSparkleGfx (com.king.ludo.Main_LudoTimeSparkleGfx)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_LudoTimeSparkleGfx extends MovieClipAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 52
//Main_SndClick (com.king.ludo.Main_SndClick)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndClick extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 53
//Main_SndFall (com.king.ludo.Main_SndFall)
package com.king.ludo {
import mx.core.*;
public class Main_SndFall extends SoundAsset {
}
}//package com.king.ludo
Section 54
//Main_SndGameEnd (com.king.ludo.Main_SndGameEnd)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndGameEnd extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 55
//Main_SndHappy1 (com.king.ludo.Main_SndHappy1)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndHappy1 extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 56
//Main_SndHappy2 (com.king.ludo.Main_SndHappy2)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndHappy2 extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 57
//Main_SndHappy3 (com.king.ludo.Main_SndHappy3)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndHappy3 extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 58
//Main_SndHappy4 (com.king.ludo.Main_SndHappy4)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndHappy4 extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 59
//Main_SndHappy5 (com.king.ludo.Main_SndHappy5)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndHappy5 extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 60
//Main_SndIntro (com.king.ludo.Main_SndIntro)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndIntro extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 61
//Main_SndKnuff (com.king.ludo.Main_SndKnuff)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndKnuff extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 62
//Main_SndLoop (com.king.ludo.Main_SndLoop)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndLoop extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 63
//Main_SndMark (com.king.ludo.Main_SndMark)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndMark extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 64
//Main_SndSix (com.king.ludo.Main_SndSix)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndSix extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 65
//Main_SndWalkLoop (com.king.ludo.Main_SndWalkLoop)
package com.king.ludo {
import mx.core.*;
public class Main_SndWalkLoop extends SoundAsset {
}
}//package com.king.ludo
Section 66
//Main_SndYippie (com.king.ludo.Main_SndYippie)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndYippie extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 67
//Main_SndYourTurn (com.king.ludo.Main_SndYourTurn)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_SndYourTurn extends SoundAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 68
//Main_Verdana (com.king.ludo.Main_Verdana)
package com.king.ludo {
import flash.display.*;
import mx.core.*;
public class Main_Verdana extends FontAsset {
public var textLabel:DisplayObject;
}
}//package com.king.ludo
Section 69
//Player (com.king.ludo.Player)
package com.king.ludo {
import com.king.ludo.gui.*;
import com.midasplayer.avatar.*;
public class Player {
public var name:String;
private var _score:int;// = 0
public var charsInGoal:int;// = 0
public var avatar:String;
public var id:int;
private var _knuffs:int;// = 0
public var playerPanel:PlayerPanel;
private var _knockedDown:int;// = 0
private var _sixRolls:int;// = 0
public var isConnected:Boolean;
public function Player(id:int, name:String, avatar:String){
super();
this.id = id;
this.name = name;
this.avatar = avatar;
isConnected = true;
}
public function get knuffs():int{
return (_knuffs);
}
public function set knuffs(knuffs:int):void{
_knuffs = knuffs;
playerPanel.setAvatarMood(AvatarMood.MOOD_HAPPY);
}
public function get score():int{
return (_score);
}
public function get sixRolls():int{
return (_sixRolls);
}
public function set score(score:int):void{
_score = score;
}
public function set sixRolls(sixRolls:int):void{
_sixRolls = sixRolls;
playerPanel.setAvatarMood(AvatarMood.MOOD_HAPPY);
}
public function statsToString():String{
return (String(((((((id + ",") + knuffs) + ",") + sixRolls) + ",") + knockedDown)));
}
public function getHappy():void{
playerPanel.setAvatarMood(AvatarMood.MOOD_HAPPY);
}
public function get knockedDown():int{
return (_knockedDown);
}
public function set knockedDown(knockedDown:int):void{
_knockedDown = knockedDown;
playerPanel.setAvatarMood(AvatarMood.MOOD_ANGRY);
}
}
}//package com.king.ludo
Section 70
//Players (com.king.ludo.Players)
package com.king.ludo {
import flash.events.*;
import com.king.ludo.gui.*;
import flash.display.*;
import flash.geom.*;
import com.king.ludo.comm.*;
import com.king.ludo.utils.*;
import flash.system.*;
import flash.utils.*;
import com.midasplayer.avatar.*;
import flash.filters.*;
public class Players extends Sprite implements LudoListener {
private var _avatarLoadedEvent:Event;
private var _avatarLoader:AvatarLoader;
private static var _selfId:int;
private static var _timeSparkle:MovieClip;
private static var _positions:Array = [new Point(55, 430), new Point(55, 55), new Point(690, 55), new Point(690, 430)];
private static var _players:Array = [];
private static var _remainingPlayers:int = 0;
private static var _this:Players;
public function Players(){
super();
_this = this;
LudoEvents.addListener(this);
var SparkleGfx:Class = Main.getInstance().LudoTimeSparkleGfx;
_timeSparkle = (new (SparkleGfx) as MovieClip);
_timeSparkle.blendMode = BlendMode.ADD;
_timeSparkle.alpha = 0.66;
_timeSparkle.stop();
if (((!((Capabilities.playerType == "External"))) && (!((Capabilities.playerType == "StandAlone"))))){
_avatarLoader = new AvatarLoader();
_avatarLoader.load(this.avatarLoaded, this.avatarLoadProgress);
};
}
public function onUserDisconnected(userId:int):void{
playerLeft(userId);
}
public function onUserMoved(charId:int, pathId:int):void{
}
public function onAllUsersConnected():void{
attemptToCreateAvatars();
}
public function onTurnStart(turnOwnerId:int):void{
getPlayer(turnOwnerId).playerPanel.setActive(true);
var p:Point = getPlayer(turnOwnerId).playerPanel.getFlowerPos();
_timeSparkle.play();
_timeSparkle.x = (p.x - (_timeSparkle.width / 2));
_timeSparkle.y = ((p.y - (_timeSparkle.height / 2)) - 5);
addChild(_timeSparkle);
}
public function onUserDice(userId:int, result:int):void{
}
private function attemptToCreateAvatars():void{
var i:int;
var p:Player;
if (_avatarLoadedEvent != null){
i = 0;
while (i < _players.length) {
p = _players[i];
p.playerPanel.createAvatar(_avatarLoadedEvent);
i++;
};
} else {
if (_avatarLoader != null){
setTimeout(attemptToCreateAvatars, 1000);
};
};
}
public function onGameEnd(winnerId:int):void{
}
public function avatarLoadProgress(e:Event):void{
}
private function avatarLoaded(e:Event):void{
_avatarLoadedEvent = e;
Debug.print("Avatar loaded", "99FFFF");
}
public function onTurnEnd():void{
var i:int;
while (i < _players.length) {
getPlayer(i).playerPanel.setActive(false);
i++;
};
_timeSparkle.stop();
if (_timeSparkle.parent){
_timeSparkle.parent.removeChild(_timeSparkle);
};
}
public static function getNumPlayers():int{
return (_players.length);
}
public static function removeTimeSparkle():void{
_timeSparkle.stop();
if (_timeSparkle.parent){
_timeSparkle.parent.removeChild(_timeSparkle);
};
}
public static function playerLeft(id:int):void{
if (!getPlayer(id).isConnected){
return;
};
getPlayer(id).playerPanel.alpha = 0.6;
getPlayer(id).isConnected = false;
var filter:ColorMatrixFilter = new ColorMatrixFilter();
var alphaIdentity:Array = [0, 0, 0, 1, 0];
var grayluma:Array = [0.3, 0.59, 0.11, 0, 0];
var colmatrix:Array = new Array();
colmatrix = colmatrix.concat(grayluma);
colmatrix = colmatrix.concat(grayluma);
colmatrix = colmatrix.concat(grayluma);
colmatrix = colmatrix.concat(alphaIdentity);
filter.matrix = colmatrix;
getPlayer(id).playerPanel.filters = [filter];
getPlayer(id).playerPanel.showChatMsg(TextMappings.get("opponent_disconnected_short_text"));
_remainingPlayers--;
if (_remainingPlayers < 2){
setTimeout(Main.getInstance().gameOver, 1500, Players.getSelf().id);
removeTimeSparkle();
};
}
public static function getSelf():Player{
return (getPlayer(_selfId));
}
public static function setSelfId(self:int):void{
_selfId = self;
}
public static function addPlayer(p:Player):void{
_players[p.id] = p;
var playerPanel:PlayerPanel = new PlayerPanel(p);
p.playerPanel = playerPanel;
playerPanel.x = _positions[p.id].x;
playerPanel.y = _positions[p.id].y;
_this.addChild(playerPanel);
_remainingPlayers++;
}
public static function getNumPlayersOnline():int{
return (_remainingPlayers);
}
public static function getPlayer(id:int):Player{
return (_players[id]);
}
}
}//package com.king.ludo
Section 71
//Projection (com.king.ludo.Projection)
package com.king.ludo {
import flash.events.*;
import com.king.ludo.gui.*;
import flash.display.*;
import flash.geom.*;
import com.king.ludo.utils.*;
import flash.utils.*;
import com.king.ludo.data.*;
public class Projection extends Sprite implements Tickable {
public var moveMarker:MoveMarker;
private var _updateList:Array;
private var _lastTick:int;
private var _lastSort:int;// = 0
public var center:Point;
private var _collect:Number;
private var _sortList:Array;
private static const GRID_SIZE:int = 43;
public function Projection(){
_sortList = [];
_updateList = [];
center = new Point(374, 295);
super();
moveMarker = new MoveMarker();
moveMarker.visible = false;
addChild(moveMarker);
addToSortList(moveMarker.getArrow());
Input.initMouseDown(moveMarker);
Input.initMouseDown(moveMarker.getArrow());
var flower:Sprite = new Sprite();
flower.mouseChildren = false;
flower.hitArea = new Sprite();
var flBit:Bitmap = new Bitmap(BitmapDispenser.getBitmapData("main_flower"));
flBit.x = ((-(flBit.width) / 2) + 2);
flBit.y = (-(flBit.height) * 0.78);
flower.x = center.x;
flower.y = center.y;
flower.addChild(flBit);
addChild(flower);
_sortList.push(flower);
sortGraphics();
_collect = 0;
}
private function collectionPosition(e:MouseEvent):void{
Debug.print((((((("positions[" + _collect) + "] = new Point(") + Main.getInstance().mouseX) + ", ") + Main.getInstance().mouseY) + ");"), "ffffff");
_collect++;
}
public function sortGraphics():void{
if ((getTimer() - _lastSort) < 200){
return;
};
_sortList.sortOn("y", Array.NUMERIC);
var i:int;
while (i < _sortList.length) {
addChild(_sortList[i]);
i++;
};
addChild(moveMarker.getArrow());
_lastSort = getTimer();
}
public function addToUpdateList(d:DisplayObject):void{
_updateList.push(d);
}
public function removeFromSortList(d:DisplayObject):void{
var i:int;
while (i < _sortList.length) {
if (d == _sortList[i]){
_sortList.splice(i, 1);
return;
};
i++;
};
}
public function addToSortList(d:DisplayObject):void{
_sortList.push(d);
}
public function removeFromUpdateList(d:DisplayObject):void{
var i:int;
while (i < _updateList.length) {
if (d == _updateList[i]){
_updateList.splice(i, 1);
return;
};
i++;
};
}
public function tick():void{
var i:int;
sortGraphics();
moveMarker.tick();
if ((getTimer() - _lastTick) > 20){
i = 0;
while (i < _updateList.length) {
_updateList[i].tick();
i++;
};
_lastTick = getTimer();
};
}
}
}//package com.king.ludo
Section 72
//Tickable (com.king.ludo.Tickable)
package com.king.ludo {
public interface Tickable {
function tick():void;
}
}//package com.king.ludo
Section 73
//AvatarLoader (com.midasplayer.avatar.AvatarLoader)
package com.midasplayer.avatar {
import flash.events.*;
import flash.display.*;
import com.king.ludo.utils.*;
import mx.rpc.soap.*;
import flash.system.*;
import flash.net.*;
import flash.external.*;
public class AvatarLoader {
private var path:String;
private var isMoneyGame:Boolean;
private var loaderId:int;
private var progressCallback:Function;
private var completeCallback:Function;
public function AvatarLoader(){
super();
path = "AvatarManager.swf";
progressCallback = null;
completeCallback = null;
isMoneyGame = false;
var p:Object = ExternalInterface.call("isMoneyGame");
if (p != null){
isMoneyGame = (p.message == 1);
};
}
public function load(callbackComplete:Function, progressCallback:Function=null):void{
this.completeCallback = callbackComplete;
this.progressCallback = progressCallback;
if (isMoneyGame){
moneyLoad();
} else {
simpleLoad();
};
}
private function onLoad(e:LoadEvent):void{
Debug.print(("AvatarLoader.onLoad() " + e));
}
private function moneyLoad():void{
ExternalInterface.addCallback("onSwfProgress", onSwfProgress);
var p:Object = ExternalInterface.call("preloadSwf", path);
if (p != null){
loaderId = p.message;
};
}
private function ioErrorHandler(e:IOErrorEvent):void{
Debug.print(("AvatarLoader.ioErrorHandler() err " + e), "ff3333");
}
private function onLoadInit(e:Event):void{
Debug.print(("AvatarLoader.onLoadInit() complete! ap1 " + e));
}
public function onSwfProgress(loaderId:int, statusCode:int, localPath:String):void{
Debug.print(((("AvatarLoader.onSwfProgress() status: " + statusCode) + " , ") + localPath), "99FFFF");
if (statusCode < 100){
};
if (statusCode == 100){
path = localPath;
simpleLoad();
} else {
if (statusCode < 0){
};
};
}
private function simpleLoad():void{
var avatarContext:LoaderContext = new LoaderContext();
avatarContext.applicationDomain = ApplicationDomain.currentDomain;
var urlReq:URLRequest = new URLRequest(path);
var avatarLdr:Loader = new Loader();
if (((!(isMoneyGame)) && (!((progressCallback == null))))){
avatarLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressCallback);
};
if (completeCallback != null){
avatarLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, completeCallback);
};
avatarLdr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
avatarLdr.contentLoaderInfo.addEventListener(LoadEvent.LOAD, onLoad, false, 0, true);
avatarLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadInit, false, 0, true);
avatarLdr.load(urlReq, avatarContext);
}
}
}//package com.midasplayer.avatar
Section 74
//AvatarMood (com.midasplayer.avatar.AvatarMood)
package com.midasplayer.avatar {
public class AvatarMood {
public static const MOOD_ANGRY:String = "angry";
public static const AVATAR_CROWN_URL:String = "/images/games/crowns/";
public static const MOOD_MAD:String = "mad";
public static const MOOD_TEASING:String = "teasing";
public static const MOOD_SUPERIOR:String = "superior";
public static const MOOD_SURPRISED:String = "surprised";
public static const MOOD_TIRED:String = "tired";
public static const MOOD_HAPPY:String = "happy";
public static const MOOD_ASHAMED:String = "ashamed";
public static const AVATAR_EXTERNAL_URL:String = "/avatar/external/";
public static const MOOD_NEUTRAL:String = "neutral";
public function AvatarMood(){
super();
}
}
}//package com.midasplayer.avatar
Section 75
//ManagedSound (com.midasplayer.sound.ManagedSound)
package com.midasplayer.sound {
import flash.media.*;
public class ManagedSound {
public var activeSounds:Array;
private var manager:SoundManager;
private var ClassReference:Class;
public function ManagedSound(manager:SoundManager, ClassReference:Class){
super();
activeSounds = new Array();
this.manager = manager;
this.ClassReference = ClassReference;
}
public function stop():void{
var i:int;
while (i < activeSounds.length) {
activeSounds[i].stop();
i++;
};
}
public function play(volume:Number=1, pan:Number=0):ManagedSoundChannel{
if (!manager.enabled){
volume = 0;
};
var channel:SoundChannel = new ClassReference().play(0, 0, new SoundTransform(volume, pan));
return (new ManagedSoundChannel(manager, this, channel));
}
public function loop(volume:Number=1, pan:Number=0):ManagedSoundChannel{
if (!manager.enabled){
volume = 0;
};
var channel:SoundChannel = new ClassReference().play(0, 999999999, new SoundTransform(volume, pan));
return (new ManagedSoundChannel(manager, this, channel));
}
public function fadeToAndStop(newVolume:Number, time:Number):void{
var i:int;
while (i < activeSounds.length) {
activeSounds[i].fadeToAndStop(newVolume, time);
i++;
};
}
public function isPlaying():Boolean{
return ((activeSounds.length > 0));
}
public function update():void{
var i:int;
while (i < activeSounds.length) {
activeSounds[i].update();
i++;
};
}
public function fadeTo(newVolume:Number, time:Number):void{
var i:int;
while (i < activeSounds.length) {
activeSounds[i].fadeTo(newVolume, time);
i++;
};
}
public function panTo(newPan:Number, time:Number):void{
var i:int;
while (i < activeSounds.length) {
activeSounds[i].panTo(newPan, time);
i++;
};
}
public function setPan(pan:Number):void{
var i:int;
while (i < activeSounds.length) {
activeSounds[i].setPan(pan);
i++;
};
}
public function setVolume(volume:Number):void{
var i:int;
while (i < activeSounds.length) {
activeSounds[i].setVolume(volume);
i++;
};
}
}
}//package com.midasplayer.sound
Section 76
//ManagedSoundChannel (com.midasplayer.sound.ManagedSoundChannel)
package com.midasplayer.sound {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class ManagedSoundChannel {
private var fadeStartVolume:Number;// = -1
private var channel:SoundChannel;
private var fadeEndVolume:Number;// = -1
private var targetVolume:Number;
private var targetPan:Number;
private var sound:ManagedSound;
private var stopAfterFade:Boolean;// = false
private var panEndTime:Number;// = -1
private var fadeEndTime:Number;// = -1
private var manager:SoundManager;
private var playing:Boolean;// = true
private var panStartTime:Number;// = -1
private var fadeStartTime:Number;// = -1
private var panEndVolume:Number;// = -1
private var panStartVolume:Number;// = -1
public function ManagedSoundChannel(manager:SoundManager, sound:ManagedSound, channel:SoundChannel){
super();
this.manager = manager;
this.sound = sound;
this.channel = channel;
sound.activeSounds.push(this);
if (channel == null){
soundComplete(null);
return;
};
channel.addEventListener(Event.SOUND_COMPLETE, soundComplete);
targetVolume = channel.soundTransform.volume;
targetPan = channel.soundTransform.pan;
update();
}
public function stop():void{
if (!playing){
return;
};
if (channel == null){
return;
};
channel.stop();
soundComplete(null);
}
public function update():void{
var t:Number;
if (!playing){
return;
};
if (fadeStartTime >= 0){
t = ((getTimer() - fadeStartTime) / (fadeEndTime - fadeStartTime));
if (t < 0){
t = 0;
};
if (t > 1){
t = 1;
};
targetVolume = (fadeStartVolume + ((fadeEndVolume - fadeStartVolume) * t));
targetVolume = (targetVolume * targetVolume);
if (t == 1){
fadeStartTime = -1;
};
if ((((t == 1)) && (stopAfterFade))){
stop();
};
};
if (panStartTime >= 0){
t = ((getTimer() - panStartTime) / (panEndTime - panStartTime));
if (t < 0){
t = 0;
};
if (t > 1){
t = 1;
};
targetPan = (panStartVolume + ((panEndVolume - panStartVolume) * t));
if (t == 1){
panStartTime = -1;
};
};
var volume:Number = (targetVolume * manager.volume);
var pan:Number = targetPan;
if (channel == null){
return;
};
if (((!((volume == channel.soundTransform.volume))) || (!((pan == channel.soundTransform.pan))))){
channel.soundTransform = new SoundTransform(volume, pan);
};
}
public function panTo(newPan:Number, time:Number):void{
if (!playing){
return;
};
panStartVolume = targetPan;
panEndVolume = newPan;
panStartTime = getTimer();
panEndTime = (getTimer() + time);
}
public function fadeTo(newVolume:Number, time:Number):void{
if (!playing){
return;
};
fadeStartVolume = Math.sqrt(targetVolume);
fadeEndVolume = Math.sqrt(newVolume);
fadeStartTime = getTimer();
fadeEndTime = (getTimer() + time);
stopAfterFade = false;
}
public function setPan(pan:Number):void{
if (!playing){
return;
};
if (channel == null){
return;
};
channel.soundTransform.pan = pan;
panStartTime = -1;
update();
}
public function fadeToAndStop(newVolume:Number, time:Number):void{
if (!playing){
return;
};
fadeTo(newVolume, time);
stopAfterFade = true;
}
public function setVolume(volume:Number):void{
if (!playing){
return;
};
stopAfterFade = false;
this.targetVolume = volume;
fadeStartTime = -1;
update();
}
public function soundComplete(e:Event):void{
if (!playing){
return;
};
sound.activeSounds.splice(sound.activeSounds.indexOf(this), 1);
playing = false;
}
public function isPlaying():Boolean{
return (playing);
}
}
}//package com.midasplayer.sound
Section 77
//SoundManager (com.midasplayer.sound.SoundManager)
package com.midasplayer.sound {
import flash.utils.*;
public class SoundManager {
private var fadeStartVolume:Number;// = -1
public var enabled:Boolean;// = true
private var lastTime:Number;// = -1
private var managedSounds:Array;
private var fadeEndTime:Number;// = -1
private var fadeStartTime:Number;// = -1
private var fadeEndVolume:Number;// = -1
public var volume:Number;// = 1
private var managedSoundMap:Object;
public function SoundManager(){
super();
managedSoundMap = new Object();
managedSounds = new Array();
}
public function getByClass(sound:Class, id:String):ManagedSound{
if (managedSoundMap[id] == null){
managedSoundMap[id] = new ManagedSound(this, sound);
managedSounds.push(managedSoundMap[id]);
};
return (managedSoundMap[id]);
}
public function update():void{
var t:Number;
var now:Number = getTimer();
if (lastTime < 0){
lastTime = now;
};
if (fadeStartTime >= 0){
t = ((getTimer() - fadeStartTime) / (fadeEndTime - fadeStartTime));
if (t < 0){
t = 0;
};
if (t > 1){
t = 1;
};
volume = (fadeStartVolume + ((fadeEndVolume - fadeStartVolume) * t));
volume = (volume * volume);
if (t == 1){
fadeStartTime = -1;
};
};
var i:int;
while (i < managedSounds.length) {
managedSounds[i].update();
i++;
};
}
public function stopAll():void{
var i:int;
while (i < managedSounds.length) {
managedSounds[i].stop();
i++;
};
}
public function get(name:String):ManagedSound{
var ClassReference:Class;
if (managedSoundMap[name] == null){
ClassReference = (getDefinitionByName(name) as Class);
if (ClassReference == null){
ClassReference = (getDefinitionByName(("sound." + name)) as Class);
};
if (ClassReference == null){
ClassReference = (getDefinitionByName(("snd." + name)) as Class);
};
if (ClassReference == null){
throw (new Error(("Failed to find sound " + name)));
};
managedSoundMap[name] = new ManagedSound(this, ClassReference);
managedSounds.push(managedSoundMap[name]);
};
return (managedSoundMap[name]);
}
public function fadeTo(newVolume:Number, time:Number):void{
fadeStartVolume = Math.sqrt(volume);
fadeEndVolume = Math.sqrt(newVolume);
fadeStartTime = getTimer();
fadeEndTime = (getTimer() + time);
}
public function setVolume(newVolume:Number):void{
this.volume = newVolume;
fadeStartTime = -1;
}
}
}//package com.midasplayer.sound
Section 78
//Linear (gs.easing.Linear)
package gs.easing {
public class Linear {
public function Linear(){
super();
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
}
public static function easeNone(t:Number, b:Number, c:Number, d:Number):Number{
return ((((c * t) / d) + b));
}
}
}//package gs.easing
Section 79
//TweenLite (gs.TweenLite)
package gs {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public class TweenLite {
public var delay:Number;
protected var _hasUpdate:Boolean;
protected var _subTweens:Array;
protected var _initted:Boolean;
public var startTime:int;
public var target:Object;
public var duration:Number;
protected var _hst:Boolean;
protected var _isDisplayObject:Boolean;
protected var _active:Boolean;
public var tweens:Array;
public var vars:Object;
public var initTime:int;
protected var _timeScale:Number;
private static var _timer:Timer = new Timer(2000);
private static var _classInitted:Boolean;
public static var defaultEase:Function = TweenLite.easeOut;
public static var version:Number = 8.16;
protected static var _all:Dictionary = new Dictionary();
private static var _sprite:Sprite = new Sprite();
protected static var _curTime:uint;
public static var overwriteManager:Object;
public static var killDelayedCallsTo:Function = TweenLite.killTweensOf;
private static var _listening:Boolean;
public function TweenLite($target:Object, $duration:Number, $vars:Object){
var v:*;
super();
if ($target == null){
return;
};
if (!_classInitted){
_curTime = getTimer();
_sprite.addEventListener(Event.ENTER_FRAME, executeAll);
if (overwriteManager == null){
overwriteManager = {mode:1, enabled:false};
};
_classInitted = true;
};
this.vars = $vars;
this.duration = (($duration) || (0.001));
this.delay = (($vars.delay) || (0));
_timeScale = (($vars.timeScale) || (1));
_active = ((($duration == 0)) && ((this.delay == 0)));
this.target = $target;
_isDisplayObject = ($target is DisplayObject);
if (!(this.vars.ease is Function)){
this.vars.ease = defaultEase;
};
if (this.vars.easeParams != null){
this.vars.proxiedEase = this.vars.ease;
this.vars.ease = easeProxy;
};
if (!isNaN(Number(this.vars.autoAlpha))){
this.vars.alpha = Number(this.vars.autoAlpha);
this.vars.visible = (this.vars.alpha > 0);
};
this.tweens = [];
_subTweens = [];
_hst = (_initted = false);
this.initTime = _curTime;
this.startTime = (this.initTime + (this.delay * 1000));
var mode:int = (((($vars.overwrite == undefined)) || (((!(overwriteManager.enabled)) && (($vars.overwrite > 1)))))) ? overwriteManager.mode : int($vars.overwrite);
if ((((_all[$target] == undefined)) || (((!(($target == null))) && ((mode == 1)))))){
delete _all[$target];
_all[$target] = new Dictionary(true);
} else {
if ((((mode > 1)) && ((this.delay == 0)))){
overwriteManager.manageOverwrites(this, _all[$target]);
};
};
_all[$target][this] = this;
if ((((((this.vars.runBackwards == true)) && (!((this.vars.renderOnStart == true))))) || (_active))){
initTweenVals();
if (_active){
render((this.startTime + 1));
} else {
render(this.startTime);
};
v = this.vars.visible;
if (this.vars.isTV == true){
v = this.vars.exposedProps.visible;
};
if (((((!((v == null))) && ((this.vars.runBackwards == true)))) && (_isDisplayObject))){
this.target.visible = Boolean(v);
};
};
if (((!(_listening)) && (!(_active)))){
_timer.addEventListener("timer", killGarbage);
_timer.start();
_listening = true;
};
}
protected function addSubTween($name:String, $proxy:Function, $target:Object, $props:Object, $info:Object=null):void{
var p:String;
var sub:Object = {name:$name, proxy:$proxy, target:$target, info:$info};
_subTweens[_subTweens.length] = sub;
for (p in $props) {
if (typeof($props[p]) == "number"){
this.tweens[this.tweens.length] = {o:$target, p:p, s:$target[p], c:($props[p] - $target[p]), sub:sub, name:$name};
} else {
this.tweens[this.tweens.length] = {o:$target, p:p, s:$target[p], c:Number($props[p]), sub:sub, name:$name};
};
};
_hst = true;
}
public function initTweenVals($hrp:Boolean=false, $reservedProps:String=""):void{
var p:String;
var i:int;
var endArray:Array;
var clr:ColorTransform;
var endClr:ColorTransform;
var tp:Object;
var v:Object = this.vars;
if (v.isTV == true){
v = v.exposedProps;
};
if (((((!($hrp)) && (!((this.delay == 0))))) && (overwriteManager.enabled))){
overwriteManager.manageOverwrites(this, _all[this.target]);
};
if ((this.target is Array)){
endArray = ((this.vars.endArray) || ([]));
i = 0;
while (i < endArray.length) {
if (((!((this.target[i] == endArray[i]))) && (!((this.target[i] == undefined))))){
this.tweens[this.tweens.length] = {o:this.target, p:i.toString(), s:this.target[i], c:(endArray[i] - this.target[i]), name:i.toString()};
};
i++;
};
} else {
if (((((!((typeof(v.tint) == "undefined"))) || ((this.vars.removeTint == true)))) && (_isDisplayObject))){
clr = this.target.transform.colorTransform;
endClr = new ColorTransform();
if (v.alpha != undefined){
endClr.alphaMultiplier = v.alpha;
delete v.alpha;
} else {
endClr.alphaMultiplier = this.target.alpha;
};
if (((!((this.vars.removeTint == true))) && (((((!((v.tint == null))) && (!((v.tint == ""))))) || ((v.tint == 0)))))){
endClr.color = v.tint;
};
addSubTween("tint", tintProxy, {progress:0}, {progress:1}, {target:this.target, color:clr, endColor:endClr});
};
if (((!((v.frame == null))) && (_isDisplayObject))){
addSubTween("frame", frameProxy, {frame:this.target.currentFrame}, {frame:v.frame}, {target:this.target});
};
if (((!(isNaN(this.vars.volume))) && (this.target.hasOwnProperty("soundTransform")))){
addSubTween("volume", volumeProxy, this.target.soundTransform, {volume:this.vars.volume}, {target:this.target});
};
for (p in v) {
if ((((((((((((((((((((((((((((((((((((((p == "ease")) || ((p == "delay")))) || ((p == "overwrite")))) || ((p == "onComplete")))) || ((p == "onCompleteParams")))) || ((p == "runBackwards")))) || ((p == "visible")))) || ((p == "autoOverwrite")))) || ((p == "persist")))) || ((p == "onUpdate")))) || ((p == "onUpdateParams")))) || ((p == "autoAlpha")))) || ((((p == "timeScale")) && (!((this.target is TweenLite))))))) || ((p == "onStart")))) || ((p == "onStartParams")))) || ((p == "renderOnStart")))) || ((p == "proxiedEase")))) || ((p == "easeParams")))) || ((($hrp) && (!(($reservedProps.indexOf(((" " + p) + " ")) == -1))))))){
} else {
if (((!(((_isDisplayObject) && ((((((p == "tint")) || ((p == "removeTint")))) || ((p == "frame"))))))) && (!((((p == "volume")) && (this.target.hasOwnProperty("soundTransform"))))))){
if (typeof(v[p]) == "number"){
this.tweens[this.tweens.length] = {o:this.target, p:p, s:this.target[p], c:(v[p] - this.target[p]), name:p};
} else {
this.tweens[this.tweens.length] = {o:this.target, p:p, s:this.target[p], c:Number(v[p]), name:p};
};
};
};
};
};
if (this.vars.runBackwards == true){
i = (this.tweens.length - 1);
while (i > -1) {
tp = this.tweens[i];
tp.s = (tp.s + tp.c);
tp.c = (tp.c * -1);
i--;
};
};
if ((((v.visible == true)) && (_isDisplayObject))){
this.target.visible = true;
};
if (this.vars.onUpdate != null){
_hasUpdate = true;
};
_initted = true;
}
public function get active():Boolean{
if (_active){
return (true);
};
if (_curTime >= this.startTime){
_active = true;
if (!_initted){
initTweenVals();
} else {
if (((!((this.vars.visible == undefined))) && (_isDisplayObject))){
this.target.visible = true;
};
};
if (this.vars.onStart != null){
this.vars.onStart.apply(null, this.vars.onStartParams);
};
if (this.duration == 0.001){
this.startTime = (this.startTime - 1);
};
return (true);
//unresolved jump
};
return (false);
}
public function render($t:uint):void{
var factor:Number;
var tp:Object;
var i:int;
var time:Number = (($t - this.startTime) / 1000);
if (time >= this.duration){
time = this.duration;
factor = 1;
} else {
factor = this.vars.ease(time, 0, 1, this.duration);
};
i = (this.tweens.length - 1);
while (i > -1) {
tp = this.tweens[i];
tp.o[tp.p] = (tp.s + (factor * tp.c));
i--;
};
if (_hst){
i = (_subTweens.length - 1);
while (i > -1) {
_subTweens[i].proxy(_subTweens[i]);
i--;
};
};
if (_hasUpdate){
this.vars.onUpdate.apply(null, this.vars.onUpdateParams);
};
if (time == this.duration){
complete(true);
};
}
protected function easeProxy($t:Number, $b:Number, $c:Number, $d:Number):Number{
return (this.vars.proxiedEase.apply(null, arguments.concat(this.vars.easeParams)));
}
public function killVars($vars:Object):void{
if (overwriteManager.enabled){
overwriteManager.killVars($vars, this.vars, this.tweens, _subTweens, []);
};
}
public function complete($skipRender:Boolean=false):void{
if (!$skipRender){
if (!_initted){
initTweenVals();
};
this.startTime = (_curTime - ((this.duration * 1000) / _timeScale));
render(_curTime);
return;
};
if (((!((this.vars.visible == undefined))) && (_isDisplayObject))){
if (((!(isNaN(this.vars.autoAlpha))) && ((this.target.alpha == 0)))){
this.target.visible = false;
} else {
if (this.vars.runBackwards != true){
this.target.visible = this.vars.visible;
};
};
};
if (this.vars.persist != true){
removeTween(this);
};
if (this.vars.onComplete != null){
this.vars.onComplete.apply(null, this.vars.onCompleteParams);
};
}
public static function easeOut($t:Number, $b:Number, $c:Number, $d:Number):Number{
$t = ($t / $d);
return ((((-($c) * $t) * ($t - 2)) + $b));
}
public static function frameProxy($o:Object):void{
$o.info.target.gotoAndStop(Math.round($o.target.frame));
}
public static function removeTween($t:TweenLite=null):void{
if (((!(($t == null))) && (!((_all[$t.target] == undefined))))){
_all[$t.target][$t] = null;
delete _all[$t.target][$t];
};
}
public static function killTweensOf($tg:Object=null, $complete:Boolean=false):void{
var o:Object;
var tw:*;
if (((!(($tg == null))) && (!((_all[$tg] == undefined))))){
if ($complete){
o = _all[$tg];
for (tw in o) {
o[tw].complete(false);
};
};
delete _all[$tg];
};
}
public static function delayedCall($delay:Number, $onComplete:Function, $onCompleteParams:Array=null):TweenLite{
return (new TweenLite($onComplete, 0, {delay:$delay, onComplete:$onComplete, onCompleteParams:$onCompleteParams, overwrite:0}));
}
public static function from($target:Object, $duration:Number, $vars:Object):TweenLite{
$vars.runBackwards = true;
return (new TweenLite($target, $duration, $vars));
}
public static function executeAll($e:Event=null):void{
var a:Dictionary;
var p:Object;
var tw:Object;
var t:uint = (_curTime = getTimer());
if (_listening){
a = _all;
for each (p in a) {
for (tw in p) {
if (((!((p[tw] == undefined))) && (p[tw].active))){
p[tw].render(t);
};
};
};
};
}
public static function volumeProxy($o:Object):void{
$o.info.target.soundTransform = $o.target;
}
public static function killGarbage($e:TimerEvent):void{
var found:Boolean;
var p:Object;
var twp:Object;
var tw:Object;
var tg_cnt:uint;
for (p in _all) {
found = false;
for (twp in _all[p]) {
found = true;
break;
};
if (!found){
delete _all[p];
} else {
tg_cnt++;
};
};
if (tg_cnt == 0){
_timer.removeEventListener("timer", killGarbage);
_timer.stop();
_listening = false;
};
}
public static function tintProxy($o:Object):void{
var n:Number = $o.target.progress;
var r:Number = (1 - n);
var sc:Object = $o.info.color;
var ec:Object = $o.info.endColor;
$o.info.target.transform.colorTransform = new ColorTransform(((sc.redMultiplier * r) + (ec.redMultiplier * n)), ((sc.greenMultiplier * r) + (ec.greenMultiplier * n)), ((sc.blueMultiplier * r) + (ec.blueMultiplier * n)), ((sc.alphaMultiplier * r) + (ec.alphaMultiplier * n)), ((sc.redOffset * r) + (ec.redOffset * n)), ((sc.greenOffset * r) + (ec.greenOffset * n)), ((sc.blueOffset * r) + (ec.blueOffset * n)), ((sc.alphaOffset * r) + (ec.alphaOffset * n)));
}
public static function to($target:Object, $duration:Number, $vars:Object):TweenLite{
return (new TweenLite($target, $duration, $vars));
}
}
}//package gs
Section 80
//BindabilityInfo (mx.binding.BindabilityInfo)
package mx.binding {
import mx.core.*;
import mx.events.*;
public class BindabilityInfo {
private var classChangeEvents:Object;
private var typeDescription:XML;
private var childChangeEvents:Object;
public static const METHOD:String = "method";
public static const ACCESSOR:String = "accessor";
public static const CHANGE_EVENT:String = "ChangeEvent";
public static const NON_COMMITTING_CHANGE_EVENT:String = "NonCommittingChangeEvent";
public static const BINDABLE:String = "Bindable";
mx_internal static const VERSION:String = "3.0.0.0";
public static const MANAGED:String = "Managed";
public function BindabilityInfo(typeDescription:XML){
childChangeEvents = {};
super();
this.typeDescription = typeDescription;
}
private function addChangeEvents(metadata:XMLList, eventListObj:Object, isCommit:Boolean):void{
var md:XML;
var arg:XMLList;
var eventName:String;
for each (md in metadata) {
arg = md.arg;
if (arg.length() > 0){
eventName = arg[0].@value;
eventListObj[eventName] = isCommit;
} else {
trace((("warning: unconverted Bindable metadata in class '" + typeDescription.@name) + "'"));
};
};
}
private function getClassChangeEvents():Object{
if (!classChangeEvents){
classChangeEvents = {};
addBindabilityEvents(typeDescription.metadata, classChangeEvents);
if (typeDescription.metadata.(@name == MANAGED).length() > 0){
classChangeEvents[PropertyChangeEvent.PROPERTY_CHANGE] = true;
};
};
return (classChangeEvents);
}
private function addBindabilityEvents(metadata:XMLList, eventListObj:Object):void{
var metadata = metadata;
var eventListObj = eventListObj;
addChangeEvents(metadata.(@name == BINDABLE), eventListObj, true);
addChangeEvents(metadata.(@name == CHANGE_EVENT), eventListObj, true);
addChangeEvents(metadata.(@name == NON_COMMITTING_CHANGE_EVENT), eventListObj, false);
}
private function copyProps(from:Object, to:Object):Object{
var propName:String;
for (propName in from) {
to[propName] = from[propName];
};
return (to);
}
public function getChangeEvents(childName:String):Object{
var childDesc:XMLList;
var numChildren:int;
var childName = childName;
var changeEvents:Object = childChangeEvents[childName];
if (!changeEvents){
changeEvents = copyProps(getClassChangeEvents(), {});
childDesc = (typeDescription.accessor.(@name == childName) + typeDescription.method.(@name == childName));
numChildren = childDesc.length();
if (numChildren == 0){
if (!typeDescription.@dynamic){
trace((((("warning: no describeType entry for '" + childName) + "' on non-dynamic type '") + typeDescription.@name) + "'"));
};
} else {
if (numChildren > 1){
trace(((((("warning: multiple describeType entries for '" + childName) + "' on type '") + typeDescription.@name) + "':\n") + childDesc));
};
addBindabilityEvents(childDesc.metadata, changeEvents);
};
childChangeEvents[childName] = changeEvents;
};
return (changeEvents);
}
}
}//package mx.binding
Section 81
//CollectionViewError (mx.collections.errors.CollectionViewError)
package mx.collections.errors {
import mx.core.*;
public class CollectionViewError extends Error {
mx_internal static const VERSION:String = "3.0.0.0";
public function CollectionViewError(message:String){
super(message);
}
}
}//package mx.collections.errors
Section 82
//CursorError (mx.collections.errors.CursorError)
package mx.collections.errors {
import mx.core.*;
public class CursorError extends Error {
mx_internal static const VERSION:String = "3.0.0.0";
public function CursorError(message:String){
super(message);
}
}
}//package mx.collections.errors
Section 83
//ItemPendingError (mx.collections.errors.ItemPendingError)
package mx.collections.errors {
import mx.core.*;
import mx.rpc.*;
public class ItemPendingError extends Error {
private var _responders:Array;
mx_internal static const VERSION:String = "3.0.0.0";
public function ItemPendingError(message:String){
super(message);
}
public function get responders():Array{
return (_responders);
}
public function addResponder(responder:IResponder):void{
if (!_responders){
_responders = [];
};
_responders.push(responder);
}
}
}//package mx.collections.errors
Section 84
//SortError (mx.collections.errors.SortError)
package mx.collections.errors {
import mx.core.*;
public class SortError extends Error {
mx_internal static const VERSION:String = "3.0.0.0";
public function SortError(message:String){
super(message);
}
}
}//package mx.collections.errors
Section 85
//ArrayCollection (mx.collections.ArrayCollection)
package mx.collections {
import mx.core.*;
import flash.utils.*;
public class ArrayCollection extends ListCollectionView implements IExternalizable {
mx_internal static const VERSION:String = "3.0.0.0";
public function ArrayCollection(source:Array=null){
super();
this.source = source;
}
public function set source(s:Array):void{
list = new ArrayList(s);
}
public function readExternal(input:IDataInput):void{
if ((list is IExternalizable)){
IExternalizable(list).readExternal(input);
} else {
source = (input.readObject() as Array);
};
}
public function writeExternal(output:IDataOutput):void{
if ((list is IExternalizable)){
IExternalizable(list).writeExternal(output);
} else {
output.writeObject(source);
};
}
public function get source():Array{
if (((list) && ((list is ArrayList)))){
return (ArrayList(list).source);
};
return (null);
}
}
}//package mx.collections
Section 86
//ArrayList (mx.collections.ArrayList)
package mx.collections {
import flash.events.*;
import mx.core.*;
import mx.events.*;
import mx.resources.*;
import flash.utils.*;
import mx.utils.*;
public class ArrayList extends EventDispatcher implements IList, IExternalizable, IPropertyChangeNotifier {
private var _source:Array;
private var _dispatchEvents:int;// = 0
private var _uid:String;
private var resourceManager:IResourceManager;
mx_internal static const VERSION:String = "3.0.0.0";
public function ArrayList(source:Array=null){
resourceManager = ResourceManager.getInstance();
super();
disableEvents();
this.source = source;
enableEvents();
_uid = UIDUtil.createUID();
}
public function itemUpdated(item:Object, property:Object=null, oldValue:Object=null, newValue:Object=null):void{
var event:PropertyChangeEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE);
event.kind = PropertyChangeEventKind.UPDATE;
event.source = item;
event.property = property;
event.oldValue = oldValue;
event.newValue = newValue;
itemUpdateHandler(event);
}
public function readExternal(input:IDataInput):void{
source = input.readObject();
}
private function internalDispatchEvent(kind:String, item:Object=null, location:int=-1):void{
var event:CollectionEvent;
var objEvent:PropertyChangeEvent;
if (_dispatchEvents == 0){
if (hasEventListener(CollectionEvent.COLLECTION_CHANGE)){
event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.kind = kind;
event.items.push(item);
event.location = location;
dispatchEvent(event);
};
if (((hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE)) && ((((kind == CollectionEventKind.ADD)) || ((kind == CollectionEventKind.REMOVE)))))){
objEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE);
objEvent.property = location;
if (kind == CollectionEventKind.ADD){
objEvent.newValue = item;
} else {
objEvent.oldValue = item;
};
dispatchEvent(objEvent);
};
};
}
public function removeAll():void{
var len:int;
var i:int;
if (length > 0){
len = length;
i = 0;
while (i < len) {
stopTrackUpdates(source[i]);
i++;
};
source.splice(0, length);
internalDispatchEvent(CollectionEventKind.RESET);
};
}
public function removeItemAt(index:int):Object{
var message:String;
if ((((index < 0)) || ((index >= length)))){
message = resourceManager.getString("collections", "outOfBounds", [index]);
throw (new RangeError(message));
};
var removed:Object = source.splice(index, 1)[0];
stopTrackUpdates(removed);
internalDispatchEvent(CollectionEventKind.REMOVE, removed, index);
return (removed);
}
public function get uid():String{
return (_uid);
}
public function getItemIndex(item:Object):int{
return (ArrayUtil.getItemIndex(item, source));
}
public function writeExternal(output:IDataOutput):void{
output.writeObject(_source);
}
public function addItem(item:Object):void{
addItemAt(item, length);
}
public function toArray():Array{
return (source.concat());
}
private function disableEvents():void{
_dispatchEvents--;
}
public function get source():Array{
return (_source);
}
public function getItemAt(index:int, prefetch:int=0):Object{
var message:String;
if ((((index < 0)) || ((index >= length)))){
message = resourceManager.getString("collections", "outOfBounds", [index]);
throw (new RangeError(message));
};
return (source[index]);
}
public function set uid(value:String):void{
_uid = value;
}
public function setItemAt(item:Object, index:int):Object{
var message:String;
var hasCollectionListener:Boolean;
var hasPropertyListener:Boolean;
var updateInfo:PropertyChangeEvent;
var event:CollectionEvent;
if ((((index < 0)) || ((index >= length)))){
message = resourceManager.getString("collections", "outOfBounds", [index]);
throw (new RangeError(message));
};
var oldItem:Object = source[index];
source[index] = item;
stopTrackUpdates(oldItem);
startTrackUpdates(item);
if (_dispatchEvents == 0){
hasCollectionListener = hasEventListener(CollectionEvent.COLLECTION_CHANGE);
hasPropertyListener = hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE);
if (((hasCollectionListener) || (hasPropertyListener))){
updateInfo = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE);
updateInfo.kind = PropertyChangeEventKind.UPDATE;
updateInfo.oldValue = oldItem;
updateInfo.newValue = item;
updateInfo.property = index;
};
if (hasCollectionListener){
event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.kind = CollectionEventKind.REPLACE;
event.location = index;
event.items.push(updateInfo);
dispatchEvent(event);
};
if (hasPropertyListener){
dispatchEvent(updateInfo);
};
};
return (oldItem);
}
public function get length():int{
if (source){
return (source.length);
};
return (0);
}
protected function stopTrackUpdates(item:Object):void{
if (((item) && ((item is IEventDispatcher)))){
IEventDispatcher(item).removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE, itemUpdateHandler);
};
}
protected function itemUpdateHandler(event:PropertyChangeEvent):void{
var objEvent:PropertyChangeEvent;
var index:uint;
internalDispatchEvent(CollectionEventKind.UPDATE, event);
if ((((_dispatchEvents == 0)) && (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE)))){
objEvent = PropertyChangeEvent(event.clone());
index = getItemIndex(event.target);
objEvent.property = ((index.toString() + ".") + event.property);
dispatchEvent(objEvent);
};
}
public function addItemAt(item:Object, index:int):void{
var message:String;
if ((((index < 0)) || ((index > length)))){
message = resourceManager.getString("collections", "outOfBounds", [index]);
throw (new RangeError(message));
};
source.splice(index, 0, item);
startTrackUpdates(item);
internalDispatchEvent(CollectionEventKind.ADD, item, index);
}
public function removeItem(item:Object):Boolean{
var index:int = getItemIndex(item);
var result = (index >= 0);
if (result){
removeItemAt(index);
};
return (result);
}
protected function startTrackUpdates(item:Object):void{
if (((item) && ((item is IEventDispatcher)))){
IEventDispatcher(item).addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, itemUpdateHandler, false, 0, true);
};
}
override public function toString():String{
if (source){
return (source.toString());
};
return (getQualifiedClassName(this));
}
private function enableEvents():void{
_dispatchEvents++;
if (_dispatchEvents > 0){
_dispatchEvents = 0;
};
}
public function set source(s:Array):void{
var i:int;
var len:int;
var event:CollectionEvent;
if (((_source) && (_source.length))){
len = _source.length;
i = 0;
while (i < len) {
stopTrackUpdates(_source[i]);
i++;
};
};
_source = (s) ? s : [];
len = _source.length;
i = 0;
while (i < len) {
startTrackUpdates(_source[i]);
i++;
};
if (_dispatchEvents == 0){
event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.kind = CollectionEventKind.RESET;
dispatchEvent(event);
};
}
}
}//package mx.collections
Section 87
//CursorBookmark (mx.collections.CursorBookmark)
package mx.collections {
import mx.core.*;
public class CursorBookmark {
private var _value:Object;
mx_internal static const VERSION:String = "3.0.0.0";
private static var _first:CursorBookmark;
private static var _last:CursorBookmark;
private static var _current:CursorBookmark;
public function CursorBookmark(value:Object){
super();
_value = value;
}
public function get value():Object{
return (_value);
}
public function getViewIndex():int{
return (-1);
}
public static function get LAST():CursorBookmark{
if (!_last){
_last = new CursorBookmark("${L}");
};
return (_last);
}
public static function get FIRST():CursorBookmark{
if (!_first){
_first = new CursorBookmark("${F}");
};
return (_first);
}
public static function get CURRENT():CursorBookmark{
if (!_current){
_current = new CursorBookmark("${C}");
};
return (_current);
}
}
}//package mx.collections
Section 88
//ICollectionView (mx.collections.ICollectionView)
package mx.collections {
import flash.events.*;
public interface ICollectionView extends IEventDispatcher {
function set filterFunction(mx.collections:ICollectionView/mx.collections:ICollectionView:length/get:Function):void;
function enableAutoUpdate():void;
function get length():int;
function disableAutoUpdate():void;
function itemUpdated(_arg1:Object, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void;
function get filterFunction():Function;
function createCursor():IViewCursor;
function refresh():Boolean;
function set sort(mx.collections:ICollectionView/mx.collections:ICollectionView:length/get:Sort):void;
function get sort():Sort;
function contains(Function:Object):Boolean;
}
}//package mx.collections
Section 89
//IList (mx.collections.IList)
package mx.collections {
import flash.events.*;
public interface IList extends IEventDispatcher {
function addItem(E:\dev\3.1.0\frameworks\projects\framework\src;mx\collections;IList.as:Object):void;
function get length():int;
function addItemAt(_arg1:Object, _arg2:int):void;
function itemUpdated(_arg1:Object, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void;
function getItemIndex(:Object):int;
function removeItemAt(mx.collections:IList/mx.collections:IList:length/get:int):Object;
function getItemAt(_arg1:int, _arg2:int=0):Object;
function removeAll():void;
function toArray():Array;
function setItemAt(_arg1:Object, _arg2:int):Object;
}
}//package mx.collections
Section 90
//ItemResponder (mx.collections.ItemResponder)
package mx.collections {
import mx.core.*;
import mx.rpc.*;
public class ItemResponder implements IResponder {
private var _faultHandler:Function;
private var _token:Object;
private var _resultHandler:Function;
mx_internal static const VERSION:String = "3.0.0.0";
public function ItemResponder(result:Function, fault:Function, token:Object=null){
super();
_resultHandler = result;
_faultHandler = fault;
_token = token;
}
public function result(data:Object):void{
_resultHandler(data, _token);
}
public function fault(info:Object):void{
_faultHandler(info, _token);
}
}
}//package mx.collections
Section 91
//IViewCursor (mx.collections.IViewCursor)
package mx.collections {
import flash.events.*;
public interface IViewCursor extends IEventDispatcher {
function get current():Object;
function moveNext():Boolean;
function get view():ICollectionView;
function movePrevious():Boolean;
function remove():Object;
function findLast(:Object):Boolean;
function get beforeFirst():Boolean;
function get afterLast():Boolean;
function findAny(:Object):Boolean;
function get bookmark():CursorBookmark;
function findFirst(:Object):Boolean;
function seek(_arg1:CursorBookmark, _arg2:int=0, _arg3:int=0):void;
function insert(mx.collections:IViewCursor/mx.collections:IViewCursor:beforeFirst/get:Object):void;
}
}//package mx.collections
Section 92
//ListCollectionView (mx.collections.ListCollectionView)
package mx.collections {
import flash.events.*;
import mx.core.*;
import mx.events.*;
import mx.resources.*;
import flash.utils.*;
import mx.utils.*;
import mx.collections.errors.*;
public class ListCollectionView extends Proxy implements ICollectionView, IList, IMXMLObject {
private var autoUpdateCounter:int;
private var _list:IList;
private var _filterFunction:Function;
protected var localIndex:Array;
mx_internal var dispatchResetEvent:Boolean;// = true
private var pendingUpdates:Array;
private var resourceManager:IResourceManager;
private var eventDispatcher:EventDispatcher;
private var revision:int;
private var _sort:Sort;
mx_internal static const VERSION:String = "3.0.0.0";
public function ListCollectionView(list:IList=null){
resourceManager = ResourceManager.getInstance();
super();
eventDispatcher = new EventDispatcher(this);
this.list = list;
}
private function handlePendingUpdates():void{
var pu:Array;
var singleUpdateEvent:CollectionEvent;
var i:int;
var event:CollectionEvent;
var j:int;
if (pendingUpdates){
pu = pendingUpdates;
pendingUpdates = null;
i = 0;
while (i < pu.length) {
event = pu[i];
if (event.kind == CollectionEventKind.UPDATE){
if (!singleUpdateEvent){
singleUpdateEvent = event;
} else {
j = 0;
while (j < event.items.length) {
singleUpdateEvent.items.push(event.items[j]);
j++;
};
};
} else {
listChangeHandler(event);
};
i++;
};
if (singleUpdateEvent){
listChangeHandler(singleUpdateEvent);
};
};
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
eventDispatcher.removeEventListener(type, listener, useCapture);
}
private function replaceItemsInView(items:Array, location:int, dispatch:Boolean=true):void{
var len:int;
var oldItems:Array;
var newItems:Array;
var i:int;
var propertyEvent:PropertyChangeEvent;
var event:CollectionEvent;
if (localIndex){
len = items.length;
oldItems = [];
newItems = [];
i = 0;
while (i < len) {
propertyEvent = items[i];
oldItems.push(propertyEvent.oldValue);
newItems.push(propertyEvent.newValue);
i++;
};
removeItemsFromView(oldItems, location, dispatch);
addItemsToView(newItems, location, dispatch);
} else {
event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.kind = CollectionEventKind.REPLACE;
event.location = location;
event.items = items;
dispatchEvent(event);
};
}
public function willTrigger(type:String):Boolean{
return (eventDispatcher.willTrigger(type));
}
private function getFilteredItemIndex(item:Object):int{
var prevItem:Object;
var len:int;
var j:int;
var loc:int = list.getItemIndex(item);
if (loc == 0){
return (0);
};
var i:int = (loc - 1);
while (i >= 0) {
prevItem = list.getItemAt(i);
if (filterFunction(prevItem)){
len = localIndex.length;
j = 0;
while (j < len) {
if (localIndex[j] == prevItem){
return ((j + 1));
};
j++;
};
};
i--;
};
return (0);
}
mx_internal function findItem(values:Object, mode:String, insertIndex:Boolean=false):int{
var message:String;
if (!sort){
message = resourceManager.getString("collections", "itemNotFound");
throw (new CollectionViewError(message));
};
if (localIndex.length == 0){
return ((insertIndex) ? 0 : -1);
};
return (sort.findItem(localIndex, values, mode, insertIndex));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(index:int):String{
return ((index - 1).toString());
}
public function removeAll():void{
var i:int;
var len:int = length;
if (len > 0){
if (localIndex){
i = (len - 1);
while (i >= 0) {
removeItemAt(i);
i--;
};
} else {
list.removeAll();
};
};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(name):Boolean{
var n:Number;
var name = name;
if ((name is QName)){
name = name.localName;
};
var index = -1;
n = parseInt(String(name));
if (!isNaN(n)){
index = int(n);
};
//unresolved jump
var _slot1 = e;
if (index == -1){
return (false);
};
return ((((index >= 0)) && ((index < length))));
}
public function getItemAt(index:int, prefetch:int=0):Object{
var message:String;
if ((((index < 0)) || ((index >= length)))){
message = resourceManager.getString("collections", "outOfBounds", [index]);
throw (new RangeError(message));
};
if (localIndex){
return (localIndex[index]);
};
if (list){
return (list.getItemAt(index, prefetch));
};
return (null);
}
private function moveItemInView(item:Object, dispatch:Boolean=true, updateEventItems:Array=null):void{
var removeLocation:int;
var i:int;
var addLocation:int;
var event:CollectionEvent;
if (localIndex){
removeLocation = -1;
i = 0;
while (i < localIndex.length) {
if (localIndex[i] == item){
removeLocation = i;
break;
};
i++;
};
if (removeLocation > -1){
localIndex.splice(removeLocation, 1);
};
addLocation = addItemsToView([item], removeLocation, false);
if (dispatch){
event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.items.push(item);
if (((((updateEventItems) && ((addLocation == removeLocation)))) && ((addLocation > -1)))){
updateEventItems.push(item);
return;
};
if ((((addLocation > -1)) && ((removeLocation > -1)))){
event.kind = CollectionEventKind.MOVE;
event.location = addLocation;
event.oldLocation = removeLocation;
} else {
if (addLocation > -1){
event.kind = CollectionEventKind.ADD;
event.location = addLocation;
} else {
if (removeLocation > -1){
event.kind = CollectionEventKind.REMOVE;
event.location = removeLocation;
} else {
dispatch = false;
};
};
};
if (dispatch){
dispatchEvent(event);
};
};
};
}
public function contains(item:Object):Boolean{
return (!((getItemIndex(item) == -1)));
}
public function get sort():Sort{
return (_sort);
}
private function removeItemsFromView(items:Array, sourceLocation:int, dispatch:Boolean=true):void{
var i:int;
var item:Object;
var loc:int;
var event:CollectionEvent;
var removedItems:Array = (localIndex) ? [] : items;
var removeLocation:int = sourceLocation;
if (localIndex){
i = 0;
while (i < items.length) {
item = items[i];
loc = getItemIndex(item);
if (loc > -1){
localIndex.splice(loc, 1);
removedItems.push(item);
removeLocation = loc;
};
i++;
};
};
if (((dispatch) && ((removedItems.length > 0)))){
event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.kind = CollectionEventKind.REMOVE;
event.location = (((!(localIndex)) || ((removedItems.length == 1)))) ? removeLocation : -1;
event.items = removedItems;
dispatchEvent(event);
};
}
public function get list():IList{
return (_list);
}
public function addItemAt(item:Object, index:int):void{
var message:String;
if ((((((index < 0)) || (!(list)))) || ((index > length)))){
message = resourceManager.getString("collections", "outOfBounds", [index]);
throw (new RangeError(message));
};
var listIndex:int = index;
if (((localIndex) && (sort))){
listIndex = list.length;
} else {
if (((localIndex) && (!((filterFunction == null))))){
if (listIndex == localIndex.length){
listIndex = list.length;
} else {
listIndex = list.getItemIndex(localIndex[index]);
};
};
};
list.addItemAt(item, listIndex);
}
public function itemUpdated(item:Object, property:Object=null, oldValue:Object=null, newValue:Object=null):void{
list.itemUpdated(item, property, oldValue, newValue);
}
private function populateLocalIndex():void{
if (list){
localIndex = list.toArray();
} else {
localIndex = [];
};
}
private function handlePropertyChangeEvents(events:Array):void{
var updatedItems:Array;
var updateEntry:Object;
var i:int;
var temp:Array;
var ctr:int;
var updateInfo:PropertyChangeEvent;
var item:Object;
var defaultMove:Boolean;
var j:int;
var ctr1:int;
var updateEvent:CollectionEvent;
var eventItems:Array = events;
if (((sort) || (!((filterFunction == null))))){
updatedItems = [];
i = 0;
while (i < events.length) {
updateInfo = events[i];
if (updateInfo.target){
item = updateInfo.target;
defaultMove = !((updateInfo.target == updateInfo.source));
} else {
item = updateInfo.source;
defaultMove = false;
};
j = 0;
while (j < updatedItems.length) {
if (updatedItems[j].item == item){
break;
};
j++;
};
if (j < updatedItems.length){
updateEntry = updatedItems[j];
} else {
updateEntry = {item:item, move:defaultMove, event:updateInfo};
updatedItems.push(updateEntry);
};
updateEntry.move = ((((((updateEntry.move) || (filterFunction))) || (!(updateInfo.property)))) || (((sort) && (sort.propertyAffectsSort(String(updateInfo.property))))));
i++;
};
eventItems = [];
i = 0;
while (i < updatedItems.length) {
updateEntry = updatedItems[i];
if (updateEntry.move){
moveItemInView(updateEntry.item, updateEntry.item, eventItems);
} else {
eventItems.push(updateEntry.item);
};
i++;
};
temp = [];
ctr = 0;
while (ctr < eventItems.length) {
ctr1 = 0;
while (ctr1 < updatedItems.length) {
if (eventItems[ctr] == updatedItems[ctr1].item){
temp.push(updatedItems[ctr1].event);
};
ctr1++;
};
ctr++;
};
eventItems = temp;
};
if (eventItems.length > 0){
updateEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
updateEvent.kind = CollectionEventKind.UPDATE;
updateEvent.items = eventItems;
dispatchEvent(updateEvent);
};
}
public function set sort(s:Sort):void{
_sort = s;
dispatchEvent(new Event("sortChanged"));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextValue(index:int){
return (getItemAt((index - 1)));
}
public function setItemAt(item:Object, index:int):Object{
var message:String;
var oldItem:Object;
if ((((((index < 0)) || (!(list)))) || ((index >= length)))){
message = resourceManager.getString("collections", "outOfBounds", [index]);
throw (new RangeError(message));
};
var listIndex:int = index;
if (localIndex){
if (index > localIndex.length){
listIndex = list.length;
} else {
oldItem = localIndex[index];
listIndex = list.getItemIndex(oldItem);
};
};
return (list.setItemAt(item, listIndex));
}
mx_internal function getBookmark(index:int):ListCollectionViewBookmark{
var value:Object;
var message:String;
var index = index;
if ((((index < 0)) || ((index > length)))){
message = resourceManager.getString("collections", "invalidIndex", [index]);
throw (new CollectionViewError(message));
};
value = getItemAt(index);
//unresolved jump
var _slot1 = e;
value = null;
return (new ListCollectionViewBookmark(value, this, revision, index));
}
private function addItemsToView(items:Array, sourceLocation:int, dispatch:Boolean=true):int{
var loc:int;
var i:int;
var item:Object;
var message:String;
var event:CollectionEvent;
var addedItems:Array = (localIndex) ? [] : items;
var addLocation:int = sourceLocation;
var firstOne:Boolean;
if (localIndex){
loc = sourceLocation;
i = 0;
while (i < items.length) {
item = items[i];
if ((((filterFunction == null)) || (filterFunction(item)))){
if (sort){
loc = findItem(item, Sort.ANY_INDEX_MODE, true);
if (firstOne){
addLocation = loc;
firstOne = false;
};
} else {
loc = getFilteredItemIndex(item);
if (firstOne){
addLocation = loc;
firstOne = false;
};
};
if (((((sort) && (sort.unique))) && ((sort.compareFunction(item, localIndex[loc]) == 0)))){
message = resourceManager.getString("collections", "incorrectAddition");
throw (new CollectionViewError(message));
};
var _temp1 = loc;
loc = (loc + 1);
localIndex.splice(_temp1, 0, item);
addedItems.push(item);
} else {
addLocation = -1;
};
i++;
};
};
if (((localIndex) && ((addedItems.length > 1)))){
addLocation = -1;
};
if (((dispatch) && ((addedItems.length > 0)))){
event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.kind = CollectionEventKind.ADD;
event.location = addLocation;
event.items = addedItems;
dispatchEvent(event);
};
return (addLocation);
}
public function dispatchEvent(event:Event):Boolean{
return (eventDispatcher.dispatchEvent(event));
}
public function set list(value:IList):void{
var oldHasItems:Boolean;
var newHasItems:Boolean;
if (_list != value){
if (_list){
_list.removeEventListener(CollectionEvent.COLLECTION_CHANGE, listChangeHandler);
oldHasItems = (_list.length > 0);
};
_list = value;
if (_list){
_list.addEventListener(CollectionEvent.COLLECTION_CHANGE, listChangeHandler, false, 0, true);
newHasItems = (_list.length > 0);
};
if (((oldHasItems) || (newHasItems))){
reset();
};
dispatchEvent(new Event("listChanged"));
};
}
mx_internal function getBookmarkIndex(bookmark:CursorBookmark):int{
var message:String;
if (((!((bookmark is ListCollectionViewBookmark))) || (!((ListCollectionViewBookmark(bookmark).view == this))))){
message = resourceManager.getString("collections", "bookmarkNotFound");
throw (new CollectionViewError(message));
};
var bm:ListCollectionViewBookmark = ListCollectionViewBookmark(bookmark);
if (bm.viewRevision != revision){
if ((((((bm.index < 0)) || ((bm.index >= length)))) || (!((getItemAt(bm.index) == bm.value))))){
bm.index = getItemIndex(bm.value);
};
bm.viewRevision = revision;
};
return (bm.index);
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
public function getItemIndex(item:Object):int{
var i:int;
var startIndex:int;
var endIndex:int;
var len:int;
if (sort){
startIndex = sort.findItem(localIndex, item, Sort.FIRST_INDEX_MODE);
if (startIndex == -1){
return (-1);
};
endIndex = sort.findItem(localIndex, item, Sort.LAST_INDEX_MODE);
i = startIndex;
while (i <= endIndex) {
if (localIndex[i] == item){
return (i);
};
i++;
};
return (-1);
} else {
if (filterFunction != null){
len = localIndex.length;
i = 0;
while (i < len) {
if (localIndex[i] == item){
return (i);
};
i++;
};
return (-1);
};
};
return (list.getItemIndex(item));
}
public function removeItemAt(index:int):Object{
var message:String;
var oldItem:Object;
if ((((index < 0)) || ((index >= length)))){
message = resourceManager.getString("collections", "outOfBounds", [index]);
throw (new RangeError(message));
};
var listIndex:int = index;
if (localIndex){
oldItem = localIndex[index];
listIndex = list.getItemIndex(oldItem);
};
return (list.removeItemAt(listIndex));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){
var n:Number;
var message:String;
var name = name;
if ((name is QName)){
name = name.localName;
};
var index = -1;
n = parseInt(String(name));
if (!isNaN(n)){
index = int(n);
};
//unresolved jump
var _slot1 = e;
if (index == -1){
message = resourceManager.getString("collections", "unknownProperty", [name]);
throw (new Error(message));
};
return (getItemAt(index));
}
public function enableAutoUpdate():void{
if (autoUpdateCounter > 0){
autoUpdateCounter--;
if (autoUpdateCounter == 0){
handlePendingUpdates();
};
};
}
mx_internal function reset():void{
var event:CollectionEvent;
internalRefresh(false);
if (dispatchResetEvent){
event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.kind = CollectionEventKind.RESET;
dispatchEvent(event);
};
}
public function toArray():Array{
var ret:Array;
if (localIndex){
ret = localIndex.concat();
} else {
ret = list.toArray();
};
return (ret);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function callProperty(name, ... _args){
return (null);
}
public function initialized(document:Object, id:String):void{
refresh();
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(name, value):void{
var n:Number;
var message:String;
var name = name;
var value = value;
if ((name is QName)){
name = name.localName;
};
var index = -1;
n = parseInt(String(name));
if (!isNaN(n)){
index = int(n);
};
//unresolved jump
var _slot1 = e;
if (index == -1){
message = resourceManager.getString("collections", "unknownProperty", [name]);
throw (new Error(message));
};
setItemAt(value, index);
}
public function addItem(item:Object):void{
addItemAt(item, length);
}
private function internalRefresh(dispatch:Boolean):Boolean{
var tmp:Array;
var len:int;
var i:int;
var item:Object;
var refreshEvent:CollectionEvent;
var dispatch = dispatch;
if (((sort) || (!((filterFunction == null))))){
populateLocalIndex();
//unresolved jump
var _slot1 = pending;
_slot1.addResponder(new ItemResponder(function (data:Object, token:Object=null):void{
internalRefresh(dispatch);
}, function (info:Object, token:Object=null):void{
}));
return (false);
if (filterFunction != null){
tmp = [];
len = localIndex.length;
i = 0;
while (i < len) {
item = localIndex[i];
if (filterFunction(item)){
tmp.push(item);
};
i = (i + 1);
};
localIndex = tmp;
};
if (sort){
sort.sort(localIndex);
dispatch = true;
};
} else {
if (localIndex){
localIndex = null;
};
};
revision++;
pendingUpdates = null;
if (dispatch){
refreshEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
refreshEvent.kind = CollectionEventKind.REFRESH;
dispatchEvent(refreshEvent);
};
return (true);
}
public function set filterFunction(f:Function):void{
_filterFunction = f;
dispatchEvent(new Event("filterFunctionChanged"));
}
public function refresh():Boolean{
return (internalRefresh(true));
}
public function get filterFunction():Function{
return (_filterFunction);
}
public function createCursor():IViewCursor{
return (new ListCollectionViewCursor(this));
}
public function hasEventListener(type:String):Boolean{
return (eventDispatcher.hasEventListener(type));
}
public function get length():int{
if (localIndex){
return (localIndex.length);
};
if (list){
return (list.length);
};
return (0);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(index:int):int{
return (((index < length)) ? (index + 1) : 0);
}
public function disableAutoUpdate():void{
autoUpdateCounter++;
}
public function toString():String{
if (localIndex){
return (ObjectUtil.toString(localIndex));
};
if (((list) && (Object(list).toString))){
return (Object(list).toString());
};
return (getQualifiedClassName(this));
}
private function listChangeHandler(event:CollectionEvent):void{
if (autoUpdateCounter > 0){
if (!pendingUpdates){
pendingUpdates = [];
};
pendingUpdates.push(event);
} else {
switch (event.kind){
case CollectionEventKind.ADD:
addItemsToView(event.items, event.location);
break;
case CollectionEventKind.RESET:
reset();
break;
case CollectionEventKind.REMOVE:
removeItemsFromView(event.items, event.location);
break;
case CollectionEventKind.REPLACE:
replaceItemsInView(event.items, event.location);
break;
case CollectionEventKind.UPDATE:
handlePropertyChangeEvents(event.items);
break;
default:
dispatchEvent(event);
};
};
}
}
}//package mx.collections
import flash.events.*;
import mx.core.*;
import mx.events.*;
import mx.resources.*;
import mx.collections.errors.*;
class ListCollectionViewBookmark extends CursorBookmark {
mx_internal var viewRevision:int;
mx_internal var index:int;
mx_internal var view:ListCollectionView;
private function ListCollectionViewBookmark(value:Object, view:ListCollectionView, viewRevision:int, index:int){
super(value);
this.view = view;
this.viewRevision = viewRevision;
this.index = index;
}
override public function getViewIndex():int{
return (view.getBookmarkIndex(this));
}
}
class ListCollectionViewCursor extends EventDispatcher implements IViewCursor {
private var _view:ListCollectionView;
private var invalid:Boolean;
private var resourceManager:IResourceManager;
private var currentIndex:int;
private var currentValue:Object;
private static const BEFORE_FIRST_INDEX:int = -1;
private static const AFTER_LAST_INDEX:int = -2;
private function ListCollectionViewCursor(view:ListCollectionView){
var view = view;
resourceManager = ResourceManager.getInstance();
super();
_view = view;
_view.addEventListener(CollectionEvent.COLLECTION_CHANGE, collectionEventHandler, false, 0, true);
currentIndex = ((view.length > 0)) ? 0 : AFTER_LAST_INDEX;
if (currentIndex == 0){
setCurrent(view.getItemAt(0), false);
//unresolved jump
var _slot1 = e;
currentIndex = BEFORE_FIRST_INDEX;
setCurrent(null, false);
};
}
public function findAny(values:Object):Boolean{
var index:int;
var values = values;
checkValid();
var lcView:ListCollectionView = ListCollectionView(view);
index = lcView.findItem(values, Sort.ANY_INDEX_MODE);
//unresolved jump
var _slot1 = e;
throw (new CursorError(_slot1.message));
if (index > -1){
currentIndex = index;
setCurrent(lcView.getItemAt(currentIndex));
};
return ((index > -1));
}
public function remove():Object{
var oldIndex:int;
var message:String;
if (((beforeFirst) || (afterLast))){
message = resourceManager.getString("collections", "invalidRemove");
throw (new CursorError(message));
};
oldIndex = currentIndex;
currentIndex++;
if (currentIndex >= view.length){
currentIndex = AFTER_LAST_INDEX;
setCurrent(null);
} else {
setCurrent(ListCollectionView(view).getItemAt(currentIndex));
//unresolved jump
var _slot1 = e;
setCurrent(null, false);
ListCollectionView(view).removeItemAt(oldIndex);
throw (_slot1);
};
var removed:Object = ListCollectionView(view).removeItemAt(oldIndex);
return (removed);
}
private function setCurrent(value:Object, dispatch:Boolean=true):void{
currentValue = value;
if (dispatch){
dispatchEvent(new FlexEvent(FlexEvent.CURSOR_UPDATE));
};
}
public function seek(bookmark:CursorBookmark, offset:int=0, prefetch:int=0):void{
var message:String;
var bookmark = bookmark;
var offset = offset;
var prefetch = prefetch;
checkValid();
if (view.length == 0){
currentIndex = AFTER_LAST_INDEX;
setCurrent(null, false);
return;
};
var newIndex:int = currentIndex;
if (bookmark == CursorBookmark.FIRST){
newIndex = 0;
} else {
if (bookmark == CursorBookmark.LAST){
newIndex = (view.length - 1);
} else {
if (bookmark != CursorBookmark.CURRENT){
newIndex = ListCollectionView(view).getBookmarkIndex(bookmark);
if (newIndex < 0){
setCurrent(null);
message = resourceManager.getString("collections", "bookmarkInvalid");
throw (new CursorError(message));
};
//unresolved jump
var _slot1 = bmError;
message = resourceManager.getString("collections", "bookmarkInvalid");
throw (new CursorError(message));
};
};
};
newIndex = (newIndex + offset);
var newCurrent:Object;
if (newIndex >= view.length){
currentIndex = AFTER_LAST_INDEX;
} else {
if (newIndex < 0){
currentIndex = BEFORE_FIRST_INDEX;
} else {
newCurrent = ListCollectionView(view).getItemAt(newIndex, prefetch);
currentIndex = newIndex;
};
};
setCurrent(newCurrent);
}
public function insert(item:Object):void{
var insertIndex:int;
var message:String;
if (afterLast){
insertIndex = view.length;
} else {
if (beforeFirst){
if (view.length > 0){
message = resourceManager.getString("collections", "invalidInsert");
throw (new CursorError(message));
};
insertIndex = 0;
} else {
insertIndex = currentIndex;
};
};
ListCollectionView(view).addItemAt(item, insertIndex);
}
public function get afterLast():Boolean{
checkValid();
return ((((currentIndex == AFTER_LAST_INDEX)) || ((view.length == 0))));
}
private function checkValid():void{
var message:String;
if (invalid){
message = resourceManager.getString("collections", "invalidCursor");
throw (new CursorError(message));
};
}
private function collectionEventHandler(event:CollectionEvent):void{
var event = event;
switch (event.kind){
case CollectionEventKind.ADD:
if (event.location <= currentIndex){
currentIndex = (currentIndex + event.items.length);
};
break;
case CollectionEventKind.REMOVE:
if (event.location < currentIndex){
currentIndex = (currentIndex - event.items.length);
} else {
if (event.location == currentIndex){
if (currentIndex < view.length){
setCurrent(ListCollectionView(view).getItemAt(currentIndex));
//unresolved jump
var _slot1 = error;
setCurrent(null, false);
} else {
currentIndex = AFTER_LAST_INDEX;
setCurrent(null);
};
};
};
break;
case CollectionEventKind.MOVE:
if (event.oldLocation == currentIndex){
currentIndex = event.location;
} else {
if (event.oldLocation < currentIndex){
currentIndex = (currentIndex - event.items.length);
};
if (event.location <= currentIndex){
currentIndex = (currentIndex + event.items.length);
};
};
break;
case CollectionEventKind.REFRESH:
if (!((beforeFirst) || (afterLast))){
currentIndex = ListCollectionView(view).getItemIndex(currentValue);
if (currentIndex == -1){
setCurrent(null);
};
};
break;
case CollectionEventKind.REPLACE:
if (event.location == currentIndex){
setCurrent(ListCollectionView(view).getItemAt(currentIndex));
//unresolved jump
var _slot1 = error;
setCurrent(null, false);
};
break;
case CollectionEventKind.RESET:
currentIndex = BEFORE_FIRST_INDEX;
setCurrent(null);
break;
};
}
public function moveNext():Boolean{
if (afterLast){
return (false);
};
var tempIndex:int = (beforeFirst) ? 0 : (currentIndex + 1);
if (tempIndex >= view.length){
tempIndex = AFTER_LAST_INDEX;
setCurrent(null);
} else {
setCurrent(ListCollectionView(view).getItemAt(tempIndex));
};
currentIndex = tempIndex;
return (!(afterLast));
}
public function get view():ICollectionView{
checkValid();
return (_view);
}
public function movePrevious():Boolean{
if (beforeFirst){
return (false);
};
var tempIndex:int = (afterLast) ? (view.length - 1) : (currentIndex - 1);
if (tempIndex == -1){
tempIndex = BEFORE_FIRST_INDEX;
setCurrent(null);
} else {
setCurrent(ListCollectionView(view).getItemAt(tempIndex));
};
currentIndex = tempIndex;
return (!(beforeFirst));
}
public function findLast(values:Object):Boolean{
var index:int;
var values = values;
checkValid();
var lcView:ListCollectionView = ListCollectionView(view);
index = lcView.findItem(values, Sort.LAST_INDEX_MODE);
//unresolved jump
var _slot1 = sortError;
throw (new CursorError(_slot1.message));
if (index > -1){
currentIndex = index;
setCurrent(lcView.getItemAt(currentIndex));
};
return ((index > -1));
}
public function get beforeFirst():Boolean{
checkValid();
return ((((currentIndex == BEFORE_FIRST_INDEX)) || ((view.length == 0))));
}
public function get bookmark():CursorBookmark{
checkValid();
if ((((view.length == 0)) || (beforeFirst))){
return (CursorBookmark.FIRST);
};
if (afterLast){
return (CursorBookmark.LAST);
};
return (ListCollectionView(view).getBookmark(currentIndex));
}
public function findFirst(values:Object):Boolean{
var index:int;
var values = values;
checkValid();
var lcView:ListCollectionView = ListCollectionView(view);
index = lcView.findItem(values, Sort.FIRST_INDEX_MODE);
//unresolved jump
var _slot1 = sortError;
throw (new CursorError(_slot1.message));
if (index > -1){
currentIndex = index;
setCurrent(lcView.getItemAt(currentIndex));
};
return ((index > -1));
}
public function get current():Object{
checkValid();
return (currentValue);
}
}
Section 93
//Sort (mx.collections.Sort)
package mx.collections {
import flash.events.*;
import mx.core.*;
import mx.resources.*;
import mx.utils.*;
import mx.collections.errors.*;
public class Sort extends EventDispatcher {
private var noFieldsDescending:Boolean;// = false
private var usingCustomCompareFunction:Boolean;
private var defaultEmptyField:SortField;
private var _fields:Array;
private var _compareFunction:Function;
private var _unique:Boolean;
private var fieldList:Array;
private var resourceManager:IResourceManager;
public static const ANY_INDEX_MODE:String = "any";
mx_internal static const VERSION:String = "3.0.0.0";
public static const LAST_INDEX_MODE:String = "last";
public static const FIRST_INDEX_MODE:String = "first";
public function Sort(){
resourceManager = ResourceManager.getInstance();
fieldList = [];
super();
}
public function get unique():Boolean{
return (_unique);
}
public function get compareFunction():Function{
return ((usingCustomCompareFunction) ? _compareFunction : internalCompare);
}
public function set unique(value:Boolean):void{
_unique = value;
}
public function sort(items:Array):void{
var fixedCompareFunction:Function;
var message:String;
var uniqueRet1:Object;
var fields:Array;
var i:int;
var sortArgs:Object;
var uniqueRet2:Object;
var items = items;
if (((!(items)) || ((items.length <= 1)))){
return;
};
if (usingCustomCompareFunction){
fixedCompareFunction = function (a:Object, b:Object):int{
return (compareFunction(a, b, _fields));
};
if (unique){
uniqueRet1 = items.sort(fixedCompareFunction, Array.UNIQUESORT);
if (uniqueRet1 == 0){
message = resourceManager.getString("collections", "nonUnique");
throw (new SortError(message));
};
} else {
items.sort(fixedCompareFunction);
};
} else {
fields = this.fields;
if (((fields) && ((fields.length > 0)))){
sortArgs = initSortFields(items[0], true);
if (unique){
if (((sortArgs) && ((fields.length == 1)))){
uniqueRet2 = items.sortOn(sortArgs.fields[0], (sortArgs.options[0] | Array.UNIQUESORT));
} else {
uniqueRet2 = items.sort(internalCompare, Array.UNIQUESORT);
};
if (uniqueRet2 == 0){
message = resourceManager.getString("collections", "nonUnique");
throw (new SortError(message));
};
} else {
if (sortArgs){
items.sortOn(sortArgs.fields, sortArgs.options);
} else {
items.sort(internalCompare);
};
};
} else {
items.sort(internalCompare);
};
};
}
public function propertyAffectsSort(property:String):Boolean{
var field:SortField;
if (((usingCustomCompareFunction) || (!(fields)))){
return (true);
};
var i:int;
while (i < fields.length) {
field = fields[i];
if ((((field.name == property)) || (field.usingCustomCompareFunction))){
return (true);
};
i++;
};
return (false);
}
private function internalCompare(a:Object, b:Object, fields:Array=null):int{
var i:int;
var len:int;
var sf:SortField;
var result:int;
if (!_fields){
result = noFieldsCompare(a, b);
} else {
i = 0;
len = (fields) ? fields.length : _fields.length;
while ((((result == 0)) && ((i < len)))) {
sf = SortField(_fields[i]);
result = sf.internalCompare(a, b);
i++;
};
};
return (result);
}
public function reverse():void{
var i:int;
if (fields){
i = 0;
while (i < fields.length) {
SortField(fields[i]).reverse();
i++;
};
};
noFieldsDescending = !(noFieldsDescending);
}
private function noFieldsCompare(a:Object, b:Object, fields:Array=null):int{
var message:String;
var a = a;
var b = b;
var fields = fields;
if (!defaultEmptyField){
defaultEmptyField = new SortField();
defaultEmptyField.initCompare(a);
//unresolved jump
var _slot1 = e;
message = resourceManager.getString("collections", "noComparator", [a]);
throw (new SortError(message));
};
var result:int = defaultEmptyField.compareFunction(a, b);
if (noFieldsDescending){
result = (result * -1);
};
return (result);
}
public function findItem(items:Array, values:Object, mode:String, returnInsertionIndex:Boolean=false, compareFunction:Function=null):int{
var compareForFind:Function;
var fieldsForCompare:Array;
var message:String;
var index:int;
var fieldName:String;
var hadPreviousFieldName:Boolean;
var i:int;
var hasFieldName:Boolean;
var objIndex:int;
var match:Boolean;
var prevCompare:int;
var nextCompare:int;
var items = items;
var values = values;
var mode = mode;
var returnInsertionIndex = returnInsertionIndex;
var compareFunction = compareFunction;
if (!items){
message = resourceManager.getString("collections", "noItems");
throw (new SortError(message));
};
if (items.length == 0){
return ((returnInsertionIndex) ? 1 : -1);
};
if (compareFunction == null){
compareForFind = this.compareFunction;
if (((values) && ((fieldList.length > 0)))){
fieldsForCompare = [];
hadPreviousFieldName = true;
i = 0;
for (;i < fieldList.length;if (hasFieldName){
if (!hadPreviousFieldName){
message = resourceManager.getString("collections", "findCondition", [fieldName]);
throw (new SortError(message));
};
fieldsForCompare.push(fieldName);
} else {
hadPreviousFieldName = false;
}, continue, fieldsForCompare.push(null), (i = (i + 1))) {
fieldName = fieldList[i];
//unresolved if
hasFieldName = !((values[fieldName] === undefined));
continue;
var _slot1 = e;
hasFieldName = false;
};
if (fieldsForCompare.length == 0){
message = resourceManager.getString("collections", "findRestriction");
throw (new SortError(message));
};
initSortFields(items[0]);
//unresolved jump
var _slot1 = initSortError;
};
} else {
compareForFind = compareFunction;
};
var found:Boolean;
var objFound:Boolean;
index = 0;
var lowerBound:int;
var upperBound:int = (items.length - 1);
var obj:Object;
var direction = 1;
while (((!(objFound)) && ((lowerBound <= upperBound)))) {
index = Math.round(((lowerBound + upperBound) / 2));
obj = items[index];
direction = (fieldsForCompare) ? compareForFind(values, obj, fieldsForCompare) : compareForFind(values, obj);
switch (direction){
case -1:
upperBound = (index - 1);
break;
case 0:
objFound = true;
switch (mode){
case ANY_INDEX_MODE:
found = true;
break;
case FIRST_INDEX_MODE:
found = (index == lowerBound);
objIndex = (index - 1);
match = true;
while (((((match) && (!(found)))) && ((objIndex >= lowerBound)))) {
obj = items[objIndex];
prevCompare = (fieldsForCompare) ? compareForFind(values, obj, fieldsForCompare) : compareForFind(values, obj);
match = (prevCompare == 0);
if (((!(match)) || (((match) && ((objIndex == lowerBound)))))){
found = true;
index = (objIndex + (match) ? 0 : 1);
};
objIndex = (objIndex - 1);
};
break;
case LAST_INDEX_MODE:
found = (index == upperBound);
objIndex = (index + 1);
match = true;
while (((((match) && (!(found)))) && ((objIndex <= upperBound)))) {
obj = items[objIndex];
nextCompare = (fieldsForCompare) ? compareForFind(values, obj, fieldsForCompare) : compareForFind(values, obj);
match = (nextCompare == 0);
if (((!(match)) || (((match) && ((objIndex == upperBound)))))){
found = true;
index = (objIndex - (match) ? 0 : 1);
};
objIndex = (objIndex + 1);
};
break;
default:
message = resourceManager.getString("collections", "unknownMode");
throw (new SortError(message));
};
break;
case 1:
lowerBound = (index + 1);
break;
};
};
if (((!(found)) && (!(returnInsertionIndex)))){
return (-1);
};
return (((direction)>0) ? (index + 1) : index);
}
private function initSortFields(item:Object, buildArraySortArgs:Boolean=false):Object{
var i:int;
var field:SortField;
var options:int;
var arraySortArgs:Object;
i = 0;
while (i < fields.length) {
SortField(fields[i]).initCompare(item);
i++;
};
if (buildArraySortArgs){
arraySortArgs = {fields:[], options:[]};
i = 0;
while (i < fields.length) {
field = fields[i];
options = field.getArraySortOnOptions();
if (options == -1){
return (null);
};
arraySortArgs.fields.push(field.name);
arraySortArgs.options.push(options);
i++;
};
};
return (arraySortArgs);
}
public function set fields(value:Array):void{
var field:SortField;
var i:int;
_fields = value;
fieldList = [];
if (_fields){
i = 0;
while (i < _fields.length) {
field = SortField(_fields[i]);
fieldList.push(field.name);
i++;
};
};
dispatchEvent(new Event("fieldsChanged"));
}
public function get fields():Array{
return (_fields);
}
public function set compareFunction(value:Function):void{
_compareFunction = value;
usingCustomCompareFunction = !((_compareFunction == null));
}
override public function toString():String{
return (ObjectUtil.toString(this));
}
}
}//package mx.collections
Section 94
//SortField (mx.collections.SortField)
package mx.collections {
import flash.events.*;
import mx.core.*;
import mx.resources.*;
import mx.utils.*;
import mx.collections.errors.*;
public class SortField extends EventDispatcher {
private var _caseInsensitive:Boolean;
private var _numeric:Object;
private var _descending:Boolean;
private var _compareFunction:Function;
private var _usingCustomCompareFunction:Boolean;
private var _name:String;
private var resourceManager:IResourceManager;
mx_internal static const VERSION:String = "3.0.0.0";
public function SortField(name:String=null, caseInsensitive:Boolean=false, descending:Boolean=false, numeric:Object=null){
resourceManager = ResourceManager.getInstance();
super();
_name = name;
_caseInsensitive = caseInsensitive;
_descending = descending;
_numeric = numeric;
_compareFunction = stringCompare;
}
public function get caseInsensitive():Boolean{
return (_caseInsensitive);
}
mx_internal function get usingCustomCompareFunction():Boolean{
return (_usingCustomCompareFunction);
}
public function set caseInsensitive(value:Boolean):void{
if (value != _caseInsensitive){
_caseInsensitive = value;
dispatchEvent(new Event("caseInsensitiveChanged"));
};
}
public function get name():String{
return (_name);
}
public function get numeric():Object{
return (_numeric);
}
public function set name(n:String):void{
_name = n;
dispatchEvent(new Event("nameChanged"));
}
private function numericCompare(a:Object, b:Object):int{
var fa:Number;
var fb:Number;
var a = a;
var b = b;
fa = ((_name == null)) ? Number(a) : Number(a[_name]);
//unresolved jump
var _slot1 = error;
fb = ((_name == null)) ? Number(b) : Number(b[_name]);
//unresolved jump
var _slot1 = error;
return (ObjectUtil.numericCompare(fa, fb));
}
public function set numeric(value:Object):void{
if (_numeric != value){
_numeric = value;
dispatchEvent(new Event("numericChanged"));
};
}
private function stringCompare(a:Object, b:Object):int{
var fa:String;
var fb:String;
var a = a;
var b = b;
fa = ((_name == null)) ? String(a) : String(a[_name]);
//unresolved jump
var _slot1 = error;
fb = ((_name == null)) ? String(b) : String(b[_name]);
//unresolved jump
var _slot1 = error;
return (ObjectUtil.stringCompare(fa, fb, _caseInsensitive));
}
public function get compareFunction():Function{
return (_compareFunction);
}
public function reverse():void{
descending = !(descending);
}
mx_internal function getArraySortOnOptions():int{
if (((((((usingCustomCompareFunction) || ((name == null)))) || ((_compareFunction == xmlCompare)))) || ((_compareFunction == dateCompare)))){
return (-1);
};
var options:int;
if (caseInsensitive){
options = (options | Array.CASEINSENSITIVE);
};
if (descending){
options = (options | Array.DESCENDING);
};
if ((((numeric == true)) || ((_compareFunction == numericCompare)))){
options = (options | Array.NUMERIC);
};
return (options);
}
private function dateCompare(a:Object, b:Object):int{
var fa:Date;
var fb:Date;
var a = a;
var b = b;
fa = ((_name == null)) ? (a as Date) : (a[_name] as Date);
//unresolved jump
var _slot1 = error;
fb = ((_name == null)) ? (b as Date) : (b[_name] as Date);
//unresolved jump
var _slot1 = error;
return (ObjectUtil.dateCompare(fa, fb));
}
mx_internal function internalCompare(a:Object, b:Object):int{
var result:int = compareFunction(a, b);
if (descending){
result = (result * -1);
};
return (result);
}
override public function toString():String{
return (ObjectUtil.toString(this));
}
private function nullCompare(a:Object, b:Object):int{
var value:Object;
var left:Object;
var right:Object;
var message:String;
var a = a;
var b = b;
var found:Boolean;
if ((((a == null)) && ((b == null)))){
return (0);
};
if (_name){
left = a[_name];
//unresolved jump
var _slot1 = error;
right = b[_name];
//unresolved jump
var _slot1 = error;
};
if ((((left == null)) && ((right == null)))){
return (0);
};
if (left == null){
left = a;
};
if (right == null){
right = b;
};
var typeLeft = typeof(left);
var typeRight = typeof(right);
if ((((typeLeft == "string")) || ((typeRight == "string")))){
found = true;
_compareFunction = stringCompare;
} else {
if ((((typeLeft == "object")) || ((typeRight == "object")))){
if ((((typeLeft is Date)) || ((typeRight is Date)))){
found = true;
_compareFunction = dateCompare;
};
} else {
if ((((typeLeft == "xml")) || ((typeRight == "xml")))){
found = true;
_compareFunction = xmlCompare;
} else {
if ((((((((typeLeft == "number")) || ((typeRight == "number")))) || ((typeLeft == "boolean")))) || ((typeRight == "boolean")))){
found = true;
_compareFunction = numericCompare;
};
};
};
};
if (found){
return (_compareFunction(left, right));
};
message = resourceManager.getString("collections", "noComparatorSortField", [name]);
throw (new SortError(message));
}
public function set descending(value:Boolean):void{
if (_descending != value){
_descending = value;
dispatchEvent(new Event("descendingChanged"));
};
}
mx_internal function initCompare(obj:Object):void{
var value:Object;
var typ:String;
var test:String;
var obj = obj;
if (!usingCustomCompareFunction){
if (numeric == true){
_compareFunction = numericCompare;
} else {
if (((caseInsensitive) || ((numeric == false)))){
_compareFunction = stringCompare;
} else {
if (_name){
value = obj[_name];
//unresolved jump
var _slot1 = error;
};
if (value == null){
value = obj;
};
typ = typeof(value);
switch (typ){
case "string":
_compareFunction = stringCompare;
break;
case "object":
if ((value is Date)){
_compareFunction = dateCompare;
} else {
_compareFunction = stringCompare;
test = value.toString();
//unresolved jump
var _slot1 = error2;
if (((!(test)) || ((test == "[object Object]")))){
_compareFunction = nullCompare;
};
};
break;
case "xml":
_compareFunction = xmlCompare;
break;
case "boolean":
case "number":
_compareFunction = numericCompare;
break;
};
};
};
};
}
public function get descending():Boolean{
return (_descending);
}
public function set compareFunction(c:Function):void{
_compareFunction = c;
_usingCustomCompareFunction = !((c == null));
}
private function xmlCompare(a:Object, b:Object):int{
var sa:String;
var sb:String;
var a = a;
var b = b;
sa = ((_name == null)) ? a.toString() : a[_name].toString();
//unresolved jump
var _slot1 = error;
sb = ((_name == null)) ? b.toString() : b[_name].toString();
//unresolved jump
var _slot1 = error;
if (numeric == true){
return (ObjectUtil.numericCompare(parseFloat(sa), parseFloat(sb)));
};
return (ObjectUtil.stringCompare(sa, sb, _caseInsensitive));
}
}
}//package mx.collections
Section 95
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.0.0.0";
public function BitmapAsset(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
super(bitmapData, pixelSnapping, smoothing);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(newWidth:Number, newHeight:Number):void{
width = newWidth;
height = newHeight;
}
public function move(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
}
}//package mx.core
Section 96
//EdgeMetrics (mx.core.EdgeMetrics)
package mx.core {
public class EdgeMetrics {
public var top:Number;
public var left:Number;
public var bottom:Number;
public var right:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public static const EMPTY:EdgeMetrics = new EdgeMetrics(0, 0, 0, 0);
;
public function EdgeMetrics(left:Number=0, top:Number=0, right:Number=0, bottom:Number=0){
super();
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
public function clone():EdgeMetrics{
return (new EdgeMetrics(left, top, right, bottom));
}
}
}//package mx.core
Section 97
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexBitmap(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
var bitmapData = bitmapData;
var pixelSnapping = pixelSnapping;
var smoothing = smoothing;
super(bitmapData, pixelSnapping, smoothing);
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 98
//FlexMovieClip (mx.core.FlexMovieClip)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexMovieClip extends MovieClip {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexMovieClip(){
super();
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 99
//FlexSprite (mx.core.FlexSprite)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexSprite extends Sprite {
mx_internal static const VERSION:String = "3.0.0.0";
public function FlexSprite(){
super();
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 100
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
public function FontAsset(){
super();
}
}
}//package mx.core
Section 101
//IBorder (mx.core.IBorder)
package mx.core {
public interface IBorder {
function get borderMetrics():EdgeMetrics;
}
}//package mx.core
Section 102
//IButton (mx.core.IButton)
package mx.core {
public interface IButton extends IUIComponent {
function get emphasized():Boolean;
function set emphasized(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IButton.as:Boolean):void;
function callLater(_arg1:Function, _arg2:Array=null):void;
}
}//package mx.core
Section 103
//IChildList (mx.core.IChildList)
package mx.core {
import flash.display.*;
import flash.geom.*;
public interface IChildList {
function get numChildren():int;
function removeChild(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IChildList.as:DisplayObject):DisplayObject;
function getChildByName(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IChildList.as:String):DisplayObject;
function removeChildAt(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IChildList.as:int):DisplayObject;
function getChildIndex(:DisplayObject):int;
function addChildAt(_arg1:DisplayObject, _arg2:int):DisplayObject;
function getObjectsUnderPoint(child:Point):Array;
function setChildIndex(_arg1:DisplayObject, _arg2:int):void;
function getChildAt(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IChildList.as:int):DisplayObject;
function addChild(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IChildList.as:DisplayObject):DisplayObject;
function contains(flash.display:DisplayObject):Boolean;
}
}//package mx.core
Section 104
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 105
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(void:Point):Point;
function get name():String;
function set width(flash.display:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(flash.display:String):void;
function set scaleX(flash.display:Number):void;
function set scaleY(flash.display:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(flash.display:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(void:Point):Point;
function get height():Number;
function set blendMode(flash.display:String):void;
function get parent():DisplayObjectContainer;
function getBounds(String:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(flash.display:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(flash.display:Number):void;
function set accessibilityProperties(flash.display:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(flash.display:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(flash.display:Number):void;
function set mask(flash.display:DisplayObject):void;
function getRect(String:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(flash.display:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(mx.core:IFlexDisplayObject/mx.core:IFlexDisplayObject:stage/get:DisplayObject):Boolean;
function set opaqueBackground(flash.display:Object):void;
function set visible(flash.display:Boolean):void;
function get mask():DisplayObject;
function set x(flash.display:Number):void;
function set y(flash.display:Number):void;
function get transform():Transform;
function set filters(flash.display:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(flash.display:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 106
//IFlexModuleFactory (mx.core.IFlexModuleFactory)
package mx.core {
public interface IFlexModuleFactory {
function create(... _args):Object;
function info():Object;
}
}//package mx.core
Section 107
//IMXMLObject (mx.core.IMXMLObject)
package mx.core {
public interface IMXMLObject {
function initialized(_arg1:Object, _arg2:String):void;
}
}//package mx.core
Section 108
//IPropertyChangeNotifier (mx.core.IPropertyChangeNotifier)
package mx.core {
import flash.events.*;
public interface IPropertyChangeNotifier extends IEventDispatcher, IUID {
}
}//package mx.core
Section 109
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get isDocument():Boolean;
function set repeaters(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function initializeRepeaterArrays(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 110
//IUIComponent (mx.core.IUIComponent)
package mx.core {
import flash.display.*;
import mx.managers.*;
public interface IUIComponent extends IFlexDisplayObject {
function set focusPane(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Sprite):void;
function get enabled():Boolean;
function set enabled(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Boolean):void;
function set isPopUp(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Boolean):void;
function get explicitMinHeight():Number;
function get percentWidth():Number;
function get isPopUp():Boolean;
function get owner():DisplayObjectContainer;
function get percentHeight():Number;
function get baselinePosition():Number;
function owns(Number:DisplayObject):Boolean;
function initialize():void;
function get maxWidth():Number;
function get minWidth():Number;
function getExplicitOrMeasuredWidth():Number;
function get explicitMaxWidth():Number;
function get explicitMaxHeight():Number;
function set percentHeight(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function get minHeight():Number;
function set percentWidth(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function get document():Object;
function get focusPane():Sprite;
function getExplicitOrMeasuredHeight():Number;
function set tweeningProperties(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Array):void;
function set explicitWidth(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function set measuredMinHeight(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function get explicitMinWidth():Number;
function get tweeningProperties():Array;
function get maxHeight():Number;
function set owner(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:DisplayObjectContainer):void;
function set includeInLayout(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Boolean):void;
function setVisible(_arg1:Boolean, _arg2:Boolean=false):void;
function parentChanged(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:DisplayObjectContainer):void;
function get explicitWidth():Number;
function get measuredMinHeight():Number;
function set measuredMinWidth(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function set explicitHeight(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void;
function get includeInLayout():Boolean;
function get measuredMinWidth():Number;
function get explicitHeight():Number;
function set systemManager(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:ISystemManager):void;
function set document(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Object):void;
function get systemManager():ISystemManager;
}
}//package mx.core
Section 111
//IUID (mx.core.IUID)
package mx.core {
public interface IUID {
function get uid():String;
function set uid(E:\dev\3.1.0\frameworks\projects\framework\src;mx\core;IUID.as:String):void;
}
}//package mx.core
Section 112
//MovieClipAsset (mx.core.MovieClipAsset)
package mx.core {
public class MovieClipAsset extends FlexMovieClip implements IFlexAsset, IFlexDisplayObject, IBorder {
private var _measuredHeight:Number;
private var _measuredWidth:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public function MovieClipAsset(){
super();
_measuredWidth = width;
_measuredHeight = height;
}
public function get measuredWidth():Number{
return (_measuredWidth);
}
public function get measuredHeight():Number{
return (_measuredHeight);
}
public function setActualSize(newWidth:Number, newHeight:Number):void{
width = newWidth;
height = newHeight;
}
public function move(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
public function get borderMetrics():EdgeMetrics{
if (scale9Grid == null){
return (EdgeMetrics.EMPTY);
};
return (new EdgeMetrics(scale9Grid.left, scale9Grid.top, Math.ceil((measuredWidth - scale9Grid.right)), Math.ceil((measuredHeight - scale9Grid.bottom))));
}
}
}//package mx.core
Section 113
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 114
//Singleton (mx.core.Singleton)
package mx.core {
public class Singleton {
mx_internal static const VERSION:String = "3.0.0.0";
private static var classMap:Object = {};
public function Singleton(){
super();
}
public static function registerClass(interfaceName:String, clazz:Class):void{
var c:Class = classMap[interfaceName];
if (!c){
classMap[interfaceName] = clazz;
};
}
public static function getClass(interfaceName:String):Class{
return (classMap[interfaceName]);
}
public static function getInstance(interfaceName:String):Object{
var c:Class = classMap[interfaceName];
if (!c){
throw (new Error((("No class registered for interface '" + interfaceName) + "'.")));
};
return (c["getInstance"]());
}
}
}//package mx.core
Section 115
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "3.0.0.0";
public function SoundAsset(){
super();
}
}
}//package mx.core
Section 116
//SpriteAsset (mx.core.SpriteAsset)
package mx.core {
public class SpriteAsset extends FlexSprite implements IFlexAsset, IFlexDisplayObject, IBorder {
private var _measuredHeight:Number;
private var _measuredWidth:Number;
mx_internal static const VERSION:String = "3.0.0.0";
public function SpriteAsset(){
super();
_measuredWidth = width;
_measuredHeight = height;
}
public function get measuredWidth():Number{
return (_measuredWidth);
}
public function get measuredHeight():Number{
return (_measuredHeight);
}
public function setActualSize(newWidth:Number, newHeight:Number):void{
width = newWidth;
height = newHeight;
}
public function move(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
public function get borderMetrics():EdgeMetrics{
if (scale9Grid == null){
return (EdgeMetrics.EMPTY);
};
return (new EdgeMetrics(scale9Grid.left, scale9Grid.top, Math.ceil((measuredWidth - scale9Grid.right)), Math.ceil((measuredHeight - scale9Grid.bottom))));
}
}
}//package mx.core
Section 117
//Elastic (mx.effects.easing.Elastic)
package mx.effects.easing {
import mx.core.*;
public class Elastic {
mx_internal static const VERSION:String = "3.0.0.0";
public function Elastic(){
super();
}
public static function easeIn(t:Number, b:Number, c:Number, d:Number, a:Number=0, p:Number=0):Number{
var s:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
if (!p){
p = (d * 0.3);
};
if (((!(a)) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
--t;
return ((-(((a * Math.pow(2, (10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p)))) + b));
}
public static function easeInOut(t:Number, b:Number, c:Number, d:Number, a:Number=0, p:Number=0):Number{
var s:Number;
if (t == 0){
return (b);
};
t = (t / (d / 2));
if (t == 2){
return ((b + c));
};
if (!p){
p = (d * (0.3 * 1.5));
};
if (((!(a)) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
if (t < 1){
--t;
return (((-0.5 * ((a * Math.pow(2, (10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p)))) + b));
};
--t;
return ((((((a * Math.pow(2, (-10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p))) * 0.5) + c) + b));
}
public static function easeOut(t:Number, b:Number, c:Number, d:Number, a:Number=0, p:Number=0):Number{
var s:Number;
if (t == 0){
return (b);
};
t = (t / d);
if (t == 1){
return ((b + c));
};
if (!p){
p = (d * 0.3);
};
if (((!(a)) || ((a < Math.abs(c))))){
a = c;
s = (p / 4);
} else {
s = ((p / (2 * Math.PI)) * Math.asin((c / a)));
};
return (((((a * Math.pow(2, (-10 * t))) * Math.sin(((((t * d) - s) * (2 * Math.PI)) / p))) + c) + b));
}
}
}//package mx.effects.easing
Section 118
//CollectionEvent (mx.events.CollectionEvent)
package mx.events {
import flash.events.*;
import mx.core.*;
public class CollectionEvent extends Event {
public var kind:String;
public var location:int;
public var items:Array;
public var oldLocation:int;
mx_internal static const VERSION:String = "3.0.0.0";
public static const COLLECTION_CHANGE:String = "collectionChange";
public function CollectionEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, kind:String=null, location:int=-1, oldLocation:int=-1, items:Array=null){
super(type, bubbles, cancelable);
this.kind = kind;
this.location = location;
this.oldLocation = oldLocation;
this.items = (items) ? items : [];
}
override public function toString():String{
return (formatToString("CollectionEvent", "kind", "location", "oldLocation", "type", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new CollectionEvent(type, bubbles, cancelable, kind, location, oldLocation, items));
}
}
}//package mx.events
Section 119
//CollectionEventKind (mx.events.CollectionEventKind)
package mx.events {
import mx.core.*;
public final class CollectionEventKind {
public static const ADD:String = "add";
public static const REMOVE:String = "remove";
public static const UPDATE:String = "update";
public static const MOVE:String = "move";
mx_internal static const EXPAND:String = "expand";
public static const REPLACE:String = "replace";
mx_internal static const VERSION:String = "3.0.0.0";
public static const REFRESH:String = "refresh";
public static const RESET:String = "reset";
public function CollectionEventKind(){
super();
}
}
}//package mx.events
Section 120
//FlexEvent (mx.events.FlexEvent)
package mx.events {
import flash.events.*;
import mx.core.*;
public class FlexEvent extends Event {
public static const ADD:String = "add";
public static const TRANSFORM_CHANGE:String = "transformChange";
public static const INIT_COMPLETE:String = "initComplete";
public static const REMOVE:String = "remove";
public static const BUTTON_DOWN:String = "buttonDown";
public static const EXIT_STATE:String = "exitState";
public static const CREATION_COMPLETE:String = "creationComplete";
public static const REPEAT:String = "repeat";
public static const LOADING:String = "loading";
public static const REPEAT_START:String = "repeatStart";
public static const INITIALIZE:String = "initialize";
public static const ENTER_STATE:String = "enterState";
public static const URL_CHANGED:String = "urlChanged";
public static const REPEAT_END:String = "repeatEnd";
mx_internal static const VERSION:String = "3.0.0.0";
public static const HIDE:String = "hide";
public static const ENTER:String = "enter";
public static const PRELOADER_DONE:String = "preloaderDone";
public static const CURSOR_UPDATE:String = "cursorUpdate";
public static const PREINITIALIZE:String = "preinitialize";
public static const INVALID:String = "invalid";
public static const IDLE:String = "idle";
public static const VALID:String = "valid";
public static const DATA_CHANGE:String = "dataChange";
public static const APPLICATION_COMPLETE:String = "applicationComplete";
public static const VALUE_COMMIT:String = "valueCommit";
public static const UPDATE_COMPLETE:String = "updateComplete";
public static const INIT_PROGRESS:String = "initProgress";
public static const SHOW:String = "show";
public function FlexEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
}
override public function clone():Event{
return (new FlexEvent(type, bubbles, cancelable));
}
}
}//package mx.events
Section 121
//ModuleEvent (mx.events.ModuleEvent)
package mx.events {
import flash.events.*;
import mx.core.*;
import mx.modules.*;
public class ModuleEvent extends ProgressEvent {
public var errorText:String;
private var _module:IModuleInfo;
public static const READY:String = "ready";
public static const ERROR:String = "error";
public static const PROGRESS:String = "progress";
mx_internal static const VERSION:String = "3.0.0.0";
public static const SETUP:String = "setup";
public static const UNLOAD:String = "unload";
public function ModuleEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:uint=0, bytesTotal:uint=0, errorText:String=null, module:IModuleInfo=null){
super(type, bubbles, cancelable, bytesLoaded, bytesTotal);
this.errorText = errorText;
this._module = module;
}
public function get module():IModuleInfo{
if (_module){
return (_module);
};
return ((target as IModuleInfo));
}
override public function clone():Event{
return (new ModuleEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText, module));
}
}
}//package mx.events
Section 122
//PropertyChangeEvent (mx.events.PropertyChangeEvent)
package mx.events {
import flash.events.*;
import mx.core.*;
public class PropertyChangeEvent extends Event {
public var newValue:Object;
public var kind:String;
public var property:Object;
public var oldValue:Object;
public var source:Object;
mx_internal static const VERSION:String = "3.0.0.0";
public static const PROPERTY_CHANGE:String = "propertyChange";
public function PropertyChangeEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, kind:String=null, property:Object=null, oldValue:Object=null, newValue:Object=null, source:Object=null){
super(type, bubbles, cancelable);
this.kind = kind;
this.property = property;
this.oldValue = oldValue;
this.newValue = newValue;
this.source = source;
}
override public function clone():Event{
return (new PropertyChangeEvent(type, bubbles, cancelable, kind, property, oldValue, newValue, source));
}
public static function createUpdateEvent(source:Object, property:Object, oldValue:Object, newValue:Object):PropertyChangeEvent{
var event:PropertyChangeEvent = new PropertyChangeEvent(PROPERTY_CHANGE);
event.kind = PropertyChangeEventKind.UPDATE;
event.oldValue = oldValue;
event.newValue = newValue;
event.source = source;
event.property = property;
return (event);
}
}
}//package mx.events
Section 123
//PropertyChangeEventKind (mx.events.PropertyChangeEventKind)
package mx.events {
import mx.core.*;
public final class PropertyChangeEventKind {
mx_internal static const VERSION:String = "3.0.0.0";
public static const UPDATE:String = "update";
public static const DELETE:String = "delete";
public function PropertyChangeEventKind(){
super();
}
}
}//package mx.events
Section 124
//ResourceEvent (mx.events.ResourceEvent)
package mx.events {
import flash.events.*;
import mx.core.*;
public class ResourceEvent extends ProgressEvent {
public var errorText:String;
mx_internal static const VERSION:String = "3.0.0.0";
public static const COMPLETE:String = "complete";
public static const PROGRESS:String = "progress";
public static const ERROR:String = "error";
public function ResourceEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:uint=0, bytesTotal:uint=0, errorText:String=null){
super(type, bubbles, cancelable, bytesLoaded, bytesTotal);
this.errorText = errorText;
}
override public function clone():Event{
return (new ResourceEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText));
}
}
}//package mx.events
Section 125
//InvalidCategoryError (mx.logging.errors.InvalidCategoryError)
package mx.logging.errors {
import mx.core.*;
public class InvalidCategoryError extends Error {
mx_internal static const VERSION:String = "3.0.0.0";
public function InvalidCategoryError(message:String){
super(message);
}
public function toString():String{
return (String(message));
}
}
}//package mx.logging.errors
Section 126
//ILogger (mx.logging.ILogger)
package mx.logging {
import flash.events.*;
public interface ILogger extends IEventDispatcher {
function debug(E:\dev\3.1.0\frameworks\projects\framework\src;mx\logging;ILogger.as:String, ... _args):void;
function fatal(E:\dev\3.1.0\frameworks\projects\framework\src;mx\logging;ILogger.as:String, ... _args):void;
function get category():String;
function warn(E:\dev\3.1.0\frameworks\projects\framework\src;mx\logging;ILogger.as:String, ... _args):void;
function error(E:\dev\3.1.0\frameworks\projects\framework\src;mx\logging;ILogger.as:String, ... _args):void;
function log(_arg1:int, _arg2:String, ... _args):void;
function info(E:\dev\3.1.0\frameworks\projects\framework\src;mx\logging;ILogger.as:String, ... _args):void;
}
}//package mx.logging
Section 127
//ILoggingTarget (mx.logging.ILoggingTarget)
package mx.logging {
public interface ILoggingTarget {
function addLogger(E:\dev\3.1.0\frameworks\projects\framework\src;mx\logging;ILoggingTarget.as:ILogger):void;
function removeLogger(E:\dev\3.1.0\frameworks\projects\framework\src;mx\logging;ILoggingTarget.as:ILogger):void;
function get level():int;
function set filters(E:\dev\3.1.0\frameworks\projects\framework\src;mx\logging;ILoggingTarget.as:Array):void;
function set level(E:\dev\3.1.0\frameworks\projects\framework\src;mx\logging;ILoggingTarget.as:int):void;
function get filters():Array;
}
}//package mx.logging
Section 128
//Log (mx.logging.Log)
package mx.logging {
import mx.core.*;
import mx.resources.*;
import mx.logging.errors.*;
public class Log {
mx_internal static const VERSION:String = "3.0.0.0";
private static var _resourceManager:IResourceManager;
private static var _targets:Array = [];
private static var _loggers:Array;
private static var NONE:int = 2147483647;
private static var _targetLevel:int = NONE;
public function Log(){
super();
}
private static function categoryMatchInFilterList(category:String, filters:Array):Boolean{
var filter:String;
var result:Boolean;
var index = -1;
var i:uint;
while (i < filters.length) {
filter = filters[i];
index = filter.indexOf("*");
if (index == 0){
return (true);
};
index = ((index < 0)) ? index = category.length;
index : (index - 1);
if (category.substring(0, index) == filter.substring(0, index)){
return (true);
};
i++;
};
return (false);
}
public static function flush():void{
_loggers = [];
_targets = [];
_targetLevel = NONE;
}
public static function isDebug():Boolean{
return (((_targetLevel)<=LogEventLevel.DEBUG) ? true : false);
}
public static function getLogger(category:String):ILogger{
var target:ILoggingTarget;
checkCategory(category);
if (!_loggers){
_loggers = [];
};
var result:ILogger = _loggers[category];
if (result == null){
result = new LogLogger(category);
_loggers[category] = result;
};
var i:int;
while (i < _targets.length) {
target = ILoggingTarget(_targets[i]);
if (categoryMatchInFilterList(category, target.filters)){
target.addLogger(result);
};
i++;
};
return (result);
}
public static function isWarn():Boolean{
return (((_targetLevel)<=LogEventLevel.WARN) ? true : false);
}
public static function addTarget(target:ILoggingTarget):void{
var filters:Array;
var logger:ILogger;
var i:String;
var message:String;
if (target){
filters = target.filters;
for (i in _loggers) {
if (categoryMatchInFilterList(i, filters)){
target.addLogger(ILogger(_loggers[i]));
};
};
_targets.push(target);
if (_targetLevel == NONE){
_targetLevel = target.level;
} else {
if (target.level < _targetLevel){
_targetLevel = target.level;
};
};
} else {
message = resourceManager.getString("logging", "invalidTarget");
throw (new ArgumentError(message));
};
}
public static function hasIllegalCharacters(value:String):Boolean{
return (!((value.search(/[\[\]\~\$\^\&\\(\)\{\}\+\?\/=`!@#%,:;'"<>\s]/) == -1)));
}
private static function checkCategory(category:String):void{
var message:String;
if ((((category == null)) || ((category.length == 0)))){
message = resourceManager.getString("logging", "invalidLen");
throw (new InvalidCategoryError(message));
};
if (((hasIllegalCharacters(category)) || (!((category.indexOf("*") == -1))))){
message = resourceManager.getString("logging", "invalidChars");
throw (new InvalidCategoryError(message));
};
}
private static function resetTargetLevel():void{
var minLevel:int = NONE;
var i:int;
while (i < _targets.length) {
if ((((minLevel == NONE)) || ((_targets[i].level < minLevel)))){
minLevel = _targets[i].level;
};
i++;
};
_targetLevel = minLevel;
}
public static function removeTarget(target:ILoggingTarget):void{
var filters:Array;
var logger:ILogger;
var i:String;
var j:int;
var message:String;
if (target){
filters = target.filters;
for (i in _loggers) {
if (categoryMatchInFilterList(i, filters)){
target.removeLogger(ILogger(_loggers[i]));
};
};
j = 0;
while (j < _targets.length) {
if (target == _targets[j]){
_targets.splice(j, 1);
j--;
};
j++;
};
resetTargetLevel();
} else {
message = resourceManager.getString("logging", "invalidTarget");
throw (new ArgumentError(message));
};
}
public static function isInfo():Boolean{
return (((_targetLevel)<=LogEventLevel.INFO) ? true : false);
}
public static function isFatal():Boolean{
return (((_targetLevel)<=LogEventLevel.FATAL) ? true : false);
}
public static function isError():Boolean{
return (((_targetLevel)<=LogEventLevel.ERROR) ? true : false);
}
private static function get resourceManager():IResourceManager{
if (!_resourceManager){
_resourceManager = ResourceManager.getInstance();
};
return (_resourceManager);
}
}
}//package mx.logging
Section 129
//LogEvent (mx.logging.LogEvent)
package mx.logging {
import flash.events.*;
import mx.core.*;
public class LogEvent extends Event {
public var level:int;
public var message:String;
mx_internal static const VERSION:String = "3.0.0.0";
public static const LOG:String = "log";
public function LogEvent(message:String="", level:int=0){
super(LogEvent.LOG, false, false);
this.message = message;
this.level = level;
}
override public function clone():Event{
return (new LogEvent(message, level));
}
public static function getLevelString(value:uint):String{
switch (value){
case LogEventLevel.INFO:
return ("INFO");
case LogEventLevel.DEBUG:
return ("DEBUG");
case LogEventLevel.ERROR:
return ("ERROR");
case LogEventLevel.WARN:
return ("WARN");
case LogEventLevel.FATAL:
return ("FATAL");
case LogEventLevel.ALL:
return ("ALL");
};
return ("UNKNOWN");
}
}
}//package mx.logging
Section 130
//LogEventLevel (mx.logging.LogEventLevel)
package mx.logging {
import mx.core.*;
public final class LogEventLevel {
public static const ALL:int = 0;
public static const FATAL:int = 1000;
public static const WARN:int = 6;
public static const INFO:int = 4;
public static const ERROR:int = 8;
public static const DEBUG:int = 2;
mx_internal static const VERSION:String = "3.0.0.0";
public function LogEventLevel(){
super();
}
}
}//package mx.logging
Section 131
//LogLogger (mx.logging.LogLogger)
package mx.logging {
import flash.events.*;
import mx.core.*;
import mx.resources.*;
public class LogLogger extends EventDispatcher implements ILogger {
private var _category:String;
private var resourceManager:IResourceManager;
mx_internal static const VERSION:String = "3.0.0.0";
public function LogLogger(category:String){
resourceManager = ResourceManager.getInstance();
super();
_category = category;
}
public function log(level:int, msg:String, ... _args):void{
var message:String;
var i:int;
if (level < LogEventLevel.DEBUG){
message = resourceManager.getString("logging", "levelLimit");
throw (new ArgumentError(message));
};
if (hasEventListener(LogEvent.LOG)){
i = 0;
while (i < _args.length) {
msg = msg.replace(new RegExp((("\\{" + i) + "\\}"), "g"), _args[i]);
i++;
};
dispatchEvent(new LogEvent(msg, level));
};
}
public function error(msg:String, ... _args):void{
var i:int;
if (hasEventListener(LogEvent.LOG)){
i = 0;
while (i < _args.length) {
msg = msg.replace(new RegExp((("\\{" + i) + "\\}"), "g"), _args[i]);
i++;
};
dispatchEvent(new LogEvent(msg, LogEventLevel.ERROR));
};
}
public function warn(msg:String, ... _args):void{
var i:int;
if (hasEventListener(LogEvent.LOG)){
i = 0;
while (i < _args.length) {
msg = msg.replace(new RegExp((("\\{" + i) + "\\}"), "g"), _args[i]);
i++;
};
dispatchEvent(new LogEvent(msg, LogEventLevel.WARN));
};
}
public function get category():String{
return (_category);
}
public function info(msg:String, ... _args):void{
var i:int;
if (hasEventListener(LogEvent.LOG)){
i = 0;
while (i < _args.length) {
msg = msg.replace(new RegExp((("\\{" + i) + "\\}"), "g"), _args[i]);
i++;
};
dispatchEvent(new LogEvent(msg, LogEventLevel.INFO));
};
}
public function debug(msg:String, ... _args):void{
var i:int;
if (hasEventListener(LogEvent.LOG)){
i = 0;
while (i < _args.length) {
msg = msg.replace(new RegExp((("\\{" + i) + "\\}"), "g"), _args[i]);
i++;
};
dispatchEvent(new LogEvent(msg, LogEventLevel.DEBUG));
};
}
public function fatal(msg:String, ... _args):void{
var i:int;
if (hasEventListener(LogEvent.LOG)){
i = 0;
while (i < _args.length) {
msg = msg.replace(new RegExp((("\\{" + i) + "\\}"), "g"), _args[i]);
i++;
};
dispatchEvent(new LogEvent(msg, LogEventLevel.FATAL));
};
}
}
}//package mx.logging
Section 132
//IFocusManager (mx.managers.IFocusManager)
package mx.managers {
import flash.display.*;
import mx.core.*;
public interface IFocusManager {
function get focusPane():Sprite;
function getFocus():IFocusManagerComponent;
function deactivate():void;
function set defaultButton(E:\dev\3.1.0\frameworks\projects\framework\src;mx\managers;IFocusManager.as:IButton):void;
function set focusPane(E:\dev\3.1.0\frameworks\projects\framework\src;mx\managers;IFocusManager.as:Sprite):void;
function set showFocusIndicator(E:\dev\3.1.0\frameworks\projects\framework\src;mx\managers;IFocusManager.as:Boolean):void;
function get defaultButtonEnabled():Boolean;
function findFocusManagerComponent(value:InteractiveObject):IFocusManagerComponent;
function get nextTabIndex():int;
function get defaultButton():IButton;
function get showFocusIndicator():Boolean;
function setFocus(E:\dev\3.1.0\frameworks\projects\framework\src;mx\managers;IFocusManager.as:IFocusManagerComponent):void;
function activate():void;
function showFocus():void;
function set defaultButtonEnabled(E:\dev\3.1.0\frameworks\projects\framework\src;mx\managers;IFocusManager.as:Boolean):void;
function hideFocus():void;
function getNextFocusManagerComponent(value:Boolean=false):IFocusManagerComponent;
}
}//package mx.managers
Section 133
//IFocusManagerComponent (mx.managers.IFocusManagerComponent)
package mx.managers {
public interface IFocusManagerComponent {
function set focusEnabled(E:\dev\3.1.0\frameworks\projects\framework\src;mx\managers;IFocusManagerComponent.as:Boolean):void;
function drawFocus(E:\dev\3.1.0\frameworks\projects\framework\src;mx\managers;IFocusManagerComponent.as:Boolean):void;
function setFocus():void;
function get focusEnabled():Boolean;
function get tabEnabled():Boolean;
function get tabIndex():int;
function get mouseFocusEnabled():Boolean;
}
}//package mx.managers
Section 134
//IFocusManagerContainer (mx.managers.IFocusManagerContainer)
package mx.managers {
import flash.events.*;
import flash.display.*;
public interface IFocusManagerContainer extends IEventDispatcher {
function set focusManager(E:\dev\3.1.0\frameworks\projects\framework\src;mx\managers;IFocusManagerContainer.as:IFocusManager):void;
function get focusManager():IFocusManager;
function get systemManager():ISystemManager;
function contains(mx.managers:DisplayObject):Boolean;
}
}//package mx.managers
Section 135
//ISystemManager (mx.managers.ISystemManager)
package mx.managers {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import mx.core.*;
import flash.text.*;
public interface ISystemManager extends IEventDispatcher, IChildList, IFlexModuleFactory {
function get focusPane():Sprite;
function get loaderInfo():LoaderInfo;
function get toolTipChildren():IChildList;
function set focusPane(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:Sprite):void;
function isTopLevel():Boolean;
function get popUpChildren():IChildList;
function get screen():Rectangle;
function isFontFaceEmbedded(mx.managers:ISystemManager/mx.managers:ISystemManager:focusPane/get:TextFormat):Boolean;
function get rawChildren():IChildList;
function get topLevelSystemManager():ISystemManager;
function getDefinitionByName(E:\dev\3.1.0\frameworks\projects\framework\src;mx\managers;ISystemManager.as:String):Object;
function activate(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void;
function deactivate(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void;
function get cursorChildren():IChildList;
function set document(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:Object):void;
function get embeddedFontList():Object;
function set numModalWindows(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:int):void;
function removeFocusManager(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void;
function get document():Object;
function get numModalWindows():int;
function addFocusManager(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void;
function get stage():Stage;
}
}//package mx.managers
Section 136
//LoaderConfig (mx.messaging.config.LoaderConfig)
package mx.messaging.config {
import mx.core.*;
public class LoaderConfig {
mx_internal static const VERSION:String = "3.0.0.0";
mx_internal static var _url:String = null;
mx_internal static var _parameters:Object;
public function LoaderConfig(){
super();
}
public static function get url():String{
return (_url);
}
public static function get parameters():Object{
return (_parameters);
}
}
}//package mx.messaging.config
Section 137
//IModuleInfo (mx.modules.IModuleInfo)
package mx.modules {
import flash.events.*;
import mx.core.*;
import flash.system.*;
public interface IModuleInfo extends IEventDispatcher {
function get ready():Boolean;
function get loaded():Boolean;
function load(_arg1:ApplicationDomain=null, _arg2:SecurityDomain=null):void;
function release():void;
function get error():Boolean;
function get data():Object;
function publish(E:\dev\3.1.0\frameworks\projects\framework\src;mx\modules;IModuleInfo.as:IFlexModuleFactory):void;
function get factory():IFlexModuleFactory;
function set data(E:\dev\3.1.0\frameworks\projects\framework\src;mx\modules;IModuleInfo.as:Object):void;
function get url():String;
function get setup():Boolean;
function unload():void;
}
}//package mx.modules
Section 138
//ModuleManager (mx.modules.ModuleManager)
package mx.modules {
import mx.core.*;
public class ModuleManager {
mx_internal static const VERSION:String = "3.0.0.0";
public function ModuleManager(){
super();
}
public static function getModule(url:String):IModuleInfo{
return (getSingleton().getModule(url));
}
private static function getSingleton():Object{
if (!ModuleManagerGlobals.managerSingleton){
ModuleManagerGlobals.managerSingleton = new ModuleManagerImpl();
};
return (ModuleManagerGlobals.managerSingleton);
}
public static function getAssociatedFactory(object:Object):IFlexModuleFactory{
return (getSingleton().getAssociatedFactory(object));
}
}
}//package mx.modules
import flash.events.*;
import flash.display.*;
import mx.core.*;
import mx.events.*;
import flash.system.*;
import flash.utils.*;
import flash.net.*;
class ModuleInfoProxy extends EventDispatcher implements IModuleInfo {
private var _data:Object;
private var info:ModuleInfo;
private var referenced:Boolean;// = false
private function ModuleInfoProxy(info:ModuleInfo){
super();
this.info = info;
info.addEventListener(ModuleEvent.SETUP, moduleEventHandler, false, 0, true);
info.addEventListener(ModuleEvent.PROGRESS, moduleEventHandler, false, 0, true);
info.addEventListener(ModuleEvent.READY, moduleEventHandler, false, 0, true);
info.addEventListener(ModuleEvent.ERROR, moduleEventHandler, false, 0, true);
info.addEventListener(ModuleEvent.UNLOAD, moduleEventHandler, false, 0, true);
}
public function get loaded():Boolean{
return (info.loaded);
}
public function release():void{
if (referenced){
info.removeReference();
referenced = false;
};
}
public function get error():Boolean{
return (info.error);
}
public function get factory():IFlexModuleFactory{
return (info.factory);
}
public function publish(factory:IFlexModuleFactory):void{
info.publish(factory);
}
public function set data(value:Object):void{
_data = value;
}
public function get ready():Boolean{
return (info.ready);
}
public function load(applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):void{
var moduleEvent:ModuleEvent;
info.resurrect();
if (!referenced){
info.addReference();
referenced = true;
};
if (info.error){
dispatchEvent(new ModuleEvent(ModuleEvent.ERROR));
} else {
if (info.loaded){
if (info.setup){
dispatchEvent(new ModuleEvent(ModuleEvent.SETUP));
if (info.ready){
moduleEvent = new ModuleEvent(ModuleEvent.PROGRESS);
moduleEvent.bytesLoaded = info.size;
moduleEvent.bytesTotal = info.size;
dispatchEvent(moduleEvent);
dispatchEvent(new ModuleEvent(ModuleEvent.READY));
};
};
} else {
info.load(applicationDomain, securityDomain);
};
};
}
private function moduleEventHandler(event:ModuleEvent):void{
dispatchEvent(event);
}
public function get url():String{
return (info.url);
}
public function get data():Object{
return (_data);
}
public function get setup():Boolean{
return (info.setup);
}
public function unload():void{
info.unload();
info.removeEventListener(ModuleEvent.SETUP, moduleEventHandler);
info.removeEventListener(ModuleEvent.PROGRESS, moduleEventHandler);
info.removeEventListener(ModuleEvent.READY, moduleEventHandler);
info.removeEventListener(ModuleEvent.ERROR, moduleEventHandler);
info.removeEventListener(ModuleEvent.UNLOAD, moduleEventHandler);
}
}
class ModuleManagerImpl extends EventDispatcher {
private var moduleList:Object;
private function ModuleManagerImpl(){
moduleList = {};
super();
}
public function getModule(url:String):IModuleInfo{
var info:ModuleInfo = (moduleList[url] as ModuleInfo);
if (!info){
info = new ModuleInfo(url);
moduleList[url] = info;
};
return (new ModuleInfoProxy(info));
}
public function getAssociatedFactory(object:Object):IFlexModuleFactory{
var m:Object;
var info:ModuleInfo;
var domain:ApplicationDomain;
var cls:Class;
var object = object;
var className:String = getQualifiedClassName(object);
for each (m in moduleList) {
info = (m as ModuleInfo);
if (!info.ready){
} else {
domain = info.applicationDomain;
cls = Class(domain.getDefinition(className));
if ((object is cls)){
return (info.factory);
};
//unresolved jump
var _slot1 = error;
};
};
return (null);
}
}
class ModuleInfo extends EventDispatcher {
private var _error:Boolean;// = false
private var loader:Loader;
private var factoryInfo:FactoryInfo;
private var limbo:Dictionary;
private var _loaded:Boolean;// = false
private var _ready:Boolean;// = false
private var numReferences:int;// = 0
private var _url:String;
private var _setup:Boolean;// = false
private function ModuleInfo(url:String){
super();
_url = url;
}
private function clearLoader():void{
if (loader){
if (loader.contentLoaderInfo){
loader.contentLoaderInfo.removeEventListener(Event.INIT, initHandler);
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandler);
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler);
loader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
};
if (loader.content){
loader.content.removeEventListener("ready", readyHandler);
};
//unresolved jump
var _slot1 = error;
if (_loaded){
loader.close();
//unresolved jump
var _slot1 = error;
};
loader.unload();
//unresolved jump
var _slot1 = error;
loader = null;
};
}
public function get size():int{
return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.bytesTotal : 0);
}
public function get loaded():Boolean{
return ((limbo) ? false : _loaded);
}
public function release():void{
if (((_ready) && (!(limbo)))){
limbo = new Dictionary(true);
limbo[factoryInfo] = 1;
factoryInfo = null;
} else {
unload();
};
}
public function get error():Boolean{
return ((limbo) ? false : _error);
}
public function get factory():IFlexModuleFactory{
return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.factory : null);
}
public function completeHandler(event:Event):void{
var moduleEvent:ModuleEvent = new ModuleEvent(ModuleEvent.PROGRESS, event.bubbles, event.cancelable);
moduleEvent.bytesLoaded = loader.contentLoaderInfo.bytesLoaded;
moduleEvent.bytesTotal = loader.contentLoaderInfo.bytesTotal;
dispatchEvent(moduleEvent);
}
public function publish(factory:IFlexModuleFactory):void{
if (factoryInfo){
return;
};
if (_url.indexOf("published://") != 0){
return;
};
factoryInfo = new FactoryInfo();
factoryInfo.factory = factory;
_loaded = true;
_setup = true;
_ready = true;
_error = false;
dispatchEvent(new ModuleEvent(ModuleEvent.SETUP));
dispatchEvent(new ModuleEvent(ModuleEvent.PROGRESS));
dispatchEvent(new ModuleEvent(ModuleEvent.READY));
}
public function initHandler(event:Event):void{
var moduleEvent:ModuleEvent;
var event = event;
factoryInfo = new FactoryInfo();
factoryInfo.factory = (loader.content as IFlexModuleFactory);
//unresolved jump
var _slot1 = error;
if (!factoryInfo.factory){
moduleEvent = new ModuleEvent(ModuleEvent.ERROR, event.bubbles, event.cancelable);
moduleEvent.bytesLoaded = 0;
moduleEvent.bytesTotal = 0;
moduleEvent.errorText = "SWF is not a loadable module";
dispatchEvent(moduleEvent);
return;
};
loader.content.addEventListener("ready", readyHandler);
factoryInfo.applicationDomain = loader.contentLoaderInfo.applicationDomain;
//unresolved jump
var _slot1 = error;
_setup = true;
dispatchEvent(new ModuleEvent(ModuleEvent.SETUP));
}
public function resurrect():void{
var f:Object;
if (((!(factoryInfo)) && (limbo))){
for (f in limbo) {
factoryInfo = (f as FactoryInfo);
break;
};
limbo = null;
};
if (!factoryInfo){
if (_loaded){
dispatchEvent(new ModuleEvent(ModuleEvent.UNLOAD));
};
loader = null;
_loaded = false;
_setup = false;
_ready = false;
_error = false;
};
}
public function errorHandler(event:ErrorEvent):void{
_error = true;
var moduleEvent:ModuleEvent = new ModuleEvent(ModuleEvent.ERROR, event.bubbles, event.cancelable);
moduleEvent.bytesLoaded = 0;
moduleEvent.bytesTotal = 0;
moduleEvent.errorText = event.text;
dispatchEvent(moduleEvent);
}
public function get ready():Boolean{
return ((limbo) ? false : _ready);
}
public function removeReference():void{
numReferences--;
if (numReferences == 0){
release();
};
}
public function addReference():void{
numReferences++;
}
public function progressHandler(event:ProgressEvent):void{
var moduleEvent:ModuleEvent = new ModuleEvent(ModuleEvent.PROGRESS, event.bubbles, event.cancelable);
moduleEvent.bytesLoaded = event.bytesLoaded;
moduleEvent.bytesTotal = event.bytesTotal;
dispatchEvent(moduleEvent);
}
public function load(applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):void{
if (_loaded){
return;
};
_loaded = true;
limbo = null;
if (_url.indexOf("published://") == 0){
return;
};
var r:URLRequest = new URLRequest(_url);
var c:LoaderContext = new LoaderContext();
c.applicationDomain = (applicationDomain) ? applicationDomain : new ApplicationDomain(ApplicationDomain.currentDomain);
c.securityDomain = securityDomain;
if ((((securityDomain == null)) && ((Security.sandboxType == Security.REMOTE)))){
c.securityDomain = SecurityDomain.currentDomain;
};
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
loader.load(r, c);
}
public function get url():String{
return (_url);
}
public function get applicationDomain():ApplicationDomain{
return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.applicationDomain : null);
}
public function readyHandler(event:Event):void{
_ready = true;
factoryInfo.bytesTotal = loader.contentLoaderInfo.bytesTotal;
clearLoader();
dispatchEvent(new ModuleEvent(ModuleEvent.READY));
}
public function get setup():Boolean{
return ((limbo) ? false : _setup);
}
public function unload():void{
clearLoader();
if (_loaded){
dispatchEvent(new ModuleEvent(ModuleEvent.UNLOAD));
};
limbo = null;
factoryInfo = null;
_loaded = false;
_setup = false;
_ready = false;
_error = false;
}
}
class FactoryInfo {
public var bytesTotal:int;// = 0
public var factory:IFlexModuleFactory;
public var applicationDomain:ApplicationDomain;
private function FactoryInfo(){
super();
}
}
Section 139
//ModuleManagerGlobals (mx.modules.ModuleManagerGlobals)
package mx.modules {
public class ModuleManagerGlobals {
public static var managerSingleton:Object = null;
public function ModuleManagerGlobals(){
super();
}
}
}//package mx.modules
Section 140
//IResourceBundle (mx.resources.IResourceBundle)
package mx.resources {
public interface IResourceBundle {
function get content():Object;
function get locale():String;
function get bundleName():String;
}
}//package mx.resources
Section 141
//IResourceManager (mx.resources.IResourceManager)
package mx.resources {
import flash.events.*;
import flash.system.*;
public interface IResourceManager extends IEventDispatcher {
function loadResourceModule(_arg1:String, _arg2:Boolean=true, _arg3:ApplicationDomain=null, _arg4:SecurityDomain=null):IEventDispatcher;
function getBoolean(_arg1:String, _arg2:String, _arg3:String=null):Boolean;
function getClass(_arg1:String, _arg2:String, _arg3:String=null):Class;
function getLocales():Array;
function removeResourceBundlesForLocale(E:\dev\3.1.0\frameworks\projects\framework\src;mx\resources;IResourceManager.as:String):void;
function getResourceBundle(_arg1:String, _arg2:String):IResourceBundle;
function get localeChain():Array;
function getInt(_arg1:String, _arg2:String, _arg3:String=null):int;
function update():void;
function set localeChain(E:\dev\3.1.0\frameworks\projects\framework\src;mx\resources;IResourceManager.as:Array):void;
function getUint(_arg1:String, _arg2:String, _arg3:String=null):uint;
function addResourceBundle(E:\dev\3.1.0\frameworks\projects\framework\src;mx\resources;IResourceManager.as:IResourceBundle):void;
function getStringArray(_arg1:String, _arg2:String, _arg3:String=null):Array;
function getBundleNamesForLocale(:String):Array;
function removeResourceBundle(_arg1:String, _arg2:String):void;
function getObject(_arg1:String, _arg2:String, _arg3:String=null);
function getString(_arg1:String, _arg2:String, _arg3:Array=null, _arg4:String=null):String;
function installCompiledResourceBundles(_arg1:ApplicationDomain, _arg2:Array, _arg3:Array):void;
function unloadResourceModule(_arg1:String, _arg2:Boolean=true):void;
function getPreferredLocaleChain():Array;
function findResourceBundleWithResource(_arg1:String, _arg2:String):IResourceBundle;
function initializeLocaleChain(E:\dev\3.1.0\frameworks\projects\framework\src;mx\resources;IResourceManager.as:Array):void;
function getNumber(_arg1:String, _arg2:String, _arg3:String=null):Number;
}
}//package mx.resources
Section 142
//IResourceModule (mx.resources.IResourceModule)
package mx.resources {
public interface IResourceModule {
function get resourceBundles():Array;
}
}//package mx.resources
Section 143
//LocaleSorter (mx.resources.LocaleSorter)
package mx.resources {
import mx.core.*;
public class LocaleSorter {
mx_internal static const VERSION:String = "3.0.0.0";
public function LocaleSorter(){
super();
}
private static function normalizeLocale(locale:String):String{
return (locale.toLowerCase().replace(/-/g, "_"));
}
public static function sortLocalesByPreference(appLocales:Array, systemPreferences:Array, ultimateFallbackLocale:String=null, addAll:Boolean=false):Array{
var result:Array;
var hasLocale:Object;
var i:int;
var j:int;
var k:int;
var l:int;
var locale:String;
var plocale:LocaleID;
var appLocales = appLocales;
var systemPreferences = systemPreferences;
var ultimateFallbackLocale = ultimateFallbackLocale;
var addAll = addAll;
var promote:Function = function (locale:String):void{
if (typeof(hasLocale[locale]) != "undefined"){
result.push(appLocales[hasLocale[locale]]);
delete hasLocale[locale];
};
};
result = [];
hasLocale = {};
var locales:Array = trimAndNormalize(appLocales);
var preferenceLocales:Array = trimAndNormalize(systemPreferences);
addUltimateFallbackLocale(preferenceLocales, ultimateFallbackLocale);
j = 0;
while (j < locales.length) {
hasLocale[locales[j]] = j;
j = (j + 1);
};
i = 0;
l = preferenceLocales.length;
while (i < l) {
plocale = LocaleID.fromString(preferenceLocales[i]);
promote(preferenceLocales[i]);
promote(plocale.toString());
while (plocale.transformToParent()) {
promote(plocale.toString());
};
plocale = LocaleID.fromString(preferenceLocales[i]);
j = 0;
while (j < l) {
locale = preferenceLocales[j];
if (plocale.isSiblingOf(LocaleID.fromString(locale))){
promote(locale);
};
j = (j + 1);
};
j = 0;
k = locales.length;
while (j < k) {
locale = locales[j];
if (plocale.isSiblingOf(LocaleID.fromString(locale))){
promote(locale);
};
j = (j + 1);
};
i = (i + 1);
};
if (addAll){
j = 0;
k = locales.length;
while (j < k) {
promote(locales[j]);
j = (j + 1);
};
};
return (result);
}
private static function addUltimateFallbackLocale(preferenceLocales:Array, ultimateFallbackLocale:String):void{
var locale:String;
if (((!((ultimateFallbackLocale == null))) && (!((ultimateFallbackLocale == ""))))){
locale = normalizeLocale(ultimateFallbackLocale);
if (preferenceLocales.indexOf(locale) == -1){
preferenceLocales.push(locale);
};
};
}
private static function trimAndNormalize(list:Array):Array{
var resultList:Array = [];
var i:int;
while (i < list.length) {
resultList.push(normalizeLocale(list[i]));
i++;
};
return (resultList);
}
}
}//package mx.resources
class LocaleID {
private var privateLangs:Boolean;// = false
private var script:String;// = ""
private var variants:Array;
private var privates:Array;
private var extensions:Object;
private var lang:String;// = ""
private var region:String;// = ""
private var extended_langs:Array;
public static const STATE_PRIMARY_LANGUAGE:int = 0;
public static const STATE_REGION:int = 3;
public static const STATE_EXTENDED_LANGUAGES:int = 1;
public static const STATE_EXTENSIONS:int = 5;
public static const STATE_SCRIPT:int = 2;
public static const STATE_VARIANTS:int = 4;
public static const STATE_PRIVATES:int = 6;
private function LocaleID(){
extended_langs = [];
variants = [];
extensions = {};
privates = [];
super();
}
public function equals(locale:LocaleID):Boolean{
return ((toString() == locale.toString()));
}
public function canonicalize():void{
var i:String;
for (i in extensions) {
if (extensions.hasOwnProperty(i)){
if (extensions[i].length == 0){
delete extensions[i];
} else {
extensions[i] = extensions[i].sort();
};
};
};
extended_langs = extended_langs.sort();
variants = variants.sort();
privates = privates.sort();
if (script == ""){
script = LocaleRegistry.getScriptByLang(lang);
};
if ((((script == "")) && (!((region == ""))))){
script = LocaleRegistry.getScriptByLangAndRegion(lang, region);
};
if ((((region == "")) && (!((script == ""))))){
region = LocaleRegistry.getDefaultRegionForLangAndScript(lang, script);
};
}
public function toString():String{
var i:String;
var stack:Array = [lang];
Array.prototype.push.apply(stack, extended_langs);
if (script != ""){
stack.push(script);
};
if (region != ""){
stack.push(region);
};
Array.prototype.push.apply(stack, variants);
for (i in extensions) {
if (extensions.hasOwnProperty(i)){
stack.push(i);
Array.prototype.push.apply(stack, extensions[i]);
};
};
if (privates.length > 0){
stack.push("x");
Array.prototype.push.apply(stack, privates);
};
return (stack.join("_"));
}
public function isSiblingOf(other:LocaleID):Boolean{
return ((((lang == other.lang)) && ((script == other.script))));
}
public function transformToParent():Boolean{
var i:String;
var lastExtension:Array;
var defaultRegion:String;
if (privates.length > 0){
privates.splice((privates.length - 1), 1);
return (true);
};
var lastExtensionName:String;
for (i in extensions) {
if (extensions.hasOwnProperty(i)){
lastExtensionName = i;
};
};
if (lastExtensionName){
lastExtension = extensions[lastExtensionName];
if (lastExtension.length == 1){
delete extensions[lastExtensionName];
return (true);
};
lastExtension.splice((lastExtension.length - 1), 1);
return (true);
};
if (variants.length > 0){
variants.splice((variants.length - 1), 1);
return (true);
};
if (script != ""){
if (LocaleRegistry.getScriptByLang(lang) != ""){
script = "";
return (true);
};
if (region == ""){
defaultRegion = LocaleRegistry.getDefaultRegionForLangAndScript(lang, script);
if (defaultRegion != ""){
region = defaultRegion;
script = "";
return (true);
};
};
};
if (region != ""){
if (!(((script == "")) && ((LocaleRegistry.getScriptByLang(lang) == "")))){
region = "";
return (true);
};
};
if (extended_langs.length > 0){
extended_langs.splice((extended_langs.length - 1), 1);
return (true);
};
return (false);
}
public static function fromString(str:String):LocaleID{
var last_extension:Array;
var subtag:String;
var subtag_length:int;
var firstChar:String;
var localeID:LocaleID = new (LocaleID);
var state:int = STATE_PRIMARY_LANGUAGE;
var subtags:Array = str.replace(/-/g, "_").split("_");
var i:int;
var l:int = subtags.length;
while (i < l) {
subtag = subtags[i].toLowerCase();
if (state == STATE_PRIMARY_LANGUAGE){
if (subtag == "x"){
localeID.privateLangs = true;
} else {
if (subtag == "i"){
localeID.lang = (localeID.lang + "i-");
} else {
localeID.lang = (localeID.lang + subtag);
state = STATE_EXTENDED_LANGUAGES;
};
};
} else {
subtag_length = subtag.length;
if (subtag_length == 0){
} else {
firstChar = subtag.charAt(0).toLowerCase();
if ((((state <= STATE_EXTENDED_LANGUAGES)) && ((subtag_length == 3)))){
localeID.extended_langs.push(subtag);
if (localeID.extended_langs.length == 3){
state = STATE_SCRIPT;
};
} else {
if ((((state <= STATE_SCRIPT)) && ((subtag_length == 4)))){
localeID.script = subtag;
state = STATE_REGION;
} else {
if ((((state <= STATE_REGION)) && ((((subtag_length == 2)) || ((subtag_length == 3)))))){
localeID.region = subtag;
state = STATE_VARIANTS;
} else {
if ((((state <= STATE_VARIANTS)) && ((((((((firstChar >= "a")) && ((firstChar <= "z")))) && ((subtag_length >= 5)))) || ((((((firstChar >= "0")) && ((firstChar <= "9")))) && ((subtag_length >= 4)))))))){
localeID.variants.push(subtag);
state = STATE_VARIANTS;
} else {
if ((((state < STATE_PRIVATES)) && ((subtag_length == 1)))){
if (subtag == "x"){
state = STATE_PRIVATES;
last_extension = localeID.privates;
} else {
state = STATE_EXTENSIONS;
last_extension = ((localeID.extensions[subtag]) || ([]));
localeID.extensions[subtag] = last_extension;
};
} else {
if (state >= STATE_EXTENSIONS){
last_extension.push(subtag);
};
};
};
};
};
};
};
};
i++;
};
localeID.canonicalize();
return (localeID);
}
}
class LocaleRegistry {
private static const SCRIPT_ID_BY_LANG:Object = {ab:5, af:1, am:2, ar:3, as:4, ay:1, be:5, bg:5, bn:4, bs:1, ca:1, ch:1, cs:1, cy:1, da:1, de:1, dv:6, dz:7, el:8, en:1, eo:1, es:1, et:1, eu:1, fa:3, fi:1, fj:1, fo:1, fr:1, frr:1, fy:1, ga:1, gl:1, gn:1, gu:9, gv:1, he:10, hi:11, hr:1, ht:1, hu:1, hy:12, id:1, in:1, is:1, it:1, iw:10, ja:13, ka:14, kk:5, kl:1, km:15, kn:16, ko:17, la:1, lb:1, ln:1, lo:18, lt:1, lv:1, mg:1, mh:1, mk:5, ml:19, mo:1, mr:11, ms:1, mt:1, my:20, na:1, nb:1, nd:1, ne:11, nl:1, nn:1, no:1, nr:1, ny:1, om:1, or:21, pa:22, pl:1, ps:3, pt:1, qu:1, rn:1, ro:1, ru:5, rw:1, sg:1, si:23, sk:1, sl:1, sm:1, so:1, sq:1, ss:1, st:1, sv:1, sw:1, ta:24, te:25, th:26, ti:2, tl:1, tn:1, to:1, tr:1, ts:1, uk:5, ur:3, ve:1, vi:1, wo:1, xh:1, yi:10, zu:1, cpe:1, dsb:1, frs:1, gsw:1, hsb:1, kok:11, mai:11, men:1, nds:1, niu:1, nqo:27, nso:1, son:1, tem:1, tkl:1, tmh:1, tpi:1, tvl:1, zbl:28};
private static const SCRIPTS:Array = ["", "latn", "ethi", "arab", "beng", "cyrl", "thaa", "tibt", "grek", "gujr", "hebr", "deva", "armn", "jpan", "geor", "khmr", "knda", "kore", "laoo", "mlym", "mymr", "orya", "guru", "sinh", "taml", "telu", "thai", "nkoo", "blis", "hans", "hant", "mong", "syrc"];
private static const DEFAULT_REGION_BY_LANG_AND_SCRIPT:Object = {bg:{5:"bg"}, ca:{1:"es"}, zh:{30:"tw", 29:"cn"}, cs:{1:"cz"}, da:{1:"dk"}, de:{1:"de"}, el:{8:"gr"}, en:{1:"us"}, es:{1:"es"}, fi:{1:"fi"}, fr:{1:"fr"}, he:{10:"il"}, hu:{1:"hu"}, is:{1:"is"}, it:{1:"it"}, ja:{13:"jp"}, ko:{17:"kr"}, nl:{1:"nl"}, nb:{1:"no"}, pl:{1:"pl"}, pt:{1:"br"}, ro:{1:"ro"}, ru:{5:"ru"}, hr:{1:"hr"}, sk:{1:"sk"}, sq:{1:"al"}, sv:{1:"se"}, th:{26:"th"}, tr:{1:"tr"}, ur:{3:"pk"}, id:{1:"id"}, uk:{5:"ua"}, be:{5:"by"}, sl:{1:"si"}, et:{1:"ee"}, lv:{1:"lv"}, lt:{1:"lt"}, fa:{3:"ir"}, vi:{1:"vn"}, hy:{12:"am"}, az:{1:"az", 5:"az"}, eu:{1:"es"}, mk:{5:"mk"}, af:{1:"za"}, ka:{14:"ge"}, fo:{1:"fo"}, hi:{11:"in"}, ms:{1:"my"}, kk:{5:"kz"}, ky:{5:"kg"}, sw:{1:"ke"}, uz:{1:"uz", 5:"uz"}, tt:{5:"ru"}, pa:{22:"in"}, gu:{9:"in"}, ta:{24:"in"}, te:{25:"in"}, kn:{16:"in"}, mr:{11:"in"}, sa:{11:"in"}, mn:{5:"mn"}, gl:{1:"es"}, kok:{11:"in"}, syr:{32:"sy"}, dv:{6:"mv"}, nn:{1:"no"}, sr:{1:"cs", 5:"cs"}, cy:{1:"gb"}, mi:{1:"nz"}, mt:{1:"mt"}, quz:{1:"bo"}, tn:{1:"za"}, xh:{1:"za"}, zu:{1:"za"}, nso:{1:"za"}, se:{1:"no"}, smj:{1:"no"}, sma:{1:"no"}, sms:{1:"fi"}, smn:{1:"fi"}, bs:{1:"ba"}};
private static const SCRIPT_BY_ID:Object = {latn:1, ethi:2, arab:3, beng:4, cyrl:5, thaa:6, tibt:7, grek:8, gujr:9, hebr:10, deva:11, armn:12, jpan:13, geor:14, khmr:15, knda:16, kore:17, laoo:18, mlym:19, mymr:20, orya:21, guru:22, sinh:23, taml:24, telu:25, thai:26, nkoo:27, blis:28, hans:29, hant:30, mong:31, syrc:32};
private static const SCRIPT_ID_BY_LANG_AND_REGION:Object = {zh:{cn:29, sg:29, tw:30, hk:30, mo:30}, mn:{cn:31, sg:5}, pa:{pk:3, in:22}, ha:{gh:1, ne:1}};
private function LocaleRegistry(){
super();
}
public static function getScriptByLangAndRegion(lang:String, region:String):String{
var langRegions:Object = SCRIPT_ID_BY_LANG_AND_REGION[lang];
if (langRegions == null){
return ("");
};
var scriptID:Object = langRegions[region];
if (scriptID == null){
return ("");
};
return (SCRIPTS[int(scriptID)].toLowerCase());
}
public static function getScriptByLang(lang:String):String{
var scriptID:Object = SCRIPT_ID_BY_LANG[lang];
if (scriptID == null){
return ("");
};
return (SCRIPTS[int(scriptID)].toLowerCase());
}
public static function getDefaultRegionForLangAndScript(lang:String, script:String):String{
var langObj:Object = DEFAULT_REGION_BY_LANG_AND_SCRIPT[lang];
var scriptID:Object = SCRIPT_BY_ID[script];
if ((((langObj == null)) || ((scriptID == null)))){
return ("");
};
return (((langObj[int(scriptID)]) || ("")));
}
}
Section 144
//ResourceBundle (mx.resources.ResourceBundle)
package mx.resources {
import mx.core.*;
import flash.system.*;
import mx.utils.*;
public class ResourceBundle implements IResourceBundle {
mx_internal var _locale:String;
private var _content:Object;
mx_internal var _bundleName:String;
mx_internal static const VERSION:String = "3.0.0.0";
mx_internal static var backupApplicationDomain:ApplicationDomain;
mx_internal static var locale:String;
public function ResourceBundle(locale:String=null, bundleName:String=null){
_content = {};
super();
mx_internal::_locale = locale;
mx_internal::_bundleName = bundleName;
_content = getContent();
}
protected function getContent():Object{
return ({});
}
public function getString(key:String):String{
return (String(_getObject(key)));
}
public function get content():Object{
return (_content);
}
public function getBoolean(key:String, defaultValue:Boolean=true):Boolean{
var temp:String = _getObject(key).toLowerCase();
if (temp == "false"){
return (false);
};
if (temp == "true"){
return (true);
};
return (defaultValue);
}
public function getStringArray(key:String):Array{
var array:Array = _getObject(key).split(",");
var n:int = array.length;
var i:int;
while (i < n) {
array[i] = StringUtil.trim(array[i]);
i++;
};
return (array);
}
public function getObject(key:String):Object{
return (_getObject(key));
}
private function _getObject(key:String):Object{
var value:Object = content[key];
if (!value){
throw (new Error(((("Key " + key) + " was not found in resource bundle ") + bundleName)));
};
return (value);
}
public function get locale():String{
return (mx_internal::_locale);
}
public function get bundleName():String{
return (mx_internal::_bundleName);
}
public function getNumber(key:String):Number{
return (Number(_getObject(key)));
}
private static function getClassByName(name:String, domain:ApplicationDomain):Class{
var c:Class;
if (domain.hasDefinition(name)){
c = (domain.getDefinition(name) as Class);
};
return (c);
}
public static function getResourceBundle(baseName:String, currentDomain:ApplicationDomain=null):ResourceBundle{
var className:String;
var bundleClass:Class;
var bundleObj:Object;
var bundle:ResourceBundle;
if (!currentDomain){
currentDomain = ApplicationDomain.currentDomain;
};
className = (((mx_internal::locale + "$") + baseName) + "_properties");
bundleClass = getClassByName(className, currentDomain);
if (!bundleClass){
className = (baseName + "_properties");
bundleClass = getClassByName(className, currentDomain);
};
if (!bundleClass){
className = baseName;
bundleClass = getClassByName(className, currentDomain);
};
if (((!(bundleClass)) && (mx_internal::backupApplicationDomain))){
className = (baseName + "_properties");
bundleClass = getClassByName(className, mx_internal::backupApplicationDomain);
if (!bundleClass){
className = baseName;
bundleClass = getClassByName(className, mx_internal::backupApplicationDomain);
};
};
if (bundleClass){
bundleObj = new (bundleClass);
if ((bundleObj is ResourceBundle)){
bundle = ResourceBundle(bundleObj);
return (bundle);
};
};
throw (new Error(("Could not find resource bundle " + baseName)));
}
}
}//package mx.resources
Section 145
//ResourceManager (mx.resources.ResourceManager)
package mx.resources {
import mx.core.*;
public class ResourceManager {
mx_internal static const VERSION:String = "3.0.0.0";
private static var implClassDependency:ResourceManagerImpl;
private static var instance:IResourceManager;
public function ResourceManager(){
super();
}
public static function getInstance():IResourceManager{
if (!instance){
instance = IResourceManager(Singleton.getInstance("mx.resources::IResourceManager"));
//unresolved jump
var _slot1 = e;
instance = new ResourceManagerImpl();
};
return (instance);
}
}
}//package mx.resources
Section 146
//ResourceManagerImpl (mx.resources.ResourceManagerImpl)
package mx.resources {
import flash.events.*;
import mx.core.*;
import mx.events.*;
import flash.system.*;
import mx.modules.*;
import flash.utils.*;
import mx.utils.*;
public class ResourceManagerImpl extends EventDispatcher implements IResourceManager {
private var resourceModules:Object;
private var initializedForNonFrameworkApp:Boolean;// = false
private var localeMap:Object;
private var _localeChain:Array;
mx_internal static const VERSION:String = "3.0.0.0";
private static var instance:IResourceManager;
public function ResourceManagerImpl(){
localeMap = {};
resourceModules = {};
super();
}
public function get localeChain():Array{
return (_localeChain);
}
public function set localeChain(value:Array):void{
_localeChain = value;
update();
}
public function getStringArray(bundleName:String, resourceName:String, locale:String=null):Array{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (null);
};
var value:* = resourceBundle.content[resourceName];
var array:Array = String(value).split(",");
var n:int = array.length;
var i:int;
while (i < n) {
array[i] = StringUtil.trim(array[i]);
i++;
};
return (array);
}
mx_internal function installCompiledResourceBundle(applicationDomain:ApplicationDomain, locale:String, bundleName:String):void{
var packageName:String;
var localName:String = bundleName;
var colonIndex:int = bundleName.indexOf(":");
if (colonIndex != -1){
packageName = bundleName.substring(0, colonIndex);
localName = bundleName.substring((colonIndex + 1));
};
if (getResourceBundle(locale, bundleName)){
return;
};
var resourceBundleClassName = (((locale + "$") + localName) + "_properties");
if (packageName != null){
resourceBundleClassName = ((packageName + ".") + resourceBundleClassName);
};
var bundleClass:Class;
if (applicationDomain.hasDefinition(resourceBundleClassName)){
bundleClass = Class(applicationDomain.getDefinition(resourceBundleClassName));
};
if (!bundleClass){
resourceBundleClassName = bundleName;
if (applicationDomain.hasDefinition(resourceBundleClassName)){
bundleClass = Class(applicationDomain.getDefinition(resourceBundleClassName));
};
};
if (!bundleClass){
resourceBundleClassName = (bundleName + "_properties");
if (applicationDomain.hasDefinition(resourceBundleClassName)){
bundleClass = Class(applicationDomain.getDefinition(resourceBundleClassName));
};
};
if (!bundleClass){
throw (new Error((((("Could not find compiled resource bundle '" + bundleName) + "' for locale '") + locale) + "'.")));
};
var resourceBundle:ResourceBundle = ResourceBundle(new (bundleClass));
resourceBundle.mx_internal::_locale = locale;
resourceBundle.mx_internal::_bundleName = bundleName;
addResourceBundle(resourceBundle);
}
public function getString(bundleName:String, resourceName:String, parameters:Array=null, locale:String=null):String{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (null);
};
var value:String = String(resourceBundle.content[resourceName]);
if (parameters){
value = StringUtil.substitute(value, parameters);
};
return (value);
}
public function loadResourceModule(url:String, updateFlag:Boolean=true, applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):IEventDispatcher{
var moduleInfo:IModuleInfo;
var resourceEventDispatcher:ResourceEventDispatcher;
var timer:Timer;
var timerHandler:Function;
var url = url;
var updateFlag = updateFlag;
var applicationDomain = applicationDomain;
var securityDomain = securityDomain;
moduleInfo = ModuleManager.getModule(url);
resourceEventDispatcher = new ResourceEventDispatcher(moduleInfo);
var readyHandler:Function = function (event:ModuleEvent):void{
var resourceModule:* = event.module.factory.create();
resourceModules[event.module.url].resourceModule = resourceModule;
if (updateFlag){
update();
};
};
moduleInfo.addEventListener(ModuleEvent.READY, readyHandler, false, 0, true);
var errorHandler:Function = function (event:ModuleEvent):void{
var resourceEvent:ResourceEvent;
var message:String = ("Unable to load resource module from " + url);
if (resourceEventDispatcher.willTrigger(ResourceEvent.ERROR)){
resourceEvent = new ResourceEvent(ResourceEvent.ERROR, event.bubbles, event.cancelable);
resourceEvent.bytesLoaded = 0;
resourceEvent.bytesTotal = 0;
resourceEvent.errorText = message;
resourceEventDispatcher.dispatchEvent(resourceEvent);
} else {
throw (new Error(message));
};
};
moduleInfo.addEventListener(ModuleEvent.ERROR, errorHandler, false, 0, true);
resourceModules[url] = new ResourceModuleInfo(moduleInfo, readyHandler, errorHandler);
timer = new Timer(0);
timerHandler = function (event:TimerEvent):void{
timer.removeEventListener(TimerEvent.TIMER, timerHandler);
timer.stop();
moduleInfo.load(applicationDomain, securityDomain);
};
timer.addEventListener(TimerEvent.TIMER, timerHandler, false, 0, true);
timer.start();
return (resourceEventDispatcher);
}
public function getLocales():Array{
var p:String;
var locales:Array = [];
for (p in localeMap) {
locales.push(p);
};
return (locales);
}
public function removeResourceBundlesForLocale(locale:String):void{
delete localeMap[locale];
}
public function getResourceBundle(locale:String, bundleName:String):IResourceBundle{
var bundleMap:Object = localeMap[locale];
if (!bundleMap){
return (null);
};
return (bundleMap[bundleName]);
}
private function dumpResourceModule(resourceModule):void{
var bundle:ResourceBundle;
var p:String;
for each (bundle in resourceModule.resourceBundles) {
trace(bundle.locale, bundle.bundleName);
for (p in bundle.content) {
};
};
}
public function addResourceBundle(resourceBundle:IResourceBundle):void{
var locale:String = resourceBundle.locale;
var bundleName:String = resourceBundle.bundleName;
if (!localeMap[locale]){
localeMap[locale] = {};
};
localeMap[locale][bundleName] = resourceBundle;
}
public function getObject(bundleName:String, resourceName:String, locale:String=null){
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (undefined);
};
return (resourceBundle.content[resourceName]);
}
public function getInt(bundleName:String, resourceName:String, locale:String=null):int{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (0);
};
var value:* = resourceBundle.content[resourceName];
return (int(value));
}
private function findBundle(bundleName:String, resourceName:String, locale:String):IResourceBundle{
supportNonFrameworkApps();
return (((locale)!=null) ? getResourceBundle(locale, bundleName) : findResourceBundleWithResource(bundleName, resourceName));
}
private function supportNonFrameworkApps():void{
if (initializedForNonFrameworkApp){
return;
};
initializedForNonFrameworkApp = true;
if (getLocales().length > 0){
return;
};
var applicationDomain:ApplicationDomain = ApplicationDomain.currentDomain;
if (!applicationDomain.hasDefinition("_CompiledResourceBundleInfo")){
return;
};
var c:Class = Class(applicationDomain.getDefinition("_CompiledResourceBundleInfo"));
var locales:Array = c.compiledLocales;
var bundleNames:Array = c.compiledResourceBundleNames;
installCompiledResourceBundles(applicationDomain, locales, bundleNames);
localeChain = locales;
}
public function getBundleNamesForLocale(locale:String):Array{
var p:String;
var bundleNames:Array = [];
for (p in localeMap[locale]) {
bundleNames.push(p);
};
return (bundleNames);
}
public function getPreferredLocaleChain():Array{
return (LocaleSorter.sortLocalesByPreference(getLocales(), getSystemPreferredLocales(), null, true));
}
public function getNumber(bundleName:String, resourceName:String, locale:String=null):Number{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (NaN);
};
var value:* = resourceBundle.content[resourceName];
return (Number(value));
}
public function update():void{
dispatchEvent(new Event(Event.CHANGE));
}
public function getClass(bundleName:String, resourceName:String, locale:String=null):Class{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (null);
};
var value:* = resourceBundle.content[resourceName];
return ((value as Class));
}
public function removeResourceBundle(locale:String, bundleName:String):void{
delete localeMap[locale][bundleName];
if (getBundleNamesForLocale(locale).length == 0){
delete localeMap[locale];
};
}
public function initializeLocaleChain(compiledLocales:Array):void{
localeChain = LocaleSorter.sortLocalesByPreference(compiledLocales, getSystemPreferredLocales(), null, true);
}
public function findResourceBundleWithResource(bundleName:String, resourceName:String):IResourceBundle{
var locale:String;
var bundleMap:Object;
var bundle:ResourceBundle;
if (!_localeChain){
return (null);
};
var n:int = _localeChain.length;
var i:int;
while (i < n) {
locale = localeChain[i];
bundleMap = localeMap[locale];
if (!bundleMap){
} else {
bundle = bundleMap[bundleName];
if (!bundle){
} else {
if ((resourceName in bundle.content)){
return (bundle);
};
};
};
i++;
};
return (null);
}
public function getUint(bundleName:String, resourceName:String, locale:String=null):uint{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (0);
};
var value:* = resourceBundle.content[resourceName];
return (uint(value));
}
private function getSystemPreferredLocales():Array{
var systemPreferences:Array;
if (Capabilities["languages"]){
systemPreferences = Capabilities["languages"];
} else {
systemPreferences = [Capabilities.language];
};
return (systemPreferences);
}
public function installCompiledResourceBundles(applicationDomain:ApplicationDomain, locales:Array, bundleNames:Array):void{
var locale:String;
var j:int;
var bundleName:String;
var n:int = (locales) ? locales.length : 0;
var m:int = (bundleNames) ? bundleNames.length : 0;
var i:int;
while (i < n) {
locale = locales[i];
j = 0;
while (j < m) {
bundleName = bundleNames[j];
mx_internal::installCompiledResourceBundle(applicationDomain, locale, bundleName);
j++;
};
i++;
};
}
public function getBoolean(bundleName:String, resourceName:String, locale:String=null):Boolean{
var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale);
if (!resourceBundle){
return (false);
};
var value:* = resourceBundle.content[resourceName];
return ((String(value).toLowerCase() == "true"));
}
public function unloadResourceModule(url:String, update:Boolean=true):void{
throw (new Error("unloadResourceModule() is not yet implemented."));
}
public static function getInstance():IResourceManager{
if (!instance){
instance = new (ResourceManagerImpl);
};
return (instance);
}
}
}//package mx.resources
import flash.events.*;
import mx.events.*;
import mx.modules.*;
class ResourceModuleInfo {
public var resourceModule:IResourceModule;
public var errorHandler:Function;
public var readyHandler:Function;
public var moduleInfo:IModuleInfo;
private function ResourceModuleInfo(moduleInfo:IModuleInfo, readyHandler:Function, errorHandler:Function){
super();
this.moduleInfo = moduleInfo;
this.readyHandler = readyHandler;
this.errorHandler = errorHandler;
}
}
class ResourceEventDispatcher extends EventDispatcher {
private function ResourceEventDispatcher(moduleInfo:IModuleInfo){
super();
moduleInfo.addEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler, false, 0, true);
moduleInfo.addEventListener(ModuleEvent.PROGRESS, moduleInfo_progressHandler, false, 0, true);
moduleInfo.addEventListener(ModuleEvent.READY, moduleInfo_readyHandler, false, 0, true);
}
private function moduleInfo_progressHandler(event:ModuleEvent):void{
var resourceEvent:ResourceEvent = new ResourceEvent(ResourceEvent.PROGRESS, event.bubbles, event.cancelable);
resourceEvent.bytesLoaded = event.bytesLoaded;
resourceEvent.bytesTotal = event.bytesTotal;
dispatchEvent(resourceEvent);
}
private function moduleInfo_readyHandler(event:ModuleEvent):void{
var resourceEvent:ResourceEvent = new ResourceEvent(ResourceEvent.COMPLETE);
dispatchEvent(resourceEvent);
}
private function moduleInfo_errorHandler(event:ModuleEvent):void{
var resourceEvent:ResourceEvent = new ResourceEvent(ResourceEvent.ERROR, event.bubbles, event.cancelable);
resourceEvent.bytesLoaded = event.bytesLoaded;
resourceEvent.bytesTotal = event.bytesTotal;
resourceEvent.errorText = event.errorText;
dispatchEvent(resourceEvent);
}
}
Section 147
//WSDLLoadEvent (mx.rpc.events.WSDLLoadEvent)
package mx.rpc.events {
import flash.events.*;
import mx.rpc.wsdl.*;
public class WSDLLoadEvent extends XMLLoadEvent {
public var wsdl:WSDL;
public static const LOAD:String = "wsdlLoad";
public function WSDLLoadEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=true, wsdl:WSDL=null, location:String=null){
super(((type == null)) ? LOAD : type, bubbles, cancelable, ((wsdl == null)) ? null : wsdl.xml, location);
this.wsdl = wsdl;
}
override public function clone():Event{
return (new WSDLLoadEvent(type, bubbles, cancelable, wsdl, location));
}
override public function toString():String{
return (formatToString("WSDLLoadEvent", "location", "type", "bubbles", "cancelable", "eventPhase"));
}
public static function createEvent(wsdl:WSDL, location:String=null):WSDLLoadEvent{
return (new WSDLLoadEvent(LOAD, false, true, wsdl, location));
}
}
}//package mx.rpc.events
Section 148
//XMLLoadEvent (mx.rpc.events.XMLLoadEvent)
package mx.rpc.events {
import flash.events.*;
public class XMLLoadEvent extends Event {
public var location:String;
public var xml:XML;
public static const LOAD:String = "xmlLoad";
public function XMLLoadEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=true, xml:XML=null, location:String=null){
super(((type == null)) ? LOAD : type, bubbles, cancelable);
this.xml = xml;
this.location = location;
}
override public function toString():String{
return (formatToString("XMLLoadEvent", "location", "type", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new XMLLoadEvent(type, bubbles, cancelable, xml, location));
}
public static function createEvent(xml:XML=null, location:String=null):XMLLoadEvent{
return (new XMLLoadEvent(LOAD, false, true, xml, location));
}
}
}//package mx.rpc.events
Section 149
//ApacheDocumentType (mx.rpc.soap.types.ApacheDocumentType)
package mx.rpc.soap.types {
import mx.rpc.soap.*;
public class ApacheDocumentType implements ICustomSOAPType {
public function ApacheDocumentType(){
super();
}
public function decode(decoder:SOAPDecoder, parent, name, value, restriction:XML=null):void{
decoder.setValue(parent, name, XML(value).elements());
}
public function encode(encoder:SOAPEncoder, parent:XML, name:QName, value, restriction:XML=null):void{
encoder.setValue(parent, value);
}
}
}//package mx.rpc.soap.types
Section 150
//DataSetType (mx.rpc.soap.types.DataSetType)
package mx.rpc.soap.types {
import mx.rpc.soap.*;
import mx.rpc.xml.*;
public class DataSetType implements ICustomSOAPType {
private var schemaConstants:SchemaConstants;
public function DataSetType(){
super();
}
private function processColumns(decoder:SOAPDecoder, tableXML:XML){
var colXML:XML;
var colsXMLList:XMLList = tableXML.elements(schemaConstants.complexTypeQName)[0].elements(schemaConstants.sequenceQName)[0].elements(schemaConstants.elementTypeQName);
var columns:* = decoder.createIterableValue();
for each (colXML in colsXMLList) {
TypeIterator.push(columns, colXML.attribute("name").toString());
};
return (columns);
}
private function processTables(schemaXML:XML):Object{
var tblXML:XML;
var tblsXMLList:XMLList = schemaXML.elements(schemaConstants.elementTypeQName)[0].elements(schemaConstants.complexTypeQName)[0].elements(schemaConstants.choiceQName)[0].elements(schemaConstants.elementTypeQName);
var tables:Object = {};
for each (tblXML in tblsXMLList) {
tables[tblXML.attribute("name")] = tblXML;
};
return (tables);
}
public function encode(encoder:SOAPEncoder, parent:XML, name:QName, value, restriction:XML=null):void{
throw (new Error("Unsupported operation - .NET DataSet diffgrams cannot be sent from client."));
}
public function decode(decoder:SOAPDecoder, parent, name, value, restriction:XML=null):void{
var tblName:String;
var tableObj:*;
var schema:Schema;
var rowXML:XML;
var rowObj:*;
if ((parent is ContentProxy)){
ContentProxy(parent).isSimple = false;
};
schemaConstants = decoder.schemaConstants;
var schemaXML:XML = XML(value).elements(schemaConstants.schemaQName)[0];
var rootDataXML:XML = XML(value).elements(SOAPConstants.diffgramQName)[0].elements()[0];
var dataSet:* = parent;
var tableDefinitions:Object = processTables(schemaXML);
var tableCollection:* = decoder.createContent();
if ((tableCollection is ContentProxy)){
ContentProxy(tableCollection).isSimple = false;
};
for (tblName in tableDefinitions) {
tableObj = decoder.createContent();
if ((tableObj is ContentProxy)){
ContentProxy(tableObj).isSimple = false;
};
decoder.setValue(tableObj, "Columns", processColumns(decoder, tableDefinitions[tblName]));
decoder.setValue(tableObj, "Rows", decoder.createIterableValue());
decoder.setValue(tableCollection, tblName, tableObj);
};
if (rootDataXML != null){
schema = new Schema(schemaXML);
decoder.schemaManager.addSchema(schema, false);
for (tblName in tableCollection) {
for each (rowXML in rootDataXML.elements(tblName)) {
rowObj = decoder.decode(rowXML, rowXML.name(), null, tableDefinitions[tblName]);
TypeIterator.push(tableCollection[tblName]["Rows"], rowObj);
};
};
decoder.schemaManager.releaseScope();
};
decoder.setValue(dataSet, "Tables", tableCollection);
}
}
}//package mx.rpc.soap.types
Section 151
//ICustomSOAPType (mx.rpc.soap.types.ICustomSOAPType)
package mx.rpc.soap.types {
import mx.rpc.soap.*;
public interface ICustomSOAPType {
function decode(_arg1:SOAPDecoder, _arg2, _arg3, _arg4, _arg5:XML=null):void;
function encode(_arg1:SOAPEncoder, _arg2:XML, _arg3:QName, _arg4, _arg5:XML=null):void;
}
}//package mx.rpc.soap.types
Section 152
//MapType (mx.rpc.soap.types.MapType)
package mx.rpc.soap.types {
import mx.rpc.soap.*;
import mx.rpc.xml.*;
import flash.utils.*;
public class MapType implements ICustomSOAPType {
public static var itemQName:QName = new QName("", "item");
public static var valueQName:QName = new QName("", "value");
public static var keyQName:QName = new QName("", "key");
public function MapType(){
super();
}
public function decode(decoder:SOAPDecoder, parent, name, value, restriction:XML=null):void{
var item:XML;
var key:Object;
var itemValue:Object;
var itemChild:XML;
var typeName:String;
var type:QName;
if ((parent is ContentProxy)){
parent.isSimple = false;
};
var constants:SchemaConstants = decoder.schemaManager.schemaConstants;
var mapValue:XML = (value as XML);
for each (item in mapValue.elements()) {
for each (itemChild in item.elements()) {
typeName = itemChild.attribute(constants.typeAttrQName);
if (((!((typeName == null))) && (!((typeName == ""))))){
type = decoder.schemaManager.getQNameForPrefixedName(typeName, itemChild);
} else {
type = constants.anyTypeQName;
};
if (itemChild.localName() == "key"){
key = decoder.createContent();
decoder.decodeType(type, key, itemChild.name(), itemChild);
} else {
if (itemChild.localName() == "value"){
itemValue = decoder.createContent();
decoder.decodeType(type, itemValue, itemChild.name(), itemChild);
} else {
throw (new Error("Apache Map datatype must only contain key/value pairs."));
};
};
};
decoder.setValue(parent, key, itemValue);
};
}
public function encode(encoder:SOAPEncoder, parent:XML, name:QName, value, restriction:XML=null):void{
var item:String;
var itemNode:XML;
var keyNode:XML;
var valueNode:XML;
var keyValue:Object;
var typeLocalName:String;
var constants:SchemaConstants;
var type:QName;
var datatypes:SchemaDatatypes = encoder.schemaManager.schemaDatatypes;
for (item in value) {
itemNode = encoder.createElement(itemQName);
keyNode = encoder.createElement(keyQName);
valueNode = encoder.createElement(valueQName);
if (item != null){
encoder.encodeType(datatypes.stringQName, keyNode, keyQName, item);
} else {
encoder.setValue(keyNode, null);
};
encoder.setValue(itemNode, keyNode);
keyValue = value[item];
if (keyValue != null){
typeLocalName = "string";
if ((keyValue is Number)){
if ((keyValue is uint)){
typeLocalName = "unsignedInt";
} else {
if ((keyValue is int)){
typeLocalName = "int";
} else {
typeLocalName = "double";
};
};
} else {
if ((keyValue is Boolean)){
typeLocalName = "boolean";
} else {
if ((keyValue is String)){
typeLocalName = "string";
} else {
if ((keyValue is ByteArray)){
if (SchemaMarshaller.byteArrayAsBase64Binary){
typeLocalName = "base64Binary";
} else {
typeLocalName = "hexBinary";
};
} else {
if ((keyValue is Date)){
typeLocalName = "dateTime";
};
};
};
};
};
constants = encoder.schemaManager.schemaConstants;
type = ((typeLocalName)!=null) ? new QName(constants.xsdURI, typeLocalName) : null;
encoder.encodeType(type, valueNode, valueQName, keyValue);
} else {
encoder.setValue(valueNode, null);
};
encoder.setValue(itemNode, valueNode);
encoder.setValue(parent, itemNode);
};
}
}
}//package mx.rpc.soap.types
Section 153
//QueryBeanType (mx.rpc.soap.types.QueryBeanType)
package mx.rpc.soap.types {
import mx.rpc.soap.*;
import mx.rpc.xml.*;
import mx.utils.*;
public class QueryBeanType implements ICustomSOAPType {
public function QueryBeanType(){
super();
}
public function decode(decoder:SOAPDecoder, parent, name, value, restriction:XML=null):void{
var returnVal:*;
var columnName:XML;
var dataXML:XML;
var item:*;
var resultItem:*;
var i:uint;
var beanXML:XML = (value as XML);
if (decoder.makeObjectsBindable){
returnVal = new XMLDecoder.listClass();
} else {
returnVal = [];
};
var colXML:XML = beanXML.columnList[0];
if (colXML == null){
return;
};
var columnsXMLList:XMLList = colXML.elements();
var columnNames:Array = [];
for each (columnName in columnsXMLList) {
columnNames.push(columnName.toString());
};
dataXML = beanXML.data[0];
if (dataXML == null){
return;
};
var soapArrayType:SOAPArrayType = new SOAPArrayType();
var tempParent:Array = [];
soapArrayType.decode(decoder, tempParent, name, dataXML, restriction);
var iterator:TypeIterator = new TypeIterator(tempParent);
while (iterator.hasNext()) {
item = iterator.next();
if (decoder.makeObjectsBindable){
resultItem = new ObjectProxy();
} else {
resultItem = {};
};
i = 0;
while (i < columnNames.length) {
resultItem[columnNames[i]] = item[i];
i++;
};
TypeIterator.push(returnVal, resultItem);
};
decoder.setValue(parent, name, returnVal);
}
public function encode(encoder:SOAPEncoder, parent:XML, name:QName, value, restriction:XML=null):void{
throw (new Error("Unsupported operation - Query Beans cannot be sent to ColdFusion."));
}
}
}//package mx.rpc.soap.types
Section 154
//RowSetType (mx.rpc.soap.types.RowSetType)
package mx.rpc.soap.types {
import mx.rpc.soap.*;
import mx.rpc.xml.*;
public class RowSetType implements ICustomSOAPType {
public function RowSetType(){
super();
}
public function decode(decoder:SOAPDecoder, parent, name, value, restriction:XML=null):void{
var i:uint;
var field:XML;
var items:XMLList;
var item:XML;
var typeAttr:String;
var typeQName:QName;
var columns:XMLList;
var row:*;
var j:uint;
var column:XML;
if ((parent is ContentProxy)){
parent.isSimple = false;
};
var rowSetNode:XML = (value as XML);
var returnVal:Array = [];
var types:Array = [];
var fields:Array = [];
var fieldNodes:XMLList = rowSetNode.elements()[0].elements();
for each (field in fieldNodes) {
typeAttr = field.attribute("type").toString();
if (((!((typeAttr == null))) && (!((typeAttr == ""))))){
typeQName = decoder.schemaManager.getQNameForPrefixedName(typeAttr, field);
};
if (typeQName == null){
typeQName = decoder.schemaManager.schemaDatatypes.stringQName;
};
types[i] = typeQName;
fields[i] = field.text().toString();
i++;
};
items = rowSetNode.elements()[1].elements();
i = 0;
for each (item in items) {
columns = item.elements();
row = decoder.createContent();
j = 0;
for each (column in columns) {
row[fields[j]] = decoder.decode(column, null, (types[j] as QName));
j++;
};
returnVal[i] = row;
i++;
};
decoder.setValue(parent, name, returnVal);
}
public function encode(encoder:SOAPEncoder, parent:XML, name:QName, value, restriction:XML=null):void{
throw (new Error("Unsupported operation - RowSet cannot be sent to a server."));
}
}
}//package mx.rpc.soap.types
Section 155
//SOAPArrayType (mx.rpc.soap.types.SOAPArrayType)
package mx.rpc.soap.types {
import mx.rpc.soap.*;
import mx.rpc.wsdl.*;
import mx.rpc.xml.*;
import mx.collections.*;
import mx.utils.*;
public class SOAPArrayType implements ICustomSOAPType {
private var schemaType:QName;
private var soapConstants:SOAPConstants;
private var schemaManager:SchemaManager;
private var processor:SchemaProcessor;
private var dimensionString:String;
private var schemaTypeName:String;
private var _dimensions:Array;
private var schemaConstants:SchemaConstants;
private var itemName:QName;
public function SOAPArrayType(){
super();
itemName = new QName("", "item");
}
private function determineWSDLArrayType(restriction:XML, wsdlConstants:WSDLConstants):String{
var soapencArrayTypeRef:String;
var soapencArrayType:QName;
var arrayTypeString:String = "";
var attribute:XML = getSingleElementFromNode(restriction, schemaConstants.attributeQName);
if (attribute != null){
soapencArrayTypeRef = attribute.@ref;
soapencArrayType = schemaManager.getQNameForPrefixedName(soapencArrayTypeRef, attribute, true);
if (soapencArrayType == soapConstants.soapencArrayTypeQName){
arrayTypeString = attribute.attribute(wsdlConstants.wsdlArrayTypeQName).toString();
};
};
return (arrayTypeString);
}
private function decodeArrayItem(parent, value):void{
var decoder:SOAPDecoder = (processor as SOAPDecoder);
var item:* = decoder.createContent(schemaType);
decoder.decodeType(schemaType, item, itemName, value);
decoder.setValue(parent, itemName, item, schemaType);
}
public function decode(decoder:SOAPDecoder, parent, name, value, restriction:XML=null):void{
var arrayTypeString:String;
var wsdlArrayType:String;
var proxy:ContentProxy;
processor = decoder;
soapConstants = decoder.soapConstants;
schemaManager = decoder.schemaManager;
schemaConstants = schemaManager.schemaConstants;
var valueXML:XML = (value as XML);
if (valueXML != null){
arrayTypeString = valueXML.@[soapConstants.soapencArrayTypeQName];
if (((!((arrayTypeString == null))) && (!((arrayTypeString == ""))))){
parseWSDLArrayType(arrayTypeString);
schemaType = schemaManager.getQNameForPrefixedName(schemaTypeName, valueXML);
};
};
if ((((schemaType == null)) && (!((restriction == null))))){
wsdlArrayType = determineWSDLArrayType(restriction, decoder.wsdlOperation.wsdlConstants);
parseWSDLArrayType(wsdlArrayType);
schemaType = schemaManager.getQNameForPrefixedName(schemaTypeName, restriction);
};
if (schemaType != null){
if ((parent is ContentProxy)){
proxy = (parent as ContentProxy);
proxy.isSimple = false;
if (((!((proxy.content is IList))) && (!((proxy.content is Array))))){
proxy.content = decoder.createIterableValue();
};
};
decodeArray(parent, dimensions, value, decoder.makeObjectsBindable);
};
}
private function getSingleElementFromNode(node:XML, ... _args):XML{
var element:XML;
var type:QName;
var elements:XMLList = node.elements();
for each (element in elements) {
if (((!((_args == null))) && ((_args.length > 0)))){
for each (type in _args) {
if (element.name() == type){
return (element);
};
};
} else {
return (element);
};
};
return (null);
}
private function decodeArray(parent, dimensions:Array, value, makeObjectsBindable:Boolean):void{
var dataXML:XML;
var entry:*;
var dimensionSize:int;
var itemValue:*;
var nestedDimension:Array;
var nestedArray:*;
var i:uint;
if ((value is XML)){
dataXML = (value as XML);
value = dataXML.elements();
};
if (((!(TypeIterator.isIterable(value))) && (!((value == ""))))){
value = [value];
};
var iter:TypeIterator = new TypeIterator(value);
var d:uint;
if (dimensions.length > 0){
entry = dimensions[0];
if (!(entry is Array)){
entry = [entry];
};
for each (dimensionSize in entry) {
d++;
if (dimensionSize < 0){
if (dimensions.length == 1){
while (iter.hasNext()) {
itemValue = iter.next();
decodeArrayItem(parent, itemValue);
};
} else {
if (dimensions.length > 1){
while (iter.hasNext()) {
itemValue = iter.next();
nestedDimension = dimensions[d];
nestedArray = SOAPDecoder(processor).createIterableValue(schemaType);
decodeArray(nestedArray, nestedDimension, itemValue, makeObjectsBindable);
TypeIterator.push(parent, nestedArray);
};
};
};
} else {
i = 0;
while (i < dimensionSize) {
itemValue = TypeIterator.getItemAt(iter.value, i);
if (dimensions.length == 1){
decodeArrayItem(parent, itemValue);
} else {
if (dimensions.length > 1){
nestedDimension = dimensions[d];
nestedArray = SOAPDecoder(processor).createIterableValue(schemaType);
decodeArray(nestedArray, nestedDimension, itemValue, makeObjectsBindable);
TypeIterator.push(parent, nestedArray);
};
};
i++;
};
};
};
};
}
private function get dimensions():Array{
if (_dimensions == null){
_dimensions = [];
};
return (_dimensions);
}
public function encode(encoder:SOAPEncoder, parent:XML, name:QName, value, restriction:XML=null):void{
var wsdlArrayType:String;
processor = encoder;
soapConstants = encoder.soapConstants;
schemaManager = encoder.schemaManager;
schemaConstants = schemaManager.schemaConstants;
value = unwrapMXMLArray(value);
if (restriction != null){
wsdlArrayType = determineWSDLArrayType(restriction, encoder.wsdlOperation.wsdlConstants);
parseWSDLArrayType(wsdlArrayType);
};
schemaType = schemaManager.getQNameForPrefixedName(schemaTypeName, restriction);
parent.addNamespace(soapConstants.encodingNamespace);
encodeDimensionInformation(parent, dimensionString);
encodeArray(parent, dimensions, value);
}
private function parseWSDLArrayType(wsdlArrayType:String):void{
var typeName:String;
var dimsString:String;
var newDimension:Array;
var startBracket:int = wsdlArrayType.indexOf("[");
var endBracket = -1;
if (startBracket > 0){
dimensionString = wsdlArrayType.substring(startBracket);
schemaTypeName = StringUtil.trim(wsdlArrayType.substring(0, startBracket));
endBracket = wsdlArrayType.indexOf("]", startBracket);
};
if ((((startBracket < 0)) || ((endBracket < 0)))){
throw (new Error((("Invalid SOAP-encoded Array type '" + wsdlArrayType) + "'.")));
};
var rankOrSizeString:String = StringUtil.trim(wsdlArrayType.substring(startBracket));
var dimsArray:Array = rankOrSizeString.split("[");
var currentDimension:Array = dimensions;
var i:int = (dimsArray.length - 1);
while (i >= 0) {
dimsString = (dimsArray[i] as String);
if (dimsString.length > 0){
if (currentDimension.length > 0){
newDimension = [];
currentDimension.push(newDimension);
currentDimension = newDimension;
};
parseDimensions(wsdlArrayType, dimsString, currentDimension);
};
i--;
};
}
private function parseDimensions(wsdlArrayType:String, dimensionsString:String, currentDimension:Array):void{
var dim:Number;
var dimString:String;
if (dimensionsString.charAt(0) == "["){
dimensionsString = dimensionsString.substring(1);
};
if (dimensionsString.charAt((dimensionsString.length - 1)) == "]"){
dimensionsString = dimensionsString.substring(0, (dimensionsString.length - 1));
};
var dimensions:Array = dimensionsString.split(",");
if (dimensions.length > 0){
for each (dimString in dimensions) {
if (dimString.length > 0){
dim = parseInt(dimString);
if (((!(isNaN(dim))) && ((dim < int.MAX_VALUE)))){
currentDimension.push(int(dim));
} else {
throw (new Error((((("Invalid dimension '" + dimString) + "' for SOAP encoded Array type '") + wsdlArrayType) + "'.")));
};
} else {
currentDimension.push(-1);
};
};
};
}
private function encodeArray(parent:XML, dimensions:Array, value):void{
var entry:*;
var dimensionSize:int;
var itemValue:*;
var nestedDimension:Array;
var nestedDimensionString:String;
var nestedArray:XML;
var i:uint;
var typeAttr:String = schemaConstants.getXSIToken(schemaConstants.typeAttrQName);
parent.@[typeAttr] = soapConstants.getSOAPEncodingToken(soapConstants.soapencArrayQName);
if (!TypeIterator.isIterable(value)){
value = [value];
};
var iter:TypeIterator = new TypeIterator(value);
var d:uint;
if (dimensions.length > 0){
entry = dimensions[0];
if (!(entry is Array)){
entry = [entry];
};
for each (dimensionSize in entry) {
d++;
if (dimensionSize < 0){
if (dimensions.length == 1){
while (iter.hasNext()) {
itemValue = iter.next();
nestedArray = new XML((("<" + itemName.localName) + "/>"));
encodeArrayItem(nestedArray, itemValue);
parent.appendChild(nestedArray);
};
} else {
if (dimensions.length > 1){
nestedDimensionString = "[]";
while (iter.hasNext()) {
itemValue = iter.next();
nestedDimension = dimensions[d];
nestedArray = new XML((("<" + itemName.localName) + "/>"));
encodeDimensionInformation(nestedArray, nestedDimensionString);
encodeArray(nestedArray, nestedDimension, itemValue);
parent.appendChild(nestedArray);
};
};
};
} else {
i = 0;
while (i < dimensionSize) {
itemValue = TypeIterator.getItemAt(iter.value, i);
if (dimensions.length == 1){
nestedArray = new XML((("<" + itemName.localName) + "/>"));
encodeArrayItem(nestedArray, itemValue);
parent.appendChild(nestedArray);
} else {
if (dimensions.length > 1){
nestedDimensionString = (("[" + dimensionSize) + "]");
nestedDimension = dimensions[d];
nestedArray = new XML((("<" + itemName.localName) + "/>"));
encodeDimensionInformation(nestedArray, nestedDimensionString);
encodeArray(nestedArray, nestedDimension, itemValue);
parent.appendChild(nestedArray);
};
};
i++;
};
};
};
};
}
private function encodeArrayItem(item:XML, value):void{
var encoder:SOAPEncoder = (processor as SOAPEncoder);
encoder.encodeType(schemaType, item, itemName, value);
}
private function encodeDimensionInformation(parent:XML, dimensionString:String):void{
var uri:String = schemaType.uri;
var prefix:String = schemaManager.getOrCreatePrefix(uri);
var ns:Namespace = new Namespace(prefix, uri);
var arrayTypeString:String = ((prefix + ":") + schemaType.localName);
arrayTypeString = (arrayTypeString + dimensionString);
parent.addNamespace(ns);
var arrayTypeAttr:String = soapConstants.getSOAPEncodingToken(soapConstants.soapencArrayTypeQName);
parent.@[arrayTypeAttr] = arrayTypeString;
}
private function unwrapMXMLArray(value){
var classInfo:Object;
var properties:Array;
var property:String;
var childValue:*;
var value = value;
var result:* = value;
if (!(value is Array)){
classInfo = ObjectUtil.getClassInfo((value as Object));
properties = classInfo["properties"];
if (properties.length == 1){
property = properties[0];
if (((!((property == null))) && (value.hasOwnProperty(property)))){
childValue = value[property];
if ((childValue is Array)){
result = childValue;
};
};
};
//unresolved jump
var _slot1 = e;
};
return (result);
}
}
}//package mx.rpc.soap.types
Section 156
//ISOAPDecoder (mx.rpc.soap.ISOAPDecoder)
package mx.rpc.soap {
import mx.rpc.wsdl.*;
import mx.rpc.xml.*;
public interface ISOAPDecoder extends IXMLDecoder {
function get wsdlOperation():WSDLOperation;
function get headerFormat():String;
function set wsdlOperation(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\soap;ISOAPDecoder.as:WSDLOperation):void;
function get multiplePartsFormat():String;
function set headerFormat(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\soap;ISOAPDecoder.as:String):void;
function set multiplePartsFormat(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\soap;ISOAPDecoder.as:String):void;
function get ignoreWhitespace():Boolean;
function set forcePartArrays(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\soap;ISOAPDecoder.as:Boolean):void;
function get resultFormat():String;
function decodeResponse(value):SOAPResult;
function set resultFormat(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\soap;ISOAPDecoder.as:String):void;
function get forcePartArrays():Boolean;
function set ignoreWhitespace(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\soap;ISOAPDecoder.as:Boolean):void;
}
}//package mx.rpc.soap
Section 157
//ISOAPEncoder (mx.rpc.soap.ISOAPEncoder)
package mx.rpc.soap {
import mx.rpc.wsdl.*;
import mx.rpc.xml.*;
public interface ISOAPEncoder extends IXMLEncoder {
function set wsdlOperation(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\soap;ISOAPEncoder.as:WSDLOperation):void;
function encodeRequest(_arg1=null, _arg2:Array=null):XML;
function get wsdlOperation():WSDLOperation;
function set ignoreWhitespace(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\soap;ISOAPEncoder.as:Boolean):void;
function get ignoreWhitespace():Boolean;
}
}//package mx.rpc.soap
Section 158
//LoadEvent (mx.rpc.soap.LoadEvent)
package mx.rpc.soap {
import flash.events.*;
import mx.rpc.events.*;
import mx.rpc.wsdl.*;
import flash.xml.*;
public class LoadEvent extends WSDLLoadEvent {
private var _document:XMLDocument;
public static const LOAD:String = "load";
public function LoadEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=true, wsdl:WSDL=null, location:String=null){
super(((type == null)) ? LOAD : type, bubbles, cancelable, wsdl, location);
}
public function get document():XMLDocument{
if ((((_document == null)) && (!((xml == null))))){
_document = new XMLDocument(xml.toXMLString());
//unresolved jump
var _slot1 = e;
};
return (_document);
}
override public function toString():String{
return (formatToString("LoadEvent", "location", "type", "bubbles", "cancelable", "eventPhase"));
}
override public function clone():Event{
return (new LoadEvent(type, bubbles, cancelable, wsdl, location));
}
public static function createEvent(wsdl:WSDL, location:String=null):LoadEvent{
return (new LoadEvent(LOAD, false, true, wsdl, location));
}
}
}//package mx.rpc.soap
Section 159
//SOAPConstants (mx.rpc.soap.SOAPConstants)
package mx.rpc.soap {
import mx.rpc.soap.types.*;
import flash.utils.*;
import mx.utils.*;
public class SOAPConstants {
public var soapBase64QName:QName;
private var _envelopeNS:Namespace;
public var headerQName:QName;
public var soapencArrayQName:QName;
private var _contentType:String;
public var soapencRefQName:QName;
public var faultQName:QName;
public var bodyQName:QName;
public var soapoffsetQName:QName;
public var actorQName:QName;
public var envelopeQName:QName;
public var mustUnderstandQName:QName;
public var soapencArrayTypeQName:QName;
private var _encodingNS:Namespace;
public static const SOAP_ENVELOPE_URI:String = "http://schemas.xmlsoap.org/soap/envelope/";
public static const XML_DECLARATION:String = "<?xml version="1.0" encoding="utf-8"?>
";
public static const SOAP_ENCODING_URI:String = "http://schemas.xmlsoap.org/soap/encoding/";
public static const USE_ENCODED:String = "encoded";
public static const RPC_STYLE:String = "rpc";
public static const SOAP_CONTENT_TYPE:String = "text/xml; charset=utf-8";
public static const mapQName:QName = new QName(APACHE_SOAP_URI, "Map");
public static const diffgramQName:QName = new QName("urn:schemas-microsoft-com:xml-diffgram-v1", "diffgram");
public static const DOC_STYLE:String = "document";
public static const WRAPPED_STYLE:String = "wrapped";
public static const USE_LITERAL:String = "literal";
public static const documentQName:QName = new QName(APACHE_SOAP_URI, "Document");
public static const DEFAULT_USE:String = "literal";
public static const SOAP12_ENVELOPE_URI:String = "http://www.w3.org/2002/12/soap-envelope";
public static const SOAP12_ENCODING_URI:String = "http://www.w3.org/2002/12/soap-encoding";
public static const rowSetQName:QName = new QName(APACHE_SOAP_URI, "RowSet");
public static const SOAP12_CONTENT_TYPE:String = "application/soap+xml; charset=utf-8";
public static const queryBeanQName:QName = new QName(COLD_FUSION_URI, "QueryBean");
public static const APACHE_SOAP_URI:String = "http://xml.apache.org/xml-soap";
public static const SOAP_ENC_PREFIX:String = "SOAP-ENC";
public static const COLD_FUSION_URI:String = "http://rpc.xml.coldfusion";
public static const DEFAULT_OPERATION_STYLE:String = "document";
public static const msdataURI:String = "urn:schemas-microsoft-com:xml-msdata";
public static const SOAP_ENV_PREFIX:String = "SOAP-ENV";
private static var customTypesInitialized:Boolean;
private static var typeMap:Object = {};
private static var constantsCache:Object;
public function SOAPConstants(envelopeNS:Namespace=null, encodingNS:Namespace=null){
super();
if (envelopeNS == null){
envelopeNS = new Namespace(SOAP_ENV_PREFIX, SOAP_ENVELOPE_URI);
};
if (encodingNS == null){
encodingNS = new Namespace(SOAP_ENC_PREFIX, SOAP_ENCODING_URI);
};
_envelopeNS = envelopeNS;
_encodingNS = encodingNS;
envelopeQName = new QName(envelopeURI, "Envelope");
headerQName = new QName(envelopeURI, "Header");
bodyQName = new QName(envelopeURI, "Body");
faultQName = new QName(envelopeURI, "Fault");
actorQName = new QName(envelopeURI, "actor");
mustUnderstandQName = new QName(envelopeURI, "mustUnderstand");
soapencArrayQName = new QName(encodingURI, "Array");
soapencArrayTypeQName = new QName(encodingURI, "arrayType");
soapencRefQName = new QName(encodingURI, "multiRef");
soapoffsetQName = new QName(encodingURI, "offset");
soapBase64QName = new QName(encodingURI, "base64");
if (!customTypesInitialized){
initCustomSOAPTypes();
};
registerCustomSOAPType(soapencArrayQName, SOAPArrayType);
registerCustomSOAPType(soapencArrayTypeQName, SOAPArrayType);
}
public function getSOAPEncodingToken(type:QName):String{
return (((encodingNamespace.prefix + ":") + type.localName));
}
public function get encodingNamespace():Namespace{
return (_encodingNS);
}
public function get contentType():String{
return (_contentType);
}
public function get encodingURI():String{
return (encodingNamespace.uri);
}
public function get envelopeNamespace():Namespace{
return (_envelopeNS);
}
public function get envelopeURI():String{
return (envelopeNamespace.uri);
}
public static function getConstants(xml:XML=null):SOAPConstants{
var envelopeNS:Namespace;
var encodingNS:Namespace;
var nsArray:Array;
var ns:Namespace;
if (xml != null){
nsArray = xml.namespaceDeclarations();
for each (ns in nsArray) {
if (((URLUtil.urisEqual(ns.uri, SOAP_ENVELOPE_URI)) || (URLUtil.urisEqual(ns.uri, SOAP12_ENVELOPE_URI)))){
envelopeNS = ns;
} else {
if (((URLUtil.urisEqual(ns.uri, SOAP_ENCODING_URI)) || (URLUtil.urisEqual(ns.uri, SOAP12_ENCODING_URI)))){
encodingNS = ns;
};
};
};
};
if (envelopeNS == null){
envelopeNS = new Namespace(SOAP_ENV_PREFIX, SOAP_ENVELOPE_URI);
};
if (encodingNS == null){
encodingNS = new Namespace(SOAP_ENC_PREFIX, SOAP_ENCODING_URI);
};
if (constantsCache == null){
constantsCache = {};
};
var constants:SOAPConstants = constantsCache[envelopeNS.uri];
if (constants == null){
constants = new SOAPConstants(envelopeNS, encodingNS);
constantsCache[envelopeNS.uri] = constants;
};
return (constants);
}
private static function initCustomSOAPTypes():void{
registerCustomSOAPType(queryBeanQName, QueryBeanType);
registerCustomSOAPType(mapQName, MapType);
registerCustomSOAPType(rowSetQName, RowSetType);
registerCustomSOAPType(documentQName, ApacheDocumentType);
registerCustomSOAPType(diffgramQName, DataSetType);
customTypesInitialized = true;
}
private static function getKey(type:QName):String{
var key:String;
if ((((type.uri == null)) || ((type.uri == "")))){
key = type.localName;
} else {
key = type.toString();
};
return (key);
}
public static function unregisterCustomSOAPType(type:QName):void{
var key:String;
if (type != null){
key = getKey(type);
delete typeMap[key];
};
}
public static function getCustomSOAPType(type:QName):ICustomSOAPType{
var soapType:ICustomSOAPType;
var key:String;
var definitionName:String;
var c:Class;
var type = type;
if (type != null){
key = getKey(type);
definitionName = (typeMap[key] as String);
if (definitionName != null){
c = (getDefinitionByName(definitionName) as Class);
soapType = (new (c) as ICustomSOAPType);
//unresolved jump
var _slot1 = e;
};
};
return (soapType);
}
public static function registerCustomSOAPType(type:QName, definition):void{
var definitionName:String;
var key:String = getKey(type);
if ((definition is String)){
definitionName = (definition as String);
} else {
definitionName = getQualifiedClassName(definition);
};
typeMap[key] = definitionName;
}
public static function isSOAPEncodedType(type:QName):Boolean{
var uri:String = ((type)!=null) ? type.uri : null;
if (uri != null){
if (((URLUtil.urisEqual(uri, SOAPConstants.SOAP_ENCODING_URI)) || (URLUtil.urisEqual(uri, SOAPConstants.SOAP12_ENCODING_URI)))){
return (true);
};
};
return (false);
}
}
}//package mx.rpc.soap
Section 160
//SOAPDecoder (mx.rpc.soap.SOAPDecoder)
package mx.rpc.soap {
import mx.rpc.wsdl.*;
import flash.xml.*;
import mx.rpc.xml.*;
import mx.rpc.soap.types.*;
import mx.logging.*;
import flash.utils.*;
import mx.utils.*;
public class SOAPDecoder extends XMLDecoder implements ISOAPDecoder {
private var _multiplePartsFormat:String;
private var _forcePartArrays:Boolean;
private var _headerFormat:String;
private var log:ILogger;
private var _resultFormat:String;
private var _ignoreWhitespace:Boolean;// = true
private var _referencesResolved:Boolean;
public var supportGenericCompoundTypes:Boolean;// = false
private var _wsdlOperation:WSDLOperation;
private var _elementsWithId:XMLList;
public static var PI_WHITESPACE_PATTERN:RegExp = new RegExp("[\\?][>]\\s*[<]", "g");
public function SOAPDecoder(){
super();
log = Log.getLogger("mx.rpc.soap.SOAPDecoder");
}
public function get soapConstants():SOAPConstants{
return (wsdlOperation.soapConstants);
}
override public function decodeComplexRestriction(restriction:XML, parent, name:QName, value):void{
var customType:ICustomSOAPType;
var schemaConstants:SchemaConstants = schemaManager.schemaConstants;
var baseName:String = restriction.@base;
var baseQName:QName = schemaManager.getQNameForPrefixedName(baseName, restriction);
if (baseQName == soapConstants.soapencArrayQName){
customType = SOAPConstants.getCustomSOAPType(baseQName);
if (customType != null){
customType.decode(this, parent, name, value, restriction);
return;
};
};
super.decodeComplexRestriction(restriction, parent, name, value);
}
public function set multiplePartsFormat(value:String):void{
_multiplePartsFormat = value;
}
private function resolveReferences(root:XML, cleanupElementsWithIdCache:Boolean=true):void{
var child:XML;
var element:XML;
var href:String;
var hashPosition:int;
var matches:XMLList;
var referent:XML;
var root = root;
var cleanupElementsWithIdCache = cleanupElementsWithIdCache;
if (_referencesResolved){
return;
};
var index:uint;
if (_elementsWithId == null){
_elementsWithId = document..*.(attribute("id").length() > 0);
};
for each (child in root.children()) {
if (child.nodeKind() == "element"){
element = child;
href = getAttributeFromNode("href", element);
if (href != null){
hashPosition = href.indexOf("#");
if (hashPosition >= 0){
href = href.substring((hashPosition + 1));
};
matches = _elementsWithId.(@id == href);
if (matches.length() > 0){
referent = matches[0];
} else {
throw (new Error((("The element referenced by id '" + href) + "' was not found.")));
};
referent.setName(element.name());
if (referent.hasComplexContent()){
resolveReferences(referent, false);
};
root.replace(index, referent);
} else {
if (element.hasComplexContent()){
resolveReferences(element, false);
};
};
};
index = (index + 1);
};
if (cleanupElementsWithIdCache){
_elementsWithId = null;
_referencesResolved = true;
};
}
protected function decodeFaults(faultsXMLList:XMLList):Array{
var faultXML:XML;
var code:QName;
var string:String;
var detail:String;
var element:XML;
var actor:String;
var faultProperties:XMLList;
var child:XML;
var fault:SOAPFault;
log.debug("SOAP: Decoding SOAP response fault");
var faults:Array = [];
for each (faultXML in faultsXMLList) {
element = faultXML;
faultProperties = faultXML.children();
for each (child in faultProperties) {
if (child.localName() == "faultcode"){
code = schemaManager.getQNameForPrefixedName(child.toString(), child);
} else {
if (child.localName() == "faultstring"){
string = child.toString();
} else {
if (child.localName() == "faultactor"){
actor = child.toString();
} else {
if (child.localName() == "detail"){
if (child.hasComplexContent()){
detail = child.children().toXMLString();
} else {
detail = child.toString();
};
};
};
};
};
};
fault = new SOAPFault(code, string, detail, element, actor);
faults.push(fault);
};
return (faults);
}
override protected function preProcessXML(root:XML):void{
if (outputEncoding.useStyle == SOAPConstants.USE_ENCODED){
resolveReferences(root);
};
}
public function get schemaConstants():SchemaConstants{
return (schemaManager.schemaConstants);
}
public function set forcePartArrays(value:Boolean):void{
_forcePartArrays = value;
}
protected function decodeHeaders(headerXML:XML):Array{
var headerChild:XML;
var xsiType:QName;
var definition:XML;
var headerContent:Object;
var headerObject:SOAPHeader;
var muValue:String;
var actValue:String;
log.debug("Decoding SOAP response headers");
var headers:Array = [];
var headerXMLList:XMLList = headerXML.elements();
for each (headerChild in headerXMLList) {
if (headerFormat == "object"){
xsiType = getXSIType(headerChild);
definition = null;
headerContent = null;
if (xsiType != null){
definition = schemaManager.getNamedDefinition(xsiType, constants.complexTypeQName, constants.simpleTypeQName);
};
if (definition != null){
schemaManager.releaseScope();
headerContent = decode(headerChild, null, xsiType);
} else {
headerContent = decode(headerChild, headerChild.name());
};
headerObject = new SOAPHeader(headerChild.name(), headerContent);
muValue = XMLUtil.getAttributeByQName(headerChild, soapConstants.mustUnderstandQName).toString();
if (muValue == "1"){
headerObject.mustUnderstand = true;
};
actValue = XMLUtil.getAttributeByQName(headerChild, soapConstants.actorQName).toString();
if (actValue != ""){
headerObject.role = actValue;
};
headers.push(headerObject);
} else {
if (headerFormat == "e4x"){
headers.push(headerChild);
} else {
if (headerFormat == "xml"){
headers.push(new XMLDocument(headerChild.toString()));
};
};
};
};
return (headers);
}
override public function decodeComplexType(definition:XML, parent, name:QName, value, restriction:XML=null, context:DecodingContext=null):void{
var valXML:XML;
if ((value is XML)){
valXML = (value as XML);
if ((((valXML.elements(SOAPConstants.diffgramQName).length() > 0)) && ((valXML.elements(schemaConstants.schemaQName).length() > 0)))){
decodeType(SOAPConstants.diffgramQName, parent, valXML.name(), value);
return;
};
};
super.decodeComplexType(definition, parent, name, value, restriction, context);
}
protected function get inputEncoding():WSDLEncoding{
var encoding:WSDLEncoding;
if (_wsdlOperation.inputMessage != null){
encoding = _wsdlOperation.inputMessage.encoding;
} else {
encoding = new WSDLEncoding();
};
return (encoding);
}
protected function decodeBody(bodyXML:XML, soapResult:SOAPResult):void{
var result:*;
var part:WSDLMessagePart;
var encodedPartValues:XMLList;
var encodedPartValue:XML;
var decodedPart:*;
var partQName:QName;
var partType:QName;
var partDefinition:XML;
var encodedNamespace:String;
var partMaxOccurs:uint;
var sinlgePartResultType:QName;
var singlePartMaxOccurs:uint;
log.debug("Decoding SOAP response body");
document = bodyXML;
preProcessXML(bodyXML);
if (wsdlOperation.outputMessage == null){
soapResult.result = undefined;
return;
};
var parts:Array = wsdlOperation.outputMessage.parts;
if ((((parts == null)) || ((parts.length == 0)))){
soapResult.result = undefined;
return;
};
var outputMessageXML:XML = bodyXML;
if (wsdlOperation.style == SOAPConstants.RPC_STYLE){
outputMessageXML = outputMessageXML.elements()[0];
} else {
if ((((outputEncoding.useStyle == SOAPConstants.USE_LITERAL)) && ((wsdlOperation.outputMessage.isWrapped == true)))){
outputMessageXML = outputMessageXML.elements()[0];
};
};
for each (part in parts) {
if (part.element != null){
if (outputMessageXML.hasComplexContent()){
encodedPartValues = outputMessageXML.elements(part.element);
} else {
encodedPartValues = outputMessageXML.text();
};
partQName = part.element;
partType = null;
} else {
partType = part.type;
partDefinition = part.definition;
if (outputMessageXML.hasComplexContent()){
if (outputEncoding.useStyle == SOAPConstants.USE_ENCODED){
partQName = new QName("", part.name.localName);
encodedPartValues = outputMessageXML.elements(partQName);
if (encodedPartValues.length() == 0){
encodedNamespace = outputEncoding.namespaceURI;
partQName = new QName(encodedNamespace, part.name.localName);
encodedPartValues = outputMessageXML.elements(partQName);
if (encodedPartValues.length() == 0){
encodedNamespace = inputEncoding.namespaceURI;
partQName = new QName(encodedNamespace, part.name.localName);
encodedPartValues = outputMessageXML.elements(partQName);
};
};
} else {
encodedPartValues = outputMessageXML.elements(part.name);
};
} else {
encodedPartValues = outputMessageXML.text();
};
};
for each (encodedPartValue in encodedPartValues) {
decodedPart = decode(encodedPartValue, partQName, partType, partDefinition);
if (parts.length > 1){
if (multiplePartsFormat == "object"){
if (result == null){
result = createContent(outputMessageXML.name());
result.isSimple = false;
};
if (result[part.name.localName] == null){
partMaxOccurs = getMaxOccurs(partDefinition);
if ((((((partMaxOccurs > 1)) && (forcePartArrays))) || ((encodedPartValues.length() > 1)))){
result[part.name.localName] = createIterableValue(part.type);
};
};
if (TypeIterator.isIterable(result[part.name.localName])){
TypeIterator.push(result[part.name.localName], decodedPart);
} else {
result[part.name.localName] = decodedPart;
};
} else {
if (multiplePartsFormat == "array"){
if (result == null){
result = createIterableValue(outputMessageXML.name());
};
TypeIterator.push(result, decodedPart);
};
};
} else {
if (result == null){
sinlgePartResultType = partType;
if (sinlgePartResultType == null){
sinlgePartResultType = part.element;
};
if (sinlgePartResultType == null){
sinlgePartResultType = part.name;
};
singlePartMaxOccurs = getMaxOccurs(partDefinition);
if ((((((singlePartMaxOccurs > 1)) && (forcePartArrays))) || ((encodedPartValues.length() > 1)))){
result = createIterableValue(sinlgePartResultType);
} else {
result = createContent();
};
};
if (TypeIterator.isIterable(result)){
TypeIterator.push(result, decodedPart);
} else {
result = decodedPart;
};
};
};
};
if ((result is ContentProxy)){
result = ContentProxy(result).content;
};
soapResult.result = result;
}
public function set wsdlOperation(value:WSDLOperation):void{
_wsdlOperation = value;
schemaManager = _wsdlOperation.schemaManager;
}
public function get multiplePartsFormat():String{
return (_multiplePartsFormat);
}
public function set headerFormat(value:String):void{
_headerFormat = value;
}
public function decodeResponse(response):SOAPResult{
var soapResult:SOAPResult;
var responseString:String;
var oldIgnoreWhitespace:Boolean;
var responseXML:XML;
var response = response;
if ((response is XML)){
responseString = XML(response).toXMLString();
} else {
responseString = String(response);
};
var startTime:int = getTimer();
log.info("Decoding SOAP response");
reset();
if (responseString != null){
log.debug("Encoded SOAP response {0}", responseString);
oldIgnoreWhitespace = XML.ignoreWhitespace;
try {
try {
responseString = responseString.replace(PI_WHITESPACE_PATTERN, "?><");
responseString = StringUtil.trim(responseString);
XML.ignoreWhitespace = ignoreWhitespace;
responseXML = new XML(responseString);
soapResult = decodeEnvelope(responseXML);
} finally {
};
} finally {
XML.ignoreWhitespace = oldIgnoreWhitespace;
};
};
log.info("Decoded SOAP response into result [{0} millis]", (getTimer() - startTime));
return (soapResult);
}
override public function decodeType(type:QName, parent, name:QName, value, restriction:XML=null):void{
var datatypes:SchemaDatatypes;
var localName:String;
var constants:SchemaConstants;
var definition:XML;
var originalType:QName = type;
var xsiType:QName = getXSIType(value);
if (xsiType != null){
type = xsiType;
};
if (outputEncoding.useStyle == SOAPConstants.USE_ENCODED){
if (SOAPConstants.isSOAPEncodedType(type)){
datatypes = schemaManager.schemaDatatypes;
if (type == soapConstants.soapBase64QName){
type = datatypes.base64BinaryQName;
} else {
localName = type.localName;
if (((!((localName == "Array"))) && (!((localName == "arrayType"))))){
type = schemaConstants.getQName(localName);
};
};
};
};
var customType:ICustomSOAPType = SOAPConstants.getCustomSOAPType(type);
if (customType != null){
customType.decode(this, parent, name, value, restriction);
setXSIType(parent, type);
} else {
constants = schemaManager.schemaConstants;
if (isBuiltInType(type)){
super.decodeType(type, parent, name, value, restriction);
} else {
definition = schemaManager.getNamedDefinition(type, constants.complexTypeQName, constants.simpleTypeQName, constants.elementTypeQName);
if (definition != null){
schemaManager.releaseScope();
super.decodeType(type, parent, name, value, restriction);
} else {
super.decodeType(originalType, parent, name, value, restriction);
};
};
};
}
public function get forcePartArrays():Boolean{
return (_forcePartArrays);
}
public function set ignoreWhitespace(value:Boolean):void{
_ignoreWhitespace = value;
}
public function get wsdlOperation():WSDLOperation{
return (_wsdlOperation);
}
public function get headerFormat():String{
return (_headerFormat);
}
public function set resultFormat(value:String):void{
_resultFormat = value;
}
protected function decodeEnvelope(responseXML:XML):SOAPResult{
var envNS:Namespace;
var schemaConst:SchemaConstants;
var nsArray:Array;
var ns:Namespace;
var headerXML:XML;
var bodyXML:XML;
var faultXMLList:XMLList;
var bodyArray:Array;
var bodyXMLList:XMLList;
var bodyChild:XML;
var nodeKind:String;
var xmlDoc:XMLDocument;
var xmlNode:XMLNode;
log.debug("Decoding SOAP response envelope");
var soapResult:SOAPResult = new SOAPResult();
if (responseXML != null){
envNS = responseXML.namespace();
};
if (envNS == null){
throw (new Error(("SOAP Response cannot be decoded. Raw response: " + responseXML)));
};
if (envNS.uri != SOAPConstants.SOAP_ENVELOPE_URI){
throw (new Error("SOAP Response Version Mismatch"));
};
nsArray = responseXML.inScopeNamespaces();
for each (ns in nsArray) {
schemaManager.namespaces[ns.prefix] = ns;
};
headerXML = responseXML[soapConstants.headerQName][0];
if (headerXML != null){
soapResult.headers = decodeHeaders(headerXML);
};
bodyXML = responseXML[soapConstants.bodyQName][0];
if ((((((bodyXML == null)) || ((bodyXML.hasComplexContent() == false)))) || ((bodyXML.children().length() <= 0)))){
soapResult.result = undefined;
} else {
faultXMLList = bodyXML[soapConstants.faultQName];
if (faultXMLList.length() > 0){
soapResult.isFault = true;
soapResult.result = decodeFaults(faultXMLList);
} else {
if (resultFormat == "object"){
decodeBody(bodyXML, soapResult);
} else {
if (resultFormat == "e4x"){
soapResult.result = bodyXML.children();
} else {
if (resultFormat == "xml"){
bodyArray = [];
bodyXMLList = bodyXML.children();
for each (bodyChild in bodyXMLList) {
nodeKind = bodyChild.nodeKind();
if (nodeKind == "element"){
xmlDoc = new XMLDocument(bodyChild.toString());
xmlNode = xmlDoc.firstChild;
bodyArray.push(xmlNode);
} else {
if (nodeKind == "text"){
bodyArray.push(bodyChild.toString());
};
};
};
soapResult.result = bodyArray;
};
};
};
};
};
return (soapResult);
}
override public function reset():void{
super.reset();
_referencesResolved = false;
_elementsWithId = null;
}
protected function get outputEncoding():WSDLEncoding{
var encoding:WSDLEncoding;
if (_wsdlOperation.outputMessage != null){
encoding = _wsdlOperation.outputMessage.encoding;
} else {
encoding = new WSDLEncoding();
};
return (encoding);
}
public function get ignoreWhitespace():Boolean{
return (_ignoreWhitespace);
}
public function get resultFormat():String{
return (_resultFormat);
}
override protected function parseValue(name, value:XMLList){
var itemQName:QName;
var items:XMLList;
if (((((supportGenericCompoundTypes) && ((outputEncoding.useStyle == SOAPConstants.USE_LITERAL)))) && ((value.length() > 0)))){
itemQName = new QName(value[0].name().uri, "item");
items = value.elements(itemQName);
if (items.length() > 0){
value = items;
};
};
return (super.parseValue(name, value));
}
}
}//package mx.rpc.soap
Section 161
//SOAPEncoder (mx.rpc.soap.SOAPEncoder)
package mx.rpc.soap {
import mx.rpc.wsdl.*;
import flash.xml.*;
import mx.rpc.xml.*;
import mx.resources.*;
import mx.rpc.soap.types.*;
import mx.logging.*;
public class SOAPEncoder extends XMLEncoder implements ISOAPEncoder {
private var log:ILogger;
private var _ignoreWhitespace:Boolean;// = true
private var _wsdlOperation:WSDLOperation;
private var isSOAPEncoding:Boolean;// = false
private var resourceManager:IResourceManager;
public function SOAPEncoder(){
resourceManager = ResourceManager.getInstance();
super();
log = Log.getLogger("mx.rpc.soap.SOAPEncoder");
}
override protected function deriveXSIType(parent:XML, type:QName, value):void{
var datatypes:SchemaDatatypes;
var soapType:QName;
var localName:String;
if (isSOAPEncoding){
datatypes = schemaManager.schemaDatatypes;
if ((((type == datatypes.anyTypeQName)) || ((type == datatypes.anySimpleTypeQName)))){
if (((isSimpleValue(value)) || ((type == datatypes.anySimpleTypeQName)))){
localName = SchemaMarshaller.guessSimpleType(value);
soapType = new QName(schemaConstants.xsdURI, localName);
};
} else {
soapType = type;
};
if (soapType != null){
parent.@[schemaConstants.getXSIToken(schemaConstants.typeAttrQName)] = schemaConstants.getXSDToken(soapType);
};
};
}
public function get soapConstants():SOAPConstants{
return (wsdlOperation.soapConstants);
}
public function set wsdlOperation(value:WSDLOperation):void{
_wsdlOperation = value;
schemaManager = _wsdlOperation.schemaManager;
}
protected function encodePartValue(part:WSDLMessagePart, value):XMLList{
var partXMLList:XMLList;
if (part.element != null){
partXMLList = encode(value, part.element);
} else {
partXMLList = encode(value, part.name, part.type, part.definition);
};
return (partXMLList);
}
protected function encodeOperationAsRPCEncoded(inputParams, bodyXML:XML):void{
isSOAPEncoding = true;
var operationXML:XML = new XML((("<" + wsdlOperation.name) + "/>"));
var inputNamespaceURI:String = inputEncoding.namespaceURI;
var inputPrefix:String = schemaManager.getOrCreatePrefix(inputNamespaceURI);
var inputNamespace:Namespace = new Namespace(inputPrefix, inputNamespaceURI);
operationXML.setNamespace(inputNamespace);
encodeMessage(inputParams, operationXML);
bodyXML.appendChild(operationXML);
bodyXML.@[(SOAPConstants.SOAP_ENV_PREFIX + ":encodingStyle")] = soapConstants.encodingURI;
}
protected function encodeEnvelope(args, headers:Array):XML{
log.debug("Encoding SOAP request envelope");
var envelopeXML:XML = new XML((("<" + soapConstants.envelopeQName.localName) + "/>"));
envelopeXML.setNamespace(soapConstants.envelopeNamespace);
envelopeXML.addNamespace(schemaConstants.xsdNamespace);
envelopeXML.addNamespace(schemaConstants.xsiNamespace);
schemaManager.namespaces[soapConstants.envelopeNamespace.prefix] = soapConstants.envelopeNamespace;
encodeHeaders(headers, envelopeXML);
encodeBody(args, envelopeXML);
return (envelopeXML);
}
protected function encodeHeaders(headers:Array, envelopeXML:XML):void{
var count:uint;
var headersXML:XML;
var i:uint;
if (headers != null){
count = headers.length;
if (count > 0){
headersXML = new XML((("<" + soapConstants.headerQName.localName) + "/>"));
headersXML.setNamespace(soapConstants.envelopeNamespace);
envelopeXML.appendChild(headersXML);
i = 0;
while (i < count) {
encodeHeaderElement(headers[i], headersXML);
i++;
};
};
};
}
protected function encodeOperationAsDocumentLiteral(inputParams:Object, bodyXML:XML):void{
var wrappedQName:QName;
var operationXML:XML;
var prefix:String;
var inputNamespace:Namespace;
var parts:Array = wsdlOperation.inputMessage.parts;
if (wsdlOperation.inputMessage.isWrapped){
wrappedQName = wsdlOperation.inputMessage.wrappedQName;
operationXML = new XML((("<" + wrappedQName.localName) + "/>"));
if (((!((wrappedQName.uri == null))) && (!((wrappedQName.uri == ""))))){
prefix = schemaManager.getOrCreatePrefix(wrappedQName.uri);
inputNamespace = new Namespace(prefix, wrappedQName.uri);
operationXML.setNamespace(inputNamespace);
};
encodeMessage(inputParams, operationXML);
bodyXML.appendChild(operationXML);
} else {
encodeMessage(inputParams, bodyXML);
};
}
override public function encode(value, name:QName=null, type:QName=null, definition:XML=null):XMLList{
var result:XMLList;
var maxOccurs:uint;
var minOccurs:uint;
var content:XMLList;
var foundScope:Boolean;
if (definition != null){
result = new XMLList();
maxOccurs = getMaxOccurs(definition);
minOccurs = getMinOccurs(definition);
if (maxOccurs == 0){
return (result);
};
if ((((value == null)) && ((minOccurs == 0)))){
return (result);
};
if (maxOccurs > 1){
content = new XMLList();
foundScope = schemaManager.pushNamespaceInScope(name.uri);
encodeGroupElement(definition, content, name, value);
if (foundScope){
schemaManager.releaseScope();
};
result = (result + content);
return (result);
};
};
return (super.encode(value, name, type, definition));
}
protected function encodeMessage(inputParams, operationXML:XML):void{
var parts:Array;
var message:String;
var part:WSDLMessagePart;
var value:*;
var name:String;
var partXMLList:XMLList;
var inName:String;
if (wsdlOperation.inputMessage != null){
parts = wsdlOperation.inputMessage.parts;
};
if (parts == null){
return;
};
var partNames:Object = {};
var optionalOmitted:int;
var i:uint;
while (i < parts.length) {
part = parts[i];
value = undefined;
if ((inputParams is Array)){
value = inputParams[i];
if (value === undefined){
if (part.optional){
optionalOmitted++;
} else {
message = resourceManager.getString("rpc", "missingInputParameter", [i]);
throw (new Error(message));
};
};
} else {
name = part.name.localName;
if (inputParams != null){
value = inputParams[name];
};
partNames[name] = value;
if ((((value === undefined)) || (((!((inputParams == null))) && (!(inputParams.hasOwnProperty(name))))))){
if (part.optional){
optionalOmitted++;
} else {
message = resourceManager.getString("rpc", "missingInputParameterWithName", [name]);
throw (new Error(message));
};
};
};
if (value !== undefined){
partXMLList = encodePartValue(part, value);
operationXML.appendChild(partXMLList);
};
i++;
};
if (inputParams != null){
if ((inputParams is Array)){
if (inputParams.length < (parts.length - optionalOmitted)){
message = resourceManager.getString("rpc", "tooFewInputParameters", [parts.length, inputParams.length]);
throw (new Error(message));
};
} else {
for (inName in inputParams) {
if (!partNames.hasOwnProperty(inName)){
message = resourceManager.getString("rpc", "unexpectedInputParameter", [inName]);
throw (new Error(message));
};
};
};
};
}
protected function preEncodedCheck(value):Object{
var xmlDocument:XMLDocument;
var xmlNode:XMLNode;
var preEncodedNode:Object;
if (value != null){
if ((value is XMLList)){
preEncodedNode = (value as XMLList);
} else {
if ((value is XML)){
preEncodedNode = (value as XML);
} else {
if ((value is XMLDocument)){
xmlDocument = (value as XMLDocument);
preEncodedNode = new XML(xmlDocument.firstChild.toString());
} else {
if ((value is XMLNode)){
xmlNode = (value as XMLNode);
preEncodedNode = new XML(xmlNode.toString());
};
};
};
};
};
return (preEncodedNode);
}
protected function encodeBody(inputParams, envelopeXML:XML):void{
log.debug("Encoding SOAP request body");
var bodyXML:XML = new XML((("<" + soapConstants.bodyQName.localName) + "/>"));
bodyXML.setNamespace(soapConstants.envelopeNamespace);
var preEncoded:Object = preEncodedCheck(inputParams);
if (preEncoded != null){
bodyXML.appendChild(preEncoded);
} else {
if (wsdlOperation.style == SOAPConstants.DOC_STYLE){
if (inputEncoding.useStyle == SOAPConstants.USE_LITERAL){
encodeOperationAsDocumentLiteral(inputParams, bodyXML);
} else {
throw (new Error("WSDL 1.1 supports operations with binding style 'document' only if use style is 'literal'."));
};
} else {
if (wsdlOperation.style == SOAPConstants.RPC_STYLE){
if (inputEncoding.useStyle == SOAPConstants.USE_LITERAL){
encodeOperationAsRPCLiteral(inputParams, bodyXML);
} else {
if (inputEncoding.useStyle == SOAPConstants.USE_ENCODED){
encodeOperationAsRPCEncoded(inputParams, bodyXML);
} else {
throw (new Error((("WSDL 1.1 does not support operations with binding style 'rpc' and use style " + inputEncoding.useStyle) + ".")));
};
};
} else {
throw (new Error((("Unrecognized binding style '" + wsdlOperation.style) + "'. Only 'document' and 'rpc' styles are supported.")));
};
};
};
envelopeXML.appendChild(bodyXML);
}
public function encodeRequest(args=null, headers:Array=null):XML{
var envelopeXML:XML;
var args = args;
var headers = headers;
reset();
var oldIgnoreWhitespace:Boolean = XML.ignoreWhitespace;
var oldPrettyPrinting:Boolean = XML.prettyPrinting;
try {
try {
XML.ignoreWhitespace = ignoreWhitespace;
XML.prettyPrinting = false;
envelopeXML = encodeEnvelope(args, headers);
} finally {
};
} finally {
XML.ignoreWhitespace = oldIgnoreWhitespace;
XML.prettyPrinting = oldPrettyPrinting;
};
return (envelopeXML);
}
public function set ignoreWhitespace(value:Boolean):void{
_ignoreWhitespace = value;
}
public function get wsdlOperation():WSDLOperation{
return (_wsdlOperation);
}
protected function encodeOperationAsRPCLiteral(inputParams:Object, bodyXML:XML):void{
var operationXML:XML = new XML((("<" + wsdlOperation.name) + "/>"));
var prefix:String = schemaManager.getOrCreatePrefix(inputEncoding.namespaceURI);
var ns:Namespace = new Namespace(prefix, inputEncoding.namespaceURI);
operationXML.setNamespace(ns);
encodeMessage(inputParams, operationXML);
bodyXML.appendChild(operationXML);
}
public function get schemaConstants():SchemaConstants{
return (schemaManager.schemaConstants);
}
override public function encodeType(type:QName, parent:XML, name:QName, value, restriction:XML=null):void{
var localName:String;
var xsiTypeAttr:String;
var datatypes:SchemaDatatypes = schemaManager.schemaDatatypes;
var xsiType:QName = getXSIType(value);
if (xsiType != null){
type = xsiType;
};
if (isSOAPEncoding){
xsiType = type;
if (SOAPConstants.isSOAPEncodedType(type)){
if (type == soapConstants.soapBase64QName){
type = datatypes.base64BinaryQName;
} else {
localName = type.localName;
if (((!((localName == "Array"))) && (!((localName == "arrayType"))))){
type = schemaConstants.getQName(localName);
};
};
};
};
var customType:ICustomSOAPType = SOAPConstants.getCustomSOAPType(type);
if (customType != null){
customType.encode(this, parent, name, value, restriction);
} else {
super.encodeType(type, parent, name, value, restriction);
};
if (xsiType != null){
xsiTypeAttr = parent.@[schemaConstants.getXSIToken(schemaConstants.typeAttrQName)];
if ((((xsiTypeAttr == null)) || ((xsiTypeAttr == "")))){
super.setXSIType(parent, xsiType);
};
};
}
override public function encodeComplexRestriction(restriction:XML, parent:XML, name:QName, value):void{
var customType:ICustomSOAPType;
var schemaConstants:SchemaConstants = schemaManager.schemaConstants;
var baseName:String = restriction.@base;
var baseQName:QName = schemaManager.getQNameForPrefixedName(baseName, restriction);
if (baseQName == soapConstants.soapencArrayQName){
customType = SOAPConstants.getCustomSOAPType(baseQName);
if (customType != null){
customType.encode(this, parent, name, value, restriction);
return;
};
};
super.encodeComplexRestriction(restriction, parent, name, value);
}
public function get ignoreWhitespace():Boolean{
return (_ignoreWhitespace);
}
protected function encodeHeaderElement(header:Object, headersXML:XML):void{
var headerElement:XMLList;
var headerElementNode:XML;
var attrStr:String;
var prefix:String;
var ns:Namespace;
var preEncodedNode:* = preEncodedCheck(header);
if (preEncodedNode != null){
headersXML.appendChild(header);
} else {
headerElement = new XMLList();
if (((!((header.content == null))) && (header.content.hasOwnProperty(header.qname.localName)))){
header.content = header.content[header.qname.localName];
};
preEncodedNode = preEncodedCheck(header.content);
if (preEncodedNode != null){
if ((preEncodedNode is XMLList)){
headerElement = (preEncodedNode as XMLList);
} else {
headerElement = new XMLList(preEncodedNode);
};
} else {
headerElement = encode(header.content, header.qname);
};
for each (headerElementNode in headerElement) {
if (((((!((header.qname.uri == null))) && ((header.qname.uri.length > 0)))) && (!((headerElementNode.namespace().uri == header.qname.uri))))){
prefix = schemaManager.getOrCreatePrefix(header.qname.uri);
ns = new Namespace(prefix, header.qname.uri);
headerElementNode.setNamespace(ns);
};
if (header.mustUnderstand){
attrStr = schemaManager.getOrCreatePrefix(soapConstants.mustUnderstandQName.uri);
headerElementNode.@[((attrStr + ":") + soapConstants.mustUnderstandQName.localName)] = "1";
};
if (header.role != null){
attrStr = schemaManager.getOrCreatePrefix(soapConstants.actorQName.uri);
headerElementNode.@[((attrStr + ":") + soapConstants.actorQName.localName)] = header.role;
};
};
headersXML.appendChild(headerElement);
};
}
protected function get inputEncoding():WSDLEncoding{
return (_wsdlOperation.inputMessage.encoding);
}
}
}//package mx.rpc.soap
Section 162
//SOAPFault (mx.rpc.soap.SOAPFault)
package mx.rpc.soap {
import mx.rpc.*;
public class SOAPFault extends Fault {
public var faultactor:String;
public var element:XML;
public var faultcode:QName;
public function SOAPFault(faultCode:QName, faultString:String, detail:String=null, element:XML=null, faultactor:String=null){
super(faultCode.localName, faultString, detail);
this.element = element;
this.faultactor = faultactor;
this.faultcode = faultCode;
}
public function get detail():String{
return (_faultDetail);
}
public function set detail(value:String):void{
_faultDetail = value;
}
override public function toString():String{
return (((((("SOAPFault (" + faultCode) + "): ") + faultString) + " ") + faultDetail));
}
public function get faultstring():String{
return (_faultString);
}
public function set faultstring(value:String):void{
_faultString = value;
}
}
}//package mx.rpc.soap
Section 163
//SOAPHeader (mx.rpc.soap.SOAPHeader)
package mx.rpc.soap {
public class SOAPHeader {
public var xmlType:QName;
public var role:String;
public var mustUnderstand:Boolean;
public var content:Object;
public var qname:QName;
public function SOAPHeader(qname:QName, content:Object){
super();
this.qname = qname;
this.content = content;
}
public function toString():String{
return (((((qname + ", ") + content) + ", ") + role));
}
}
}//package mx.rpc.soap
Section 164
//SOAPResult (mx.rpc.soap.SOAPResult)
package mx.rpc.soap {
public class SOAPResult {
public var headers:Array;
public var isFault:Boolean;
public var result;
public function SOAPResult(){
super();
}
}
}//package mx.rpc.soap
Section 165
//WSDL (mx.rpc.wsdl.WSDL)
package mx.rpc.wsdl {
import mx.rpc.soap.*;
import mx.rpc.xml.*;
import mx.resources.*;
import mx.logging.*;
import mx.rpc.*;
public class WSDL {
private var resourceManager:IResourceManager;
private var _schemaManager:SchemaManager;
private var _wsdlConstants:WSDLConstants;
private var _log:ILogger;
private var importsManager:QualifiedResourceManager;
private var _targetNamespace:Namespace;
private var _schemaConstants:SchemaConstants;
private var _soapConstants:SOAPConstants;
private var serviceMap:Object;
private var namespaces:Object;
private var _xml:XML;
public function WSDL(xml:XML){
resourceManager = ResourceManager.getInstance();
super();
_xml = xml;
_log = Log.getLogger("mx.rpc.wsdl.WSDL");
processNamespaces();
processSchemas();
}
private function parseService(serviceName:String=null, portName:String=null):WSDLService{
var service:WSDLService;
var serviceXML:XML;
var x:XML;
var port:WSDLPort;
var imports:Array;
var childWSDL:WSDL;
var serviceXMLList:XMLList = xml.elements(wsdlConstants.serviceQName);
for each (x in serviceXMLList) {
if (serviceName == null){
serviceXML = x;
serviceName = x.@name.toString();
break;
} else {
if (x.@name == serviceName){
serviceXML = x;
break;
};
};
};
if (serviceXML != null){
service = new WSDLService(serviceName);
port = parsePort(service, serviceXML, portName);
if (port != null){
service.addPort(port);
};
} else {
if (importsManager != null){
imports = importsManager.getResources();
for each (childWSDL in imports) {
service = childWSDL.parseService(serviceName, portName);
if (service != null){
break;
};
};
};
};
return (service);
}
public function getTypes(targetNamespace:Namespace):XML{
var types:XML;
var imports:Array;
var childWSDL:WSDL;
var typesXMLList:XMLList = xml.elements(wsdlConstants.typesQName);
if (typesXMLList.length() > 0){
types = typesXMLList[0];
} else {
if (importsManager != null){
imports = importsManager.getResourcesForNamespace(targetNamespace);
for each (childWSDL in imports) {
types = childWSDL.getTypes(targetNamespace);
if (types != null){
break;
};
};
};
};
return (types);
}
public function get soapConstants():SOAPConstants{
if (_soapConstants == null){
_soapConstants = SOAPConstants.getConstants(xml);
};
return (_soapConstants);
}
private function processNamespaces():void{
var tns:String;
var nsArray:Array;
var ns:Namespace;
if (_xml != null){
tns = _xml.@targetNamespace.toString();
_targetNamespace = new Namespace(tns);
namespaces = {};
nsArray = _xml.namespaceDeclarations();
for each (ns in nsArray) {
namespaces[ns.prefix] = ns;
};
_wsdlConstants = WSDLConstants.getConstants(_xml);
_schemaConstants = SchemaConstants.getConstants(_xml);
schemaManager.addNamespaces(namespaces);
};
}
public function get targetNamespace():Namespace{
return (_targetNamespace);
}
public function get wsdlConstants():WSDLConstants{
if (_wsdlConstants == null){
_wsdlConstants = WSDLConstants.getConstants(xml);
};
return (_wsdlConstants);
}
public function get schemaManager():SchemaManager{
if (_schemaManager == null){
_schemaManager = new SchemaManager();
_schemaManager.schemaConstants = schemaConstants;
};
return (_schemaManager);
}
private function parseBinding(bindingQName:QName):WSDLBinding{
var binding:WSDLBinding;
var bindingXML:XML;
var x:XML;
var soapBindingXMLList:XMLList;
var prefixedTypeName:String;
var portTypeQName:QName;
var portType:WSDLPortType;
var operationXMLList:XMLList;
var operationXML:XML;
var style:String;
var transport:String;
var operationName:String;
var operation:WSDLOperation;
var soapOperationXMLList:XMLList;
var operationExtensionXMLList:XMLList;
var operationExtensionXML:XML;
var encoding:WSDLEncoding;
var extensionXMLList:XMLList;
var extensionXML:XML;
var extensionName:String;
var extensionMessage:WSDLMessage;
var soapAction:String;
var opStyle:String;
var faultName:String;
var imports:Array;
var childWSDL:WSDL;
var bindingXMLList:XMLList = xml.elements(wsdlConstants.bindingQName);
for each (x in bindingXMLList) {
if (x.@name == bindingQName.localName){
bindingXML = x;
break;
};
};
if (bindingXML != null){
binding = new WSDLBinding(bindingQName.localName);
soapBindingXMLList = bindingXML.elements(wsdlConstants.soapBindingQName);
if (soapBindingXMLList.length() > 0){
style = soapBindingXMLList[0].@style.toString();
binding.style = style;
transport = soapBindingXMLList[0].@transport.toString();
binding.transport = transport;
};
prefixedTypeName = bindingXML.@type.toString();
portTypeQName = schemaManager.getQNameForPrefixedName(prefixedTypeName, bindingXML);
portType = new WSDLPortType(portTypeQName.localName);
binding.portType = portType;
operationXMLList = bindingXML.elements(wsdlConstants.operationQName);
for each (operationXML in operationXMLList) {
operationName = operationXML.@name.toString();
operation = new WSDLOperation(operationName);
operation.schemaManager = schemaManager;
operation.namespaces = namespaces;
operation.wsdlConstants = wsdlConstants;
soapOperationXMLList = operationXML.elements(wsdlConstants.soapOperationQName);
if (soapOperationXMLList.length() > 0){
soapAction = soapOperationXMLList[0].@soapAction.toString();
operation.soapAction = soapAction;
opStyle = soapOperationXMLList[0].@style.toString();
if (opStyle == ""){
operation.style = binding.style;
} else {
operation.style = opStyle;
};
};
operationExtensionXMLList = operationXML.elements(wsdlConstants.inputQName);
if (operationExtensionXMLList.length() > 0){
operationExtensionXML = operationExtensionXMLList[0];
operation.inputMessage = new WSDLMessage();
extensionXMLList = operationExtensionXML.elements(wsdlConstants.soapBodyQName);
if (extensionXMLList.length() > 0){
extensionXML = extensionXMLList[0];
encoding = parseEncodingExtension(extensionXML);
operation.inputMessage.encoding = encoding;
};
extensionXMLList = operationExtensionXML.elements(wsdlConstants.soapHeaderQName);
for each (extensionXML in extensionXMLList) {
extensionMessage = parseHeader(operationName, extensionXML);
operation.inputMessage.addHeader(extensionMessage);
};
extensionXMLList = operationExtensionXML.elements(wsdlConstants.soapHeaderFaultQName);
for each (extensionXML in extensionXMLList) {
extensionMessage = parseHeader(operationName, extensionXML);
operation.inputMessage.addHeaderFault(extensionMessage);
};
};
operationExtensionXMLList = operationXML.elements(wsdlConstants.outputQName);
if (operationExtensionXMLList.length() > 0){
operationExtensionXML = operationExtensionXMLList[0];
operation.outputMessage = new WSDLMessage();
extensionXMLList = operationExtensionXML.elements(wsdlConstants.soapBodyQName);
if (extensionXMLList.length() > 0){
extensionXML = extensionXMLList[0];
encoding = parseEncodingExtension(extensionXML);
operation.outputMessage.encoding = encoding;
};
extensionXMLList = operationExtensionXML.elements(wsdlConstants.soapHeaderQName);
for each (extensionXML in extensionXMLList) {
extensionMessage = parseHeader(operationName, extensionXML);
operation.outputMessage.addHeader(extensionMessage);
};
extensionXMLList = operationExtensionXML.elements(wsdlConstants.soapHeaderFaultQName);
for each (extensionXML in extensionXMLList) {
extensionMessage = parseHeader(operationName, extensionXML);
operation.outputMessage.addHeaderFault(extensionMessage);
};
};
operationExtensionXMLList = operationXML.elements(wsdlConstants.faultQName);
for each (operationExtensionXML in operationExtensionXMLList) {
extensionXMLList = operationExtensionXML.elements(wsdlConstants.soapFaultQName);
if (extensionXMLList.length() > 0){
extensionXML = extensionXMLList[0];
faultName = extensionXML.@["name"].toString();
extensionMessage = new WSDLMessage(faultName);
encoding = parseEncodingExtension(extensionXML, false, true);
extensionMessage.encoding = encoding;
operation.addFault(extensionMessage);
};
};
portType.addOperation(operation);
};
parsePortType(portTypeQName, portType);
} else {
if (importsManager != null){
imports = importsManager.getResources();
for each (childWSDL in imports) {
binding = childWSDL.parseBinding(bindingQName);
if (binding != null){
break;
};
};
};
};
return (binding);
}
private function parsePort(service:WSDLService, serviceXML:XML, portName:String=null):WSDLPort{
var port:WSDLPort;
var portXML:XML;
var x:XML;
var soapAddressXMLList:XMLList;
var prefixedBindingName:String;
var bindingQName:QName;
var binding:WSDLBinding;
var message:String;
var portXMLList:XMLList = serviceXML.elements(wsdlConstants.portQName);
for each (x in portXMLList) {
if (portName == null){
portXML = x;
portName = x.@name.toString();
break;
} else {
if (x.@name == portName){
portXML = x;
break;
};
};
};
if (portXML != null){
port = new WSDLPort(portName, service);
soapAddressXMLList = portXML.elements(wsdlConstants.soapAddressQName);
if (soapAddressXMLList.length() > 0){
port.endpointURI = soapAddressXMLList[0].@location.toString();
};
prefixedBindingName = portXML.@binding.toString();
bindingQName = schemaManager.getQNameForPrefixedName(prefixedBindingName, portXML);
binding = parseBinding(bindingQName);
if (binding != null){
port.binding = binding;
} else {
message = resourceManager.getString("rpc", "unrecognizedBindingName", [bindingQName.localName, bindingQName.uri]);
throw (new Fault("WSDL.UnrecognizedBindingName", message));
};
};
return (port);
}
public function get xml():XML{
return (_xml);
}
private function parseDocumentOperation(operation:WSDLOperation):void{
var part:WSDLMessagePart;
var element:XML;
var elementTypeString:String;
var elementType:QName;
var complexTypes:XMLList;
var complexType:XML;
var attributes:XMLList;
var sequences:XMLList;
var sequence:XML;
var input:WSDLMessage;
var requestElements:XMLList;
var requestElement:XML;
var output:WSDLMessage;
var resultElements:XMLList;
var resultElement:XML;
if (((((!((operation.inputMessage == null))) && (!((operation.inputMessage.encoding == null))))) && ((operation.inputMessage.encoding.useStyle == SOAPConstants.USE_LITERAL)))){
input = operation.inputMessage;
if (((!((input.parts == null))) && ((input.parts.length == 1)))){
schemaManager.reset();
part = input.parts[0];
if (part.element != null){
element = schemaManager.getNamedDefinition(part.element, schemaConstants.elementTypeQName);
if (((!((element == null))) && ((element.@["name"] == operation.name)))){
elementTypeString = element.@["type"];
if (((!((elementTypeString == null))) && (!((elementTypeString == ""))))){
elementType = schemaManager.getQNameForPrefixedName(elementTypeString, element);
complexType = schemaManager.getNamedDefinition(elementType, schemaConstants.complexTypeQName);
} else {
complexTypes = element.elements(schemaConstants.complexTypeQName);
if (complexTypes.length() == 1){
complexType = complexTypes[0];
};
};
if (complexType != null){
attributes = complexType.elements(schemaConstants.attributeQName);
if (attributes.length() == 0){
sequences = complexType.elements(schemaConstants.sequenceQName);
if ((((complexType.elements().length() == 0)) || ((sequences.length() == 1)))){
input.isWrapped = true;
input.wrappedQName = part.element;
input.parts = [];
if (sequences.length() == 1){
sequence = sequences[0];
requestElements = sequence.elements(schemaConstants.elementTypeQName);
for each (requestElement in requestElements) {
part = parseWrappedMessagePart(requestElement);
input.addPart(part);
};
};
};
};
};
};
};
};
};
complexType = null;
elementTypeString = null;
if (((((!((operation.outputMessage == null))) && (!((operation.outputMessage.encoding == null))))) && ((operation.outputMessage.encoding.useStyle == SOAPConstants.USE_LITERAL)))){
output = operation.outputMessage;
if (((!((output.parts == null))) && ((output.parts.length == 1)))){
part = output.parts[0];
if (part.element != null){
schemaManager.reset();
element = schemaManager.getNamedDefinition(part.element, schemaConstants.elementTypeQName);
if (element != null){
elementTypeString = element.@["type"];
if (((!((elementTypeString == null))) && (!((elementTypeString == ""))))){
elementType = schemaManager.getQNameForPrefixedName(elementTypeString, element);
complexType = schemaManager.getNamedDefinition(elementType, schemaConstants.complexTypeQName);
} else {
complexTypes = element.elements(schemaConstants.complexTypeQName);
if (complexTypes.length() == 1){
complexType = complexTypes[0];
};
};
if (complexType != null){
attributes = complexType.elements(schemaConstants.attributeQName);
if (attributes.length() == 0){
sequences = complexType.elements(schemaConstants.sequenceQName);
if ((((complexType.elements().length() == 0)) || ((sequences.length() == 1)))){
output.isWrapped = true;
output.wrappedQName = part.element;
output.parts = [];
if (sequences.length() == 1){
sequence = sequences[0];
resultElements = sequence.elements(schemaConstants.elementTypeQName);
for each (resultElement in resultElements) {
part = parseWrappedMessagePart(resultElement);
output.addPart(part);
};
};
};
};
};
};
};
};
};
}
private function parseMessage(message:WSDLMessage, messageQName:QName, operationName:String, mode:int):Boolean{
var messageXML:XML;
var foundMatchingMessage:Boolean;
var x:XML;
var partXMLList:XMLList;
var partXML:XML;
var partName:String;
var part:WSDLMessagePart;
var imports:Array;
var childWSDL:WSDL;
var encoding:WSDLEncoding = message.encoding;
var messageXMLList:XMLList = xml.elements(wsdlConstants.messageQName);
for each (x in messageXMLList) {
if (x.@name == messageQName.localName){
messageXML = x;
break;
};
};
if (messageXML != null){
foundMatchingMessage = true;
if ((((message.name == null)) || ((message.name == "")))){
if (mode == WSDLConstants.MODE_IN){
message.name = (operationName + "Request");
} else {
if (mode == WSDLConstants.MODE_OUT){
message.name = (operationName + "Response");
};
};
};
partXMLList = messageXML.elements(wsdlConstants.partQName);
for each (partXML in partXMLList) {
partName = partXML.@name;
if (((!((encoding == null))) && (!(encoding.hasPart(partName))))){
} else {
part = parseMessagePart(partXML);
message.addPart(part);
};
};
} else {
if (importsManager != null){
imports = importsManager.getResources();
for each (childWSDL in imports) {
foundMatchingMessage = childWSDL.parseMessage(message, messageQName, operationName, mode);
if (foundMatchingMessage){
break;
};
};
};
};
return (foundMatchingMessage);
}
private function parseHeader(operationName:String, headerXML:XML):WSDLMessage{
var headerName:String = headerXML.@["part"].toString();
var headerMessage:WSDLMessage = new WSDLMessage(headerName);
var encoding:WSDLEncoding = parseEncodingExtension(headerXML, true);
headerMessage.encoding = encoding;
parseMessage(headerMessage, encoding.message, operationName, WSDLConstants.MODE_HEADER);
return (headerMessage);
}
public function addSchema(schema:Schema):void{
schemaManager.addSchema(schema);
}
private function processSchemas():void{
var schemas:XMLList;
var schemaXML:XML;
var schema:Schema;
var types:XML = getTypes(targetNamespace);
if (types != null){
schemas = types.elements(schemaConstants.schemaQName);
for each (schemaXML in schemas) {
schema = new Schema(schemaXML);
addSchema(schema);
};
};
}
public function addImport(targetNamespace:Namespace, wsdl:WSDL):void{
if (importsManager == null){
importsManager = new QualifiedResourceManager();
};
importsManager.addResource(targetNamespace, wsdl);
}
private function parseMessagePart(partXML:XML):WSDLMessagePart{
var elementName:String;
var elementQName:QName;
var typeName:String;
var typeQName:QName;
var partName:String = partXML.@name;
var partQName:QName = new QName("", partName);
var part:WSDLMessagePart = new WSDLMessagePart(partQName);
var partXMLElement:String = partXML.@element;
var partXMLType:String = partXML.@type;
if (partXMLElement != ""){
elementName = partXML.@element;
elementQName = schemaManager.getQNameForPrefixedName(elementName, partXML);
part.element = elementQName;
} else {
if (partXMLType != ""){
typeName = partXML.@type;
typeQName = schemaManager.getQNameForPrefixedName(typeName, partXML);
part.type = typeQName;
};
};
return (part);
}
private function parseWrappedMessagePart(elementXML:XML):WSDLMessagePart{
var ref:QName;
var partType:String;
if (elementXML.attribute("ref").length() == 1){
ref = schemaManager.getQNameForPrefixedName(elementXML.@ref, elementXML, true);
elementXML = schemaManager.getNamedDefinition(ref, schemaConstants.elementTypeQName);
if (elementXML == null){
throw (new Error((("Cannot resolve element definition for ref '" + ref) + "'")));
};
};
var partName:String = elementXML.@name;
var partQName:QName = schemaManager.getQNameForElement(partName, elementXML.@form);
var part:WSDLMessagePart = new WSDLMessagePart(partQName);
var minOccurs:String = elementXML.@minOccurs;
var maxOccurs:String = elementXML.@maxOccurs;
if (((!((minOccurs == ""))) && ((parseInt(minOccurs) == 0)))){
part.optional = true;
};
if (ref != null){
part.element = ref;
} else {
partType = elementXML.@type;
if (((!((partType == ""))) || (!(elementXML.hasComplexContent())))){
if ((((partType == null)) || ((partType == "")))){
part.type = schemaConstants.anyTypeQName;
} else {
part.type = schemaManager.getQNameForPrefixedName(partType, elementXML);
};
if (((!((minOccurs == ""))) || (!((maxOccurs == ""))))){
part.definition = elementXML;
};
} else {
if (elementXML.hasComplexContent()){
part.definition = elementXML;
};
};
};
if (ref != null){
schemaManager.releaseScope();
};
return (part);
}
public function get schemaConstants():SchemaConstants{
if (_schemaConstants == null){
_schemaConstants = SchemaConstants.getConstants(xml);
};
return (_schemaConstants);
}
public function getOperation(operationName:String, serviceName:String=null, portName:String=null):WSDLOperation{
var port:WSDLPort = getPort(serviceName, portName);
var binding:WSDLBinding = port.binding;
var portType:WSDLPortType = binding.portType;
var operation:WSDLOperation = portType.getOperation(operationName);
return (operation);
}
private function parsePortType(portTypeQName:QName, portType:WSDLPortType):Boolean{
var portTypeXML:XML;
var foundMatchingPortType:Boolean;
var x:XML;
var operationsXMLList:XMLList;
var operationXML:XML;
var operationName:String;
var operation:WSDLOperation;
var messageName:String;
var messageQName:QName;
var message:WSDLMessage;
var inputXMLList:XMLList;
var outputXMLList:XMLList;
var faultsXMLList:XMLList;
var faultXML:XML;
var faultName:String;
var imports:Array;
var childWSDL:WSDL;
var portTypeXMLList:XMLList = xml.elements(wsdlConstants.portTypeQName);
for each (x in portTypeXMLList) {
if (x.@name == portTypeQName.localName){
portTypeXML = x;
break;
};
};
if (portTypeXML != null){
foundMatchingPortType = true;
operationsXMLList = portTypeXML.elements(wsdlConstants.operationQName);
for each (operationXML in operationsXMLList) {
operationName = operationXML.@name.toString();
operation = portType.getOperation(operationName);
if (operationName == null){
_log.warn("An operation '{0}' was found in the port type but is missing binding information.", operationName);
} else {
inputXMLList = operationXML.elements(wsdlConstants.inputQName);
if (inputXMLList.length() > 0){
schemaManager.reset();
messageName = inputXMLList[0].@message.toString();
messageQName = schemaManager.getQNameForPrefixedName(messageName, inputXMLList[0]);
message = operation.inputMessage;
message.name = messageQName.localName;
parseMessage(message, messageQName, operationName, WSDLConstants.MODE_IN);
};
outputXMLList = operationXML.elements(wsdlConstants.outputQName);
if (outputXMLList.length() > 0){
schemaManager.reset();
messageName = outputXMLList[0].@message.toString();
messageQName = schemaManager.getQNameForPrefixedName(messageName, outputXMLList[0]);
message = operation.outputMessage;
message.name = messageQName.localName;
parseMessage(message, messageQName, operationName, WSDLConstants.MODE_OUT);
};
faultsXMLList = operationXML.elements(wsdlConstants.faultQName);
for each (faultXML in faultsXMLList) {
schemaManager.reset();
faultName = faultXML.@name.toString();
message = operation.getFault(faultName);
if (message != null){
messageName = faultXML.@message.toString();
messageQName = schemaManager.getQNameForPrefixedName(messageName, faultXML);
parseMessage(message, messageQName, operationName, WSDLConstants.MODE_FAULT);
};
};
if (operation.style == SOAPConstants.DOC_STYLE){
parseDocumentOperation(operation);
};
};
};
} else {
if (importsManager != null){
imports = importsManager.getResources();
for each (childWSDL in imports) {
foundMatchingPortType = childWSDL.parsePortType(portTypeQName, portType);
if (foundMatchingPortType){
break;
};
};
};
};
return (foundMatchingPortType);
}
public function getPort(serviceName:String=null, portName:String=null):WSDLPort{
var port:WSDLPort;
var message:String;
var service:WSDLService = getService(serviceName, portName);
if (service != null){
if (portName == null){
port = service.defaultPort;
} else {
port = service.getPort(portName);
};
};
if (port == null){
message = resourceManager.getString("rpc", "noServiceAndPort", [serviceName, portName]);
throw (new Fault("Client.NoSuchPort", message));
};
return (port);
}
private function parseEncodingExtension(extensionXML:XML, isHeader:Boolean=false, isFault:Boolean=false):WSDLEncoding{
var messageName:String;
var encoding:WSDLEncoding = new WSDLEncoding();
encoding.useStyle = extensionXML.@["use"].toString();
encoding.namespaceURI = extensionXML.@["namespace"].toString();
encoding.encodingStyle = extensionXML.@["encodingStyle"].toString();
if (isHeader){
messageName = extensionXML.@["message"].toString();
encoding.message = schemaManager.getQNameForPrefixedName(messageName, extensionXML);
encoding.setParts(extensionXML.@["part"].toString());
} else {
if (!isFault){
encoding.setParts(extensionXML.@["parts"].toString());
};
};
return (encoding);
}
public function getService(serviceName:String=null, portName:String=null):WSDLService{
var service:WSDLService;
var port:WSDLPort;
var tempService:WSDLService;
var p:WSDLPort;
var message:String;
var detail:String;
if (((!((serviceMap == null))) && (!((serviceName == null))))){
service = serviceMap[serviceName];
if (service != null){
if (portName != null){
port = service.getPort(portName);
};
if (port == null){
tempService = parseService(serviceName, portName);
for each (p in tempService.ports) {
service.addPort(p);
};
};
};
};
if (service == null){
service = parseService(serviceName, portName);
if (service != null){
if (serviceMap == null){
serviceMap = {};
};
serviceMap[service.name] = service;
} else {
if (serviceName != null){
message = resourceManager.getString("rpc", "noSuchServiceInWSDL", [serviceName]);
throw (new Fault("Client.NoSuchService", message));
};
message = resourceManager.getString("rpc", "noServiceElement");
detail = resourceManager.getString("rpc", "noServiceElement.details", [""]);
throw (new Fault("Server.NoServicesInWSDL", message, detail));
};
};
return (service);
}
}
}//package mx.rpc.wsdl
Section 166
//WSDLBinding (mx.rpc.wsdl.WSDLBinding)
package mx.rpc.wsdl {
import mx.rpc.soap.*;
public class WSDLBinding {
private var _name:String;
private var _transport:String;
private var _style:String;
private var _portType:WSDLPortType;
public function WSDLBinding(name:String){
super();
_name = name;
}
public function set style(value:String):void{
_style = value;
}
public function get transport():String{
if (_transport == null){
_transport = WSDLConstants.SOAP_HTTP_URI;
};
return (_transport);
}
public function get name():String{
return (_name);
}
public function toString():String{
return (((((("WSDLBinding name=" + _name) + ", style=") + _style) + ", transport=") + _transport));
}
public function get style():String{
if (_style == null){
_style = SOAPConstants.DEFAULT_OPERATION_STYLE;
};
return (_style);
}
public function set transport(value:String):void{
_transport = value;
}
public function set portType(value:WSDLPortType):void{
_portType = value;
}
public function get portType():WSDLPortType{
return (_portType);
}
}
}//package mx.rpc.wsdl
Section 167
//WSDLConstants (mx.rpc.wsdl.WSDLConstants)
package mx.rpc.wsdl {
import mx.utils.*;
public class WSDLConstants {
public var portTypeQName:QName;
public var soapFaultQName:QName;
public var documentationQName:QName;
public var soapHeaderQName:QName;
public var bindingQName:QName;
public var faultQName:QName;
public var portQName:QName;
public var outputQName:QName;
public var typesQName:QName;
public var wsdlArrayTypeQName:QName;
private var _soapNS:Namespace;
public var soapHeaderFaultQName:QName;
public var soapAddressQName:QName;
public var soapBindingQName:QName;
private var _wsdlNS:Namespace;
public var soapBodyQName:QName;
public var messageQName:QName;
public var soapOperationQName:QName;
public var serviceQName:QName;
public var partQName:QName;
public var inputQName:QName;
public var operationQName:QName;
public var importQName:QName;
public var definitionsQName:QName;
public static const MODE_IN:int = 0;
public static const SOAP_HTTP_URI:String = "http://schemas.xmlsoap.org/soap/http/";
public static const DEFAULT_WSDL_VERSION:String = "1.1";
public static const DEFAULT_STYLE:String = "document";
public static const WSDL_PREFIX:String = "wsdl";
public static const WSDL_HTTP_URI:String = "http://schemas.xmlsoap.org/wsdl/http/";
public static const MODE_OUT:int = 1;
public static const WSDL_SOAP_URI:String = "http://schemas.xmlsoap.org/wsdl/soap/";
public static const WSDL20_SOAP_URI:String = "http://www.w3.org/2006/01/wsdl/soap";
public static const MODE_HEADER:int = 3;
public static const MODE_FAULT:int = 2;
public static const WSDL20_URI:String = "http://www.w3.org/2006/01/wsdl";
public static const WSDL_URI:String = "http://schemas.xmlsoap.org/wsdl/";
public static const WSDL_SOAP_PREFIX:String = "wsoap";
public static const WSDL_SOAP12_URI:String = "http://schemas.xmlsoap.org/wsdl/soap12/";
public static const WSDL20_SOAP12_URI:String = "http://www.w3.org/2006/01/wsdl/soap";
public static const WSDL20_HTTP_URI:String = "http://www.w3.org/2006/01/wsdl/http";
private static var constantsCache:Object;
public function WSDLConstants(wsdlNS:Namespace=null, soapNS:Namespace=null){
super();
if (wsdlNS == null){
wsdlNS = new Namespace(WSDL_PREFIX, WSDL_URI);
};
if (soapNS == null){
soapNS = new Namespace(WSDL_SOAP_PREFIX, WSDL_SOAP_URI);
};
_wsdlNS = wsdlNS;
_soapNS = soapNS;
definitionsQName = new QName(wsdlURI, "definitions");
importQName = new QName(wsdlURI, "import");
typesQName = new QName(wsdlURI, "types");
messageQName = new QName(wsdlURI, "message");
portTypeQName = new QName(wsdlURI, "portType");
bindingQName = new QName(wsdlURI, "binding");
serviceQName = new QName(wsdlURI, "service");
documentationQName = new QName(wsdlURI, "documentation");
portQName = new QName(wsdlURI, "port");
operationQName = new QName(wsdlURI, "operation");
inputQName = new QName(wsdlURI, "input");
outputQName = new QName(wsdlURI, "output");
partQName = new QName(wsdlURI, "part");
faultQName = new QName(wsdlURI, "fault");
wsdlArrayTypeQName = new QName(wsdlURI, "arrayType");
soapAddressQName = new QName(soapURI, "address");
soapBindingQName = new QName(soapURI, "binding");
soapOperationQName = new QName(soapURI, "operation");
soapBodyQName = new QName(soapURI, "body");
soapFaultQName = new QName(soapURI, "fault");
soapHeaderQName = new QName(soapURI, "header");
soapHeaderFaultQName = new QName(soapURI, "headerfault");
}
public function get soapNamespace():Namespace{
return (_soapNS);
}
public function get wsdlNamespace():Namespace{
return (_wsdlNS);
}
public function get soapURI():String{
return (soapNamespace.uri);
}
public function get wsdlURI():String{
return (wsdlNamespace.uri);
}
public static function getConstants(xml:XML):WSDLConstants{
var wsdlNS:Namespace;
var soapNS:Namespace;
var nsArray:Array;
var ns:Namespace;
if (xml != null){
nsArray = xml.inScopeNamespaces();
for each (ns in nsArray) {
if (URLUtil.urisEqual(ns.uri, WSDL_URI)){
wsdlNS = ns;
} else {
if (URLUtil.urisEqual(ns.uri, WSDL20_URI)){
wsdlNS = ns;
};
};
if (URLUtil.urisEqual(ns.uri, WSDL_SOAP_URI)){
soapNS = ns;
} else {
if (URLUtil.urisEqual(ns.uri, WSDL20_SOAP_URI)){
soapNS = ns;
} else {
if (URLUtil.urisEqual(ns.uri, WSDL20_SOAP12_URI)){
soapNS = ns;
};
};
};
};
};
if (wsdlNS == null){
wsdlNS = new Namespace(WSDL_PREFIX, WSDL_URI);
};
if (soapNS == null){
soapNS = new Namespace(WSDL_SOAP_PREFIX, WSDL_SOAP_URI);
};
if (constantsCache == null){
constantsCache = {};
};
var constants:WSDLConstants = constantsCache[wsdlNS.uri];
if (constants == null){
constants = new WSDLConstants(wsdlNS, soapNS);
constantsCache[wsdlNS.uri] = constants;
};
return (constants);
}
}
}//package mx.rpc.wsdl
Section 168
//WSDLEncoding (mx.rpc.wsdl.WSDLEncoding)
package mx.rpc.wsdl {
import mx.rpc.soap.*;
public class WSDLEncoding {
private var _parts:Array;
private var _message:QName;
private var _soapConstants:SOAPConstants;
private var _namespaceURI:String;
private var _useStyle:String;
private var _encodingStyle:String;
public function WSDLEncoding(){
_encodingStyle = SOAPConstants.SOAP_ENCODING_URI;
_useStyle = SOAPConstants.DEFAULT_USE;
super();
}
public function get parts():Array{
return (_parts);
}
public function set namespaceURI(value:String):void{
_namespaceURI = value;
}
public function get soapConstants():SOAPConstants{
if (_soapConstants == null){
_soapConstants = SOAPConstants.getConstants(null);
};
return (_soapConstants);
}
public function setParts(value:String):void{
var array:Array;
var part:String;
if (((!((value == null))) && ((value.length > 0)))){
_parts = [];
array = value.split(" ");
for each (part in array) {
if (part.length > 0){
_parts.push(part);
};
};
} else {
_parts = null;
};
}
public function get message():QName{
return (_message);
}
public function get useStyle():String{
return (_useStyle);
}
public function hasPart(name:String):Boolean{
var part:String;
if (((!((_parts == null))) && ((_parts.length > 0)))){
for each (part in _parts) {
if (part == name){
return (true);
};
};
return (false);
};
return (true);
}
public function set message(value:QName):void{
_message = value;
}
public function get namespaceURI():String{
return (_namespaceURI);
}
public function set useStyle(value:String):void{
_useStyle = value;
}
public function set encodingStyle(value:String):void{
_encodingStyle = (value) ? value : soapConstants.encodingURI;
}
public function get encodingStyle():String{
if (_encodingStyle == null){
_encodingStyle = soapConstants.encodingURI;
};
return (_encodingStyle);
}
}
}//package mx.rpc.wsdl
Section 169
//WSDLMessage (mx.rpc.wsdl.WSDLMessage)
package mx.rpc.wsdl {
public class WSDLMessage {
public var parts:Array;
private var _headerFaultsMap:Object;
private var _partsMap:Object;
public var name:String;
public var encoding:WSDLEncoding;
public var wrappedQName:QName;
public var isWrapped:Boolean;
private var _headersMap:Object;
public function WSDLMessage(name:String=null){
super();
this.name = name;
}
public function getHeader(name:String):WSDLMessage{
var header:WSDLMessage;
if (_headersMap != null){
header = _headersMap[name];
};
return (header);
}
public function getPart(name:String):WSDLMessagePart{
var part:WSDLMessagePart;
if (_partsMap != null){
part = _partsMap[name];
};
return (part);
}
public function addHeaderFault(headerFault:WSDLMessage):void{
if (_headerFaultsMap == null){
_headerFaultsMap = {};
};
_headerFaultsMap[headerFault.name] = headerFault;
}
public function addPart(part:WSDLMessagePart):void{
if (_partsMap == null){
_partsMap = {};
};
if (parts == null){
parts = [];
};
_partsMap[part.name.localName] = part;
parts.push(part);
}
public function addHeader(header:WSDLMessage):void{
if (_headersMap == null){
_headersMap = {};
};
_headersMap[header.name] = header;
}
public function getHeaderFault(name:String):WSDLMessage{
var headerFault:WSDLMessage;
if (_headerFaultsMap != null){
headerFault = _headerFaultsMap[name];
};
return (headerFault);
}
}
}//package mx.rpc.wsdl
Section 170
//WSDLMessagePart (mx.rpc.wsdl.WSDLMessagePart)
package mx.rpc.wsdl {
public class WSDLMessagePart {
public var optional:Boolean;
private var _name:QName;
public var definition:XML;
public var type:QName;
public var element:QName;
public function WSDLMessagePart(name:QName, element:QName=null, type:QName=null){
super();
_name = name;
this.type = type;
this.element = element;
}
public function get name():QName{
return (_name);
}
}
}//package mx.rpc.wsdl
Section 171
//WSDLOperation (mx.rpc.wsdl.WSDLOperation)
package mx.rpc.wsdl {
import mx.rpc.soap.*;
import mx.rpc.xml.*;
public class WSDLOperation {
private var _soapAction:String;
private var _soapConstants:SOAPConstants;
public var outputMessage:WSDLMessage;
private var _faultsMap:Object;
private var _schemaManager:SchemaManager;
public var inputMessage:WSDLMessage;
private var _wsdlConstants:WSDLConstants;
private var _name:String;
public var style:String;
public var namespaces:Object;
public function WSDLOperation(name:String){
super();
_name = name;
}
public function addFault(fault:WSDLMessage):void{
if (_faultsMap == null){
_faultsMap = {};
};
_faultsMap[fault.name] = fault;
}
public function set soapAction(value:String):void{
_soapAction = value;
}
public function get soapConstants():SOAPConstants{
if (_soapConstants == null){
_soapConstants = SOAPConstants.getConstants(null);
};
return (_soapConstants);
}
public function set soapConstants(value:SOAPConstants):void{
_soapConstants = value;
}
public function get name():String{
return (_name);
}
public function get wsdlConstants():WSDLConstants{
if (_wsdlConstants == null){
_wsdlConstants = WSDLConstants.getConstants(null);
};
return (_wsdlConstants);
}
public function get schemaManager():SchemaManager{
return (_schemaManager);
}
public function set wsdlConstants(value:WSDLConstants):void{
_wsdlConstants = value;
}
public function set schemaManager(manager:SchemaManager):void{
_schemaManager = manager;
}
public function get soapAction():String{
if (_soapAction == null){
_soapAction = "";
};
return (_soapAction);
}
public function getFault(name:String):WSDLMessage{
var fault:WSDLMessage;
if (_faultsMap != null){
fault = _faultsMap[name];
};
return (fault);
}
}
}//package mx.rpc.wsdl
Section 172
//WSDLPort (mx.rpc.wsdl.WSDLPort)
package mx.rpc.wsdl {
public class WSDLPort {
private var _binding:WSDLBinding;
private var _name:String;
private var _service:WSDLService;
private var _endpointURI:String;
public function WSDLPort(name:String, service:WSDLService){
super();
_name = name;
_service = service;
}
public function get binding():WSDLBinding{
return (_binding);
}
public function set binding(value:WSDLBinding):void{
_binding = value;
}
public function get name():String{
return (_name);
}
public function toString():String{
return (((((("WSDLPort name=" + _name) + ", endpointURI=") + _endpointURI) + ", binding=") + _binding));
}
public function set endpointURI(value:String):void{
_endpointURI = value;
}
public function get service():WSDLService{
return (_service);
}
public function get endpointURI():String{
return (_endpointURI);
}
}
}//package mx.rpc.wsdl
Section 173
//WSDLPortType (mx.rpc.wsdl.WSDLPortType)
package mx.rpc.wsdl {
public class WSDLPortType {
private var _operations:Object;
private var _name:String;
public function WSDLPortType(name:String){
super();
_name = name;
_operations = {};
}
public function getOperation(name:String):WSDLOperation{
return (_operations[name]);
}
public function addOperation(operation:WSDLOperation):void{
_operations[operation.name] = operation;
}
public function get name():String{
return (_name);
}
public function operations():Object{
return (_operations);
}
}
}//package mx.rpc.wsdl
Section 174
//WSDLService (mx.rpc.wsdl.WSDLService)
package mx.rpc.wsdl {
public class WSDLService {
private var _ports:Object;
private var _defaultPort:WSDLPort;
private var _name:String;
public function WSDLService(name:String){
super();
_name = name;
_ports = {};
}
public function addPort(port:WSDLPort):void{
_ports[port.name] = port;
if (_defaultPort == null){
_defaultPort = port;
};
}
public function get ports():Object{
return (_ports);
}
public function getPort(name:String):WSDLPort{
return (_ports[name]);
}
public function get defaultPort():WSDLPort{
return (_defaultPort);
}
public function get name():String{
return (_name);
}
}
}//package mx.rpc.wsdl
Section 175
//ContentProxy (mx.rpc.xml.ContentProxy)
package mx.rpc.xml {
import flash.utils.*;
import mx.utils.*;
public dynamic class ContentProxy extends Proxy {
private var _isSimple:Boolean;// = true
private var _content;
private var _propertyList:Array;
private var _makeObjectsBindable:Boolean;
public function ContentProxy(content=undefined, makeObjectsBindable:Boolean=false, isSimple:Boolean=true){
super();
object_proxy::content = content;
object_proxy::makeObjectsBindable = makeObjectsBindable;
object_proxy::isSimple = isSimple;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(name):Boolean{
var deleted:Boolean;
var oldVal:Object;
if (((!(_isSimple)) && (!((_content == null))))){
oldVal = _content[name];
deleted = delete _content[name];
};
return (deleted);
}
object_proxy function set makeObjectsBindable(value:Boolean):void{
_makeObjectsBindable = value;
if (((((value) && (!(_isSimple)))) && (!((_content is ObjectProxy))))){
_content = new ObjectProxy(_content);
};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextValue(index:int){
if (((!(_isSimple)) && (!((_content == null))))){
return (_content[_propertyList[(index - 1)]]);
};
return (undefined);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){
if (_content != null){
return (_content[name]);
};
return (undefined);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(name):Boolean{
var hasProperty:Boolean;
if (_content != null){
hasProperty = (name in _content);
};
return (hasProperty);
}
object_proxy function setupPropertyList():void{
var prop:String;
if (getQualifiedClassName(_content) == "Object"){
_propertyList = [];
for (prop in _content) {
_propertyList.push(prop);
};
} else {
_propertyList = ObjectUtil.getClassInfo(_content, null, {includeReadOnly:false, uris:["*"]}).properties;
};
}
object_proxy function set content(value):void{
if ((value is ContentProxy)){
value = ContentProxy(value).object_proxy::content;
};
_content = value;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(index:int):int{
if (index == 0){
object_proxy::setupPropertyList();
};
if (index < _propertyList.length){
return ((index + 1));
};
return (0);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(name, value):void{
var oldContent:*;
if (_isSimple){
oldContent = _content;
if (oldContent !== value){
_content = value;
};
} else {
if (_content == null){
_content = object_proxy::createObject();
};
oldContent = _content[name];
if (oldContent !== value){
_content[name] = value;
};
};
}
object_proxy function set isSimple(value:Boolean):void{
_isSimple = value;
}
object_proxy function get content(){
return (_content);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function callProperty(name, ... _args){
if (_content != null){
return (_content[name].apply(_content, _args));
};
return (undefined);
}
object_proxy function createObject(){
if (object_proxy::makeObjectsBindable){
return (new ObjectProxy());
};
return ({});
}
object_proxy function get isSimple():Boolean{
return (_isSimple);
}
object_proxy function get makeObjectsBindable():Boolean{
return (_makeObjectsBindable);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(index:int):String{
return (_propertyList[(index - 1)]);
}
}
}//package mx.rpc.xml
Section 176
//DecodingContext (mx.rpc.xml.DecodingContext)
package mx.rpc.xml {
public class DecodingContext {
public var index:int;// = 0
public var anyIndex:int;// = -1
public var hasContextSiblings:Boolean;// = false
public function DecodingContext(){
super();
}
}
}//package mx.rpc.xml
Section 177
//IXMLDecoder (mx.rpc.xml.IXMLDecoder)
package mx.rpc.xml {
public interface IXMLDecoder {
function decode(_arg1, _arg2:QName=null, _arg3:QName=null, _arg4:XML=null);
function set recordXSIType(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\xml;IXMLDecoder.as:Boolean):void;
function get recordXSIType():Boolean;
function get typeRegistry():SchemaTypeRegistry;
function set makeObjectsBindable(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\xml;IXMLDecoder.as:Boolean):void;
function get makeObjectsBindable():Boolean;
function set typeRegistry(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\xml;IXMLDecoder.as:SchemaTypeRegistry):void;
function reset():void;
}
}//package mx.rpc.xml
Section 178
//IXMLEncoder (mx.rpc.xml.IXMLEncoder)
package mx.rpc.xml {
public interface IXMLEncoder {
function get xmlSpecialCharsFilter():Function;
function encode(_arg1, _arg2:QName=null, _arg3:QName=null, _arg4:XML=null):XMLList;
function get strictNillability():Boolean;
function set strictNillability(name:Boolean):void;
function set xmlSpecialCharsFilter(name:Function):void;
function reset():void;
}
}//package mx.rpc.xml
Section 179
//IXMLSchemaInstance (mx.rpc.xml.IXMLSchemaInstance)
package mx.rpc.xml {
public interface IXMLSchemaInstance {
function get xsiType():QName;
function set xsiType(E:\dev\3.1.0\frameworks\projects\rpc\src;mx\rpc\xml;IXMLSchemaInstance.as:QName):void;
}
}//package mx.rpc.xml
Section 180
//QualifiedResourceManager (mx.rpc.xml.QualifiedResourceManager)
package mx.rpc.xml {
public class QualifiedResourceManager {
protected var resources:Array;
protected var resourcesMap:Object;
public function QualifiedResourceManager(){
super();
}
public function getResourcesForNamespace(ns:Namespace):Array{
return (getResourcesForURI(ns.uri));
}
public function getResourcesForURI(uri:String):Array{
if (resourcesMap == null){
return (null);
};
if (uri == null){
uri = "";
};
var resourcesArray:Array = resourcesMap[uri];
return (resourcesArray);
}
public function addResource(ns:Namespace, resource:Object):void{
if (resources == null){
resources = [];
};
resources.push(resource);
if (resourcesMap == null){
resourcesMap = {};
};
var uri:String = ns.uri;
if (uri == null){
uri = "";
};
var existingResources:Array = (resourcesMap[uri] as Array);
if (existingResources == null){
existingResources = [];
};
existingResources.push(resource);
resourcesMap[uri] = existingResources;
}
public function getResources():Array{
return (resources);
}
}
}//package mx.rpc.xml
Section 181
//Schema (mx.rpc.xml.Schema)
package mx.rpc.xml {
public class Schema {
public var elementFormDefault:String;// = "unqualified"
private var _targetNamespace:Namespace;
private var _schemaDatatypes:SchemaDatatypes;
private var _xml:XML;
private var _namespaces:Object;
private var importsManager:QualifiedResourceManager;
public var attributeFormDefault:String;// = "unqualified"
public var finalDefault:String;
private var _schemaConstants:SchemaConstants;
public var blockDefault:String;
public function Schema(xml:XML=null){
super();
this.xml = xml;
}
public function set xml(value:XML):void{
var tns:String;
var nsArray:Array;
var ns:Namespace;
_xml = value;
if (_xml != null){
tns = _xml.@targetNamespace.toString();
_targetNamespace = new Namespace(tns);
attributeFormDefault = _xml.@attributeFormDefault.toString();
if (attributeFormDefault == ""){
attributeFormDefault = "unqualified";
};
blockDefault = _xml.@blockDefault.toString();
elementFormDefault = _xml.@elementFormDefault.toString();
if (elementFormDefault == ""){
elementFormDefault = "unqualified";
};
finalDefault = _xml.@finalDefault.toString();
namespaces = {};
nsArray = _xml.inScopeNamespaces();
for each (ns in nsArray) {
namespaces[ns.prefix] = ns;
};
_schemaConstants = SchemaConstants.getConstants(_xml);
_schemaDatatypes = SchemaDatatypes.getConstants(_schemaConstants.xsdURI);
} else {
_schemaConstants = null;
_schemaDatatypes = null;
};
}
public function addInclude(fragment:XMLList):void{
xml.appendChild(fragment);
}
public function get targetNamespace():Namespace{
return (_targetNamespace);
}
public function set targetNamespace(tns:Namespace):void{
_targetNamespace = tns;
}
public function get xml():XML{
return (_xml);
}
public function addImport(targetNamespace:Namespace, schema:Schema):void{
if (importsManager == null){
importsManager = new QualifiedResourceManager();
};
importsManager.addResource(targetNamespace, schema);
}
public function get schemaConstants():SchemaConstants{
if (_schemaConstants == null){
_schemaConstants = SchemaConstants.getConstants(_xml);
};
return (_schemaConstants);
}
public function set namespaces(value:Object):void{
_namespaces = value;
}
public function getNamedDefinition(name:QName, ... _args):Object{
var imports:Array;
var schema:Schema;
var currentTargetNamespace:Namespace;
var schemaXML:XML;
var constants:SchemaConstants;
var t:uint;
var componentType:QName;
var localComponentType:QName;
var definition:XML;
var name = name;
var componentTypes = _args;
var uri:String = name.uri;
var schemas:Array = [this];
if (importsManager != null){
imports = importsManager.getResourcesForURI(uri);
if (imports != null){
schemas = schemas.concat(imports);
};
};
var s:uint;
while (s < schemas.length) {
schema = (schemas[s] as Schema);
currentTargetNamespace = schema.targetNamespace;
schemaXML = schema.xml;
constants = schema.schemaConstants;
t = 0;
while (t < componentTypes.length) {
componentType = (componentTypes[t] as QName);
if ((((schema.elementFormDefault == "qualified")) && ((componentType == schemaConstants.elementTypeQName)))){
//unresolved if
//unresolved if
} else {
if ((((schema.attributeFormDefault == "qualified")) && ((componentType == schemaConstants.attributeQName)))){
//unresolved if
//unresolved if
} else {
if (((((!((componentType == schemaConstants.elementTypeQName))) && (!((componentType == schemaConstants.attributeQName))))) && (!((currentTargetNamespace.uri == name.uri))))){
} else {
localComponentType = new QName(constants.xsdURI, componentType.localName);
definition = schemaXML[localComponentType].(@name == name.localName)[0];
if (definition != null){
return ({definition:definition, schema:schema});
};
};
};
};
t = (t + 1);
};
s = (s + 1);
};
return (null);
}
public function get namespaces():Object{
if (_namespaces == null){
_namespaces = {};
};
return (_namespaces);
}
public function get schemaDatatypes():SchemaDatatypes{
if (_schemaDatatypes == null){
_schemaDatatypes = SchemaDatatypes.getConstants(schemaConstants.xsdURI);
};
return (_schemaDatatypes);
}
}
}//package mx.rpc.xml
Section 182
//SchemaConstants (mx.rpc.xml.SchemaConstants)
package mx.rpc.xml {
import mx.utils.*;
public class SchemaConstants {
public var documentationQName:QName;
public var minInclusiveQName:QName;
public var enumerationTypeQName:QName;
public var keyQName:QName;
public var appinfoQName:QName;
public var anyQName:QName;
public var typeAttrQName:QName;
public var choiceQName:QName;
public var maxInclusiveQName:QName;
public var redefineQName:QName;
public var anyTypeQName:QName;
public var attributeGroupQName:QName;
private var _xsiNS:Namespace;
public var extensionQName:QName;
public var listQName:QName;
public var selectorQName:QName;
public var patternQName:QName;
public var minLengthQName:QName;
public var keyrefQName:QName;
public var restrictionQName:QName;
public var annotationQName:QName;
public var nilQName:QName;
public var complexTypeQName:QName;
public var fieldQName:QName;
public var unionQName:QName;
public var uniqueQName:QName;
public var schemaQName:QName;
public var nameQName:QName;
public var maxLengthQName:QName;
public var includeQName:QName;
public var lengthQName:QName;
public var sequenceQName:QName;
public var groupQName:QName;
private var _xsdNS:Namespace;
public var attributeQName:QName;
public var elementTypeQName:QName;
public var anyAttributeQName:QName;
public var simpleTypeQName:QName;
public var complexContentQName:QName;
public var importQName:QName;
public var allQName:QName;
public var simpleContentQName:QName;
public static const MODE_ELEMENT:int = 1;
public static const XSI_URI_2000:String = "http://www.w3.org/2000/10/XMLSchema-instance";
public static const XSI_URI_2001:String = "http://www.w3.org/2001/XMLSchema-instance";
public static const XSI_URI_1999:String = "http://www.w3.org/1999/XMLSchema-instance";
public static const MODE_TYPE:int = 0;
public static const XSD_URI_2000:String = "http://www.w3.org/2000/10/XMLSchema";
public static const XSD_URI_2001:String = "http://www.w3.org/2001/XMLSchema";
public static const XML_SCHEMA_INSTANCE_PREFIX:String = "xsi";
public static const XML_SCHEMA_PREFIX:String = "xsd";
public static const XSD_URI_1999:String = "http://www.w3.org/1999/XMLSchema";
public static const XML_SCHEMA_URI:String = "http://www.w3.org/2001/XMLSchema";
public static const XML_SCHEMA_INSTANCE_URI:String = "http://www.w3.org/2001/XMLSchema-instance";
private static var constantsCache:Object;
public function SchemaConstants(xsdNS:Namespace=null, xsiNS:Namespace=null){
super();
if (xsdNS == null){
xsdNS = new Namespace(XML_SCHEMA_PREFIX, XSD_URI_2001);
};
if (xsiNS == null){
xsiNS = new Namespace(XML_SCHEMA_INSTANCE_PREFIX, XSI_URI_2001);
};
_xsdNS = xsdNS;
_xsiNS = xsiNS;
allQName = new QName(xsdURI, "all");
annotationQName = new QName(xsdURI, "annotation");
anyQName = new QName(xsdURI, "any");
anyTypeQName = new QName(xsdURI, "anyType");
anyAttributeQName = new QName(xsdURI, "anyAttribute");
appinfoQName = new QName(xsdURI, "appinfo");
attributeQName = new QName(xsdURI, "attribute");
attributeGroupQName = new QName(xsdURI, "attributeGroup");
choiceQName = new QName(xsdURI, "choice");
complexContentQName = new QName(xsdURI, "complexContent");
complexTypeQName = new QName(xsdURI, "complexType");
documentationQName = new QName(xsdURI, "documentation");
elementTypeQName = new QName(xsdURI, "element");
enumerationTypeQName = new QName(xsdURI, "enumeration");
extensionQName = new QName(xsdURI, "extension");
fieldQName = new QName(xsdURI, "field");
groupQName = new QName(xsdURI, "group");
importQName = new QName(xsdURI, "import");
includeQName = new QName(xsdURI, "include");
keyQName = new QName(xsdURI, "key");
keyrefQName = new QName(xsdURI, "keyref");
lengthQName = new QName(xsdURI, "length");
listQName = new QName(xsdURI, "list");
maxInclusiveQName = new QName(xsdURI, "maxInclusive");
maxLengthQName = new QName(xsdURI, "maxLength");
minInclusiveQName = new QName(xsdURI, "minInclusive");
minLengthQName = new QName(xsdURI, "minLength");
nameQName = new QName(xsdURI, "name");
patternQName = new QName(xsdURI, "pattern");
redefineQName = new QName(xsdURI, "redefine");
restrictionQName = new QName(xsdURI, "restriction");
schemaQName = new QName(xsdURI, "schema");
selectorQName = new QName(xsdURI, "selector");
sequenceQName = new QName(xsdURI, "sequence");
simpleContentQName = new QName(xsdURI, "simpleContent");
simpleTypeQName = new QName(xsdURI, "simpleType");
unionQName = new QName(xsdURI, "union");
uniqueQName = new QName(xsdURI, "unique");
var nilStr:String = "nil";
if (xsdURI == SchemaConstants.XSD_URI_1999){
nilStr = "null";
};
nilQName = new QName(xsiURI, nilStr);
typeAttrQName = new QName(xsiURI, "type");
}
public function get xsdNamespace():Namespace{
return (_xsdNS);
}
public function getXSDToken(type:QName):String{
return (((xsdNamespace.prefix + ":") + type.localName));
}
public function get xsiNamespace():Namespace{
return (_xsiNS);
}
public function get xsiURI():String{
return (xsiNamespace.uri);
}
public function getXSIToken(type:QName):String{
return (((xsiNamespace.prefix + ":") + type.localName));
}
public function get xsdURI():String{
return (xsdNamespace.uri);
}
public function getQName(localName:String):QName{
if (localName == "type"){
return (typeAttrQName);
};
return (new QName(xsdURI, localName));
}
public static function getConstants(xml:XML=null):SchemaConstants{
var xsdNS:Namespace;
var xsiNS:Namespace;
var nsArray:Array;
var ns:Namespace;
if (xml != null){
nsArray = xml.namespaceDeclarations();
for each (ns in nsArray) {
if (URLUtil.urisEqual(ns.uri, XSD_URI_1999)){
xsdNS = ns;
} else {
if (URLUtil.urisEqual(ns.uri, XSD_URI_2000)){
xsdNS = ns;
} else {
if (URLUtil.urisEqual(ns.uri, XSD_URI_2001)){
xsdNS = ns;
} else {
if (URLUtil.urisEqual(ns.uri, XSI_URI_1999)){
xsiNS = ns;
} else {
if (URLUtil.urisEqual(ns.uri, XSI_URI_2000)){
xsiNS = ns;
} else {
if (URLUtil.urisEqual(ns.uri, XSI_URI_2001)){
xsiNS = ns;
};
};
};
};
};
};
};
};
if (xsdNS == null){
xsdNS = new Namespace(XML_SCHEMA_PREFIX, XSD_URI_2001);
};
if (xsiNS == null){
xsiNS = new Namespace(XML_SCHEMA_INSTANCE_PREFIX, XSI_URI_2001);
};
if (constantsCache == null){
constantsCache = {};
};
var constants:SchemaConstants = constantsCache[xsdNS.uri];
if (constants == null){
constants = new SchemaConstants(xsdNS, xsiNS);
constantsCache[xsdNS.uri] = constants;
};
return (constants);
}
}
}//package mx.rpc.xml
Section 183
//SchemaDatatypes (mx.rpc.xml.SchemaDatatypes)
package mx.rpc.xml {
public class SchemaDatatypes {
public var hexBinaryQName:QName;
public var unsignedIntQName:QName;
public var NMTOKENSQName:QName;
public var nonPositiveIntegerQName:QName;
public var integerQName:QName;
public var stringQName:QName;
public var anyAtomicTypeQName:QName;
public var unsignedLongQName:QName;
public var tokenQName:QName;
public var languageQName:QName;
public var IDQName:QName;
public var NMTOKENQName:QName;
public var nonNegativeIntegerQName:QName;
public var doubleQName:QName;
public var base64BinaryQName:QName;
public var booleanQName:QName;
public var unsignedShortQName:QName;
public var dayTimeDurationQName:QName;
public var gYearMonthQName:QName;
public var anySimpleTypeQName:QName;
public var durationQName:QName;
public var IDREF:QName;
public var byteQName:QName;
public var QNameQName:QName;
public var shortQName:QName;
public var dateQName:QName;
public var longQName:QName;
public var normalizedStringQName:QName;
public var positiveIntegerQName:QName;
public var anyURIQName:QName;
public var floatQName:QName;
public var NCNameQName:QName;
public var timeInstantQName:QName;
public var NameQName:QName;
public var gYearQName:QName;
public var NOTATIONQName:QName;
public var dateTimeQName:QName;
public var gMonthQName:QName;
public var decimalQName:QName;
public var timeQName:QName;
public var negativeIntegerQName:QName;
public var gMonthDayQName:QName;
public var IDREFS:QName;
public var ENTITY:QName;
public var yearMonthDurationQName:QName;
public var gDayQName:QName;
public var intQName:QName;
public var ENTITIES:QName;
public var precisionDecimal:QName;
public var anyTypeQName:QName;
public var unsignedByteQName:QName;
private static var constantsCache:Object;
public function SchemaDatatypes(xsdURI:String=null){
super();
if ((((xsdURI == null)) || ((xsdURI == "")))){
xsdURI = SchemaConstants.XSD_URI_2001;
};
anyTypeQName = new QName(xsdURI, "anyType");
anySimpleTypeQName = new QName(xsdURI, "anySimpleType");
anyAtomicTypeQName = new QName(xsdURI, "anyAtomicType");
stringQName = new QName(xsdURI, "string");
booleanQName = new QName(xsdURI, "boolean");
decimalQName = new QName(xsdURI, "decimal");
precisionDecimal = new QName(xsdURI, "precisionDecimal");
floatQName = new QName(xsdURI, "float");
doubleQName = new QName(xsdURI, "double");
durationQName = new QName(xsdURI, "duration");
dateTimeQName = new QName(xsdURI, "dateTime");
timeQName = new QName(xsdURI, "time");
dateQName = new QName(xsdURI, "date");
gYearMonthQName = new QName(xsdURI, "gYearMonth");
gYearQName = new QName(xsdURI, "gYear");
gMonthDayQName = new QName(xsdURI, "gMonthDay");
gDayQName = new QName(xsdURI, "gDay");
gMonthQName = new QName(xsdURI, "gMonth");
hexBinaryQName = new QName(xsdURI, "hexBinary");
base64BinaryQName = new QName(xsdURI, "base64Binary");
anyURIQName = new QName(xsdURI, "anyURI");
QNameQName = new QName(xsdURI, "QName");
NOTATIONQName = new QName(xsdURI, "NOTATION");
normalizedStringQName = new QName(xsdURI, "normalizedString");
tokenQName = new QName(xsdURI, "token");
languageQName = new QName(xsdURI, "language");
NMTOKENQName = new QName(xsdURI, "NMTOKEN");
NMTOKENSQName = new QName(xsdURI, "NMTOKENS");
NameQName = new QName(xsdURI, "Name");
NCNameQName = new QName(xsdURI, "NCName");
IDQName = new QName(xsdURI, "ID");
IDREF = new QName(xsdURI, "IDREF");
IDREFS = new QName(xsdURI, "IDREFS");
ENTITY = new QName(xsdURI, "ENTITY");
ENTITIES = new QName(xsdURI, "ENTITIES");
integerQName = new QName(xsdURI, "integer");
nonPositiveIntegerQName = new QName(xsdURI, "nonPositiveInteger");
negativeIntegerQName = new QName(xsdURI, "negativeInteger");
longQName = new QName(xsdURI, "long");
intQName = new QName(xsdURI, "int");
shortQName = new QName(xsdURI, "short");
byteQName = new QName(xsdURI, "byte");
nonNegativeIntegerQName = new QName(xsdURI, "nonNegativeInteger");
unsignedLongQName = new QName(xsdURI, "unsignedLong");
unsignedIntQName = new QName(xsdURI, "unsignedInt");
unsignedShortQName = new QName(xsdURI, "unsignedShort");
unsignedByteQName = new QName(xsdURI, "unsignedByte");
positiveIntegerQName = new QName(xsdURI, "positiveInteger");
yearMonthDurationQName = new QName(xsdURI, "yearMonthDuration");
dayTimeDurationQName = new QName(xsdURI, "dayTimeDuration");
if (xsdURI == SchemaConstants.XSD_URI_1999){
timeInstantQName = new QName(xsdURI, "timeInstant");
};
}
public static function getConstants(xsdURI:String=null):SchemaDatatypes{
if (constantsCache == null){
constantsCache = {};
};
if ((((xsdURI == null)) || ((xsdURI == "")))){
xsdURI = SchemaConstants.XSD_URI_2001;
};
var constants:SchemaDatatypes = constantsCache[xsdURI];
if (constants == null){
constants = new SchemaDatatypes(xsdURI);
constantsCache[xsdURI] = constants;
};
return (constants);
}
}
}//package mx.rpc.xml
Section 184
//SchemaManager (mx.rpc.xml.SchemaManager)
package mx.rpc.xml {
public class SchemaManager extends QualifiedResourceManager {
private var _namespaces:Object;
private var _schemaMarshaller:SchemaMarshaller;
private var _schemaConstants:SchemaConstants;
private var namespaceCount:uint;// = 0
private var schemaStack:Array;
private var initialScope;
private var _schemaDatatypes:SchemaDatatypes;
public function SchemaManager(){
super();
initialScope = [];
schemaStack = [];
}
public function addNamespaces(map:Object):void{
var prefix:String;
var ns:Namespace;
for (prefix in map) {
ns = (map[prefix] as Namespace);
namespaces[prefix] = ns;
};
}
public function getNamedDefinition(name:QName, ... _args):XML{
var schema:Schema;
var result:Object;
var definition:XML;
var schemas:Array = currentScope();
var s:int;
while (s < schemas.length) {
schema = schemas[s];
_args.unshift(name);
result = schema.getNamedDefinition.apply(schema, _args);
if (result != null){
definition = (result.definition as XML);
pushSchemaInScope(result.schema);
return (definition);
};
s++;
};
return (null);
}
public function releaseScope(){
return (schemaStack.pop());
}
public function marshall(value, type:QName=null, restriction:XML=null):String{
return (schemaMarshaller.marshall(value, type, restriction));
}
public function reset():void{
namespaceCount = 0;
schemaStack = [];
schemaStack.push(initialScope);
}
public function pushSchemaInScope(schema:Schema):void{
var newSchemaSet:Array;
if (schema != null){
newSchemaSet = [schema];
newSchemaSet["current"] = newSchemaSet[0];
schemaStack.push(newSchemaSet);
};
}
public function pushNamespaceInScope(nsParam):Boolean{
var schema:Schema;
var ns:Namespace = new Namespace(nsParam);
var schemas:Array = currentScope();
var s:int;
while (s < schemas.length) {
schema = schemas[s];
if (schema.targetNamespace.uri == ns.uri){
pushSchemaInScope(schema);
return (true);
};
s++;
};
return (false);
}
public function getQNameForAttribute(ncname:String, form:String=null):QName{
var qname:QName;
if ((((form == "qualified")) || ((((form == null)) && ((currentSchema.attributeFormDefault == "qualified")))))){
qname = new QName(currentSchema.targetNamespace.uri, ncname);
} else {
qname = new QName("", ncname);
};
return (qname);
}
public function currentScope():Array{
var current:Array = schemaStack.pop();
if (current != null){
schemaStack.push(current);
} else {
current = [];
};
return (current);
}
public function set schemaConstants(value:SchemaConstants):void{
_schemaConstants = value;
}
public function addSchema(schema:Schema, toCurrentScope:Boolean=true):void{
var schemaSet:Array;
addResource(schema.targetNamespace, schema);
if (toCurrentScope == true){
schemaSet = schemaStack.pop();
};
if (schemaSet == null){
schemaSet = [];
};
schemaSet.push(schema);
if (!schemaSet.hasOwnProperty("current")){
schemaSet["current"] = schemaSet[0];
};
schemaStack.push(schemaSet);
if (schemaStack.length == 1){
initialScope = schemaStack[0];
};
}
public function getOrCreatePrefix(uri:String):String{
var result:String;
var ns:Namespace;
var nameSpace:Namespace;
var schemaNamespaces:Object;
for each (ns in namespaces) {
if (ns.uri == uri){
return (ns.prefix);
};
};
if (currentSchema != null){
schemaNamespaces = currentSchema.namespaces;
for each (ns in schemaNamespaces) {
if (ns.uri == uri){
return (ns.prefix);
};
};
};
var prefixString:String = "ns";
var newPrefix:String = (prefixString + namespaceCount);
if (namespaces[newPrefix] != null){
namespaceCount++;
newPrefix = (prefixString + namespaceCount);
nameSpace = new Namespace(newPrefix, uri);
namespaces[newPrefix] = nameSpace;
return (newPrefix);
};
nameSpace = new Namespace(newPrefix, uri);
namespaces[newPrefix] = nameSpace;
return (newPrefix);
}
public function unmarshall(value, type:QName=null, restriction:XML=null){
return (schemaMarshaller.unmarshall(value, type, restriction));
}
public function set namespaces(value:Object):void{
_namespaces = value;
}
public function get schemaDatatypes():SchemaDatatypes{
if (_schemaDatatypes == null){
_schemaDatatypes = SchemaDatatypes.getConstants(schemaConstants.xsdURI);
};
return (_schemaDatatypes);
}
public function get namespaces():Object{
if (_namespaces == null){
_namespaces = {};
};
return (_namespaces);
}
public function getQNameForElement(ncname:String, form:String=null):QName{
var qname:QName;
if ((((form == "qualified")) || ((((((form == null)) || ((form == "")))) && ((currentSchema.elementFormDefault == "qualified")))))){
qname = new QName(currentSchema.targetNamespace.uri, ncname);
} else {
qname = new QName("", ncname);
};
return (qname);
}
public function get currentSchema():Schema{
var schema:Schema;
var schemaSet:Array = currentScope();
if (schemaSet.hasOwnProperty("current")){
schema = schemaSet["current"];
};
return (schema);
}
public function get schemaMarshaller():SchemaMarshaller{
if (_schemaMarshaller == null){
_schemaMarshaller = new SchemaMarshaller(schemaConstants, schemaDatatypes);
};
return (_schemaMarshaller);
}
public function get schemaConstants():SchemaConstants{
if (_schemaConstants == null){
_schemaConstants = SchemaConstants.getConstants();
};
return (_schemaConstants);
}
public function getQNameForPrefixedName(prefixedName:String, parent:XML=null, qualifyToTargetNamespace:Boolean=false):QName{
var qname:QName;
var prefix:String;
var localName:String;
var ns:Namespace;
var localNamespaces:Array;
var localNS:Namespace;
var parentNS:Namespace;
var prefixIndex:int = prefixedName.indexOf(":");
if (prefixIndex > 0){
prefix = prefixedName.substr(0, prefixIndex);
localName = prefixedName.substr((prefixIndex + 1));
} else {
localName = prefixedName;
};
if ((((prefix == null)) && ((qualifyToTargetNamespace == true)))){
ns = currentSchema.targetNamespace;
};
if (prefix == null){
prefix = "";
};
if (ns == null){
if (parent != null){
localNamespaces = parent.inScopeNamespaces();
for each (localNS in localNamespaces) {
if (localNS.prefix == prefix){
ns = localNS;
break;
};
};
};
};
if (ns == null){
ns = namespaces[prefix];
};
if (ns == null){
ns = currentSchema.namespaces[prefix];
};
if (ns == null){
parentNS = ((parent)!=null) ? parent.namespace() : null;
if (((!((parentNS == null))) && ((parentNS.prefix == "")))){
ns = parentNS;
} else {
ns = currentSchema.targetNamespace;
};
};
if (ns != null){
qname = new QName(ns.uri, localName);
} else {
qname = new QName("", localName);
};
return (qname);
}
}
}//package mx.rpc.xml
Section 185
//SchemaMarshaller (mx.rpc.xml.SchemaMarshaller)
package mx.rpc.xml {
import flash.utils.*;
import mx.utils.*;
public class SchemaMarshaller {
private var unmarshallers:Object;
private var constants:SchemaConstants;
private var datatypes:SchemaDatatypes;
private var marshallers:Object;
private var _validating:Boolean;
public static const FLOAT_MIN_VALUE:Number = Math.pow(2, -149);
public static const LONG_MIN_VALUE:Number = -9.22337203685478E18;
public static const BYTE_MIN_VALUE:Number = -128;
public static const LONG_MAX_VALUE:Number = 9.22337203685478E18;
public static const USHORT_MAX_VALUE:Number = 0xFFFF;
public static const FLOAT_MAX_VALUE:Number = ((Math.pow(2, 24) - 1) * Math.pow(2, 104));
public static const SHORT_MIN_VALUE:Number = -32768;
public static const ULONG_MAX_VALUE:Number = 1.84467440737096E19;
public static const BYTE_MAX_VALUE:Number = 127;
public static const SHORT_MAX_VALUE:Number = 32767;
public static const UBYTE_MAX_VALUE:Number = 0xFF;
public static var whitespaceTrimPattern:RegExp = new RegExp("^[ ]+|[ ]+$", "g");
public static var whitespaceReplacePattern:RegExp = new RegExp("[\t\r\n]", "g");
public static var byteArrayAsBase64Binary:Boolean = true;
public static var whitespaceCollapsePattern:RegExp = new RegExp("[ \t\r\n]+", "g");
public function SchemaMarshaller(constants:SchemaConstants, datatypes:SchemaDatatypes){
super();
this.constants = constants;
this.datatypes = datatypes;
registerMarshallers();
}
public function unmarshallBoolean(value, type:QName=null, restriction:XML=null):Boolean{
if (value == null){
return (false);
};
var bool:String = whitespaceCollapse(value).toLowerCase();
if ((((bool == "true")) || ((bool == "1")))){
return (true);
};
return (false);
}
public function marshallDuration(value, type:QName=null, restriction:XML=null):String{
return (whitespaceCollapse(value));
}
private function registerMarshallers():void{
marshallers = {};
marshallers[datatypes.booleanQName.localName] = marshallBoolean;
marshallers[datatypes.anyTypeQName.localName] = marshallAny;
marshallers[datatypes.anySimpleTypeQName.localName] = marshallAny;
marshallers[datatypes.anyAtomicTypeQName.localName] = marshallAny;
marshallers[datatypes.stringQName.localName] = marshallString;
marshallers[datatypes.booleanQName.localName] = marshallBoolean;
marshallers[datatypes.decimalQName.localName] = marshallDecimal;
marshallers[datatypes.precisionDecimal.localName] = marshallDecimal;
marshallers[datatypes.floatQName.localName] = marshallFloat;
marshallers[datatypes.doubleQName.localName] = marshallDouble;
marshallers[datatypes.durationQName.localName] = marshallDuration;
marshallers[datatypes.dateTimeQName.localName] = marshallDatetime;
marshallers[datatypes.timeQName.localName] = marshallDatetime;
marshallers[datatypes.dateQName.localName] = marshallDatetime;
marshallers[datatypes.gYearMonthQName.localName] = marshallGregorian;
marshallers[datatypes.gYearQName.localName] = marshallGregorian;
marshallers[datatypes.gMonthDayQName.localName] = marshallGregorian;
marshallers[datatypes.gDayQName.localName] = marshallGregorian;
marshallers[datatypes.gMonthQName.localName] = marshallGregorian;
marshallers[datatypes.hexBinaryQName.localName] = marshallHexBinary;
marshallers[datatypes.base64BinaryQName.localName] = marshallBase64Binary;
marshallers[datatypes.anyURIQName.localName] = marshallString;
marshallers[datatypes.QNameQName.localName] = marshallString;
marshallers[datatypes.NOTATIONQName.localName] = marshallString;
marshallers[datatypes.normalizedStringQName.localName] = marshallString;
marshallers[datatypes.tokenQName.localName] = marshallString;
marshallers[datatypes.languageQName.localName] = marshallString;
marshallers[datatypes.NMTOKENQName.localName] = marshallString;
marshallers[datatypes.NMTOKENSQName.localName] = marshallString;
marshallers[datatypes.NameQName.localName] = marshallString;
marshallers[datatypes.NCNameQName.localName] = marshallString;
marshallers[datatypes.IDQName.localName] = marshallString;
marshallers[datatypes.IDREF.localName] = marshallString;
marshallers[datatypes.IDREFS.localName] = marshallString;
marshallers[datatypes.ENTITY.localName] = marshallString;
marshallers[datatypes.ENTITIES.localName] = marshallString;
marshallers[datatypes.integerQName.localName] = marshallInteger;
marshallers[datatypes.nonPositiveIntegerQName.localName] = marshallInteger;
marshallers[datatypes.negativeIntegerQName.localName] = marshallInteger;
marshallers[datatypes.longQName.localName] = marshallInteger;
marshallers[datatypes.intQName.localName] = marshallInteger;
marshallers[datatypes.shortQName.localName] = marshallInteger;
marshallers[datatypes.byteQName.localName] = marshallInteger;
marshallers[datatypes.nonNegativeIntegerQName.localName] = marshallInteger;
marshallers[datatypes.unsignedLongQName.localName] = marshallInteger;
marshallers[datatypes.unsignedIntQName.localName] = marshallInteger;
marshallers[datatypes.unsignedShortQName.localName] = marshallInteger;
marshallers[datatypes.unsignedByteQName.localName] = marshallInteger;
marshallers[datatypes.positiveIntegerQName.localName] = marshallInteger;
marshallers[datatypes.yearMonthDurationQName.localName] = marshallDatetime;
marshallers[datatypes.dayTimeDurationQName.localName] = marshallDatetime;
if (datatypes.timeInstantQName != null){
marshallers[datatypes.timeInstantQName.localName] = marshallDatetime;
};
unmarshallers = {};
unmarshallers[datatypes.booleanQName.localName] = unmarshallBoolean;
unmarshallers[datatypes.anyTypeQName.localName] = unmarshallAny;
unmarshallers[datatypes.anySimpleTypeQName.localName] = unmarshallAny;
unmarshallers[datatypes.anyAtomicTypeQName.localName] = unmarshallAny;
unmarshallers[datatypes.stringQName.localName] = unmarshallString;
unmarshallers[datatypes.booleanQName.localName] = unmarshallBoolean;
unmarshallers[datatypes.decimalQName.localName] = unmarshallDecimal;
unmarshallers[datatypes.precisionDecimal.localName] = unmarshallDecimal;
unmarshallers[datatypes.floatQName.localName] = unmarshallFloat;
unmarshallers[datatypes.doubleQName.localName] = unmarshallDouble;
unmarshallers[datatypes.durationQName.localName] = unmarshallDuration;
unmarshallers[datatypes.dateTimeQName.localName] = unmarshallDatetime;
unmarshallers[datatypes.timeQName.localName] = unmarshallDatetime;
unmarshallers[datatypes.dateQName.localName] = unmarshallDate;
unmarshallers[datatypes.gYearMonthQName.localName] = unmarshallGregorian;
unmarshallers[datatypes.gYearQName.localName] = unmarshallGregorian;
unmarshallers[datatypes.gMonthDayQName.localName] = unmarshallGregorian;
unmarshallers[datatypes.gDayQName.localName] = unmarshallGregorian;
unmarshallers[datatypes.gMonthQName.localName] = unmarshallGregorian;
unmarshallers[datatypes.hexBinaryQName.localName] = unmarshallHexBinary;
unmarshallers[datatypes.base64BinaryQName.localName] = unmarshallBase64Binary;
unmarshallers[datatypes.anyURIQName.localName] = unmarshallString;
unmarshallers[datatypes.QNameQName.localName] = unmarshallString;
unmarshallers[datatypes.NOTATIONQName.localName] = unmarshallString;
unmarshallers[datatypes.normalizedStringQName.localName] = unmarshallString;
unmarshallers[datatypes.tokenQName.localName] = unmarshallString;
unmarshallers[datatypes.languageQName.localName] = unmarshallString;
unmarshallers[datatypes.NMTOKENQName.localName] = unmarshallString;
unmarshallers[datatypes.NMTOKENSQName.localName] = unmarshallString;
unmarshallers[datatypes.NameQName.localName] = unmarshallString;
unmarshallers[datatypes.NCNameQName.localName] = unmarshallString;
unmarshallers[datatypes.IDQName.localName] = unmarshallString;
unmarshallers[datatypes.IDREF.localName] = unmarshallString;
unmarshallers[datatypes.IDREFS.localName] = unmarshallString;
unmarshallers[datatypes.ENTITY.localName] = unmarshallString;
unmarshallers[datatypes.ENTITIES.localName] = unmarshallString;
unmarshallers[datatypes.integerQName.localName] = unmarshallInteger;
unmarshallers[datatypes.nonPositiveIntegerQName.localName] = unmarshallInteger;
unmarshallers[datatypes.negativeIntegerQName.localName] = unmarshallInteger;
unmarshallers[datatypes.longQName.localName] = unmarshallInteger;
unmarshallers[datatypes.intQName.localName] = unmarshallInteger;
unmarshallers[datatypes.shortQName.localName] = unmarshallInteger;
unmarshallers[datatypes.byteQName.localName] = unmarshallInteger;
unmarshallers[datatypes.nonNegativeIntegerQName.localName] = unmarshallInteger;
unmarshallers[datatypes.unsignedLongQName.localName] = unmarshallInteger;
unmarshallers[datatypes.unsignedIntQName.localName] = unmarshallInteger;
unmarshallers[datatypes.unsignedShortQName.localName] = unmarshallInteger;
unmarshallers[datatypes.unsignedByteQName.localName] = unmarshallInteger;
unmarshallers[datatypes.positiveIntegerQName.localName] = unmarshallInteger;
unmarshallers[datatypes.yearMonthDurationQName.localName] = unmarshallDatetime;
unmarshallers[datatypes.dayTimeDurationQName.localName] = unmarshallDatetime;
if (datatypes.timeInstantQName != null){
unmarshallers[datatypes.timeInstantQName.localName] = unmarshallDatetime;
};
}
public function unmarshallAny(value, type:QName=null, restriction:XML=null){
var result:*;
var unmarshaller:Function;
var lowerS:String;
if (value === undefined){
return (undefined);
};
if (value == null){
return (null);
};
var s:String = whitespaceCollapse(value);
if (s == ""){
unmarshaller = unmarshallers[datatypes.stringQName.localName];
} else {
if (((((((isNaN(Number(s))) || ((s.charAt(0) == "0")))) || ((((s.charAt(0) == "-")) && ((s.charAt(1) == "0")))))) || ((s.charAt((s.length - 1)) == "E")))){
lowerS = s.toLowerCase();
if ((((lowerS == "true")) || ((lowerS == "false")))){
unmarshaller = unmarshallers[datatypes.booleanQName.localName];
} else {
unmarshaller = unmarshallers[datatypes.stringQName.localName];
};
} else {
unmarshaller = unmarshallers[datatypes.doubleQName.localName];
};
};
result = unmarshaller(value, type, restriction);
return (result);
}
public function marshallDouble(value, type:QName=null, restriction:XML=null):String{
var result:String;
var number:Number = Number(value);
result = specialNumber(number);
if (result == null){
result = number.toString();
};
return (result);
}
public function unmarshallDatetime(value, type:QName=null, restriction:XML=null):Object{
var date:Date;
var datePart:String;
var timePart:String;
var utc:Boolean;
var offset:Boolean;
var index:int;
var offsetDirection:int;
var offsetMillis:Number;
var offsetHours:int;
var offsetMinutes:int;
var year:uint;
var month:uint;
var day:uint;
var now:Date;
if (value == null){
return (null);
};
var rawValue:String = whitespaceCollapse(value);
var sep:int = rawValue.indexOf("T");
if (sep != -1){
datePart = rawValue.substring(0, sep);
timePart = rawValue.substring((sep + 1));
} else {
timePart = rawValue;
};
var hours:int = int(timePart.substring(0, 2));
var minutes:int = int(timePart.substring(3, 5));
var millisStart:int = timePart.indexOf(".", 6);
var seconds:int = int(timePart.substring(6, 8));
var tzIndex:int = timePart.indexOf("Z", 8);
if (tzIndex == -1){
tzIndex = timePart.indexOf("+", 8);
if (tzIndex != -1){
offsetDirection = 1;
} else {
tzIndex = timePart.indexOf("-", 8);
if (tzIndex != -1){
offsetDirection = -1;
};
};
if (tzIndex != -1){
index = (tzIndex + 1);
offsetHours = int(timePart.substring(index, (index + 2)));
index = (index + 3);
offsetMinutes = int(timePart.substring(index, (index + 2)));
offsetMillis = ((offsetHours * 3600000) + (offsetMinutes * 60000));
utc = true;
offset = true;
};
} else {
utc = true;
};
var millis:int;
if (millisStart != -1){
if (utc){
millis = int(timePart.substring((millisStart + 1), tzIndex));
} else {
millis = int(timePart.substring((millisStart + 1)));
};
};
if (datePart != null){
index = datePart.indexOf("-", 1);
var _temp1 = index;
index = (index + 1);
year = uint(datePart.substring(0, _temp1));
month = uint(datePart.substring(index, (index + 2)));
index = (index + 3);
day = uint(datePart.substring(index, (index + 2)));
if (utc){
date = new Date(Date.UTC(year, (month - 1), day));
} else {
date = new Date(year, (month - 1), day);
};
} else {
if (utc){
now = new Date();
date = new Date(Date.UTC(now.fullYearUTC, now.monthUTC, now.dateUTC));
} else {
date = new Date();
};
};
if (utc){
date.setUTCHours(hours, minutes, seconds, millis);
if (offset){
if (offsetDirection > 0){
date.time = (date.time - offsetMillis);
} else {
date.time = (date.time + offsetMillis);
};
};
} else {
date.setHours(hours, minutes, seconds, millis);
};
return (date);
}
public function marshall(value, type:QName=null, restriction:XML=null){
var result:*;
if (type == null){
type = datatypes.anyTypeQName;
};
var marshaller:Function = marshallers[type.localName];
if (marshaller != null){
result = marshaller(value, type, restriction);
} else {
throw (new TypeError((("Cannot marshall type '" + type) + "' to simple content.")));
};
return (result);
}
public function marshallInteger(value, type:QName=null, restriction:XML=null):String{
var result:String;
var number:Number;
if ((value is Number)){
number = (value as Number);
} else {
number = Number(whitespaceCollapse(value));
};
var min:Number = -(Number.MAX_VALUE);
var max:Number = Number.MAX_VALUE;
if (type == datatypes.longQName){
min = LONG_MIN_VALUE;
max = LONG_MAX_VALUE;
} else {
if (type == datatypes.intQName){
min = int.MIN_VALUE;
max = int.MAX_VALUE;
} else {
if (type == datatypes.shortQName){
min = SHORT_MIN_VALUE;
max = SHORT_MAX_VALUE;
} else {
if (type == datatypes.byteQName){
min = BYTE_MIN_VALUE;
max = BYTE_MAX_VALUE;
} else {
if (type == datatypes.unsignedLongQName){
min = 0;
max = ULONG_MAX_VALUE;
} else {
if (type == datatypes.unsignedIntQName){
min = 0;
max = uint.MAX_VALUE;
} else {
if (type == datatypes.unsignedShortQName){
min = 0;
max = USHORT_MAX_VALUE;
} else {
if (type == datatypes.unsignedByteQName){
min = 0;
max = UBYTE_MAX_VALUE;
} else {
if (type == datatypes.positiveIntegerQName){
min = 1;
max = Number.MAX_VALUE;
} else {
if (type == datatypes.nonNegativeIntegerQName){
min = 0;
max = Number.MAX_VALUE;
} else {
if (type == datatypes.negativeIntegerQName){
min = -(Number.MAX_VALUE);
max = -1;
} else {
if (type == datatypes.nonPositiveIntegerQName){
min = -(Number.MAX_VALUE);
max = 0;
} else {
if (type == datatypes.integerQName){
min = -(Number.MAX_VALUE);
max = Number.MAX_VALUE;
};
};
};
};
};
};
};
};
};
};
};
};
};
var integer:Number = Math.floor(number);
if (integer >= min){
if (integer > max){
if (validating){
throw (new RangeError(((("The value '" + value) + "' is too large for ") + type.localName)));
};
return (whitespaceCollapse(value));
};
} else {
if (validating){
throw (new RangeError(((("The value '" + value) + "' is too small for ") + type.localName)));
};
return (whitespaceCollapse(value));
};
result = integer.toString();
return (result);
}
public function get validating():Boolean{
return (_validating);
}
public function marshallHexBinary(value, type:QName=null, restriction:XML=null):String{
var valueString:String;
var encoder:HexEncoder;
var ba:ByteArray = (value as ByteArray);
if (ba != null){
encoder = new HexEncoder();
encoder.encode(ba);
valueString = encoder.drain();
} else {
throw (new Error("Cannot marshall value as hex binary."));
};
return (valueString);
}
public function unmarshallGregorian(value, type:QName=null, restriction:XML=null){
var rawValue:String = whitespaceCollapse(value);
var result:* = rawValue;
if (type == datatypes.gYearQName){
result = uint(rawValue.substring(0, 4));
} else {
if (type == datatypes.gMonthQName){
result = uint(rawValue.substring(2, 4));
} else {
if (type == datatypes.gDayQName){
result = uint(rawValue.substring(3, 5));
};
};
};
return (result);
}
public function unmarshallDouble(value, type:QName=null, restriction:XML=null):Number{
var result:Number;
var s:String;
if (value != null){
s = whitespaceCollapse(value);
if (s == "INF"){
result = Number.POSITIVE_INFINITY;
} else {
if (s == "-INF"){
result = Number.NEGATIVE_INFINITY;
} else {
result = Number(s);
};
};
};
return (result);
}
public function unmarshallDuration(value, type:QName=null, restriction:XML=null){
return (whitespaceCollapse(value));
}
public function unmarshallHexBinary(value, type:QName=null, restriction:XML=null):ByteArray{
var data:String;
var decoder:HexDecoder;
if (value != null){
data = whitespaceCollapse(value);
decoder = new HexDecoder();
decoder.decode(data);
return (decoder.drain());
};
return (null);
}
public function marshallBase64Binary(value, type:QName=null, restriction:XML=null):String{
var result:String;
var encoder:Base64Encoder;
var ba:ByteArray = (value as ByteArray);
if (ba != null){
encoder = new Base64Encoder();
encoder.insertNewLines = false;
encoder.encodeBytes(ba);
result = encoder.drain();
} else {
return (null);
};
return (result);
}
public function unmarshallString(value, type:QName=null, restriction:XML=null):String{
var result:String;
if (value != null){
result = value.toString();
};
return (result);
}
public function marshallDecimal(value, type:QName=null, restriction:XML=null):String{
var result:String;
var number:Number;
var str:String;
if ((value is Number)){
number = (value as Number);
} else {
str = whitespaceCollapse(value);
number = Number(str);
};
result = specialNumber(number);
if (result != null){
if (validating){
throw (new Error((("Invalid decimal value '" + value) + "'.")));
};
result = whitespaceCollapse(value);
} else {
result = number.toString();
};
return (result);
}
public function set validating(value:Boolean):void{
_validating = value;
}
public function unmarshall(value, type:QName=null, restriction:XML=null){
var rawValue:String;
var xml:XML;
var nilAttribute:String;
var list:XMLList;
if ((value is XML)){
xml = (value as XML);
if (xml.nodeKind() == "element"){
nilAttribute = xml.attribute(constants.nilQName).toString();
if (nilAttribute == "true"){
rawValue = null;
} else {
rawValue = xml.text().toString();
};
} else {
rawValue = xml.toString();
};
} else {
if ((value is XMLList)){
list = (value as XMLList);
rawValue = list.text().toString();
} else {
if (value != null){
rawValue = value.toString();
};
};
};
if (type == null){
type = datatypes.anyTypeQName;
};
var unmarshaller:Function = unmarshallers[type.localName];
if (unmarshaller != null){
value = unmarshaller(rawValue, type, restriction);
} else {
throw (new TypeError((("Cannot unmarshall type '" + type) + "' from XML.")));
};
return (value);
}
public function marshallDatetime(value, type:QName=null, restriction:XML=null):String{
var result:String;
var date:Date;
var n:Number;
if ((value is Number)){
date = new Date();
date.time = (value as Number);
value = date;
};
if ((value is Date)){
date = (value as Date);
result = "";
if ((((type == datatypes.dateTimeQName)) || ((type == datatypes.dateQName)))){
result = result.concat(date.getUTCFullYear(), "-");
n = (date.getUTCMonth() + 1);
if (n < 10){
result = result.concat("0");
};
result = result.concat(n, "-");
n = date.getUTCDate();
if (n < 10){
result = result.concat("0");
};
result = result.concat(n);
};
if (type == datatypes.dateTimeQName){
result = result.concat("T");
};
if ((((type == datatypes.dateTimeQName)) || ((type == datatypes.timeQName)))){
n = date.getUTCHours();
if (n < 10){
result = result.concat("0");
};
result = result.concat(n, ":");
n = date.getUTCMinutes();
if (n < 10){
result = result.concat("0");
};
result = result.concat(n, ":");
n = date.getUTCSeconds();
if (n < 10){
result = result.concat("0");
};
result = result.concat(n);
n = date.getUTCMilliseconds();
if (n > 0){
result = result.concat(".");
if (n < 10){
result = result.concat("00");
} else {
if (n < 100){
result = result.concat("0");
};
};
result = result.concat(n);
};
};
result = result.concat("Z");
} else {
if ((value is String)){
result = (value as String);
};
};
return (result);
}
public function unmarshallDecimal(value, type:QName=null, restriction:XML=null):Number{
return (unmarshallDouble(value, type));
}
public function marshallFloat(value, type:QName=null, restriction:XML=null):String{
var result:String;
var number:Number;
var str:String;
if ((value is Number)){
number = (value as Number);
} else {
str = whitespaceCollapse(value);
number = Number(str);
};
result = specialNumber(number);
if (result == null){
if (validating){
if (number > 0){
if (number > FLOAT_MAX_VALUE){
throw (new RangeError((("The value '" + value) + "' is too large for a single-precision floating point value.")));
};
if (number < FLOAT_MIN_VALUE){
throw (new RangeError((("The value '" + value) + "' is too small for a single-precision floating point value.")));
};
} else {
if (-(number) > FLOAT_MAX_VALUE){
throw (new RangeError((("The absolute value of '" + value) + "' is too large for a single-precision floating point value.")));
};
if (-(number) < FLOAT_MIN_VALUE){
throw (new RangeError((("The absolute value of '" + value) + "' is too small for a single-precision floating point value.")));
};
};
};
result = number.toString();
};
return (result);
}
public function unmarshallInteger(value, type:QName=null, restriction:XML=null):Number{
return (parseInt(value));
}
public function unmarshallDate(value, type:QName=null, restriction:XML=null):Object{
var date:Date;
var index:int;
var year:uint;
var month:uint;
var day:uint;
var offsetDirection:String;
var hours:int;
var minutes:int;
var millis:Number;
if (value == null){
return (null);
};
var datePart:String = whitespaceCollapse(value);
if (datePart != null){
index = datePart.indexOf("-", 1);
var _temp1 = index;
index = (index + 1);
year = uint(datePart.substring(0, _temp1));
month = uint(datePart.substring(index, (index + 2)));
index = (index + 3);
day = uint(datePart.substring(index, (index + 2)));
index = (index + 2);
if (datePart.charAt(index) == "Z"){
date = new Date(Date.UTC(year, (month - 1), day));
} else {
if (datePart.length > 10){
date = new Date(Date.UTC(year, (month - 1), day));
var _temp2 = index;
index = (index + 1);
offsetDirection = datePart.charAt(_temp2);
hours = int(datePart.substring(index, (index + 2)));
index = (index + 3);
minutes = int(datePart.substring(index, (index + 2)));
millis = ((hours * 3600000) + (minutes * 60000));
if (offsetDirection == "+"){
date.time = (date.time - millis);
} else {
date.time = (date.time + millis);
};
} else {
date = new Date(year, (month - 1), day);
};
};
};
return (date);
}
public function unmarshallBase64Binary(value, type:QName=null, restriction:XML=null):ByteArray{
if (value == null){
return (null);
};
var data:String = whitespaceCollapse(value);
var decoder:Base64Decoder = new Base64Decoder();
decoder.decode(data);
return (decoder.drain());
}
public function marshallGregorian(value, type:QName=null, restriction:XML=null):String{
var date:Date;
var n:Number;
var hyphen:int;
var year:String;
var month:String;
var day:String;
if ((value is Date)){
date = (value as Date);
} else {
if ((value is Number)){
n = (value as Number);
} else {
value = whitespaceCollapse(value);
};
};
var result:String = "";
if ((((type == datatypes.gYearMonthQName)) || ((type == datatypes.gYearQName)))){
if ((value is Date)){
n = date.getUTCFullYear();
} else {
if ((value is String)){
year = (value as String);
hyphen = year.indexOf("-", 1);
if (hyphen > 0){
year = year.substring(0, hyphen);
};
n = parseInt(year);
};
};
if (((isNaN(n)) || ((n == 0)))){
if (validating){
throw (new Error(((("Invalid year supplied for type " + type.localName) + " in value ") + value)));
};
return (whitespaceCollapse(value));
} else {
year = n.toFixed(0);
if (year.indexOf("-") == 0){
while (year.length < 5) {
year = ((year.substring(0, 1) + "0") + year.substring(1));
};
} else {
while (year.length < 4) {
year = ("0" + year);
};
};
result = result.concat(year);
};
if (type != datatypes.gYearQName){
result = result.concat("-");
};
};
if ((((((type == datatypes.gYearMonthQName)) || ((type == datatypes.gMonthDayQName)))) || ((type == datatypes.gMonthQName)))){
if (type != datatypes.gYearMonthQName){
result = result.concat("--");
};
if ((value is Date)){
n = (date.getUTCMonth() + 1);
} else {
month = value.toString();
if (type == datatypes.gMonthDayQName){
hyphen = month.indexOf("--", 0);
if (hyphen == 0){
month = month.substring(2, 4);
} else {
if (validating){
throw (new Error((((("Invalid month supplied for " + type.localName) + " in value ") + value) + ". The format must be '--MM-DD'.")));
};
return (whitespaceCollapse(value));
};
} else {
if (type == datatypes.gYearMonthQName){
hyphen = month.indexOf("-", 1);
if (hyphen > 0){
month = month.substring((hyphen + 1), (hyphen + 3));
} else {
if (validating){
throw (new Error((((("Invalid month supplied for " + type.localName) + " in value ") + value) + ". The format must be '--CCYY-MM'.")));
};
return (whitespaceCollapse(value));
};
} else {
hyphen = month.indexOf("--", 0);
if (hyphen > 0){
month = month.substring(2, 4);
};
};
};
n = parseInt(month);
};
if (((((isNaN(n)) || ((n <= 0)))) || ((n > 12)))){
if (validating){
throw (new Error(((("Invalid month supplied for type " + type.localName) + " in value ") + value)));
};
return (whitespaceCollapse(value));
} else {
n = int(n);
if (n < 10){
result = result.concat("0");
};
result = result.concat(n);
};
if (type == datatypes.gMonthDayQName){
result = result.concat("-");
};
};
if ((((type == datatypes.gMonthDayQName)) || ((type == datatypes.gDayQName)))){
if (type == datatypes.gDayQName){
result = result.concat("---");
};
if ((value is Date)){
n = date.getUTCDate();
} else {
if ((value is String)){
day = (value as String);
if (type == datatypes.gMonthDayQName){
hyphen = day.indexOf("--", 0);
if (hyphen == 0){
day = day.substring(5, 7);
} else {
if (validating){
throw (new Error((("Invalid day supplied for gMonthDay in value " + value) + ". The format must be '--MM-DD'.")));
};
return (whitespaceCollapse(value));
};
} else {
hyphen = day.indexOf("---", 0);
if (hyphen == 0){
day = day.substring(3, 5);
};
};
n = parseInt(day);
};
};
if (((((isNaN(n)) || ((n <= 0)))) || ((n > 31)))){
if (validating){
throw (new Error(((("Invalid day supplied for type " + type.localName) + " in value ") + value)));
};
return (whitespaceCollapse(value));
} else {
n = int(n);
if (n < 10){
result = result.concat("0");
};
result = result.concat(n);
};
};
return (result);
}
public function marshallBoolean(value, type:QName=null, restriction:XML=null):String{
var result:String;
var s:String;
if (value != null){
if ((value is Boolean)){
result = ((value as Boolean)) ? "true" : "false";
} else {
if ((value is Number)){
result = ((value)==1) ? "true" : "false";
} else {
if ((value is Object)){
s = Object(value).toString();
if ((((((((s == "true")) || ((s == "false")))) || ((s == "1")))) || ((s == "0")))){
result = s;
} else {
throw (new Error((("String '" + value) + "' is not a Boolean.")));
};
};
};
};
};
return (result);
}
public function unmarshallFloat(value, type:QName=null, restriction:XML=null):Number{
return (unmarshallDouble(value, type, restriction));
}
public function marshallAny(value, type:QName=null, restriction:XML=null){
if (value === undefined){
return (undefined);
};
if (value == null){
return (null);
};
var localName:String = guessSimpleType(value);
if (type != null){
type = new QName(type.uri, localName);
} else {
type = new QName(constants.xsdURI, localName);
};
var marshaller:Function = marshallers[type.localName];
if (marshaller != null){
return (marshaller(value, type));
};
throw (new TypeError((("Cannot marshall type '" + type) + "' to simple content.")));
}
public function marshallString(value, type:QName=null, restriction:XML=null):String{
if (((!((value == null))) && ((value is Object)))){
return (Object(value).toString());
};
return (null);
}
public static function guessSimpleType(value){
var localName:String = "string";
if ((value is uint)){
localName = "unsignedInt";
} else {
if ((value is int)){
localName = "int";
} else {
if ((value is Number)){
localName = "double";
} else {
if ((value is Boolean)){
localName = "boolean";
} else {
if ((value is String)){
localName = "string";
} else {
if ((value is ByteArray)){
if (byteArrayAsBase64Binary){
localName = "base64Binary";
} else {
localName = "hexBinary";
};
} else {
if ((value is Date)){
localName = "dateTime";
};
};
};
};
};
};
};
return (localName);
}
private static function whitespaceCollapse(value):String{
if (value == null){
return (null);
};
var s:String = value.toString();
s = s.replace(whitespaceCollapsePattern, " ");
s = s.replace(whitespaceTrimPattern, "");
return (s);
}
private static function specialNumber(value:Number):String{
if (value == Number.NEGATIVE_INFINITY){
return ("-INF");
};
if (value == Number.POSITIVE_INFINITY){
return ("INF");
};
if (isNaN(value)){
return ("NaN");
};
return (null);
}
private static function whitespaceReplace(value):String{
if (value == null){
return (null);
};
var s:String = value.toString();
s = s.replace(whitespaceReplacePattern, " ");
return (s);
}
}
}//package mx.rpc.xml
Section 186
//SchemaProcessor (mx.rpc.xml.SchemaProcessor)
package mx.rpc.xml {
import mx.utils.*;
public class SchemaProcessor {
private var _schemaManager:SchemaManager;
protected var strictOccurenceBounds:Boolean;// = false
public function SchemaProcessor(){
super();
}
protected function getMinOccurs(definition:XML):uint{
var minOccurs:uint = 1;
var attributeValue:String = getAttributeFromNode("minOccurs", definition);
if (attributeValue != null){
minOccurs = parseInt(attributeValue);
};
return (minOccurs);
}
protected function getSingleElementFromNode(node:XML, ... _args):XML{
var element:XML;
var type:QName;
var elements:XMLList = node.elements();
for each (element in elements) {
if (((!((_args == null))) && ((_args.length > 0)))){
for each (type in _args) {
if (element.name() == type){
return (element);
};
};
} else {
return (element);
};
};
return (null);
}
public function get schemaManager():SchemaManager{
if (_schemaManager == null){
_schemaManager = new SchemaManager();
};
return (_schemaManager);
}
protected function get constants():SchemaConstants{
return (schemaManager.schemaConstants);
}
protected function getAttributeFromNode(name, node:XML):String{
var value:String;
var attribute:XMLList;
if (node != null){
attribute = node.attribute(name);
if (attribute.length() > 0){
value = attribute[0];
};
};
return (value);
}
public function isBuiltInType(type:QName):Boolean{
var uri:String = ((type)!=null) ? type.uri : null;
if (uri != null){
if (((((URLUtil.urisEqual(uri, SchemaConstants.XSD_URI_1999)) || (URLUtil.urisEqual(uri, SchemaConstants.XSD_URI_2000)))) || (URLUtil.urisEqual(uri, SchemaConstants.XSD_URI_2001)))){
return (true);
};
};
return (false);
}
protected function getMaxOccurs(definition:XML):uint{
var maxOccurs:uint = 1;
var attributeValue:String = getAttributeFromNode("maxOccurs", definition);
if (attributeValue != null){
maxOccurs = ((attributeValue)=="unbounded") ? uint.MAX_VALUE : parseInt(attributeValue);
};
return (maxOccurs);
}
public function reset():void{
schemaManager.reset();
}
public function set schemaManager(manager:SchemaManager):void{
_schemaManager = manager;
}
public function getValueOccurence(value):uint{
var result:uint = 1;
if (((!((value == null))) && (TypeIterator.isIterable(value)))){
result = TypeIterator.getLength(value);
} else {
if (value === undefined){
result = 0;
};
};
return (result);
}
}
}//package mx.rpc.xml
Section 187
//SchemaTypeRegistry (mx.rpc.xml.SchemaTypeRegistry)
package mx.rpc.xml {
import flash.utils.*;
public class SchemaTypeRegistry {
private var classMap:Object;
private var collectionMap:Object;
private static var _instance:SchemaTypeRegistry;
public function SchemaTypeRegistry(){
classMap = {};
collectionMap = {};
super();
}
public function getClass(type:Object):Class{
var c:Class;
var key:String;
var definitionName:String;
if (type != null){
key = getKey(type);
definitionName = (classMap[key] as String);
if (definitionName != null){
c = (getDefinitionByName(definitionName) as Class);
};
};
return (c);
}
private function register(type:Object, definition:Object, map:Object):void{
var definitionName:String;
var key:String = getKey(type);
if ((definition is String)){
definitionName = (definition as String);
} else {
definitionName = getQualifiedClassName(definition);
};
map[key] = definitionName;
}
public function getCollectionClass(type:Object):Class{
var c:Class;
var key:String;
var definitionName:String;
if (type != null){
key = getKey(type);
definitionName = (collectionMap[key] as String);
if (definitionName != null){
c = (getDefinitionByName(definitionName) as Class);
};
};
return (c);
}
public function unregisterCollectionClass(type:Object):void{
var key:String;
if (type != null){
key = getKey(type);
delete collectionMap[key];
};
}
private function getKey(type:Object):String{
var key:String;
var typeQName:QName;
if ((type is QName)){
typeQName = (type as QName);
if ((((typeQName.uri == null)) || ((typeQName.uri == "")))){
key = typeQName.localName;
} else {
key = typeQName.toString();
};
} else {
key = type.toString();
};
return (key);
}
public function registerClass(type:Object, definition:Object):void{
register(type, definition, classMap);
}
public function registerCollectionClass(type:Object, definition:Object):void{
register(type, definition, collectionMap);
}
public function unregisterClass(type:Object):void{
var key:String;
if (type != null){
key = getKey(type);
delete classMap[key];
};
}
public static function getInstance():SchemaTypeRegistry{
if (_instance == null){
_instance = new (SchemaTypeRegistry);
};
return (_instance);
}
}
}//package mx.rpc.xml
Section 188
//SimpleContent (mx.rpc.xml.SimpleContent)
package mx.rpc.xml {
import mx.rpc.xml.*;
dynamic class SimpleContent {
public var value;
function SimpleContent(val){
super();
value = val;
}
public function valueOf():Object{
return ((value as Object));
}
public function toString():String{
var object:Object = (value as Object);
return (((object == null)) ? null : object.toString());
}
}
}//package mx.rpc.xml
Section 189
//TypeIterator (mx.rpc.xml.TypeIterator)
package mx.rpc.xml {
import mx.collections.*;
public class TypeIterator {
private var _value;
private var counter:uint;
public function TypeIterator(value){
super();
_value = value;
}
public function get value(){
return (_value);
}
public function next(){
var result:*;
try {
try {
result = getItemAt(_value, counter);
} finally {
};
} finally {
counter++;
};
return (result);
}
public function get length():uint{
return (getLength(_value));
}
public function hasNext():Boolean{
if (_value != null){
return ((getLength(_value) > counter));
};
return (false);
}
public function reset():void{
counter = 0;
}
public static function push(parent, value):uint{
var result:uint;
var complexParent:*;
var arrayValue:Array;
var listValue:IList;
var xmlList:XMLList;
if (parent != null){
if ((((parent is ContentProxy)) && (!(ContentProxy(parent).isSimple)))){
complexParent = ContentProxy(parent).content;
if (TypeIterator.isIterable(complexParent)){
parent = complexParent;
};
};
if ((parent is Array)){
arrayValue = (parent as Array);
result = arrayValue.push(value);
} else {
if ((parent is IList)){
listValue = (parent as IList);
listValue.addItem(value);
result = listValue.length;
} else {
if ((parent is XMLList)){
xmlList = (parent as XMLList);
xmlList = (xmlList + value);
result = xmlList.length();
};
};
};
};
return (result);
}
public static function getLength(value):uint{
var result:uint;
var arrayValue:Array;
var listValue:IList;
var xmlList:XMLList;
if (value != null){
if ((value is Array)){
arrayValue = (value as Array);
result = arrayValue.length;
} else {
if ((value is IList)){
listValue = (value as IList);
result = listValue.length;
} else {
if ((value is XMLList)){
xmlList = (value as XMLList);
result = xmlList.length();
};
};
};
};
return (result);
}
public static function getItemAt(value, index:uint){
var result:*;
var arrayValue:Array;
var listValue:IList;
var xmlList:XMLList;
if (value != null){
if ((value is Array)){
arrayValue = (value as Array);
result = arrayValue[index];
} else {
if ((value is IList)){
listValue = (value as IList);
result = listValue.getItemAt(index);
} else {
if ((value is XMLList)){
xmlList = (value as XMLList);
result = xmlList[index];
};
};
};
};
return (result);
}
public static function isIterable(value):Boolean{
var complexValue:*;
if ((((value is ContentProxy)) && (!(ContentProxy(value).isSimple)))){
complexValue = ContentProxy(value).content;
if (TypeIterator.isIterable(complexValue)){
value = complexValue;
};
};
if ((((((value is Array)) || ((value is IList)))) || ((value is XMLList)))){
return (true);
};
return (false);
}
}
}//package mx.rpc.xml
Section 190
//XMLDecoder (mx.rpc.xml.XMLDecoder)
package mx.rpc.xml {
import mx.logging.*;
import flash.utils.*;
import mx.collections.*;
import mx.utils.*;
public class XMLDecoder extends SchemaProcessor implements IXMLDecoder {
private var _recordXSIType:Boolean;
protected var document:XML;
private var log:ILogger;
private var _makeObjectsBindable:Boolean;
private var _typeRegistry:SchemaTypeRegistry;
public static var listClass:Class = ArrayCollection;
public function XMLDecoder(){
super();
log = Log.getLogger("mx.rpc.xml.XMLDecoder");
typeRegistry = SchemaTypeRegistry.getInstance();
}
public function createIterableValue(type:Object=null){
var value:*;
var c:Class;
var type = type;
if (type != null){
c = typeRegistry.getCollectionClass(type);
if (c != null){
value = new (c);
};
};
//unresolved jump
var _slot1 = e1;
log.debug("Error while resolving custom collection type for '{0}'.\nError: '{1}'.", type, _slot1);
if (value == null){
if (makeObjectsBindable){
value = new listClass();
} else {
value = [];
};
};
//unresolved jump
var _slot1 = e2;
log.warn("Unable to create instance of '{0}'.", listClass);
return (value);
}
public function get makeObjectsBindable():Boolean{
return (_makeObjectsBindable);
}
public function decodeAnyElement(definition:XML, parent, name:QName, valueElements:XMLList, context:DecodingContext=null, isRequired:Boolean=true):Boolean{
var includedNamespaces:Array;
var targetNamespace:String;
var element:XML;
var processContents:String;
var namespacesString:String;
var propertyName:QName;
var any:*;
var elementVal:*;
if (context == null){
context = new DecodingContext();
};
var allowTargetNamespace:Boolean;
var maxOccurs:uint = getMaxOccurs(definition);
var minOccurs:uint = getMinOccurs(definition);
if (definition != null){
processContents = definition.@["processContents"];
namespacesString = definition.@["namespace"];
if (((!((namespacesString == ""))) && (!((namespacesString == "##any"))))){
if (((!((schemaManager.currentSchema == null))) && (!((schemaManager.currentSchema.targetNamespace == null))))){
targetNamespace = schemaManager.currentSchema.targetNamespace.uri;
};
if (namespacesString == "##other"){
allowTargetNamespace = false;
} else {
if (namespacesString.indexOf("##targetNamespace") >= 0){
namespacesString = namespacesString.replace("##targetNamespace", targetNamespace);
};
includedNamespaces = namespacesString.split(" ");
};
};
};
var applicableValues:XMLList = getApplicableValues(parent, valueElements, null, context, maxOccurs);
for each (element in applicableValues) {
propertyName = (element.name() as QName);
if (((!(allowTargetNamespace)) && (URLUtil.urisEqual(propertyName.uri, targetNamespace)))){
break;
};
if (includeNamespace(propertyName.uri, includedNamespaces)){
if (processContents == "skip"){
elementVal = element.toXMLString();
} else {
elementVal = element;
};
decodeAnyType(parent, propertyName, new XMLList(elementVal));
if (context.anyIndex < 0){
context.anyIndex = (context.index + 0);
};
context.index++;
};
};
return (true);
}
public function decodeComplexRestriction(restriction:XML, parent, name:QName, value):void{
var childDefinition:XML;
var baseName:String = getAttributeFromNode("base", restriction);
if (baseName == null){
throw (new Error("A complexContent restriction must declare a base type."));
};
var baseType:QName = schemaManager.getQNameForPrefixedName(baseName, restriction);
var childElements:XMLList = restriction.elements();
var valueElements:XMLList = new XMLList();
if ((value is XML)){
valueElements = (value as XML).elements();
} else {
if ((value is XMLList)){
valueElements = value;
};
};
for each (childDefinition in childElements) {
if (childDefinition.name() == constants.sequenceQName){
decodeSequence(childDefinition, parent, name, valueElements);
} else {
if (childDefinition.name() == constants.groupQName){
decodeGroupReference(childDefinition, parent, name, valueElements);
} else {
if (childDefinition.name() == constants.allQName){
decodeAll(childDefinition, parent, name, valueElements);
} else {
if (childDefinition.name() == constants.choiceQName){
decodeChoice(childDefinition, parent, name, valueElements);
} else {
if (childDefinition.name() == constants.attributeQName){
decodeAttribute(childDefinition, parent, value);
} else {
if (childDefinition.name() == constants.attributeGroupQName){
decodeAttributeGroup(childDefinition, parent, value);
} else {
if (childDefinition.name() == constants.anyAttributeQName){
decodeAnyAttribute(childDefinition, parent, value);
};
};
};
};
};
};
};
};
}
public function decodeGroupElement(definition:XML, parent, valueElements:XMLList, context:DecodingContext=null, isRequired:Boolean=true, hasSiblings:Boolean=true):Boolean{
var ref:QName;
var element:*;
var typeAttribute:String;
var typeQName:QName;
var emptyArray:*;
var elementOccurs:uint;
var item:XML;
if (context == null){
context = new DecodingContext();
};
var maxOccurs:uint = getMaxOccurs(definition);
var minOccurs:uint = getMinOccurs(definition);
if (definition.attribute("ref").length() == 1){
ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
definition = schemaManager.getNamedDefinition(ref, constants.elementTypeQName);
if (definition == null){
throw (new Error((("Cannot resolve element definition for ref '" + ref) + "'")));
};
};
if (maxOccurs == 0){
return (true);
};
var elementName:String = definition.@name.toString();
var elementQName:QName = schemaManager.getQNameForElement(elementName, getAttributeFromNode("form", definition));
var applicableValues:XMLList = getApplicableValues(parent, valueElements, elementQName, context, maxOccurs);
if ((((applicableValues.length() == 1)) && (isXSINil(applicableValues[0])))){
setValue(parent, elementQName, null);
context.index++;
return (true);
};
if (maxOccurs > 1){
typeAttribute = getAttributeFromNode("type", definition);
if (typeAttribute != null){
typeQName = schemaManager.getQNameForPrefixedName(typeAttribute, definition);
};
emptyArray = createIterableValue(typeQName);
if (hasSiblings){
setValue(parent, elementQName, emptyArray, typeQName);
} else {
if (!(((parent is ContentProxy)) && (!((parent.object_proxy::content == undefined))))){
setValue(parent, null, emptyArray, typeQName);
};
};
};
if (applicableValues.length() == 0){
if (minOccurs == 0){
return (true);
};
return (false);
};
if (maxOccurs == 1){
element = decodeElementTopLevel(definition, elementQName, parseValue(elementQName, applicableValues));
setValue(parent, elementQName, element);
context.index++;
} else {
if (maxOccurs > 1){
if (applicableValues.length() < minOccurs){
if (strictOccurenceBounds){
throw (new Error((((((("Value supplied for element '" + elementQName) + "' occurs ") + applicableValues.length()) + " times which falls short of minOccurs ") + minOccurs) + ".")));
};
return (false);
};
if (applicableValues.length() > maxOccurs){
if (strictOccurenceBounds){
throw (new Error((((((("Value supplied for element of type '" + elementQName) + "' occurs ") + applicableValues.length()) + " times which exceeds maxOccurs ") + maxOccurs) + ".")));
};
return (false);
};
elementOccurs = 0;
while ((((elementOccurs < maxOccurs)) && ((elementOccurs < applicableValues.length())))) {
item = applicableValues[elementOccurs];
element = decodeElementTopLevel(definition, elementQName, item);
setValue(parent, elementQName, element);
context.index++;
elementOccurs++;
};
};
};
if (ref != null){
schemaManager.releaseScope();
};
return (true);
}
public function decodeElementTopLevel(definition:XML, elementQName:QName, value){
var content:*;
var processedElement:*;
var typeQName:QName;
var typeDefinition:XML;
var typeQName2:QName;
var nillable:Boolean = ((definition.@nillable.toString() == "true")) ? true : false;
if (((nillable) && ((value == null)))){
return (value);
};
var fixedValue:String = getAttributeFromNode("fixed", definition);
if (fixedValue != null){
value = fixedValue;
};
var defaultValue:String = getAttributeFromNode("default", definition);
if (((!(nillable)) && ((value == null)))){
value = defaultValue;
};
if (value == null){
return (value);
};
var attributeValue:String = getAttributeFromNode("type", definition);
if (attributeValue != null){
typeQName = schemaManager.getQNameForPrefixedName(attributeValue, definition);
content = createContent(typeQName);
decodeType(typeQName, content, elementQName, value);
return (content);
};
if (definition.hasComplexContent()){
typeDefinition = getSingleElementFromNode(definition, constants.complexTypeQName, constants.simpleTypeQName);
content = createContent();
if (typeDefinition.name() == constants.complexTypeQName){
decodeComplexType(typeDefinition, content, elementQName, value);
} else {
if (typeDefinition.name() == constants.simpleTypeQName){
decodeSimpleType(typeDefinition, content, elementQName, value);
};
};
return (content);
} else {
if (((!((fixedValue == null))) || (!((defaultValue == null))))){
typeQName2 = schemaManager.schemaDatatypes.stringQName;
} else {
typeQName2 = constants.anyTypeQName;
};
content = createContent(typeQName2);
decodeType(typeQName2, content, elementQName, value);
};
return (!NULL!);
}
protected function parseValue(name, value:XMLList){
var result:* = value;
if (value.hasSimpleContent()){
if (isXSINil(value)){
result = null;
} else {
result = value.toString();
};
} else {
if (value.length() == 1){
result = value[0];
};
};
return (result);
}
protected function includeNamespace(namespaceURI:String, includedNamespaces:Array=null):Boolean{
var matchFound:Boolean;
var definedURI:String;
if (includedNamespaces != null){
matchFound = false;
for each (definedURI in includedNamespaces) {
if ((((definedURI == "##local")) && ((namespaceURI == null)))){
return (true);
};
if (URLUtil.urisEqual(namespaceURI, definedURI)){
return (true);
};
};
return (false);
};
return (true);
}
public function get typeRegistry():SchemaTypeRegistry{
return (_typeRegistry);
}
public function decodeSimpleContent(definition:XML, parent, name:QName, value, restriction:XML=null):void{
var baseName:String;
var baseType:QName;
var simpleValue:*;
var baseDefinition:XML;
var extensions:XMLList;
var extensionChild:XML;
var result:*;
var childDefinition:XML = getSingleElementFromNode(definition, constants.extensionQName, constants.restrictionQName);
if ((parent is ContentProxy)){
ContentProxy(parent).object_proxy::isSimple = true;
};
if (childDefinition != null){
baseName = getAttributeFromNode("base", childDefinition);
if (baseName == null){
throw (new Error("A simpleContent extension or restriction must declare a base type."));
};
baseType = schemaManager.getQNameForPrefixedName(baseName, childDefinition);
if (!isBuiltInType(baseType)){
baseDefinition = schemaManager.getNamedDefinition(baseType, constants.complexTypeQName, constants.simpleTypeQName);
if (baseDefinition == null){
throw (new Error((("Cannot find base type definition '" + baseType) + "'")));
};
schemaManager.releaseScope();
};
if (childDefinition.name() == constants.extensionQName){
if (isBuiltInType(baseType)){
simpleValue = getSimpleValue(value, name);
result = marshallBuiltInType(baseType, parent, name, simpleValue, restriction);
setSimpleValue(parent, name, result, baseType);
} else {
decodeType(baseType, parent, name, value, restriction);
};
extensions = childDefinition.elements();
for each (extensionChild in extensions) {
if (extensionChild.name() == constants.attributeQName){
decodeAttribute(extensionChild, parent, value, restriction);
} else {
if (extensionChild.name() == constants.attributeGroupQName){
decodeAttributeGroup(extensionChild, parent, value, restriction);
} else {
if (extensionChild.name() == constants.anyAttributeQName){
decodeAnyAttribute(extensionChild, parent, value, restriction);
};
};
};
};
} else {
if (childDefinition.name() == constants.restrictionQName){
simpleValue = getSimpleValue(value, name);
decodeSimpleRestriction(childDefinition, parent, name, simpleValue);
};
};
};
}
public function decodeGroupReference(definition:XML, parent, name:QName, valueElements:XMLList, context:DecodingContext=null, isRequired:Boolean=true):Boolean{
var ref:QName;
var childDefinition:XML;
if (definition.attribute("ref").length() == 1){
ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
definition = schemaManager.getNamedDefinition(ref, constants.groupQName);
if (definition == null){
throw (new Error((("Cannot resolve group definition for '" + ref) + "'")));
};
} else {
throw (new Error("A group reference element must have the ref attribute."));
};
var groupElements:XMLList = definition.elements();
var groupSatisfied:Boolean;
for each (childDefinition in groupElements) {
if (childDefinition.name() == constants.allQName){
groupSatisfied = decodeAll(childDefinition, parent, name, valueElements, context, isRequired);
} else {
if (childDefinition.name() == constants.choiceQName){
groupSatisfied = decodeChoice(childDefinition, parent, name, valueElements, context, isRequired);
} else {
if (childDefinition.name() == constants.sequenceQName){
groupSatisfied = decodeSequence(childDefinition, parent, name, valueElements, context, isRequired);
};
};
};
};
schemaManager.releaseScope();
return (groupSatisfied);
}
public function setSimpleValue(parent, name, value, type:Object=null):void{
var parentProxy:ContentProxy;
if ((parent is ContentProxy)){
parentProxy = (parent as ContentProxy);
if (parentProxy.object_proxy::isSimple){
parentProxy.object_proxy::content = value;
return;
};
};
setValue(parent, name, value, type);
}
public function decodeAnyAttribute(definition:XML, parent, value=undefined, restriction:XML=null):void{
var xml:XML;
var includedNamespaces:Array;
var allowTargetNamespace:Boolean;
var targetNamespace:String;
var namespacesString:String;
var attributes:XMLList;
var attribute:XML;
var attributeName:QName;
var attributeValue:*;
if (((!((value === undefined))) && ((value is XML)))){
xml = (value as XML);
allowTargetNamespace = true;
namespacesString = definition.@["namespace"];
if (((!((namespacesString == ""))) && (!((namespacesString == "##any"))))){
if (((!((schemaManager.currentSchema == null))) && (!((schemaManager.currentSchema.targetNamespace == null))))){
targetNamespace = schemaManager.currentSchema.targetNamespace.uri;
};
if (namespacesString == "##other"){
allowTargetNamespace = false;
} else {
if (namespacesString.indexOf("##targetNamespace") >= 0){
namespacesString = namespacesString.replace("##targetNamespace", targetNamespace);
};
includedNamespaces = namespacesString.split(" ");
};
};
attributes = xml.attributes();
for each (attribute in attributes) {
attributeName = (attribute.name() as QName);
if (((!(allowTargetNamespace)) && (URLUtil.urisEqual(attributeName.uri, targetNamespace)))){
} else {
if (includeNamespace(attributeName.uri, includedNamespaces)){
attributeValue = getAttribute(value, attributeName);
if (attributeValue != null){
setAttribute(parent, attributeName, attributeValue);
};
};
};
};
};
}
public function decodeSimpleType(definition:XML, parent, name:QName, value, restriction:XML=null):void{
var definitionChild:XML = getSingleElementFromNode(definition, constants.restrictionQName, constants.listQName, constants.unionQName);
if (definitionChild.name() == constants.restrictionQName){
decodeSimpleRestriction(definitionChild, parent, name, value);
} else {
if (definitionChild.name() == constants.listQName){
decodeSimpleList(definitionChild, parent, name, value, restriction);
} else {
if (definitionChild.name() == constants.listQName){
decodeSimpleUnion(definitionChild, parent, name, value, restriction);
};
};
};
}
public function hasAttribute(parent, name):Boolean{
return (!((getAttribute(parent, name) === undefined)));
}
public function getProperties(value):Array{
var elements:XMLList;
var element:XML;
var properties:Array = [];
if ((value is XML)){
elements = XML(value).elements();
} else {
if ((value is XMLList)){
elements = XMLList(value).elements();
};
};
if (elements != null){
for each (element in elements) {
properties.push(element.name());
};
};
return (properties);
}
protected function preProcessXML(root:XML):void{
}
protected function isXSINil(value):Boolean{
var nilAttribute:String;
if (value != null){
nilAttribute = "false";
if ((value is XML)){
nilAttribute = XML(value).attribute(constants.nilQName).toString();
} else {
if ((value is XMLList)){
nilAttribute = XMLList(value).attribute(constants.nilQName).toString();
};
};
if (nilAttribute == "true"){
return (true);
};
};
return (false);
}
public function set typeRegistry(value:SchemaTypeRegistry):void{
_typeRegistry = value;
}
public function marshallBuiltInType(type:QName, parent, name:QName, value, restriction:XML=null){
var content:*;
var valueList:XMLList;
if ((((type == constants.anyTypeQName)) && (!(isSimpleValue(value))))){
content = createContent();
if ((content is ContentProxy)){
ContentProxy(content).object_proxy::isSimple = false;
};
if ((value is XML)){
valueList = value.elements();
} else {
valueList = new XMLList(value);
};
decodeAnyType(content, name, valueList);
return (content);
//unresolved jump
};
return (schemaManager.unmarshall(value, type, restriction));
}
public function getSimpleValue(parent, name){
var xml:XML;
var list:XMLList;
if ((parent is XML)){
xml = (parent as XML);
if (xml.hasSimpleContent()){
return (xml.toString());
};
} else {
if ((parent is XMLList)){
list = (parent as XMLList);
if (list.hasSimpleContent()){
return (list.toString());
};
};
};
return (getValue(parent, name));
}
public function setValue(parent, name, value, type:Object=null):void{
var existingValue:*;
var propertyName:String;
var proxyParent:ContentProxy;
var parent = parent;
var name = name;
var value = value;
var type = type;
if (parent != null){
if ((value is ContentProxy)){
value = ContentProxy(value).object_proxy::content;
};
if (TypeIterator.isIterable(parent)){
TypeIterator.push(parent, value);
} else {
if (name != null){
if ((name is ContentProxy)){
name = ContentProxy(name).object_proxy::content;
};
if ((name is QName)){
propertyName = QName(name).localName;
} else {
propertyName = Object(name).toString();
};
if ((((parent is ContentProxy)) && (ContentProxy(parent).object_proxy::isSimple))){
existingValue = ContentProxy(parent).object_proxy::content;
} else {
if (Object(parent).hasOwnProperty(propertyName)){
existingValue = getExistingValue(parent, propertyName);
} else {
if (Object(parent).hasOwnProperty(("_" + propertyName))){
existingValue = getExistingValue(parent, ("_" + propertyName));
};
};
};
if (existingValue != null){
existingValue = promoteValueToArray(existingValue, type);
TypeIterator.push(existingValue, value);
value = existingValue;
};
if ((((parent is ContentProxy)) && (ContentProxy(parent).object_proxy::isSimple))){
ContentProxy(parent).object_proxy::content = value;
} else {
parent[propertyName] = value;
//unresolved jump
var _slot1 = e;
parent[("_" + propertyName)] = value;
};
//unresolved jump
var _slot1 = e;
log.warn("Unable to set property '{0}' on parent.", propertyName);
} else {
if ((parent is ContentProxy)){
proxyParent = (parent as ContentProxy);
existingValue = proxyParent.object_proxy::content;
if (existingValue !== undefined){
existingValue = promoteValueToArray(existingValue, type);
proxyParent.object_proxy::content = existingValue;
TypeIterator.push(existingValue, value);
value = existingValue;
};
proxyParent.object_proxy::content = value;
};
};
};
};
}
public function decodeComplexContent(definition:XML, parent, name:QName, value, context:DecodingContext):void{
var childDefinition:XML = getSingleElementFromNode(definition, constants.extensionQName, constants.restrictionQName);
if (childDefinition.name() == constants.extensionQName){
decodeComplexExtension(childDefinition, parent, name, value, context);
} else {
if (childDefinition.name() == constants.restrictionQName){
decodeComplexRestriction(childDefinition, parent, name, value);
};
};
}
public function getValue(parent, name, index:Number=-1){
var result:*;
var qname:QName;
var elements:XMLList;
if ((name is QName)){
qname = (name as QName);
if ((((qname.uri == null)) || ((qname.uri == "")))){
name = qname.localName;
};
};
if ((parent is XML)){
elements = XML(parent).elements(name);
if (elements.length() > 0){
result = parseValue(name, elements);
};
} else {
if ((parent is XMLList)){
elements = XMLList(parent).elements(name);
if (elements.length() > 0){
result = parseValue(name, elements);
};
} else {
if ((parent is ContentProxy)){
if (qname != null){
name = qname.localName;
};
result = ((parent as ContentProxy).hasOwnProperty(name)) ? parent[name] : undefined;
} else {
if (!isSimpleValue(parent)){
result = parent[name];
};
};
};
};
return (result);
}
public function decodeComplexType(definition:XML, parent, name:QName, value, restriction:XML=null, context:DecodingContext=null):void{
var childDefinition:XML;
if ((parent is ContentProxy)){
ContentProxy(parent).object_proxy::isSimple = false;
};
var childElements:XMLList = definition.elements();
var valueElements:XMLList = new XMLList();
if ((value is XML)){
valueElements = (value as XML).elements();
} else {
if ((value is XMLList)){
valueElements = value;
};
};
for each (childDefinition in childElements) {
if (childDefinition.name() == constants.simpleContentQName){
decodeSimpleContent(childDefinition, parent, name, value, restriction);
} else {
if (childDefinition.name() == constants.complexContentQName){
decodeComplexContent(childDefinition, parent, name, value, context);
} else {
if (childDefinition.name() == constants.sequenceQName){
decodeSequence(childDefinition, parent, name, valueElements, context);
} else {
if (childDefinition.name() == constants.groupQName){
decodeGroupReference(childDefinition, parent, name, valueElements, context);
} else {
if (childDefinition.name() == constants.allQName){
decodeAll(childDefinition, parent, name, valueElements, context);
} else {
if (childDefinition.name() == constants.choiceQName){
decodeChoice(childDefinition, parent, name, valueElements, context);
} else {
if (childDefinition.name() == constants.attributeQName){
decodeAttribute(childDefinition, parent, value, restriction);
} else {
if (childDefinition.name() == constants.attributeGroupQName){
decodeAttributeGroup(childDefinition, parent, value, restriction);
} else {
if (childDefinition.name() == constants.anyAttributeQName){
decodeAnyAttribute(childDefinition, parent, value, restriction);
};
};
};
};
};
};
};
};
};
};
}
public function decodeChoice(definition:XML, parent, name:QName, valueElements:XMLList, context:DecodingContext=null, isRequired:Boolean=true):Boolean{
var choiceSatisfied:Boolean;
var lastIndex:uint;
var choiceOccurs:uint;
var childDefinition:XML;
if (context == null){
context = new DecodingContext();
};
var maxOccurs:uint = getMaxOccurs(definition);
var minOccurs:uint = getMinOccurs(definition);
if (maxOccurs == 0){
return (false);
};
if ((((valueElements == null)) && ((minOccurs == 0)))){
return (true);
};
var choiceElements:XMLList = definition.elements();
if (choiceElements.length() == 0){
return (true);
};
choiceOccurs = 0;
while (choiceOccurs < maxOccurs) {
lastIndex = (context.index + 0);
choiceSatisfied = false;
for each (childDefinition in choiceElements) {
if (childDefinition.name() == constants.elementTypeQName){
choiceSatisfied = ((choiceSatisfied) || (decodeGroupElement(childDefinition, parent, valueElements, context, false)));
if (context.index > lastIndex){
break;
};
} else {
if (childDefinition.name() == constants.sequenceQName){
choiceSatisfied = ((choiceSatisfied) || (decodeSequence(childDefinition, parent, name, valueElements, context, false)));
if (context.index > lastIndex){
break;
};
} else {
if (childDefinition.name() == constants.groupQName){
choiceSatisfied = ((choiceSatisfied) || (decodeGroupReference(childDefinition, parent, name, valueElements, context, false)));
if (context.index > lastIndex){
break;
};
} else {
if (childDefinition.name() == constants.choiceQName){
choiceSatisfied = ((choiceSatisfied) || (decodeChoice(childDefinition, parent, name, valueElements, context, false)));
if (context.index > lastIndex){
break;
};
} else {
if (childDefinition.name() == constants.anyQName){
choiceSatisfied = ((choiceSatisfied) || (decodeAnyElement(childDefinition, parent, name, valueElements, context, false)));
if (context.index > lastIndex){
break;
};
};
};
};
};
};
};
if (!choiceSatisfied){
break;
};
choiceOccurs++;
};
if (choiceOccurs < minOccurs){
if (((isRequired) && (strictOccurenceBounds))){
throw (new Error((((((("Value supplied for choice " + name.toString()) + " occurs ") + choiceOccurs) + " times which falls short of minOccurs ") + minOccurs) + ".")));
};
return (false);
};
return (true);
}
public function get recordXSIType():Boolean{
return (_recordXSIType);
}
public function set recordXSIType(value:Boolean):void{
_recordXSIType = value;
}
public function decodeType(type:QName, parent, name:QName, value, restriction:XML=null):void{
var result:*;
var definition:XML;
var definitionType:QName;
if (isBuiltInType(type)){
result = marshallBuiltInType(type, parent, name, value, restriction);
setValue(parent, name, result, type);
} else {
definition = schemaManager.getNamedDefinition(type, constants.complexTypeQName, constants.simpleTypeQName);
if (definition == null){
throw (new Error((("Cannot find definition for type '" + type) + "'")));
};
if (isXSINil(value)){
setValue(parent, name, null, type);
return;
};
definitionType = (definition.name() as QName);
if (definitionType == constants.complexTypeQName){
decodeComplexType(definition, parent, name, value, restriction);
} else {
if (definitionType == constants.simpleTypeQName){
decodeSimpleType(definition, parent, name, value, restriction);
} else {
throw (new Error(("Invalid type definition " + definitionType)));
};
};
schemaManager.releaseScope();
};
setXSIType(parent, type);
}
protected function promoteValueToArray(value, type:Object=null){
var array:*;
if (!TypeIterator.isIterable(value)){
array = createIterableValue(type);
TypeIterator.push(array, value);
value = array;
};
return (value);
}
public function decodeAttribute(definition:XML, parent, value=undefined, restriction:XML=null):void{
var ref:QName;
var attributeName:QName;
var attributeFixed:String;
var attributeValue:*;
var attributeDefault:String;
var typeDefinition:XML;
var typeName:String;
var attributeType:QName;
var result:*;
if (definition.attribute("ref").length() == 1){
ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
definition = schemaManager.getNamedDefinition(ref, constants.attributeQName);
if (definition == null){
throw (new Error((("Cannot resolve attribute definition for '" + ref) + "'")));
};
};
var attributeNameString:String = definition.@name.toString();
var attributeUse:String = definition.attribute("use").toString();
if (attributeUse != "prohibited"){
attributeName = schemaManager.getQNameForAttribute(attributeNameString, getAttributeFromNode("form", definition));
attributeFixed = getAttributeFromNode("fixed", definition);
if (attributeFixed != null){
value = attributeFixed;
} else {
value = getAttribute(value, attributeName);
if (value === undefined){
attributeDefault = getAttributeFromNode("default", definition);
if (attributeDefault != null){
value = attributeDefault;
};
};
};
if (value !== undefined){
attributeValue = createContent();
typeName = getAttributeFromNode("type", definition);
if (typeName != null){
attributeType = schemaManager.getQNameForPrefixedName(definition.@type, definition);
} else {
attributeType = schemaManager.schemaDatatypes.anySimpleTypeQName;
};
if (attributeType != null){
if (isBuiltInType(attributeType)){
result = marshallBuiltInType(attributeType, attributeValue, attributeName, value, restriction);
setValue(attributeValue, attributeName, result);
} else {
typeDefinition = schemaManager.getNamedDefinition(attributeType, constants.simpleTypeQName);
if (typeDefinition != null){
decodeSimpleType(typeDefinition, attributeValue, attributeName, value, restriction);
} else {
throw (new Error(((("Cannot find simpleType " + attributeType) + " for attribute ") + attributeName)));
};
schemaManager.releaseScope();
};
} else {
typeDefinition = getSingleElementFromNode(definition, constants.simpleTypeQName);
if (typeDefinition != null){
decodeSimpleType(typeDefinition, attributeValue, attributeName, value, restriction);
} else {
if (value != null){
attributeValue = value;
};
};
};
};
if (attributeValue != null){
setAttribute(parent, attributeName, attributeValue);
};
};
if (ref != null){
schemaManager.releaseScope();
};
}
protected function getApplicableValues(parent, valueElements:XMLList, name:QName, context:DecodingContext, maxOccurs:uint):XMLList{
var applicableValues:XMLList = new XMLList();
var startIndex:uint = context.index;
var skipAhead:Boolean;
if ((((context.anyIndex > -1)) && (!((name == null))))){
startIndex = context.anyIndex;
skipAhead = true;
};
var i:uint = startIndex;
while (i < valueElements.length()) {
if (applicableValues.length() == maxOccurs){
break;
};
if ((((((name == null)) || ((valueElements[i].name() == name)))) || ((((((name.uri == "")) || ((name.uri == null)))) && ((name.localName == valueElements[i].name().localName)))))){
applicableValues = (applicableValues + valueElements[i]);
if (i < context.index){
parent[name.localName] = null;
};
skipAhead = false;
} else {
if (skipAhead == false){
break;
};
};
i++;
};
return (applicableValues);
}
public function decodeAttributeGroup(definition:XML, parent, value=undefined, restriction:XML=null):void{
var ref:QName;
var attribute:XML;
var attributeGroups:XMLList;
var attributeGroup:XML;
var anyAttribute:XML;
if (definition.attribute("ref").length() == 1){
ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
definition = schemaManager.getNamedDefinition(ref, constants.attributeGroupQName);
if (definition == null){
throw (new Error((("Cannot resolve attributeGroup definition for '" + ref) + "'")));
};
};
var attributes:XMLList = definition.elements(constants.attributeQName);
for each (attribute in attributes) {
decodeAttribute(attribute, parent, value, restriction);
};
attributeGroups = definition.elements(constants.attributeGroupQName);
for each (attributeGroup in attributeGroups) {
decodeAttributeGroup(attributeGroup, parent, value, restriction);
};
anyAttribute = getSingleElementFromNode(definition, constants.anyAttributeQName);
if (anyAttribute != null){
decodeAnyAttribute(anyAttribute, parent, value, restriction);
};
if (ref != null){
schemaManager.releaseScope();
};
}
public function decodeAll(definition:XML, parent, name:QName, valueElements:XMLList, context:DecodingContext=null, isRequired:Boolean=true):Boolean{
var childDefinition:XML;
if (context == null){
context = new DecodingContext();
};
var minOccurs:uint = getMinOccurs(definition);
var allElements:XMLList = definition.elements();
var hasSiblings:Boolean = (((allElements.length() > 1)) || (context.hasContextSiblings));
var requireChild:Boolean = ((isRequired) && ((minOccurs > 0)));
var groupSatisfied = !(requireChild);
for each (childDefinition in allElements) {
context.index = 0;
context.anyIndex = 0;
if (childDefinition.name() == constants.annotationQName){
groupSatisfied = true;
} else {
if (childDefinition.name() == constants.elementTypeQName){
if (!decodeGroupElement(childDefinition, parent, valueElements, context, requireChild, hasSiblings)){
break;
};
} else {
if (childDefinition.name() == constants.anyQName){
if (!decodeAnyElement(childDefinition, parent, name, valueElements, context, requireChild)){
break;
};
};
};
};
groupSatisfied = true;
};
return (groupSatisfied);
}
public function isSimpleValue(value):Boolean{
if ((value is XML)){
return (XML(value).hasSimpleContent());
};
if ((((((((((((((value is String)) || ((value is Number)))) || ((value is Boolean)))) || ((value is Date)))) || ((value is int)))) || ((value is uint)))) || ((value is ByteArray)))){
return (true);
};
return (false);
}
public function decodeSequence(definition:XML, parent, name:QName, valueElements:XMLList, context:DecodingContext=null, isRequired:Boolean=true):Boolean{
var sequenceOccurs:uint;
var requireChild:Boolean;
var sequenceSatisfied:Boolean;
var lastIndex:uint;
var childDefinition:XML;
if (context == null){
context = new DecodingContext();
};
var maxOccurs:uint = getMaxOccurs(definition);
var minOccurs:uint = getMinOccurs(definition);
if (maxOccurs == 0){
return (false);
};
if ((((((valueElements == null)) || ((valueElements.length() == 0)))) && ((minOccurs == 0)))){
return (true);
};
var sequenceElements:XMLList = definition.elements();
var hasSiblings:Boolean = (((sequenceElements.length() > 1)) || (context.hasContextSiblings));
if (sequenceElements.length() == 0){
return (true);
};
sequenceOccurs = 0;
while (sequenceOccurs < maxOccurs) {
requireChild = ((isRequired) && ((sequenceOccurs < minOccurs)));
sequenceSatisfied = true;
lastIndex = (context.index + 0);
for each (childDefinition in sequenceElements) {
sequenceSatisfied = false;
if (childDefinition.name() == constants.annotationQName){
sequenceSatisfied = true;
};
if (childDefinition.name() == constants.elementTypeQName){
if (!decodeGroupElement(childDefinition, parent, valueElements, context, requireChild, hasSiblings)){
break;
};
} else {
if (childDefinition.name() == constants.groupQName){
if (!decodeGroupReference(childDefinition, parent, name, valueElements, context, requireChild)){
break;
};
} else {
if (childDefinition.name() == constants.choiceQName){
if (!decodeChoice(childDefinition, parent, name, valueElements, context, requireChild)){
break;
};
} else {
if (childDefinition.name() == constants.sequenceQName){
if (!decodeSequence(childDefinition, parent, name, valueElements, context, requireChild)){
break;
};
} else {
if (childDefinition.name() == constants.anyQName){
if (!decodeAnyElement(childDefinition, parent, name, valueElements, context, requireChild)){
break;
};
};
};
};
};
};
sequenceSatisfied = true;
};
if (((!(sequenceSatisfied)) && (requireChild))){
if (strictOccurenceBounds){
throw (new Error((("Cannot find value for definition " + childDefinition.toXMLString()) + " in sequence.")));
};
return (false);
};
if (lastIndex == context.index){
if (sequenceSatisfied){
sequenceOccurs++;
sequenceOccurs = ((sequenceOccurs > minOccurs)) ? sequenceOccurs : minOccurs;
};
break;
};
sequenceOccurs++;
};
if (sequenceOccurs < minOccurs){
if (((isRequired) && (strictOccurenceBounds))){
throw (new Error((((((("Value supplied for sequence " + name.toString()) + " occurs ") + sequenceOccurs) + " times which falls short of minOccurs ") + minOccurs) + ".")));
};
return (false);
};
return (true);
}
public function setAttribute(parent, name, value):void{
var parentProxy:ContentProxy;
var existingContent:*;
var simpleContent:SimpleContent;
if ((parent is ContentProxy)){
parentProxy = (parent as ContentProxy);
if (parentProxy.object_proxy::isSimple){
existingContent = parentProxy.object_proxy::content;
if (!(existingContent is SimpleContent)){
simpleContent = new SimpleContent(existingContent);
parentProxy.object_proxy::content = simpleContent;
};
parentProxy.object_proxy::isSimple = false;
};
};
setValue(parent, name, value);
}
public function createContent(type:QName=null){
var c:Class;
var className:String;
var type = type;
var content:* = undefined;
if (((!((type == null))) && (!((typeRegistry == null))))){
c = typeRegistry.getClass(type);
if (c == null){
c = typeRegistry.getCollectionClass(type);
};
if (c != null){
content = new (c);
//unresolved jump
var _slot1 = e;
className = getQualifiedClassName(c);
log.debug("Unable to create new instance of Class '{0}' for type '{1}'.", className, type);
};
};
return (new ContentProxy(content, makeObjectsBindable));
}
override public function reset():void{
super.reset();
document = null;
}
public function getAttribute(parent, name){
var result:*;
var attribute:XMLList;
if ((parent is XML)){
attribute = XML(parent).attribute(name);
result = parseValue(name, attribute);
} else {
if ((parent is XMLList)){
attribute = XMLList(parent).attribute(name);
result = parseValue(name, attribute);
};
};
return (result);
}
public function decodeSimpleRestriction(restriction:XML, parent, name:QName, value):void{
var baseName:String;
var baseType:QName;
var simpleTypeDefinition:XML = getSingleElementFromNode(restriction, constants.simpleTypeQName);
if (simpleTypeDefinition != null){
decodeSimpleType(simpleTypeDefinition, parent, name, value, restriction);
} else {
baseName = getAttributeFromNode("base", restriction);
baseType = schemaManager.getQNameForPrefixedName(baseName, restriction);
decodeType(baseType, parent, name, value, restriction);
};
}
protected function setXSIType(value, type:QName):void{
if (((!((value == null))) && (recordXSIType))){
if ((value is ContentProxy)){
value = value.object_proxy::content;
};
if (value != null){
if ((value is ObjectProxy)){
ObjectProxy(value).object_proxy::type = type;
} else {
if ((value is IXMLSchemaInstance)){
IXMLSchemaInstance(value).xsiType = type;
};
};
};
};
}
public function decodeSimpleUnion(definition:XML, parent, name:QName, value, restriction:XML=null):void{
var type:QName;
var args:*;
var prefixedName:String;
var simpleType:QName;
var memberList:String = getAttributeFromNode("memberTypes", definition);
var memberArray:Array = memberList.split(" ");
var i:int;
while (i < memberArray.length) {
prefixedName = memberArray[i];
simpleType = schemaManager.getQNameForPrefixedName(prefixedName, definition);
if (!isBuiltInType(simpleType)){
args = getValue(value, simpleType);
if (args !== undefined){
type = simpleType;
break;
};
};
i++;
};
if (!type){
type = schemaManager.schemaDatatypes.stringQName;
};
var result:* = marshallBuiltInType(type, parent, name, value, restriction);
setValue(parent, name, result, type);
}
protected function getExistingValue(parent, propertyName:String){
var existingValue:*;
var classInfo:XML;
var properties:XMLList;
var property:XML;
var propertyType:String;
var tempValue:*;
var parent = parent;
var propertyName = propertyName;
var object:Object = Object(parent);
if ((parent is ContentProxy)){
object = ContentProxy(parent).object_proxy::content;
};
if ((object is ObjectProxy)){
object = ObjectProxy(object).object_proxy::object;
};
var className:String = getQualifiedClassName(object);
if (className == "Object"){
existingValue = parent[propertyName];
} else {
classInfo = DescribeTypeCache.describeType(object).typeDescription;
properties = (classInfo..accessor.(((@access == "readwrite")) && ((@name == propertyName))) + classInfo..variable.(@name == propertyName));
if (properties.length() > 0){
property = properties[0];
propertyType = property.@type;
tempValue = parent[propertyName];
if ((((((propertyType == "Object")) || ((propertyType == "*")))) || (TypeIterator.isIterable(tempValue)))){
existingValue = tempValue;
};
};
};
return (existingValue);
}
protected function getXSIType(value):QName{
var xsiType:QName;
var xml:XML;
var xsi:String;
if ((value is XML)){
xml = (value as XML);
} else {
if ((((value is XMLList)) && ((value.length() == 1)))){
xml = value[0];
};
};
if (xml != null){
xsi = XMLUtil.getAttributeByQName(xml, constants.typeAttrQName).toString();
if (((!((xsi == null))) && (!((xsi == ""))))){
xsiType = schemaManager.getQNameForPrefixedName(xsi, xml);
};
};
return (xsiType);
}
public function decode(xml, name:QName=null, type:QName=null, definition:XML=null){
var content:*;
var elementDefinition:XML;
var xml = xml;
var name = name;
var type = type;
var definition = definition;
if (((((!((xml is XML))) && (!((xml is XMLList))))) && (!((xml is String))))){
throw (new ArgumentError("The xml argument must be of type XML, XMLList or String."));
};
if ((xml is XML)){
document = xml;
} else {
if ((xml is XMLList)){
if (XMLList(xml).length() != 1){
throw (new ArgumentError("The xml argument must have a length of 1 when passed as an XMLList."));
};
document = XMLList(xml)[0];
} else {
if ((xml is String)){
document = new XML(xml);
//unresolved jump
var _slot1 = e;
throw (new ArgumentError(("The xml argument does not contain valid xml. " + xml)));
};
};
};
preProcessXML(document);
if (type != null){
content = createContent(type);
decodeType(type, content, name, document);
} else {
elementDefinition = definition;
if (elementDefinition == null){
elementDefinition = schemaManager.getNamedDefinition(name, constants.elementTypeQName);
};
if (elementDefinition == null){
content = createContent(type);
decodeType(constants.anyTypeQName, content, name, document);
} else {
content = decodeElementTopLevel(elementDefinition, name, document);
if (definition == null){
schemaManager.releaseScope();
};
};
};
if ((content is ContentProxy)){
content = ContentProxy(content).object_proxy::content;
};
return (content);
}
public function hasValue(parent, name):Boolean{
return (!((getValue(parent, name) === undefined)));
}
public function decodeAnyType(parent, name:QName, valueElements:XMLList):void{
var elementVal:XML;
var propertyName:QName;
var propertyVal:*;
var xsiType:QName;
for each (elementVal in valueElements) {
propertyName = (elementVal.name() as QName);
xsiType = getXSIType(elementVal);
if (xsiType != null){
propertyVal = createContent();
decodeType(schemaManager.schemaDatatypes.anyTypeQName, propertyVal, propertyName, elementVal);
} else {
propertyVal = marshallBuiltInType(schemaManager.schemaDatatypes.anyTypeQName, parent, propertyName, elementVal);
};
setValue(parent, propertyName, propertyVal, xsiType);
};
}
public function set makeObjectsBindable(value:Boolean):void{
_makeObjectsBindable = value;
}
public function decodeComplexExtension(definition:XML, parent, name:QName, value, context:DecodingContext=null):void{
var childDefinition:XML;
if (context == null){
context = new DecodingContext();
};
context.hasContextSiblings = true;
var baseName:String = getAttributeFromNode("base", definition);
if (baseName == null){
throw (new Error("A complexContent extension must declare a base type."));
};
var baseType:QName = schemaManager.getQNameForPrefixedName(baseName, definition);
var baseDefinition:XML = schemaManager.getNamedDefinition(baseType, constants.complexTypeQName);
if (baseDefinition == null){
throw (new Error((("Cannot find base type definition '" + baseType) + "'")));
};
decodeComplexType(baseDefinition, parent, name, value, null, context);
schemaManager.releaseScope();
var childElements:XMLList = definition.elements();
var valueElements:XMLList = new XMLList();
if ((value is XML)){
valueElements = (value as XML).elements();
} else {
if ((value is XMLList)){
valueElements = value;
};
};
for each (childDefinition in childElements) {
if (childDefinition.name() == constants.sequenceQName){
decodeSequence(childDefinition, parent, name, valueElements, context);
} else {
if (childDefinition.name() == constants.groupQName){
decodeGroupReference(childDefinition, parent, name, valueElements, context);
} else {
if (childDefinition.name() == constants.allQName){
decodeAll(childDefinition, parent, name, valueElements, context);
} else {
if (childDefinition.name() == constants.choiceQName){
decodeChoice(childDefinition, parent, name, valueElements, context);
} else {
if (childDefinition.name() == constants.attributeQName){
decodeAttribute(childDefinition, parent, value);
} else {
if (childDefinition.name() == constants.attributeGroupQName){
decodeAttributeGroup(childDefinition, parent, value);
} else {
if (childDefinition.name() == constants.anyAttributeQName){
decodeAnyAttribute(childDefinition, parent, value);
};
};
};
};
};
};
};
};
}
public function decodeSimpleList(definition:XML, parent, name:QName, value, restriction:XML=null):void{
var itemTypeQName:QName;
var itemDefinition:XML;
var item:*;
var tempValue:*;
var encodedItem:String;
var itemTypeAttribute:String = definition.@itemType;
if (itemTypeAttribute != ""){
itemTypeQName = schemaManager.getQNameForPrefixedName(itemTypeAttribute, definition);
} else {
itemDefinition = getSingleElementFromNode(definition, constants.simpleTypeQName);
};
var listValue:String = "";
if (!TypeIterator.isIterable(value)){
value = [value];
};
var iter:TypeIterator = new TypeIterator(value);
while (iter.hasNext()) {
item = iter.next();
tempValue = createContent();
if (itemTypeQName != null){
decodeType(itemTypeQName, tempValue, name, item, restriction);
} else {
decodeSimpleType(itemDefinition, tempValue, name, item, restriction);
};
encodedItem = ((tempValue)!=null) ? tempValue.toString() : "";
listValue = listValue.concat(encodedItem);
if (iter.hasNext()){
listValue = listValue.concat(" ");
};
};
setValue(parent, name, listValue, itemTypeQName);
}
}
}//package mx.rpc.xml
Section 191
//XMLEncoder (mx.rpc.xml.XMLEncoder)
package mx.rpc.xml {
import flash.utils.*;
import mx.collections.*;
import mx.utils.*;
public class XMLEncoder extends SchemaProcessor implements IXMLEncoder {
private var _xmlSpecialCharsFilter:Function;
private var _strictNillability:Boolean;// = false
public function XMLEncoder(){
_xmlSpecialCharsFilter = escapeXML;
super();
}
protected function deriveXSIType(parent:XML, type:QName, value):void{
}
public function appendValue(parent:XMLList, value):void{
parent[parent.length()] = value;
}
public function getAttribute(parent, name){
return (getValue(parent, name));
}
public function set strictNillability(strict:Boolean):void{
_strictNillability = strict;
}
public function encodeComplexType(definition:XML, parent:XML, name:QName, value, restriction:XML=null):void{
var childDefinition:XML;
var childElements:XMLList = definition.elements();
var children:XMLList = new XMLList();
for each (childDefinition in childElements) {
if (childDefinition.name() == constants.sequenceQName){
encodeSequence(childDefinition, children, name, value);
} else {
if (childDefinition.name() == constants.simpleContentQName){
encodeSimpleContent(childDefinition, parent, name, value, restriction);
} else {
if (childDefinition.name() == constants.complexContentQName){
encodeComplexContent(childDefinition, parent, name, value);
} else {
if (childDefinition.name() == constants.groupQName){
encodeGroupReference(childDefinition, children, name, value);
} else {
if (childDefinition.name() == constants.allQName){
encodeAll(childDefinition, children, name, value);
} else {
if (childDefinition.name() == constants.choiceQName){
encodeChoice(childDefinition, children, name, value);
} else {
if (childDefinition.name() == constants.attributeQName){
encodeAttribute(childDefinition, parent, name, value, restriction);
} else {
if (childDefinition.name() == constants.attributeGroupQName){
encodeAttributeGroup(childDefinition, parent, name, value, restriction);
} else {
if (childDefinition.name() == constants.anyAttributeQName){
encodeAnyAttribute(childDefinition, parent, name, value, restriction);
};
};
};
};
};
};
};
};
};
};
setValue(parent, children);
}
public function encode(value, name:QName=null, type:QName=null, definition:XML=null):XMLList{
var content:XML;
var elementDefinition:XML;
var mustReleaseScope:Boolean;
var result:XMLList = new XMLList();
if (name == null){
name = new QName("", "root");
};
if (type != null){
content = encodeXSINil(null, name, value);
if (content == null){
content = createElement(name);
if (value == null){
setValue(content, null);
} else {
encodeType(type, content, name, value);
};
};
} else {
elementDefinition = definition;
mustReleaseScope = false;
if (elementDefinition == null){
elementDefinition = schemaManager.getNamedDefinition(name, constants.elementTypeQName);
if (elementDefinition != null){
mustReleaseScope = true;
};
};
content = encodeElementTopLevel(elementDefinition, name, value);
if (mustReleaseScope){
schemaManager.releaseScope();
};
};
if (content != null){
result = (result + content);
};
return (result);
}
public function encodeXSINil(definition:XML, name:QName, value, isRequired:Boolean=true):XML{
var item:XML;
var nillable:Boolean;
if (strictNillability){
if (definition != null){
nillable = ((definition.@nillable.toString() == "true")) ? true : false;
} else {
nillable = false;
};
};
var fixedValue:String = getAttributeFromNode("fixed", definition);
if (((!(((strictNillability) && (nillable)))) && (!((fixedValue == null))))){
item = createElement(name);
setValue(item, schemaManager.marshall(fixedValue, schemaManager.schemaDatatypes.stringQName));
return (item);
};
if (value != null){
return (null);
};
var defaultValue:String = getAttributeFromNode("default", definition);
if ((((value == null)) && (!((defaultValue == null))))){
item = createElement(name);
setValue(item, schemaManager.marshall(defaultValue, schemaManager.schemaDatatypes.stringQName));
return (item);
};
if (((((nillable) && ((value === null)))) && ((isRequired == true)))){
item = createElement(name);
setValue(item, null);
return (item);
};
return (null);
}
public function resolveNamedProperty(parent, name){
var value:*;
var parent = parent;
var name = name;
var fallbackName:String;
if (!isSimpleValue(parent)){
value = parent[name];
if (value === undefined){
fallbackName = ("_" + name.toString());
};
//unresolved jump
var _slot1 = e;
fallbackName = ("_" + name.toString());
if (((!((fallbackName == null))) && (parent.hasOwnProperty(fallbackName)))){
value = parent[fallbackName];
};
};
return (value);
}
public function containsNodeByName(list:XMLList, name:QName, strict:Boolean=false):Boolean{
var node:XML;
var currentURI:String = schemaManager.currentSchema.targetNamespace.uri;
for each (node in list) {
if (((strict) || (((!((name.uri == ""))) && (!((name.uri == null))))))){
if ((((node.name().uri == "")) && ((currentURI == name.uri)))){
if (node.name().localName == name.localName){
return (true);
};
} else {
if (node.name() == name){
return (true);
};
};
} else {
if (node.name().localName == name.localName){
return (true);
};
};
};
return (false);
}
public function encodeComplexExtension(definition:XML, parent:XML, name:QName, value):void{
var childDefinition:XML;
var extension:XML;
var baseName:String = getAttributeFromNode("base", definition);
if (baseName == null){
throw (new Error("A complexContent extension must declare a base type."));
};
var baseType:QName = schemaManager.getQNameForPrefixedName(baseName, definition);
var baseDefinition:XML = schemaManager.getNamedDefinition(baseType, constants.complexTypeQName);
if (baseDefinition == null){
throw (new Error((("Cannot find base type definition '" + baseType) + "'")));
};
encodeComplexType(baseDefinition, parent, name, value);
schemaManager.releaseScope();
var childDefinitions:XMLList = definition.elements();
var extChildren:XMLList = new XMLList();
for each (childDefinition in childDefinitions) {
if (childDefinition.name() == constants.sequenceQName){
encodeSequence(childDefinition, extChildren, name, value);
} else {
if (childDefinition.name() == constants.groupQName){
encodeGroupReference(childDefinition, extChildren, name, value);
} else {
if (childDefinition.name() == constants.allQName){
encodeAll(childDefinition, extChildren, name, value);
} else {
if (childDefinition.name() == constants.choiceQName){
encodeChoice(childDefinition, extChildren, name, value);
} else {
if (childDefinition.name() == constants.attributeQName){
encodeAttribute(childDefinition, parent, name, value);
} else {
if (childDefinition.name() == constants.attributeGroupQName){
encodeAttributeGroup(childDefinition, parent, name, value);
} else {
if (childDefinition.name() == constants.anyAttributeQName){
encodeAnyAttribute(childDefinition, parent, name, value);
};
};
};
};
};
};
};
};
for each (extension in extChildren) {
delete parent[extension.name()];
delete parent[new QName("", extension.name().localName)];
delete parent[new QName(null, extension.name().localName)];
};
setValue(parent, extChildren);
}
public function encodeSimpleList(definition:XML, parent:XML, name:QName, value, restriction:XML=null):void{
var itemTypeQName:QName;
var itemDefinition:XML;
var item:*;
var tempElement:*;
var itemTypeAttribute:String = definition.@itemType;
if (itemTypeAttribute != ""){
itemTypeQName = schemaManager.getQNameForPrefixedName(itemTypeAttribute, definition);
} else {
itemDefinition = getSingleElementFromNode(definition, constants.simpleTypeQName);
};
var listValue:String = "";
if (!TypeIterator.isIterable(value)){
value = [value];
};
var iter:TypeIterator = new TypeIterator(value);
while (iter.hasNext()) {
item = iter.next();
tempElement = <temp/>
;
if (item == null){
} else {
if (itemTypeQName != null){
encodeType(itemTypeQName, tempElement, name, item, restriction);
} else {
encodeSimpleType(itemDefinition, tempElement, name, item, restriction);
};
listValue = listValue.concat(tempElement.toString());
if (iter.hasNext()){
listValue = listValue.concat(" ");
};
};
};
setValue(parent, listValue);
}
public function hasAttribute(parent, name):Boolean{
return (!((getAttribute(parent, name) === undefined)));
}
public function encodeAll(definition:XML, parent:XMLList, name:QName, value, isRequired:Boolean=true):Boolean{
return (encodeSequence(definition, parent, name, value, isRequired));
}
public function encodeAttribute(definition:XML, parent:XML, name:QName, value=undefined, restriction:XML=null):void{
var ref:QName;
var attributeName:QName;
var attributeFixed:String;
var tempElement:*;
var attributeFound:Boolean;
var attributeDefault:String;
var typeDefinition:XML;
var typeName:String;
var attributeType:QName;
if (definition.attribute("ref").length() == 1){
ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
definition = schemaManager.getNamedDefinition(ref, constants.attributeQName);
if (definition == null){
throw (new Error((("Cannot resolve attribute definition for '" + ref) + "'")));
};
};
var attributeNameString:String = definition.@name.toString();
var attributeUse:String = definition.attribute("use").toString();
if (attributeUse != "prohibited"){
attributeName = schemaManager.getQNameForAttribute(attributeNameString, getAttributeFromNode("form", definition));
attributeFixed = getAttributeFromNode("fixed", definition);
if (attributeFixed != null){
value = attributeFixed;
} else {
value = getValue(value, attributeName);
if (value === undefined){
attributeDefault = getAttributeFromNode("default", definition);
if (attributeDefault != null){
value = attributeDefault;
};
};
};
if (value !== undefined){
tempElement = <temp/>
;
typeName = getAttributeFromNode("type", definition);
if (typeName != null){
attributeType = schemaManager.getQNameForPrefixedName(definition.@type, definition);
} else {
attributeType = schemaManager.schemaDatatypes.anySimpleTypeQName;
};
if (attributeType != null){
if (isBuiltInType(attributeType)){
tempElement.appendChild(schemaManager.marshall(value, attributeType, restriction));
} else {
typeDefinition = schemaManager.getNamedDefinition(attributeType, constants.simpleTypeQName);
if (typeDefinition != null){
encodeSimpleType(typeDefinition, tempElement, attributeName, value, restriction);
} else {
throw (new Error(((("Cannot find simpleType " + attributeType) + " for attribute ") + attributeName)));
};
schemaManager.releaseScope();
};
} else {
typeDefinition = getSingleElementFromNode(definition, constants.simpleTypeQName);
if (typeDefinition != null){
encodeSimpleType(typeDefinition, tempElement, attributeName, value, restriction);
} else {
if (value != null){
tempElement.appendChild(value.toString());
};
};
};
};
if (tempElement !== undefined){
setAttribute(parent, attributeName, tempElement);
};
};
if (ref != null){
schemaManager.releaseScope();
};
}
public function setValue(parent, value):void{
var currentChild:XML;
if (value !== undefined){
if ((parent is XML)){
currentChild = (parent as XML);
} else {
if ((((parent is XMLList)) && ((parent.length() > 0)))){
currentChild = parent[(parent.length() - 1)];
};
};
if (currentChild != null){
if (value === null){
currentChild.@[schemaManager.schemaConstants.nilQName] = "true";
currentChild.addNamespace(constants.xsiNamespace);
} else {
if ((((value is XML)) || ((value is XMLList)))){
currentChild.appendChild(value);
} else {
if (value !== undefined){
currentChild.appendChild(xmlSpecialCharsFilter(Object(value)));
};
};
};
};
};
}
public function getProperties(value):Array{
var classInfo:Object = ObjectUtil.getClassInfo((value as Object), null, {includeReadOnly:false});
return (classInfo.properties);
}
public function encodeComplexRestriction(restriction:XML, parent:XML, name:QName, value):void{
var childDefinition:XML;
var baseName:String = getAttributeFromNode("base", restriction);
if (baseName == null){
throw (new Error("A complexContent restriction must declare a base type."));
};
var baseType:QName = schemaManager.getQNameForPrefixedName(baseName, restriction);
var childDefinitions:XMLList = restriction.elements();
var children:XMLList = parent.elements();
for each (childDefinition in childDefinitions) {
if (childDefinition.name() == constants.sequenceQName){
encodeSequence(childDefinition, children, name, value);
} else {
if (childDefinition.name() == constants.groupQName){
encodeGroupReference(childDefinition, children, name, value);
} else {
if (childDefinition.name() == constants.allQName){
encodeAll(childDefinition, children, name, value);
} else {
if (childDefinition.name() == constants.choiceQName){
encodeChoice(childDefinition, children, name, value);
} else {
if (childDefinition.name() == constants.attributeQName){
encodeAttribute(childDefinition, parent, name, value, restriction);
} else {
if (childDefinition.name() == constants.attributeGroupQName){
encodeAttributeGroup(childDefinition, parent, name, value, restriction);
} else {
if (childDefinition.name() == constants.anyAttributeQName){
encodeAnyAttribute(childDefinition, parent, name, value, restriction);
};
};
};
};
};
};
};
};
parent.setChildren(children);
}
public function get xmlSpecialCharsFilter():Function{
return (_xmlSpecialCharsFilter);
}
public function encodeAnyElement(definition:XML, siblings:XMLList, name:QName, value, isRequired:Boolean=true, encodedVals:Dictionary=null):Boolean{
var item:XML;
var arrValue:*;
var arrayItem:*;
var arrayChildren:XMLList;
var objProperty:Object;
var propValue:*;
var propQName:QName;
var propItem:XML;
var propChildren:XMLList;
var maxOccurs:uint = getMaxOccurs(definition);
var minOccurs:uint = getMinOccurs(definition);
if (isSimpleValue(value)){
item = createElement(name);
setValue(item, value);
appendValue(siblings, item);
} else {
if ((((value is XML)) || ((value is XMLList)))){
appendValue(siblings, value);
} else {
if (encodedVals == null){
encodedVals = new Dictionary(true);
};
if (!(value is QName)){
if (encodedVals[value] != null){
throw (new Error("Cannot encode complex structure. Cyclic references detected."));
};
encodedVals[value] = true;
};
if ((((value is Array)) || ((value is IList)))){
if ((value is IList)){
value = IList(value).toArray();
};
for each (arrValue in (value as Array)) {
arrayItem = createElement(name);
if (arrValue == null){
setValue(arrayItem, null);
} else {
if (arrValue != null){
arrayChildren = new XMLList();
encodeAnyElement(definition, arrayChildren, name, arrValue, isRequired, encodedVals);
if (isSimpleValue(arrValue)){
arrayItem = arrayChildren[0];
} else {
setValue(arrayItem, arrayChildren);
};
};
};
appendValue(siblings, arrayItem);
};
} else {
for each (objProperty in getProperties(value)) {
propValue = getValue(value, objProperty);
propQName = new QName(name.uri, objProperty);
if (!containsNodeByName(siblings, propQName)){
propItem = encodeXSINil(definition, propQName, propValue);
if (propItem != null){
appendValue(siblings, propItem);
} else {
if (propValue != null){
propChildren = new XMLList();
encodeAnyElement(definition, propChildren, propQName, propValue, isRequired, encodedVals);
appendValue(siblings, propChildren);
};
};
};
};
};
delete encodedVals[value];
};
};
return (true);
}
public function getSimpleValue(parent, name){
var simpleValue:* = getValue(parent, name);
if (simpleValue === undefined){
simpleValue = getValue(parent, "_value");
};
return (simpleValue);
}
public function getValue(parent, name){
var value:*;
var node:XMLList;
if ((((parent is XML)) || ((parent is XMLList)))){
node = parent[name];
if (node.length() > 0){
value = node;
};
} else {
if (TypeIterator.isIterable(parent)){
if (((parent.hasOwnProperty(name)) && (!((parent[name] === undefined))))){
value = resolveNamedProperty(parent, name);
} else {
value = parent;
};
} else {
if (!isSimpleValue(parent)){
if ((name is QName)){
name = QName(name).localName;
};
value = resolveNamedProperty(parent, name);
} else {
value = parent;
};
};
};
return (value);
}
public function encodeGroupReference(definition:XML, parent:XMLList, name:QName, value, isRequired:Boolean=true):Boolean{
var ref:QName;
var childDefinition:XML;
if (definition.attribute("ref").length() == 1){
ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
definition = schemaManager.getNamedDefinition(ref, constants.groupQName);
if (definition == null){
throw (new Error((("Cannot resolve group definition for '" + ref) + "'")));
};
} else {
throw (new Error("A group reference element must have the ref attribute"));
};
var groupElements:XMLList = definition.elements();
var groupSatisfied:Boolean;
for each (childDefinition in groupElements) {
if (childDefinition.name() == constants.sequenceQName){
groupSatisfied = encodeSequence(childDefinition, parent, name, value, isRequired);
} else {
if (childDefinition.name() == constants.allQName){
groupSatisfied = encodeAll(childDefinition, parent, name, value, isRequired);
} else {
if (childDefinition.name() == constants.choiceQName){
groupSatisfied = encodeChoice(childDefinition, parent, name, value, isRequired);
};
};
};
};
schemaManager.releaseScope();
return (groupSatisfied);
}
public function encodeSimpleRestriction(restriction:XML, parent:XML, name:QName, value):void{
var baseName:String;
var baseType:QName;
var simpleTypeDefinition:XML = getSingleElementFromNode(restriction, constants.simpleTypeQName);
if (simpleTypeDefinition != null){
encodeSimpleType(simpleTypeDefinition, parent, name, value, restriction);
} else {
baseName = getAttributeFromNode("base", restriction);
baseType = schemaManager.getQNameForPrefixedName(baseName, restriction);
encodeType(baseType, parent, name, value, restriction);
};
}
public function encodeAnyAttribute(definition:XML, parent:XML, name:QName, value=undefined, restriction:XML=null):void{
var propertyName:Object;
var attributeValue:*;
if (value !== undefined){
if (((!(isSimpleValue(value))) && (!((value is Array))))){
for (propertyName in getProperties(value)) {
if (((!(hasAttribute(value, propertyName))) && (!(hasValue(value, propertyName))))){
attributeValue = getAttribute(value, propertyName);
if (attributeValue != null){
setAttribute(parent, propertyName, attributeValue);
};
};
};
};
};
}
public function encodeSimpleUnion(definition:XML, parent:XML, name:QName, value, restriction:XML=null):void{
var type:QName;
var args:*;
var prefixedName:String;
var simpleType:QName;
var memberList:String = getAttributeFromNode("memberTypes", definition);
var memberArray:Array = memberList.split(" ");
var i:int;
while (i < memberArray.length) {
prefixedName = memberArray[i];
simpleType = schemaManager.getQNameForPrefixedName(prefixedName, definition);
if (!isBuiltInType(simpleType)){
args = getValue(value, simpleType);
if (args !== undefined){
type = simpleType;
break;
};
};
i++;
};
if (!type){
type = schemaManager.schemaDatatypes.stringQName;
};
setValue(parent, schemaManager.marshall(value, type, restriction));
}
public function encodeSimpleType(definition:XML, parent:XML, name:QName, value, restriction:XML=null):void{
var definitionChild:XML = getSingleElementFromNode(definition, constants.restrictionQName, constants.listQName, constants.unionQName);
if (definitionChild.name() == constants.restrictionQName){
encodeSimpleRestriction(definitionChild, parent, name, value);
} else {
if (definitionChild.name() == constants.listQName){
encodeSimpleList(definitionChild, parent, name, value, restriction);
} else {
if (definitionChild.name() == constants.listQName){
encodeSimpleUnion(definitionChild, parent, name, value, restriction);
};
};
};
}
public function get strictNillability():Boolean{
return (_strictNillability);
}
public function encodeElementTopLevel(definition:XML, elementQName:QName, value):XML{
var typeQName:QName;
var typeDefinition:XML;
var element:XML = encodeXSINil(definition, elementQName, value);
if (element != null){
return (element);
};
if (value == null){
return (null);
};
element = createElement(elementQName);
var typeAttribute:String = getAttributeFromNode("type", definition);
if (typeAttribute != null){
typeQName = schemaManager.getQNameForPrefixedName(typeAttribute, definition);
encodeType(typeQName, element, elementQName, value);
} else {
if (((!((definition == null))) && (definition.hasComplexContent()))){
typeDefinition = getSingleElementFromNode(definition, constants.complexTypeQName, constants.simpleTypeQName);
if (typeDefinition.name() == constants.complexTypeQName){
encodeComplexType(typeDefinition, element, elementQName, value);
} else {
if (typeDefinition.name() == constants.simpleTypeQName){
encodeSimpleType(typeDefinition, element, elementQName, value);
};
};
} else {
encodeType(constants.anyTypeQName, element, elementQName, value);
};
};
return (element);
}
private function escapeXML(value:Object):String{
var str:String = value.toString();
str = str.replace(/&/g, "&").replace(/</g, "<");
return (str);
}
public function encodeChoice(definition:XML, parent:XMLList, name:QName, value, isRequired:Boolean=true):Boolean{
var lastIndex:uint;
var choiceOccurs:uint;
var childDefinition:XML;
var maxOccurs:uint = getMaxOccurs(definition);
var minOccurs:uint = getMinOccurs(definition);
if (maxOccurs == 0){
return (false);
};
if ((((value == null)) && ((minOccurs == 0)))){
return (true);
};
var choiceElements:XMLList = definition.elements();
var choiceSatisfied:Boolean;
if (choiceElements.length() > 0){
choiceSatisfied = false;
};
for each (childDefinition in choiceElements) {
if (childDefinition.name() == constants.elementTypeQName){
choiceSatisfied = ((encodeGroupElement(childDefinition, parent, name, value, false)) || (choiceSatisfied));
} else {
if (childDefinition.name() == constants.sequenceQName){
choiceSatisfied = ((encodeSequence(childDefinition, parent, name, value, false)) || (choiceSatisfied));
} else {
if (childDefinition.name() == constants.groupQName){
choiceSatisfied = ((encodeGroupReference(childDefinition, parent, name, value, false)) || (choiceSatisfied));
} else {
if (childDefinition.name() == constants.choiceQName){
choiceSatisfied = ((encodeChoice(childDefinition, parent, name, value, false)) || (choiceSatisfied));
} else {
if (childDefinition.name() == constants.anyQName){
choiceSatisfied = ((encodeAnyElement(childDefinition, parent, name, value, false)) || (choiceSatisfied));
};
};
};
};
};
};
return (choiceSatisfied);
}
public function setAttribute(parent:XML, name, value):void{
if (value != null){
parent.@[name] = value.toString();
};
}
public function isSimpleValue(value):Boolean{
if ((((((((((((((value is String)) || ((value is Number)))) || ((value is Boolean)))) || ((value is Date)))) || ((value is int)))) || ((value is uint)))) || ((value is ByteArray)))){
return (true);
};
return (false);
}
public function encodeComplexContent(definition:XML, parent:XML, name:QName, value):void{
var childDefinition:XML = getSingleElementFromNode(definition, constants.extensionQName, constants.restrictionQName);
if (childDefinition.name() == constants.extensionQName){
encodeComplexExtension(childDefinition, parent, name, value);
} else {
if (childDefinition.name() == constants.restrictionQName){
encodeComplexRestriction(childDefinition, parent, name, value);
};
};
}
public function createElement(name):XML{
var element:XML;
var elementName:QName;
var prefix:String;
var ns:Namespace;
if ((name is QName)){
elementName = (name as QName);
} else {
elementName = new QName("", name.toString());
};
element = new XML((("<" + elementName.localName) + "/>"));
if (((!((elementName.uri == null))) && ((elementName.uri.length > 0)))){
prefix = schemaManager.getOrCreatePrefix(elementName.uri);
ns = new Namespace(prefix, elementName.uri);
element.setNamespace(ns);
};
return (element);
}
protected function setXSIType(parent:XML, type:QName):void{
var namespaceURI:String = type.uri;
var prefix:String = schemaManager.getOrCreatePrefix(namespaceURI);
var prefixNamespace:Namespace = new Namespace(prefix, namespaceURI);
parent.addNamespace(prefixNamespace);
parent.@[constants.getXSIToken(constants.typeAttrQName)] = ((prefix + ":") + type.localName);
}
public function encodeGroupElement(definition:XML, siblings:XMLList, name:QName, value, isRequired:Boolean=true):Boolean{
var ref:QName;
var encodedElement:XML;
var valueOccurence:uint;
var iter:TypeIterator;
var i:uint;
var item:*;
var maxOccurs:uint = getMaxOccurs(definition);
var minOccurs:uint = getMinOccurs(definition);
isRequired = ((isRequired) && ((minOccurs > 0)));
if (definition.attribute("ref").length() == 1){
ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
definition = schemaManager.getNamedDefinition(ref, constants.elementTypeQName);
if (definition == null){
throw (new Error((("Cannot resolve element definition for ref '" + ref) + "'")));
};
};
if (maxOccurs == 0){
return (true);
};
var elementName:String = definition.@name.toString();
var elementQName:QName = schemaManager.getQNameForElement(elementName, getAttributeFromNode("form", definition));
var elementValue:* = getValue(value, elementQName);
if (elementValue == null){
encodedElement = encodeElementTopLevel(definition, elementQName, elementValue);
if (encodedElement != null){
appendValue(siblings, encodedElement);
};
if (((isRequired) && ((encodedElement == null)))){
return (false);
};
return (true);
};
if (maxOccurs == 1){
encodedElement = encodeElementTopLevel(definition, elementQName, elementValue);
if (encodedElement != null){
appendValue(siblings, encodedElement);
};
} else {
if (maxOccurs > 1){
valueOccurence = getValueOccurence(elementValue);
if (valueOccurence < minOccurs){
throw (new Error((((((("Value supplied for element '" + elementQName) + "' occurs ") + valueOccurence) + " times which falls short of minOccurs ") + minOccurs) + ".")));
};
if (valueOccurence > maxOccurs){
throw (new Error((((((("Value supplied for element of type '" + elementQName) + "' occurs ") + valueOccurence) + " times which exceeds maxOccurs ") + maxOccurs) + ".")));
};
if (!TypeIterator.isIterable(elementValue)){
elementValue = [elementValue];
};
iter = new TypeIterator(elementValue);
i = 0;
while ((((i < maxOccurs)) && ((i < valueOccurence)))) {
if (iter.hasNext()){
item = iter.next();
} else {
if (i > minOccurs){
break;
};
};
encodedElement = encodeElementTopLevel(definition, elementQName, item);
if (encodedElement == null){
encodedElement = createElement(elementQName);
setValue(encodedElement, null);
};
appendValue(siblings, encodedElement);
i++;
};
};
};
if (ref != null){
schemaManager.releaseScope();
};
return (true);
}
public function set xmlSpecialCharsFilter(func:Function):void{
if (func != null){
_xmlSpecialCharsFilter = func;
} else {
_xmlSpecialCharsFilter = escapeXML;
};
}
public function encodeType(type:QName, parent:XML, name:QName, value, restriction:XML=null):void{
var children:XMLList;
var definitionType:QName;
var xsiType:QName = getXSIType(value);
if (xsiType != null){
type = xsiType;
};
var definition:XML = schemaManager.getNamedDefinition(type, constants.complexTypeQName, constants.simpleTypeQName);
if (isBuiltInType(type)){
if ((((type == constants.anyTypeQName)) && (!(isSimpleValue(value))))){
children = new XMLList();
encodeAnyElement(definition, children, name, value);
setValue(parent, children);
} else {
setValue(parent, schemaManager.marshall(value, type, restriction));
};
deriveXSIType(parent, type, value);
} else {
if (definition == null){
throw (new Error((("Cannot find definition for type '" + type) + "'")));
};
definitionType = (definition.name() as QName);
if (definitionType == constants.complexTypeQName){
encodeComplexType(definition, parent, name, value, restriction);
} else {
if (definitionType == constants.simpleTypeQName){
encodeSimpleType(definition, parent, name, value, restriction);
} else {
throw (new Error(("Invalid type definition " + definitionType)));
};
};
};
if (definition != null){
schemaManager.releaseScope();
};
}
public function encodeSimpleContent(definition:XML, parent:XML, name:QName, value, restriction:XML=null):void{
var baseName:String;
var baseType:QName;
var simpleValue:*;
var baseDefinition:XML;
var extensions:XMLList;
var extensionChild:XML;
var childDefinition:XML = getSingleElementFromNode(definition, constants.extensionQName, constants.restrictionQName);
if (childDefinition != null){
baseName = getAttributeFromNode("base", childDefinition);
if (baseName == null){
throw (new Error("A simpleContent extension or restriction must declare a base type."));
};
baseType = schemaManager.getQNameForPrefixedName(baseName, childDefinition);
if (!isBuiltInType(baseType)){
baseDefinition = schemaManager.getNamedDefinition(baseType, constants.complexTypeQName, constants.simpleTypeQName);
if (baseDefinition == null){
throw (new Error((("Cannot find base type definition '" + baseType) + "'")));
};
schemaManager.releaseScope();
};
if (childDefinition.name() == constants.extensionQName){
if (isBuiltInType(baseType)){
simpleValue = getSimpleValue(value, name);
setValue(parent, schemaManager.marshall(simpleValue, baseType, restriction));
} else {
encodeType(baseType, parent, value, restriction);
};
extensions = childDefinition.elements();
for each (extensionChild in extensions) {
if (extensionChild.name() == constants.attributeQName){
encodeAttribute(extensionChild, parent, name, value, restriction);
} else {
if (extensionChild.name() == constants.attributeGroupQName){
encodeAttributeGroup(extensionChild, parent, name, value, restriction);
} else {
if (extensionChild.name() == constants.anyAttributeQName){
encodeAnyAttribute(extensionChild, parent, name, value, restriction);
};
};
};
};
} else {
if (childDefinition.name() == constants.restrictionQName){
simpleValue = getSimpleValue(value, name);
encodeSimpleRestriction(childDefinition, parent, name, simpleValue);
};
};
};
}
protected function getXSIType(value):QName{
var xsiType:QName;
if (value != null){
if ((((value is ObjectProxy)) && (!((value.object_proxy::type == null))))){
xsiType = value.object_proxy::type;
} else {
if ((((value is IXMLSchemaInstance)) && (!((IXMLSchemaInstance(value).xsiType == null))))){
xsiType = IXMLSchemaInstance(value).xsiType;
};
};
};
return (xsiType);
}
public function hasValue(parent, name):Boolean{
return (!((getValue(parent, name) === undefined)));
}
public function encodeAttributeGroup(definition:XML, parent:XML, name:QName, value=undefined, restriction:XML=null):void{
var ref:QName;
var attributeDefinition:XML;
var attributeGroups:XMLList;
var attributeGroup:XML;
var anyAttribute:XML;
if (definition.attribute("ref").length() == 1){
ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
definition = schemaManager.getNamedDefinition(ref, constants.attributeGroupQName);
if (definition == null){
throw (new Error((("Cannot resolve attributeGroup definition for '" + ref) + "'")));
};
};
var attributes:XMLList = definition.elements(constants.attributeQName);
for each (attributeDefinition in attributes) {
encodeAttribute(attributeDefinition, parent, name, value, restriction);
};
attributeGroups = definition.elements(constants.attributeGroupQName);
for each (attributeGroup in attributeGroups) {
encodeAttributeGroup(attributeGroup, parent, name, value, restriction);
};
anyAttribute = getSingleElementFromNode(definition, constants.anyAttributeQName);
if (anyAttribute != null){
encodeAnyAttribute(anyAttribute, parent, name, value, restriction);
};
if (ref != null){
schemaManager.releaseScope();
};
}
public function encodeSequence(definition:XML, siblings:XMLList, name:QName, value, isRequired:Boolean=true):Boolean{
var childDefinition:XML;
var maxOccurs:uint = getMaxOccurs(definition);
var minOccurs:uint = getMinOccurs(definition);
if (maxOccurs == 0){
return (true);
};
if ((((value == null)) && ((minOccurs == 0)))){
return (true);
};
var sequenceElements:XMLList = definition.elements();
var requireChild:Boolean = ((isRequired) && ((minOccurs > 0)));
var sequenceSatisfied:Boolean;
for each (childDefinition in sequenceElements) {
sequenceSatisfied = false;
if (childDefinition.name() == constants.elementTypeQName){
if (!encodeGroupElement(childDefinition, siblings, name, value, isRequired)){
break;
};
} else {
if (childDefinition.name() == constants.groupQName){
if (!encodeGroupReference(childDefinition, siblings, name, value, isRequired)){
break;
};
} else {
if (childDefinition.name() == constants.choiceQName){
if (!encodeChoice(childDefinition, siblings, name, value, isRequired)){
break;
};
} else {
if (childDefinition.name() == constants.sequenceQName){
if (!encodeSequence(childDefinition, siblings, name, value, isRequired)){
break;
};
} else {
if (childDefinition.name() == constants.anyQName){
if (!encodeAnyElement(childDefinition, siblings, name, value, isRequired)){
break;
};
};
};
};
};
};
sequenceSatisfied = true;
};
return (((sequenceSatisfied) || (!(isRequired))));
}
}
}//package mx.rpc.xml
Section 192
//Fault (mx.rpc.Fault)
package mx.rpc {
public class Fault extends Error {
public var rootCause:Object;
protected var _faultCode:String;
protected var _faultString:String;
protected var _faultDetail:String;
public function Fault(faultCode:String, faultString:String, faultDetail:String=null){
super((((((("faultCode:" + faultCode) + " faultString:'") + faultString) + "' faultDetail:'") + faultDetail) + "'"));
this._faultCode = faultCode;
this._faultString = (faultString) ? faultString : "";
this._faultDetail = faultDetail;
}
public function toString():String{
var s:String = "[RPC Fault";
s = (s + ((" faultString=\"" + faultString) + "\""));
s = (s + ((" faultCode=\"" + faultCode) + "\""));
s = (s + ((" faultDetail=\"" + faultDetail) + "\"]"));
return (s);
}
public function get faultCode():String{
return (_faultCode);
}
public function get faultString():String{
return (_faultString);
}
public function get faultDetail():String{
return (_faultDetail);
}
}
}//package mx.rpc
Section 193
//IResponder (mx.rpc.IResponder)
package mx.rpc {
public interface IResponder {
function fault(:Object):void;
function result(:Object):void;
}
}//package mx.rpc
Section 194
//ArrayUtil (mx.utils.ArrayUtil)
package mx.utils {
import mx.core.*;
public class ArrayUtil {
mx_internal static const VERSION:String = "3.0.0.0";
public function ArrayUtil(){
super();
}
public static function getItemIndex(item:Object, source:Array):int{
var n:int = source.length;
var i:int;
while (i < n) {
if (source[i] === item){
return (i);
};
i++;
};
return (-1);
}
public static function toArray(obj:Object):Array{
if (!obj){
return ([]);
};
if ((obj is Array)){
return ((obj as Array));
};
return ([obj]);
}
}
}//package mx.utils
Section 195
//Base64Decoder (mx.utils.Base64Decoder)
package mx.utils {
import mx.resources.*;
import flash.utils.*;
public class Base64Decoder {
private var filled:int;// = 0
private var data:ByteArray;
private var count:int;// = 0
private var work:Array;
private var resourceManager:IResourceManager;
private static const ESCAPE_CHAR_CODE:Number = 61;
private static const inverse:Array = [64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64];
public function Base64Decoder(){
work = [0, 0, 0, 0];
resourceManager = ResourceManager.getInstance();
super();
data = new ByteArray();
}
public function flush():ByteArray{
var message:String;
if (count > 0){
message = resourceManager.getString("utils", "partialBlockDropped", [count]);
throw (new Error(message));
};
return (drain());
}
public function reset():void{
data = new ByteArray();
count = 0;
filled = 0;
}
public function decode(encoded:String):void{
var c:Number;
var i:uint;
for (;i < encoded.length;i++) {
c = encoded.charCodeAt(i);
if (c == ESCAPE_CHAR_CODE){
var _local4 = count++;
work[_local4] = -1;
} else {
if (inverse[c] != 64){
_local4 = count++;
work[_local4] = inverse[c];
} else {
continue;
};
};
if (count == 4){
count = 0;
data.writeByte(((work[0] << 2) | ((work[1] & 0xFF) >> 4)));
filled++;
if (work[2] == -1){
break;
};
data.writeByte(((work[1] << 4) | ((work[2] & 0xFF) >> 2)));
filled++;
if (work[3] == -1){
break;
};
data.writeByte(((work[2] << 6) | work[3]));
filled++;
};
};
}
public function toByteArray():ByteArray{
var result:ByteArray = flush();
reset();
return (result);
}
public function drain():ByteArray{
var result:ByteArray = new ByteArray();
copyByteArray(data, result, filled);
filled = 0;
return (result);
}
private static function copyByteArray(source:ByteArray, destination:ByteArray, length:uint=0):void{
var oldPosition:int = source.position;
source.position = 0;
destination.position = 0;
var i:uint;
while ((((source.bytesAvailable > 0)) && ((i < length)))) {
destination.writeByte(source.readByte());
i++;
};
source.position = oldPosition;
destination.position = 0;
}
}
}//package mx.utils
Section 196
//Base64Encoder (mx.utils.Base64Encoder)
package mx.utils {
import flash.utils.*;
public class Base64Encoder {
private var _line:uint;
private var _count:uint;
private var _buffers:Array;
public var insertNewLines:Boolean;// = true
private var _work:Array;
public static const MAX_BUFFER_SIZE:uint = 32767;
private static const ALPHABET_CHAR_CODES:Array = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47];
public static const CHARSET_UTF_8:String = "UTF-8";
private static const ESCAPE_CHAR_CODE:Number = 61;
public static var newLine:int = 10;
public function Base64Encoder(){
_work = [0, 0, 0];
super();
reset();
}
public function flush():String{
if (_count > 0){
encodeBlock();
};
var result:String = drain();
reset();
return (result);
}
public function toString():String{
return (flush());
}
public function reset():void{
_buffers = [];
_buffers.push([]);
_count = 0;
_line = 0;
_work[0] = 0;
_work[1] = 0;
_work[2] = 0;
}
public function encodeBytes(data:ByteArray, offset:uint=0, length:uint=0):void{
if (length == 0){
length = data.length;
};
var oldPosition:uint = data.position;
data.position = offset;
var plainIndex:uint = offset;
while (plainIndex < length) {
_work[_count] = data[plainIndex];
_count++;
if ((((_count == _work.length)) || ((((offset + length) - plainIndex) == 1)))){
encodeBlock();
_count = 0;
_work[0] = 0;
_work[1] = 0;
_work[2] = 0;
};
plainIndex++;
};
data.position = oldPosition;
}
public function encode(data:String, offset:uint=0, length:uint=0):void{
if (length == 0){
length = data.length;
};
var plainIndex:uint = offset;
while (plainIndex < (offset + length)) {
_work[_count] = data.charCodeAt(plainIndex);
_count++;
if ((((_count == _work.length)) || ((((offset + length) - plainIndex) == 1)))){
encodeBlock();
_count = 0;
_work[0] = 0;
_work[1] = 0;
_work[2] = 0;
};
plainIndex++;
};
}
private function encodeBlock():void{
var currentBuffer:Array = (_buffers[(_buffers.length - 1)] as Array);
if (currentBuffer.length >= MAX_BUFFER_SIZE){
currentBuffer = [];
_buffers.push(currentBuffer);
};
currentBuffer.push(ALPHABET_CHAR_CODES[((_work[0] & 0xFF) >> 2)]);
currentBuffer.push(ALPHABET_CHAR_CODES[(((_work[0] & 3) << 4) | ((_work[1] & 240) >> 4))]);
if (_count > 1){
currentBuffer.push(ALPHABET_CHAR_CODES[(((_work[1] & 15) << 2) | ((_work[2] & 192) >> 6))]);
} else {
currentBuffer.push(ESCAPE_CHAR_CODE);
};
if (_count > 2){
currentBuffer.push(ALPHABET_CHAR_CODES[(_work[2] & 63)]);
} else {
currentBuffer.push(ESCAPE_CHAR_CODE);
};
if (insertNewLines){
if ((_line = (_line + 4)) == 76){
currentBuffer.push(newLine);
_line = 0;
};
};
}
public function encodeUTFBytes(data:String):void{
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes(data);
bytes.position = 0;
encodeBytes(bytes);
}
public function drain():String{
var buffer:Array;
var result:String = "";
var i:uint;
while (i < _buffers.length) {
buffer = (_buffers[i] as Array);
result = (result + String.fromCharCode.apply(null, buffer));
i++;
};
_buffers = [];
_buffers.push([]);
return (result);
}
}
}//package mx.utils
Section 197
//DescribeTypeCache (mx.utils.DescribeTypeCache)
package mx.utils {
import mx.core.*;
import flash.utils.*;
import mx.binding.*;
public class DescribeTypeCache {
mx_internal static const VERSION:String = "3.0.0.0";
private static var cacheHandlers:Object = {};
private static var typeCache:Object = {};
public function DescribeTypeCache(){
super();
}
public static function describeType(o):DescribeTypeCacheRecord{
var className:String;
var typeDescription:XML;
var record:DescribeTypeCacheRecord;
if ((o is String)){
className = o;
} else {
className = getQualifiedClassName(o);
};
if ((className in typeCache)){
return (typeCache[className]);
};
if ((o is String)){
o = getDefinitionByName(o);
};
typeDescription = describeType(o);
record = new DescribeTypeCacheRecord();
record.typeDescription = typeDescription;
record.typeName = className;
typeCache[className] = record;
return (record);
}
public static function registerCacheHandler(valueName:String, handler:Function):void{
cacheHandlers[valueName] = handler;
}
static function extractValue(valueName:String, record:DescribeTypeCacheRecord){
if ((valueName in cacheHandlers)){
return (cacheHandlers[valueName](record));
};
return (undefined);
}
private static function bindabilityInfoHandler(record:DescribeTypeCacheRecord){
return (new BindabilityInfo(record.typeDescription));
}
registerCacheHandler("bindabilityInfo", bindabilityInfoHandler);
}
}//package mx.utils
Section 198
//DescribeTypeCacheRecord (mx.utils.DescribeTypeCacheRecord)
package mx.utils {
import flash.utils.*;
public dynamic class DescribeTypeCacheRecord extends Proxy {
public var typeDescription:XML;
public var typeName:String;
private var cache:Object;
public function DescribeTypeCacheRecord(){
cache = {};
super();
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){
var result:* = cache[name];
if (result === undefined){
result = DescribeTypeCache.extractValue(name, this);
cache[name] = result;
};
return (result);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(name):Boolean{
if ((name in cache)){
return (true);
};
var value:* = DescribeTypeCache.extractValue(name, this);
if (value === undefined){
return (false);
};
cache[name] = value;
return (true);
}
}
}//package mx.utils
Section 199
//HexDecoder (mx.utils.HexDecoder)
package mx.utils {
import flash.utils.*;
public class HexDecoder {
private var _output:ByteArray;
private var _work:Array;
public function HexDecoder(){
_work = [0, 0];
super();
_output = new ByteArray();
}
public function flush():ByteArray{
return (drain());
}
public function drain():ByteArray{
var result:ByteArray = _output;
_output = new ByteArray();
result.position = 0;
return (result);
}
public function digit(char:String):int{
switch (char){
case "A":
case "a":
return (10);
case "B":
case "b":
return (11);
case "C":
case "c":
return (12);
case "D":
case "d":
return (13);
case "E":
case "e":
return (14);
case "F":
case "f":
return (15);
default:
return (new Number(char));
};
}
public function decode(encoded:String):void{
var i:int;
while (i < encoded.length) {
_work[0] = digit(encoded.charAt(i));
i++;
_work[1] = digit(encoded.charAt(i));
_output.writeByte((((_work[0] << 4) | _work[1]) & 0xFF));
i++;
};
}
}
}//package mx.utils
Section 200
//HexEncoder (mx.utils.HexEncoder)
package mx.utils {
import flash.utils.*;
public class HexEncoder {
private var _work:int;// = 0
private var _buffers:Array;
public var encodingStyle:String;
public static const MAX_BUFFER_SIZE:uint = 32767;
public static const UPPER_CASE:String = "upper";
public static const LOWER_CASE:String = "lower";
private static const UPPER_CHAR_CODES:Array = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70];
private static const LOWER_CHAR_CODES:Array = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102];
public static var encodingStyle:String = "upper";
public function HexEncoder(){
super();
_buffers = [];
_buffers.push([]);
}
public function flush():String{
return (drain());
}
public function encode(data:ByteArray, offset:uint=0, length:uint=0):void{
if (length == 0){
length = data.length;
};
if (offset < length){
data.position = offset;
};
var style:String = ((this.encodingStyle)!=null) ? this.encodingStyle : HexEncoder.encodingStyle;
if (((!((style == UPPER_CASE))) && (!((style == LOWER_CASE))))){
style = UPPER_CASE;
};
var digits:Array = ((style)==UPPER_CASE) ? UPPER_CHAR_CODES : LOWER_CHAR_CODES;
while (data.bytesAvailable > 0) {
encodeBlock(data.readByte(), digits);
};
}
private function encodeBlock(_work:int, digits:Array):void{
var currentBuffer:Array = (_buffers[(_buffers.length - 1)] as Array);
if (currentBuffer.length >= MAX_BUFFER_SIZE){
currentBuffer = [];
_buffers.push(currentBuffer);
};
currentBuffer.push(digits[((_work & 240) >>> 4)]);
currentBuffer.push(digits[(_work & 15)]);
}
public function drain():String{
var buffer:Array;
var result:String = "";
var i:uint;
while (i < _buffers.length) {
buffer = (_buffers[i] as Array);
result = (result + String.fromCharCode.apply(null, buffer));
i++;
};
_buffers = [];
_buffers.push([]);
return (result);
}
}
}//package mx.utils
Section 201
//IXMLNotifiable (mx.utils.IXMLNotifiable)
package mx.utils {
public interface IXMLNotifiable {
function xmlNotification(_arg1:Object, _arg2:String, _arg3:Object, _arg4:Object, _arg5:Object):void;
}
}//package mx.utils
Section 202
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static var counter:int = 0;
public function NameUtil(){
super();
}
public static function displayObjectToString(displayObject:DisplayObject):String{
var result:String;
var s:String;
var indices:Array;
var o:DisplayObject = displayObject;
while (o != null) {
if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){
break;
};
s = o.name;
if ((o is IRepeaterClient)){
indices = IRepeaterClient(o).instanceIndices;
if (indices){
s = (s + (("[" + indices.join("][")) + "]"));
};
};
result = ((result == null)) ? s : ((s + ".") + result);
o = o.parent;
};
return (result);
}
public static function createUniqueName(object:Object):String{
if (!object){
return (null);
};
var name:String = getQualifiedClassName(object);
var index:int = name.indexOf("::");
if (index != -1){
name = name.substr((index + 2));
};
var charCode:int = name.charCodeAt((name.length - 1));
if ((((charCode >= 48)) && ((charCode <= 57)))){
name = (name + "_");
};
return ((name + counter++));
}
}
}//package mx.utils
Section 203
//object_proxy (mx.utils.object_proxy)
package mx.utils {
public namespace object_proxy = "http://www.adobe.com/2006/actionscript/flash/objectproxy";
}//package mx.utils
Section 204
//ObjectProxy (mx.utils.ObjectProxy)
package mx.utils {
import flash.events.*;
import mx.core.*;
import mx.events.*;
import flash.utils.*;
public dynamic class ObjectProxy extends Proxy implements IExternalizable, IPropertyChangeNotifier {
private var _id:String;
protected var notifiers:Object;
protected var propertyList:Array;
private var _proxyLevel:int;
private var _type:QName;
protected var dispatcher:EventDispatcher;
protected var proxyClass:Class;
private var _item:Object;
public function ObjectProxy(item:Object=null, uid:String=null, proxyDepth:int=-1){
proxyClass = ObjectProxy;
super();
if (!item){
item = {};
};
_item = item;
_proxyLevel = proxyDepth;
notifiers = {};
dispatcher = new EventDispatcher(this);
if (uid){
_id = uid;
};
}
public function dispatchEvent(event:Event):Boolean{
return (dispatcher.dispatchEvent(event));
}
public function hasEventListener(type:String):Boolean{
return (dispatcher.hasEventListener(type));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(name, value):void{
var notifier:IPropertyChangeNotifier;
var event:PropertyChangeEvent;
var oldVal:* = _item[name];
if (oldVal !== value){
_item[name] = value;
notifier = IPropertyChangeNotifier(notifiers[name]);
if (notifier){
notifier.removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangeHandler);
delete notifiers[name];
};
if (dispatcher.hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE)){
if ((name is QName)){
name = QName(name).localName;
};
event = PropertyChangeEvent.createUpdateEvent(this, name.toString(), oldVal, value);
dispatcher.dispatchEvent(event);
};
};
}
public function willTrigger(type:String):Boolean{
return (dispatcher.willTrigger(type));
}
public function readExternal(input:IDataInput):void{
var value:Object = input.readObject();
_item = value;
}
public function writeExternal(output:IDataOutput):void{
output.writeObject(_item);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(name){
var result:*;
if (notifiers[name.toString()]){
return (notifiers[name]);
};
result = _item[name];
if (result){
if ((((_proxyLevel == 0)) || (ObjectUtil.isSimple(result)))){
return (result);
};
result = getComplexProperty(name, result);
};
return (result);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function hasProperty(name):Boolean{
return ((name in _item));
}
public function get uid():String{
if (_id === null){
_id = UIDUtil.createUID();
};
return (_id);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextNameIndex(index:int):int{
if (index == 0){
setupPropertyList();
};
if (index < propertyList.length){
return ((index + 1));
};
return (0);
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextName(index:int):String{
return (propertyList[(index - 1)]);
}
public function set uid(value:String):void{
_id = value;
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function callProperty(name, ... _args){
return (_item[name].apply(_item, _args));
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
dispatcher.removeEventListener(type, listener, useCapture);
}
protected function setupPropertyList():void{
var prop:String;
if (getQualifiedClassName(_item) == "Object"){
propertyList = [];
for (prop in _item) {
propertyList.push(prop);
};
} else {
propertyList = ObjectUtil.getClassInfo(_item, null, {includeReadOnly:true, uris:["*"]}).properties;
};
}
object_proxy function getComplexProperty(name, value){
if ((value is IPropertyChangeNotifier)){
value.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangeHandler);
notifiers[name] = value;
return (value);
};
if (getQualifiedClassName(value) == "Object"){
value = new proxyClass(_item[name], null, ((_proxyLevel > 0)) ? (_proxyLevel - 1) : _proxyLevel);
value.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangeHandler);
notifiers[name] = value;
return (value);
};
return (value);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function deleteProperty(name):Boolean{
var event:PropertyChangeEvent;
var notifier:IPropertyChangeNotifier = IPropertyChangeNotifier(notifiers[name]);
if (notifier){
notifier.removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE, propertyChangeHandler);
delete notifiers[name];
};
var oldVal:* = _item[name];
var deleted = delete _item[name];
if (dispatcher.hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE)){
event = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE);
event.kind = PropertyChangeEventKind.DELETE;
event.property = name;
event.oldValue = oldVal;
event.source = this;
dispatcher.dispatchEvent(event);
};
return (deleted);
}
object_proxy function get type():QName{
return (_type);
}
object_proxy function set type(value:QName):void{
_type = value;
}
public function propertyChangeHandler(event:PropertyChangeEvent):void{
dispatcher.dispatchEvent(event);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function nextValue(index:int){
return (_item[propertyList[(index - 1)]]);
}
object_proxy function get object():Object{
return (_item);
}
}
}//package mx.utils
Section 205
//ObjectUtil (mx.utils.ObjectUtil)
package mx.utils {
import mx.core.*;
import flash.xml.*;
import flash.utils.*;
import mx.collections.*;
public class ObjectUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static var defaultToStringExcludes:Array = ["password", "credentials"];
private static var CLASS_INFO_CACHE:Object = {};
private static var refCount:int = 0;
public function ObjectUtil(){
super();
}
public static function isSimple(value:Object):Boolean{
var type = typeof(value);
switch (type){
case "number":
case "string":
case "boolean":
return (true);
case "object":
return ((((value is Date)) || ((value is Array))));
};
return (false);
}
private static function internalToString(value:Object, indent:int=0, refs:Dictionary=null, namespaceURIs:Array=null, exclude:Array=null):String{
var str:String;
var classInfo:Object;
var properties:Array;
var id:Object;
var isArray:Boolean;
var isDict:Boolean;
var prop:*;
var j:int;
var value = value;
var indent = indent;
var refs = refs;
var namespaceURIs = namespaceURIs;
var exclude = exclude;
var type:String = ((value == null)) ? "null" : typeof(value);
switch (type){
case "boolean":
case "number":
return (value.toString());
case "string":
return ((("\"" + value.toString()) + "\""));
case "object":
if ((value is Date)){
return (value.toString());
};
if ((value is XMLNode)){
return (value.toString());
};
if ((value is Class)){
return ((("(" + getQualifiedClassName(value)) + ")"));
};
classInfo = getClassInfo(value, exclude, {includeReadOnly:true, uris:namespaceURIs});
properties = classInfo.properties;
str = (("(" + classInfo.name) + ")");
if (refs == null){
refs = new Dictionary(true);
};
id = refs[value];
if (id != null){
str = (str + ("#" + int(id)));
return (str);
};
if (value != null){
str = (str + ("#" + refCount.toString()));
refs[value] = refCount;
refCount++;
};
isArray = (value is Array);
isDict = (value is Dictionary);
indent = (indent + 2);
j = 0;
for (;j < properties.length;(j = (j + 1))) {
str = newline(str, indent);
prop = properties[j];
if (isArray){
str = (str + "[");
} else {
if (isDict){
str = (str + "{");
};
};
if (isDict){
str = (str + internalToString(prop, indent, refs, namespaceURIs, exclude));
} else {
str = (str + prop.toString());
};
if (isArray){
str = (str + "] ");
} else {
if (isDict){
str = (str + "} = ");
} else {
str = (str + " = ");
};
};
str = (str + internalToString(value[prop], indent, refs, namespaceURIs, exclude));
continue;
var _slot1 = e;
str = (str + "?");
};
indent = (indent - 2);
return (str);
case "xml":
return (value.toString());
default:
return ((("(" + type) + ")"));
};
}
public static function getClassInfo(obj:Object, excludes:Array=null, options:Object=null):Object{
var n:int;
var i:int;
var result:Object;
var cacheKey:String;
var className:String;
var classAlias:String;
var properties:XMLList;
var prop:XML;
var metadataInfo:Object;
var classInfo:XML;
var numericIndex:Boolean;
var key:*;
var p:String;
var pi:Number;
var uris:Array;
var uri:String;
var qName:QName;
var j:int;
var obj = obj;
var excludes = excludes;
var options = options;
if ((obj is ObjectProxy)){
obj = ObjectProxy(obj).object_proxy::object;
};
if (options == null){
options = {includeReadOnly:true, uris:null, includeTransient:true};
};
var propertyNames:Array = [];
var dynamic:Boolean;
if (typeof(obj) == "xml"){
className = "XML";
properties = obj.text();
if (properties.length()){
propertyNames.push("*");
};
properties = obj.attributes();
} else {
classInfo = DescribeTypeCache.describeType(obj).typeDescription;
className = classInfo.@name.toString();
classAlias = classInfo.@alias.toString();
dynamic = (classInfo.@isDynamic.toString() == "true");
if (options.includeReadOnly){
properties = (classInfo..accessor.(@access != "writeonly") + classInfo..variable);
} else {
properties = (classInfo..accessor.(@access == "readwrite") + classInfo..variable);
};
numericIndex = false;
};
if (!dynamic){
cacheKey = getCacheKey(obj, excludes, options);
result = CLASS_INFO_CACHE[cacheKey];
if (result != null){
return (result);
};
};
result = {};
result["name"] = className;
result["alias"] = classAlias;
result["properties"] = propertyNames;
result["dynamic"] = dynamic;
var _local5 = recordMetadata(properties);
metadataInfo = _local5;
result["metadata"] = _local5;
var excludeObject:Object = {};
if (excludes){
n = excludes.length;
i = 0;
while (i < n) {
excludeObject[excludes[i]] = 1;
i = (i + 1);
};
};
var isArray = (className == "Array");
var isDict = (className == "flash.utils::Dictionary");
if (isDict){
for (key in obj) {
propertyNames.push(key);
};
} else {
if (dynamic){
for (p in obj) {
if (excludeObject[p] != 1){
if (isArray){
pi = parseInt(p);
if (isNaN(pi)){
propertyNames.push(new QName("", p));
} else {
propertyNames.push(pi);
};
} else {
propertyNames.push(new QName("", p));
};
};
};
numericIndex = ((isArray) && (!(isNaN(Number(p)))));
};
};
if (((((isArray) || (isDict))) || ((className == "Object")))){
} else {
if (className == "XML"){
n = properties.length();
i = 0;
while (i < n) {
p = properties[i].name();
if (excludeObject[p] != 1){
propertyNames.push(new QName("", ("@" + p)));
};
i = (i + 1);
};
} else {
n = properties.length();
uris = options.uris;
i = 0;
for (;i < n;(i = (i + 1))) {
prop = properties[i];
p = prop.@name.toString();
uri = prop.@uri.toString();
if (excludeObject[p] == 1){
} else {
if (((!(options.includeTransient)) && (internalHasMetadata(metadataInfo, p, "Transient")))){
} else {
if (uris != null){
if ((((uris.length == 1)) && ((uris[0] == "*")))){
qName = new QName(uri, p);
obj[qName];
propertyNames.push();
//unresolved jump
var _slot1 = e;
} else {
j = 0;
for (;j < uris.length;(j = (j + 1))) {
uri = uris[j];
if (prop.@uri.toString() == uri){
qName = new QName(uri, p);
obj[qName];
propertyNames.push(qName);
continue;
var _slot1 = e;
};
};
};
} else {
if (uri.length == 0){
qName = new QName(uri, p);
obj[qName];
propertyNames.push(qName);
continue;
var _slot1 = e;
};
};
};
};
};
};
};
propertyNames.sort((Array.CASEINSENSITIVE | (numericIndex) ? Array.NUMERIC : 0));
if (!isDict){
i = 0;
while (i < (propertyNames.length - 1)) {
if (propertyNames[i].toString() == propertyNames[(i + 1)].toString()){
propertyNames.splice(i, 1);
i = (i - 1);
};
i = (i + 1);
};
};
if (!dynamic){
cacheKey = getCacheKey(obj, excludes, options);
CLASS_INFO_CACHE[cacheKey] = result;
};
return (result);
}
private static function arrayCompare(a:Array, b:Array, currentDepth:int, desiredDepth:int, refs:Dictionary):int{
var key:Object;
var result:int;
if (a.length != b.length){
if (a.length < b.length){
result = -1;
} else {
result = 1;
};
} else {
for (key in a) {
if (b.hasOwnProperty(key)){
result = internalCompare(a[key], b[key], currentDepth, desiredDepth, refs);
if (result != 0){
return (result);
};
} else {
return (-1);
};
};
for (key in b) {
if (!a.hasOwnProperty(key)){
return (1);
};
};
};
return (result);
}
public static function stringCompare(a:String, b:String, caseInsensitive:Boolean=false):int{
if ((((a == null)) && ((b == null)))){
return (0);
};
if (a == null){
return (1);
};
if (b == null){
return (-1);
};
if (caseInsensitive){
a = a.toLocaleLowerCase();
b = b.toLocaleLowerCase();
};
var result:int = a.localeCompare(b);
if (result < -1){
result = -1;
} else {
if (result > 1){
result = 1;
};
};
return (result);
}
public static function dateCompare(a:Date, b:Date):int{
if ((((a == null)) && ((b == null)))){
return (0);
};
if (a == null){
return (1);
};
if (b == null){
return (-1);
};
var na:Number = a.getTime();
var nb:Number = b.getTime();
if (na < nb){
return (-1);
};
if (na > nb){
return (1);
};
return (0);
}
public static function numericCompare(a:Number, b:Number):int{
if (((isNaN(a)) && (isNaN(b)))){
return (0);
};
if (isNaN(a)){
return (1);
};
if (isNaN(b)){
return (-1);
};
if (a < b){
return (-1);
};
if (a > b){
return (1);
};
return (0);
}
private static function newline(str:String, n:int=0):String{
var result:String = str;
result = (result + "\n");
var i:int;
while (i < n) {
result = (result + " ");
i++;
};
return (result);
}
private static function recordMetadata(properties:XMLList):Object{
var prop:XML;
var propName:String;
var metadataList:XMLList;
var metadata:Object;
var md:XML;
var mdName:String;
var argsList:XMLList;
var value:Object;
var arg:XML;
var existing:Object;
var argKey:String;
var argValue:String;
var existingArray:Array;
var properties = properties;
var result:Object;
for each (prop in properties) {
propName = prop.attribute("name").toString();
metadataList = prop.metadata;
if (metadataList.length() > 0){
if (result == null){
result = {};
};
metadata = {};
result[propName] = metadata;
for each (md in metadataList) {
mdName = md.attribute("name").toString();
argsList = md.arg;
value = {};
for each (arg in argsList) {
argKey = arg.attribute("key").toString();
if (argKey != null){
argValue = arg.attribute("value").toString();
value[argKey] = argValue;
};
};
existing = metadata[mdName];
if (existing != null){
if ((existing is Array)){
existingArray = (existing as Array);
} else {
existingArray = [];
};
existingArray.push(value);
existing = existingArray;
} else {
existing = value;
};
metadata[mdName] = existing;
};
};
};
//unresolved jump
var _slot1 = e;
return (result);
}
public static function compare(a:Object, b:Object, depth:int=-1):int{
return (internalCompare(a, b, 0, depth, new Dictionary(true)));
}
private static function listCompare(a:IList, b:IList, currentDepth:int, desiredDepth:int, refs:Dictionary):int{
var i:int;
var result:int;
if (a.length != b.length){
if (a.length < b.length){
result = -1;
} else {
result = 1;
};
} else {
i = 0;
while (i < a.length) {
result = internalCompare(a.getItemAt(i), b.getItemAt(i), (currentDepth + 1), desiredDepth, refs);
if (result != 0){
i = a.length;
};
i++;
};
};
return (result);
}
private static function internalCompare(a:Object, b:Object, currentDepth:int, desiredDepth:int, refs:Dictionary):int{
var newDepth:int;
var aRef:Boolean;
var bRef:Boolean;
var aProps:Array;
var bProps:Array;
var propName:QName;
var aProp:Object;
var bProp:Object;
var i:int;
if ((((a == null)) && ((b == null)))){
return (0);
};
if (a == null){
return (1);
};
if (b == null){
return (-1);
};
if ((a is ObjectProxy)){
a = ObjectProxy(a).object_proxy::object;
};
if ((b is ObjectProxy)){
b = ObjectProxy(b).object_proxy::object;
};
var typeOfA = typeof(a);
var typeOfB = typeof(b);
var result:int;
if (typeOfA == typeOfB){
switch (typeOfA){
case "boolean":
result = numericCompare(Number(a), Number(b));
break;
case "number":
result = numericCompare((a as Number), (b as Number));
break;
case "string":
result = stringCompare((a as String), (b as String));
break;
case "object":
newDepth = ((desiredDepth > 0)) ? (desiredDepth - 1) : desiredDepth;
aRef = refs[a];
bRef = refs[b];
if (((aRef) && (!(bRef)))){
return (1);
};
if (((bRef) && (!(aRef)))){
return (-1);
};
if (((bRef) && (aRef))){
return (0);
};
refs[a] = true;
refs[b] = true;
if (((!((desiredDepth == -1))) && ((currentDepth > desiredDepth)))){
result = stringCompare(a.toString(), b.toString());
} else {
if ((((a is Array)) && ((b is Array)))){
result = arrayCompare((a as Array), (b as Array), currentDepth, desiredDepth, refs);
} else {
if ((((a is Date)) && ((b is Date)))){
result = dateCompare((a as Date), (b as Date));
} else {
if ((((a is IList)) && ((b is IList)))){
result = listCompare((a as IList), (b as IList), currentDepth, desiredDepth, refs);
} else {
if ((((a is ByteArray)) && ((b is ByteArray)))){
result = byteArrayCompare((a as ByteArray), (b as ByteArray));
} else {
if (getQualifiedClassName(a) == getQualifiedClassName(b)){
aProps = getClassInfo(a).properties;
if (getQualifiedClassName(a) == "Object"){
bProps = getClassInfo(b).properties;
result = arrayCompare(aProps, bProps, currentDepth, newDepth, refs);
};
if (result != 0){
return (result);
};
i = 0;
while (i < aProps.length) {
propName = aProps[i];
aProp = a[propName];
bProp = b[propName];
result = internalCompare(aProp, bProp, (currentDepth + 1), newDepth, refs);
if (result != 0){
i = aProps.length;
};
i++;
};
} else {
return (1);
};
};
};
};
};
};
break;
};
} else {
return (stringCompare(typeOfA, typeOfB));
};
return (result);
}
public static function hasMetadata(obj:Object, propName:String, metadataName:String, excludes:Array=null, options:Object=null):Boolean{
var classInfo:Object = getClassInfo(obj, excludes, options);
var metadataInfo:Object = classInfo["metadata"];
return (internalHasMetadata(metadataInfo, propName, metadataName));
}
private static function internalHasMetadata(metadataInfo:Object, propName:String, metadataName:String):Boolean{
var metadata:Object;
if (metadataInfo != null){
metadata = metadataInfo[propName];
if (metadata != null){
if (metadata[metadataName] != null){
return (true);
};
};
};
return (false);
}
public static function toString(value:Object, namespaceURIs:Array=null, exclude:Array=null):String{
if (exclude == null){
exclude = defaultToStringExcludes;
};
refCount = 0;
return (internalToString(value, 0, null, namespaceURIs, exclude));
}
private static function byteArrayCompare(a:ByteArray, b:ByteArray):int{
var i:int;
var result:int;
if (a.length != b.length){
if (a.length < b.length){
result = -1;
} else {
result = 1;
};
} else {
a.position = 0;
b.position = 0;
i = 0;
while (i < a.length) {
result = numericCompare(a.readByte(), b.readByte());
if (result != 0){
i = a.length;
};
i++;
};
};
return (result);
}
public static function copy(value:Object):Object{
var buffer:ByteArray = new ByteArray();
buffer.writeObject(value);
buffer.position = 0;
var result:Object = buffer.readObject();
return (result);
}
private static function getCacheKey(o:Object, excludes:Array=null, options:Object=null):String{
var i:uint;
var excl:String;
var flag:String;
var value:String;
var key:String = getQualifiedClassName(o);
if (excludes != null){
i = 0;
while (i < excludes.length) {
excl = (excludes[i] as String);
if (excl != null){
key = (key + excl);
};
i++;
};
};
if (options != null){
for (flag in options) {
key = (key + flag);
value = (options[flag] as String);
if (value != null){
key = (key + value);
};
};
};
return (key);
}
}
}//package mx.utils
Section 206
//StringUtil (mx.utils.StringUtil)
package mx.utils {
import mx.core.*;
public class StringUtil {
mx_internal static const VERSION:String = "3.0.0.0";
public function StringUtil(){
super();
}
public static function trim(str:String):String{
if (str == null){
return ("");
};
var startIndex:int;
while (isWhitespace(str.charAt(startIndex))) {
startIndex++;
};
var endIndex:int = (str.length - 1);
while (isWhitespace(str.charAt(endIndex))) {
endIndex--;
};
if (endIndex >= startIndex){
return (str.slice(startIndex, (endIndex + 1)));
};
return ("");
}
public static function isWhitespace(character:String):Boolean{
switch (character){
case " ":
case "\t":
case "\r":
case "\n":
case "\f":
return (true);
default:
return (false);
};
}
public static function substitute(str:String, ... _args):String{
var args:Array;
if (str == null){
return ("");
};
var len:uint = _args.length;
if ((((len == 1)) && ((_args[0] is Array)))){
args = (_args[0] as Array);
len = args.length;
} else {
args = _args;
};
var i:int;
while (i < len) {
str = str.replace(new RegExp((("\\{" + i) + "\\}"), "g"), args[i]);
i++;
};
return (str);
}
public static function trimArrayElements(value:String, delimiter:String):String{
var items:Array;
var len:int;
var i:int;
if (((!((value == ""))) && (!((value == null))))){
items = value.split(delimiter);
len = items.length;
i = 0;
while (i < len) {
items[i] = StringUtil.trim(items[i]);
i++;
};
if (len > 0){
value = items.join(delimiter);
};
};
return (value);
}
}
}//package mx.utils
Section 207
//UIDUtil (mx.utils.UIDUtil)
package mx.utils {
import mx.core.*;
import flash.utils.*;
public class UIDUtil {
mx_internal static const VERSION:String = "3.0.0.0";
private static const ALPHA_CHAR_CODES:Array = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70];
private static var uidDictionary:Dictionary = new Dictionary(true);
public function UIDUtil(){
super();
}
public static function fromByteArray(ba:ByteArray):String{
var chars:Array;
var index:uint;
var i:uint;
var b:int;
if (((((!((ba == null))) && ((ba.length >= 16)))) && ((ba.bytesAvailable >= 16)))){
chars = new Array(36);
index = 0;
i = 0;
while (i < 16) {
if ((((((((i == 4)) || ((i == 6)))) || ((i == 8)))) || ((i == 10)))){
var _temp1 = index;
index = (index + 1);
var _local6 = _temp1;
chars[_local6] = 45;
};
b = ba.readByte();
var _temp2 = index;
index = (index + 1);
_local6 = _temp2;
chars[_local6] = ALPHA_CHAR_CODES[((b & 240) >>> 4)];
var _temp3 = index;
index = (index + 1);
var _local7 = _temp3;
chars[_local7] = ALPHA_CHAR_CODES[(b & 15)];
i++;
};
return (String.fromCharCode.apply(null, chars));
};
return (null);
}
public static function isUID(uid:String):Boolean{
var i:uint;
var c:Number;
if (((!((uid == null))) && ((uid.length == 36)))){
i = 0;
while (i < 36) {
c = uid.charCodeAt(i);
if ((((((((i == 8)) || ((i == 13)))) || ((i == 18)))) || ((i == 23)))){
if (c != 45){
return (false);
};
} else {
if ((((((c < 48)) || ((c > 70)))) || ((((c > 57)) && ((c < 65)))))){
return (false);
};
};
i++;
};
return (true);
};
return (false);
}
public static function createUID():String{
var i:int;
var j:int;
var uid:Array = new Array(36);
var index:int;
i = 0;
while (i < 8) {
var _temp1 = index;
index = (index + 1);
var _local7 = _temp1;
uid[_local7] = ALPHA_CHAR_CODES[Math.floor((Math.random() * 16))];
i++;
};
i = 0;
while (i < 3) {
var _temp2 = index;
index = (index + 1);
_local7 = _temp2;
uid[_local7] = 45;
j = 0;
while (j < 4) {
var _temp3 = index;
index = (index + 1);
var _local8 = _temp3;
uid[_local8] = ALPHA_CHAR_CODES[Math.floor((Math.random() * 16))];
j++;
};
i++;
};
var _temp4 = index;
index = (index + 1);
_local7 = _temp4;
uid[_local7] = 45;
var time:Number = new Date().getTime();
var timeString:String = ("0000000" + time.toString(16).toUpperCase()).substr(-8);
i = 0;
while (i < 8) {
var _temp5 = index;
index = (index + 1);
_local8 = _temp5;
uid[_local8] = timeString.charCodeAt(i);
i++;
};
i = 0;
while (i < 4) {
var _temp6 = index;
index = (index + 1);
_local8 = _temp6;
uid[_local8] = ALPHA_CHAR_CODES[Math.floor((Math.random() * 16))];
i++;
};
return (String.fromCharCode.apply(null, uid));
}
public static function toByteArray(uid:String):ByteArray{
var result:ByteArray;
var i:uint;
var c:String;
var h1:uint;
var h2:uint;
if (isUID(uid)){
result = new ByteArray();
i = 0;
while (i < uid.length) {
c = uid.charAt(i);
if (c == "-"){
} else {
h1 = getDigit(c);
i++;
h2 = getDigit(uid.charAt(i));
result.writeByte((((h1 << 4) | h2) & 0xFF));
};
i++;
};
result.position = 0;
return (result);
};
return (null);
}
private static function getDigit(hex:String):uint{
switch (hex){
case "A":
case "a":
return (10);
case "B":
case "b":
return (11);
case "C":
case "c":
return (12);
case "D":
case "d":
return (13);
case "E":
case "e":
return (14);
case "F":
case "f":
return (15);
default:
return (new uint(hex));
};
}
public static function getUID(item:Object):String{
var result:String;
var xitem:XML;
var nodeKind:String;
var notificationFunction:Function;
var item = item;
result = null;
if (item == null){
return (result);
};
if ((item is IUID)){
result = IUID(item).uid;
if ((((result == null)) || ((result.length == 0)))){
result = createUID();
IUID(item).uid = result;
};
} else {
if ((((item is IPropertyChangeNotifier)) && (!((item is IUIComponent))))){
result = IPropertyChangeNotifier(item).uid;
if ((((result == null)) || ((result.length == 0)))){
result = createUID();
IPropertyChangeNotifier(item).uid = result;
};
} else {
if ((item is String)){
return ((item as String));
};
if ((((item is XMLList)) && ((item.length == 1)))){
item = item[0];
};
if ((item is XML)){
xitem = XML(item);
nodeKind = xitem.nodeKind();
if ((((nodeKind == "text")) || ((nodeKind == "attribute")))){
return (xitem.toString());
};
notificationFunction = xitem.notification();
if (!(notificationFunction is Function)){
notificationFunction = XMLNotifier.initializeXMLForNotification();
xitem.setNotification(notificationFunction);
};
if (notificationFunction["uid"] == undefined){
result = (notificationFunction["uid"] = createUID());
};
result = notificationFunction["uid"];
} else {
if (("mx_internal_uid" in item)){
return (item.mx_internal_uid);
};
if (("uid" in item)){
return (item.uid);
};
result = uidDictionary[item];
if (!result){
result = createUID();
item.mx_internal_uid = result;
//unresolved jump
var _slot1 = e;
uidDictionary[item] = result;
};
};
//unresolved jump
var _slot1 = e;
result = item.toString();
};
};
return (result);
}
}
}//package mx.utils
Section 208
//URLUtil (mx.utils.URLUtil)
package mx.utils {
import mx.messaging.config.*;
public class URLUtil {
public static const SERVER_NAME_TOKEN:String = "{server.name}";
private static const SERVER_PORT_REGEX:RegExp = new RegExp("\\{server.port\\}", "g");
private static const SERVER_NAME_REGEX:RegExp = new RegExp("\\{server.name\\}", "g");
public static const SERVER_PORT_TOKEN:String = "{server.port}";
public function URLUtil(){
super();
}
public static function hasUnresolvableTokens():Boolean{
return (!((LoaderConfig.url == null)));
}
public static function getServerName(url:String):String{
var sp:String = getServerNameWithPort(url);
var delim:int = sp.indexOf("]");
delim = ((delim)>-1) ? sp.indexOf(":", delim) : sp.indexOf(":");
if (delim > 0){
sp = sp.substring(0, delim);
};
return (sp);
}
public static function isHttpsURL(url:String):Boolean{
return (((!((url == null))) && ((url.indexOf("https://") == 0))));
}
private static function internalObjectToString(object:Object, separator:String, prefix:String, encodeURL:Boolean):String{
var p:String;
var value:Object;
var name:String;
var s:String = "";
var first:Boolean;
for (p in object) {
if (first){
first = false;
} else {
s = (s + separator);
};
value = object[p];
name = (prefix) ? ((prefix + ".") + p) : p;
if (encodeURL){
name = encodeURIComponent(name);
};
if ((value is String)){
s = (s + ((name + "=") + (encodeURL) ? encodeURIComponent((value as String)) : value));
} else {
if ((value is Number)){
value = value.toString();
if (encodeURL){
value = encodeURIComponent((value as String));
};
s = (s + ((name + "=") + value));
} else {
if ((value is Boolean)){
s = (s + ((name + "=") + (value) ? "true" : "false"));
} else {
if ((value is Array)){
s = (s + internalArrayToString((value as Array), separator, name, encodeURL));
} else {
s = (s + internalObjectToString(value, separator, name, encodeURL));
};
};
};
};
};
return (s);
}
public static function getFullURL(rootURL:String, url:String):String{
var slashPos:Number;
if (((!((url == null))) && (!(URLUtil.isHttpURL(url))))){
if (url.indexOf("./") == 0){
url = url.substring(2);
};
if (URLUtil.isHttpURL(rootURL)){
if (url.charAt(0) == "/"){
slashPos = rootURL.indexOf("/", 8);
if (slashPos == -1){
slashPos = rootURL.length;
};
} else {
slashPos = (rootURL.lastIndexOf("/") + 1);
if (slashPos <= 8){
rootURL = (rootURL + "/");
slashPos = rootURL.length;
};
};
if (slashPos > 0){
url = (rootURL.substring(0, slashPos) + url);
};
};
};
return (url);
}
public static function getServerNameWithPort(url:String):String{
var start:int = (url.indexOf("/") + 2);
var length:int = url.indexOf("/", start);
return (((length == -1)) ? url.substring(start) : url.substring(start, length));
}
public static function replaceProtocol(uri:String, newProtocol:String):String{
return (uri.replace(getProtocol(uri), newProtocol));
}
public static function urisEqual(uri1:String, uri2:String):Boolean{
if (((!((uri1 == null))) && (!((uri2 == null))))){
uri1 = StringUtil.trim(uri1).toLowerCase();
uri2 = StringUtil.trim(uri2).toLowerCase();
if (uri1.charAt((uri1.length - 1)) != "/"){
uri1 = (uri1 + "/");
};
if (uri2.charAt((uri2.length - 1)) != "/"){
uri2 = (uri2 + "/");
};
};
return ((uri1 == uri2));
}
public static function getProtocol(url:String):String{
var slash:int = url.indexOf("/");
var indx:int = url.indexOf(":/");
if ((((indx > -1)) && ((indx < slash)))){
return (url.substring(0, indx));
};
indx = url.indexOf("::");
if ((((indx > -1)) && ((indx < slash)))){
return (url.substring(0, indx));
};
return ("");
}
private static function internalArrayToString(array:Array, separator:String, prefix:String, encodeURL:Boolean):String{
var value:Object;
var name:String;
var s:String = "";
var first:Boolean;
var n:int = array.length;
var i:int;
while (i < n) {
if (first){
first = false;
} else {
s = (s + separator);
};
value = array[i];
name = ((prefix + ".") + i);
if (encodeURL){
name = encodeURIComponent(name);
};
if ((value is String)){
s = (s + ((name + "=") + (encodeURL) ? encodeURIComponent((value as String)) : value));
} else {
if ((value is Number)){
value = value.toString();
if (encodeURL){
value = encodeURIComponent((value as String));
};
s = (s + ((name + "=") + value));
} else {
if ((value is Boolean)){
s = (s + ((name + "=") + (value) ? "true" : "false"));
} else {
if ((value is Array)){
s = (s + internalArrayToString((value as Array), separator, name, encodeURL));
} else {
s = (s + internalObjectToString(value, separator, name, encodeURL));
};
};
};
};
i++;
};
return (s);
}
public static function objectToString(object:Object, separator:String=";", encodeURL:Boolean=true):String{
var s:String = internalObjectToString(object, separator, null, encodeURL);
return (s);
}
public static function replaceTokens(url:String):String{
var loaderProtocol:String;
var loaderServerName:String;
var loaderPort:uint;
var loaderURL:String = ((LoaderConfig.url == null)) ? "" : LoaderConfig.url;
if (url.indexOf(SERVER_NAME_TOKEN) > 0){
loaderProtocol = URLUtil.getProtocol(loaderURL);
loaderServerName = "localhost";
if (loaderProtocol.toLowerCase() != "file"){
loaderServerName = URLUtil.getServerName(loaderURL);
};
url = url.replace(SERVER_NAME_REGEX, loaderServerName);
};
var portToken:int = url.indexOf(SERVER_PORT_TOKEN);
if (portToken > 0){
loaderPort = URLUtil.getPort(loaderURL);
if (loaderPort > 0){
url = url.replace(SERVER_PORT_REGEX, loaderPort);
} else {
if (url.charAt((portToken - 1)) == ":"){
url = (url.substring(0, (portToken - 1)) + url.substring(portToken));
};
url = url.replace(SERVER_PORT_REGEX, "");
};
};
return (url);
}
public static function getPort(url:String):uint{
var p:Number;
var sp:String = getServerNameWithPort(url);
var delim:int = sp.indexOf("]");
delim = ((delim)>-1) ? sp.indexOf(":", delim) : sp.indexOf(":");
var port:uint;
if (delim > 0){
p = Number(sp.substring((delim + 1)));
if (!isNaN(p)){
port = int(p);
};
};
return (port);
}
public static function stringToObject(string:String, separator:String=";", decodeURL:Boolean=true):Object{
var pieces:Array;
var name:String;
var value:Object;
var obj:Object;
var m:int;
var j:int;
var temp:Object;
var prop:String;
var subProp:String;
var idx:Object;
var o:Object = {};
var arr:Array = string.split(separator);
var n:int = arr.length;
var i:int;
while (i < n) {
pieces = arr[i].split("=");
name = pieces[0];
if (decodeURL){
name = decodeURIComponent(name);
};
value = pieces[1];
if (decodeURL){
value = decodeURIComponent((value as String));
};
if (value == "true"){
value = true;
} else {
if (value == "false"){
value = false;
} else {
temp = int(value);
if (temp.toString() == value){
value = temp;
} else {
temp = Number(value);
if (temp.toString() == value){
value = temp;
};
};
};
};
obj = o;
pieces = name.split(".");
m = pieces.length;
j = 0;
while (j < (m - 1)) {
prop = pieces[j];
if ((((obj[prop] == null)) && ((j < (m - 1))))){
subProp = pieces[(j + 1)];
idx = int(subProp);
if (idx.toString() == subProp){
obj[prop] = [];
} else {
obj[prop] = {};
};
};
obj = obj[prop];
j++;
};
obj[pieces[j]] = value;
i++;
};
return (o);
}
public static function replacePort(uri:String, newPort:uint):String{
var portEnd:int;
var result:String = "";
var indx:int = uri.indexOf("]");
if (indx == -1){
indx = uri.indexOf(":");
};
var portStart:int = uri.indexOf(":", (indx + 1));
if (portStart > -1){
portStart++;
portEnd = uri.indexOf("/", portStart);
result = ((uri.substring(0, portStart) + newPort.toString()) + uri.substring(portEnd, uri.length));
} else {
portEnd = uri.indexOf("/", indx);
if (portEnd > -1){
if (uri.charAt((portEnd + 1)) == "/"){
portEnd = uri.indexOf("/", (portEnd + 2));
};
if (portEnd > 0){
result = (((uri.substring(0, portEnd) + ":") + newPort.toString()) + uri.substring(portEnd, uri.length));
} else {
result = ((uri + ":") + newPort.toString());
};
} else {
result = ((uri + ":") + newPort.toString());
};
};
return (result);
}
public static function isHttpURL(url:String):Boolean{
return (((!((url == null))) && ((((url.indexOf("http://") == 0)) || ((url.indexOf("https://") == 0))))));
}
}
}//package mx.utils
Section 209
//XMLNotifier (mx.utils.XMLNotifier)
package mx.utils {
import mx.core.*;
import flash.utils.*;
public class XMLNotifier {
mx_internal static const VERSION:String = "3.0.0.0";
private static var instance:XMLNotifier;
public function XMLNotifier(x:XMLNotifierSingleton){
super();
}
public function watchXML(xml:Object, notifiable:IXMLNotifiable, uid:String=null):void{
var xmlWatchers:Dictionary;
var xitem:XML = XML(xml);
var watcherFunction:Object = xitem.notification();
if (!(watcherFunction is Function)){
watcherFunction = initializeXMLForNotification();
xitem.setNotification((watcherFunction as Function));
if (((uid) && ((watcherFunction["uid"] == null)))){
watcherFunction["uid"] = uid;
};
};
if (watcherFunction["watched"] == undefined){
xmlWatchers = new Dictionary(true);
watcherFunction["watched"] = xmlWatchers;
} else {
xmlWatchers = watcherFunction["watched"];
};
xmlWatchers[notifiable] = true;
}
public function unwatchXML(xml:Object, notifiable:IXMLNotifiable):void{
var xmlWatchers:Dictionary;
var xitem:XML = XML(xml);
var watcherFunction:Object = xitem.notification();
if (!(watcherFunction is Function)){
return;
};
if (watcherFunction["watched"] != undefined){
xmlWatchers = watcherFunction["watched"];
delete xmlWatchers[notifiable];
};
}
public static function getInstance():XMLNotifier{
if (!instance){
instance = new XMLNotifier(new XMLNotifierSingleton());
};
return (instance);
}
mx_internal static function initializeXMLForNotification():Function{
var notificationFunction:Function = function (currentTarget:Object, ty:String, tar:Object, value:Object, detail:Object):void{
var notifiable:Object;
var xmlWatchers:Dictionary = arguments.callee.watched;
if (xmlWatchers != null){
for (notifiable in xmlWatchers) {
IXMLNotifiable(notifiable).xmlNotification(currentTarget, ty, tar, value, detail);
};
};
};
return (notificationFunction);
}
}
}//package mx.utils
class XMLNotifierSingleton {
private function XMLNotifierSingleton(){
super();
}
}
Section 210
//XMLUtil (mx.utils.XMLUtil)
package mx.utils {
import mx.core.*;
import flash.xml.*;
public class XMLUtil {
mx_internal static const VERSION:String = "3.0.0.0";
public function XMLUtil(){
super();
}
public static function createXMLDocument(str:String):XMLDocument{
var xml:XMLDocument = new XMLDocument();
xml.ignoreWhite = true;
xml.parseXML(str);
return (xml);
}
public static function qnamesEqual(qname1:QName, qname2:QName):Boolean{
return ((((qname1.uri == qname2.uri)) && ((qname1.localName == qname2.localName))));
}
public static function getAttributeByQName(xml:XML, attrQName:QName):XMLList{
var attribute:XML;
var thisQName:QName;
var attributes:XMLList = xml.attribute(attrQName);
for each (attribute in attributes) {
thisQName = attribute.name();
if (thisQName.uri == attrQName.uri){
return (new XMLList(attribute));
};
};
return (new XMLList());
}
public static function qnameToString(qname:QName):String{
return ((((qname.uri) && (!((qname.uri == ""))))) ? ((qname.uri + ":") + qname.localName) : qname.localName);
}
}
}//package mx.utils
Section 211
//_CompiledResourceBundleInfo (_CompiledResourceBundleInfo)
package {
public class _CompiledResourceBundleInfo {
public static function get compiledLocales():Array{
return (["en_US"]);
}
public static function get compiledResourceBundleNames():Array{
return (["collections", "logging", "rpc", "utils"]);
}
}
}//package
Section 212
//en_US$collections_properties (en_US$collections_properties)
package {
import mx.resources.*;
public class en_US$collections_properties extends ResourceBundle {
public function en_US$collections_properties(){
super("en_US", "collections");
}
override protected function getContent():Object{
var _local1:Object = {findCondition:"Find criteria must contain all sort fields leading up to '{0}'.", noComparatorSortField:"Cannot determine comparator for SortField with name '{0}'.", outOfBounds:"Index '{0}' specified is out of bounds.", nonUnique:"Non-unique values in items.", incorrectAddition:"Attempt to add an item already in the view.", findRestriction:"Find criteria must contain at least one sort field value.", invalidType:"Incorrect type. Must be of type XML or a XMLList that contains one XML object. ", unknownMode:"Unknown find mode.", invalidIndex:"Invalid index: '{0}'.", invalidRemove:"Cannot remove when current is beforeFirst or afterLast.", unknownProperty:"Unknown Property: '{0}'.", invalidInsert:"Cannot insert when current is beforeFirst.", itemNotFound:"Cannot find when view is not sorted.", bookmarkInvalid:"Bookmark no longer valid.", noComparator:"Cannot determine comparator for '{0}'.", invalidCursor:"Cursor no longer valid.", noItems:"No items to search.", bookmarkNotFound:"Bookmark is not from this view."};
return (_local1);
}
}
}//package
Section 213
//en_US$logging_properties (en_US$logging_properties)
package {
import mx.resources.*;
public class en_US$logging_properties extends ResourceBundle {
public function en_US$logging_properties(){
super("en_US", "logging");
}
override protected function getContent():Object{
var _local1:Object = {invalidTarget:"Invalid target specified.", charsInvalid:"Error for filter '{0}': The following characters are not valid: []~$^&/(){}<>+=_-`!@#%?,:;'\".", charPlacement:"Error for filter '{0}': '*' must be the right most character.", levelLimit:"Level must be less than LogEventLevel.ALL.", invalidChars:"Categories can not contain any of the following characters: []`~,!@#$%*^&()]{}+=|';?><./\".", invalidLen:"Categories must be at least one character in length."};
return (_local1);
}
}
}//package
Section 214
//en_US$rpc_properties (en_US$rpc_properties)
package {
import mx.resources.*;
public class en_US$rpc_properties extends ResourceBundle {
public function en_US$rpc_properties(){
super("en_US", "rpc");
}
override protected function getContent():Object{
var _local1:Object = {noBaseSchemaAddress:"Cannot resolve relative schema import without a fully qualified base address.", unrecognizedPortTypeName:"The WSDL parser couldn't find a portType named '{0}' in namespace '{1}'", noListenerForHeader:"No event listener for header {0}", cannotConnectToDestination:"Couldn't establish a connection to '{0}'", unexpectedException:"Runtime exception {0}", noServiceElement.details:"No <wsdl:service> elements found in WSDL at {0}.", unableToLoadWSDL:"Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL ({0})", errorWhileLoadingFromParent:"Error while loading imported schema from parent location: {0}", unexpectedSchemaException:"Error while importing schema: {0}", unrecognizedBindingName:"The WSDL parser couldn't find a binding named '{0}' in namespace '{1}'", cannotResetService:"Cannot reset the service of an Operation", mustSpecifyWSDLLocation:"You must specify the WSDL location with useProxy set to false.", urlNotSpecified:"A URL must be specified with useProxy set to false.", unexpectedInputParameter:"Unexpected parameter '{0}' found in input arguments.", noBaseWSDLAddress:"Cannot resolve relative WSDL import without a fully qualified base address.", noListenerForEvent:"An event was received for which no listener was defined. Please add an event listener. {0}", unknownSchemaVersion:"Unknown schema version", missingInputParameter:"Array of input arguments did not contain a required parameter at position {0}", unrecognizedNamespace:"The WSDL parser had no registered document for the namespace '{0}'", multiplePortsFound:"A valid port was not specified. Unable to select a default port as there are multiple ports in the WSDL file.", wsdlDefinitionsNotFirst:"Definitions must be the first element in a WSDL document", xmlEncodeReturnNoXMLNode:"xmlEncode did not return XMLNode", xmlDecodeReturnNull:"xmlDecode returned null", tooFewInputParameters:"Too few parameters - expected at least {0} but found {1}", noPortsInWSDL:"There are no valid ports in the WSDL file for the {0} service.", invalidResultFormat:"Invalid resultFormat '{0}' valid formats are [{1}, {2}, {3}, {4}, {5}]", unrecognizedMessageName:"The WSDL parser couldn't find a message named '{0}' in namespace '{1}'", operationsNotAllowedInService:"Cannot assign operations into an RPC Service ({0})", badSchemaNode:"Bad schema node", noSuchServiceInWSDL:"The requested service '{0}' was not found in the WSDL file.", destinationOrWSDLNotSpecified:"A destination and/or WSDL must be specified.", noBaseWSDLAddress.details:"Please specify the location of the WSDL document for the WebService.", missingInputParameterWithName:"Required parameter '{0}' not found in input arguments.", badElement:"Element {0}:{1} not resolvable", overloadedOperation:"The WSDL contains an overloaded operation ({0}) - we do not currently support this usage.", defaultDecoderFailed:"Default decoder could not decode result", faultyWSDLFormat:"Faulty WSDL format", soapVersionMismatch:"Request implements version: {0}, Response implements version {1}", badType:"Type {0} not resolvable", noSuchService:"Couldn't find service '{0}'", cannotResetOperationName:"Cannot reset the name of an Operation", unknownSchemaElement:"Unknown element: {0}", pendingCallExists:"Attempt to invoke while another call is pending. Either change concurrency options or avoid multiple calls.", noServiceAndPort:"Couldn't find a matching port (service = '{0}', port = '{1}')", noServices:"There are no valid services in the WSDL file.", unknownProtocol:"Unknown protocol '{0}'", unknownSchemaType:"Unknown schema type system", invalidSoapResultFormat:"Invalid resultFormat '{0}'. Valid formats are 'object', 'xml', and 'e4x'", xmlEncodeReturnNull:"xmlEncode returned null", cannotFindType:"Cannot find type for: {0}", noServiceElement:"Could not load WSDL"};
return (_local1);
}
}
}//package
Section 215
//en_US$utils_properties (en_US$utils_properties)
package {
import mx.resources.*;
public class en_US$utils_properties extends ResourceBundle {
public function en_US$utils_properties(){
super("en_US", "utils");
}
override protected function getContent():Object{
var _local1:Object = {partialBlockDropped:"A partial block ({0} of 4 bytes) was dropped. Decoded data is probably truncated!"};
return (_local1);
}
}
}//package