distiny
August 23rd, 2012, 11:31 PM
So I want to make myself a custom BG for csgo but found out it are flash animations/movies located at: D:\steam\SteamApps\common\Counter-Strike Global Offensive\csgo\resource\flash
background.swf is the file we are after so I decompiled the swf into the actionscript code But I'm not familiar with it. Anyone got any idea's ?
the code:
movie 'D:\steam\SteamApps\common\Counter-Strike Global Offensive\csgo\resource\flash\background.swf' {
// flash 8, total frames: 1, frame rate: 30 fps, 1280x720 px, compressed
frame 1 {
function onResize(rm) {
rm.DisableAdditionalScaling = true;
rm.ResetPosition(BackgroundMain, Lib.ResizeManager.SCALE_BIGGEST, Lib.ResizeManager.POSITION_CENTER, Lib.ResizeManager.POSITION_CENTER, Lib.ResizeManager.ALIGN_CENTER, Lib.ResizeManager.ALIGN_CENTER);
}
function onUIHide(mc, rm) {
hideBackground();
}
function onUIShow(mc, rm) {
showBackground();
}
function showBackground() {
var v2 = _global.GameInterface.GetConvarNumber('player_team playedlast') == _global.TeamID_CounterTerrorist;
BackgroundMain.BackgroundHolder.bg_CT._visible = v2;
BackgroundMain.BackgroundHolder.bg_T._visible = !v2;
BackgroundMain.gotoAndPlay('StartShow');
}
function hideBackground() {
BackgroundMain.gotoAndPlay('StartHide');
}
function onUnload(mc) {
_global.FrontEndBackgroundMovie = null;
_global.resizeManager.RemoveListener(this);
return true;
}
_global.FrontEndBackgroundMovie = this;
_global.resizeManager.AddListener(this);
stop();
}
movieClip 3 {
}
movieClip 4 {
}
movieClip 5 {
frame 1 {
}
}
movieClip 7 {
}
movieClip 8 {
frame 2001 {
gotoAndPlay(1);
}
}
movieClip 11 {
}
movieClip 14 {
}
movieClip 15 {
frame 500 {
gotoAndPlay(1);
}
}
movieClip 17 {
}
movieClip 18 {
frame 600 {
gotoAndPlay(1);
}
}
movieClip 21 {
}
movieClip 24 {
}
movieClip 27 {
}
movieClip 30 {
}
movieClip 33 {
}
movieClip 36 {
}
movieClip 39 {
}
movieClip 40 {
}
movieClip 41 {
frame 2500 {
gotoAndPlay(1);
}
}
movieClip 44 {
}
movieClip 46 {
}
movieClip 47 {
frame 1001 {
gotoAndPlay(1);
}
}
movieClip 48 {
frame 1 {
stop();
ct2a._visible = false;
t2a._visible = false;
}
frame 2 {
stop();
}
frame 11 {
stop();
if (bRunFisrtTime == false) {
ct2a._visible = false;
t2a._visible = false;
bRunFisrtTime = true;
}
}
frame 21 {
gotoAndStop(2);
}
}
movieClip 51 {
}
movieClip 52 {
}
movieClip 53 {
frame 1 {
this.stop();
}
frame 22 {
stop();
}
frame 33 {
stop();
}
}
movieClip 54 __Packages.Lib.ResizeManager {
#initclip
if (!_global.Lib) {
_global.Lib = new Object();
}
if (!_global.Lib.ResizeManager) {
var v1 = function () {
var v2 = 0;
while (v2 <= Lib.ResizeManager.SCALE_USING_HORIZONTAL) {
this.ScalingFactors.push(1);
++v2;
}
v2 = 0;
while (v2 <= Lib.ResizeManager.REFERENCE_CENTER_Y) {
this.ReferencePositions.push(0);
++v2;
}
};
Lib.ResizeManager = v1;
var v2 = v1.prototype;
v2.getSafezone = function (name) {
var v2 = 0.85;
if (_global.GameInterface) {
v2 = _global.GameInterface.GetConvarNumber(name);
}
if (v2 == null || v2 == undefined) {
v2 = 0.85;
}
if (v2 <= 0.1) {
v2 = 0.1;
return v2;
}
if (v2 > 1) {
v2 = 1;
}
return v2;
};
v2.UpdateReferencePositions = function () {
var v3 = this.getSafezone('safezonex');
var v4 = this.getSafezone('safezoney');
if (_global.GameInterface) {
this.AdditionalScaling = _global.GameInterface.GetConvarNumber('hud_scaling ');
}
Lib.ResizeManager.POSITION_SAFE_LEFT = (1 - v3) / 2;
Lib.ResizeManager.POSITION_SAFE_RIGHT = Lib.ResizeManager.POSITION_SAFE_LEFT + v3;
Lib.ResizeManager.POSITION_SAFE_TOP = (1 - v4) / 2;
Lib.ResizeManager.POSITION_SAFE_BOTTOM = Lib.ResizeManager.POSITION_SAFE_TOP + v4;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_LEFT] = this.ScreenX;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_RIGHT] = this.ScreenX + this.ScreenWidth;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_TOP] = this.ScreenY;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_BOTTOM] = this.ScreenY + this.ScreenHeight;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_CENTER_X] = Math.floor((this.ReferencePositions[Lib.ResizeManager.REFERENCE_LEFT] + this.ReferencePositions[Lib.ResizeManager.REFERENCE_RIGHT]) / 2);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_CENTER_Y] = Math.floor((this.ReferencePositions[Lib.ResizeManager.REFERENCE_TOP] + this.ReferencePositions[Lib.ResizeManager.REFERENCE_BOTTOM]) / 2);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_SAFE_LEFT] = this.ScreenX + Math.ceil(Lib.ResizeManager.POSITION_SAFE_LEFT * this.ScreenWidth);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_SAFE_TOP] = this.ScreenY + Math.ceil(Lib.ResizeManager.POSITION_SAFE_TOP * this.ScreenHeight);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_SAFE_RIGHT] = this.ScreenX + Math.floor(Lib.ResizeManager.POSITION_SAFE_RIGHT * this.ScreenWidth);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_SAFE_BOTTOM] = this.ScreenY + Math.floor(Lib.ResizeManager.POSITION_SAFE_BOTTOM * this.ScreenHeight);
};
v2.GetScalingValue = function (index, disableAdditionalScaling) {
if (disableAdditionalScaling == null || disableAdditionalScaling == undefined) {
disableAdditionalScaling = this.DisableAdditionalScaling;
}
if (this.ApplyAdditionalScaling && !disableAdditionalScaling) {
return this.ScalingFactors[index] * this.AdditionalScaling;
} else {
return this.ScalingFactors[index];
}
};
v2.SetXYScaling = function (obj, scalingX, disableAdditionalScalingX, scalingY, disableAdditionalScalingY) {
if (obj.originalWidth == null) {
obj.originalWidth = obj._width;
obj.originalHeight = obj._height;
}
var v3 = this.GetScalingValue(scalingX, disableAdditionalScalingX);
var v4 = this.GetScalingValue(scalingY, disableAdditionalScalingY);
obj.scaledWidth = Math.ceil(obj.originalWidth * v3);
obj.scaledHeight = Math.ceil(obj.originalHeight * v4);
return {'x': v3, 'y': v4};
};
v2.SetScaling = function (obj, scaling) {
var v4 = scaling;
if (obj.originalWidth == null) {
obj.originalWidth = obj._width;
obj.originalHeight = obj._height;
}
scaling = this.GetScalingValue(scaling);
obj.scaledWidth = Math.ceil(obj.originalWidth * scaling);
obj.scaledHeight = Math.ceil(obj.originalHeight * scaling);
if (v4 == Lib.ResizeManager.SCALE_BIGGEST) {
if (obj.scaledWidth > this.ScreenWidth + 1 || obj.scaledHeight > this.ScreenHeight + 1) {
if (this.ScreenHeight > 0 && this.ScreenWidth / this.ScreenHeight >= 3) {
scaling = this.SetScaling(obj, Lib.ResizeManager.SCALE_SMALLEST);
}
}
}
return scaling;
};
v2.SetMatrixXY = function (obj, x, y, scaleX, scaleY) {
var v2 = new flash.geom.Matrix(scaleX, 0, 0, scaleY, x, y);
obj.transform.matrix = v2;
obj._width = Math.ceil(obj._width);
obj._height = Math.ceil(obj._height);
};
v2.SetMatrix = function (obj, x, y, scale) {
var v2 = new flash.geom.Matrix(scale, 0, 0, scale, x, y);
obj.transform.matrix = v2;
obj._width = Math.ceil(obj._width);
obj._height = Math.ceil(obj._height);
};
v2.GetPctPosition = function (position, anchor, rectDim, stageDim) {
return Math.floor(stageDim * position - rectDim * anchor);
};
v2.ResetPosition = function (obj, scaling, positiony, positionx, anchory, anchorx) {
var v3 = this.SetScaling(obj, scaling);
var v5 = this.GetPctPosition(positionx, anchorx, obj.scaledWidth, this.ScreenWidth);
var v4 = this.GetPctPosition(positiony, anchory, obj.scaledHeight, this.ScreenHeight);
this.SetMatrix(obj, this.ScreenX + v5, this.ScreenY + v4, v3);
};
v2.GetPixelPosition = function (screenReference, screenOffset, elementAlignment, elementSize) {
return Math.floor(this.ReferencePositions[screenReference] + screenOffset - elementSize * elementAlignment);
};
v2.ResetPositionByPixel = function (obj, scaling, xScreenReference, xScreenOffset, xElementAlign, yScreenReference, yScreenOffset, yElementAlign) {
var v3 = this.SetScaling(obj, scaling);
var v5 = this.GetPixelPosition(xScreenReference, xScreenOffset, xElementAlign, obj.scaledWidth);
var v4 = this.GetPixelPosition(yScreenReference, yScreenOffset, yElementAlign, obj.scaledHeight);
this.SetMatrix(obj, v5, v4, v3);
};
v2.ResetXYPositionByPixel = function (obj, scalingX, includeAdditionalScalingX, scalingY, includeAdditionalScalingY, xScreenReference, xScreenOffset, xElementAlign, yScreenReference, yScreenOffset, yElementAlign) {
var v2 = this.SetXYScaling(obj, scalingX, includeAdditionalScalingX, scalingY, includeAdditionalScalingY);
var v5 = this.GetPixelPosition(xScreenReference, xScreenOffset, xElementAlign, obj.scaledWidth);
var v4 = this.GetPixelPosition(yScreenReference, yScreenOffset, yElementAlign, obj.scaledHeight);
this.SetMatrixXY(obj, v5, v4, v2.x, v2.y);
};
v2.ResetPositionByPercentage = function (obj, scaling, xScreenReference, xScreenOffset, xElementAlign, yScreenReference, yScreenOffset, yElementAlign) {
var v3 = this.SetScaling(obj, scaling);
var v5 = this.GetPixelPosition(xScreenReference, xScreenOffset * this.ScreenWidth, xElementAlign, obj.scaledWidth);
var v4 = this.GetPixelPosition(yScreenReference, yScreenOffset * this.ScreenHeight, yElementAlign, obj.scaledHeight);
this.SetMatrix(obj, v5, v4, v3);
};
v2.updateSafeZone = function () {
this.UpdateReferencePositions();
var v4 = this.Listeners.length;
var v3;
var v2 = 0;
while (v2 < v4) {
v3 = this.Listeners[v2];
if (v3.onResize != undefined) {
this.Listeners[v2].onResize(this);
this.DisableAdditionalScaling = false;
}
v2 += 1;
}
};
v2.onResize = function () {
this.doResize(false);
};
v2.doResize = function (force) {
var v2 = Stage.visibleRect;
if (v2 == null) {
this.ScreenWidth = Stage.width;
this.ScreenHeight = Stage.height;
this.ScreenX = 0;
this.ScreenY = 0;
} else {
var v3 = false;
var v6 = Math.floor(v2.left);
var v4 = Math.floor(v2.top);
var v9 = Math.ceil(v2.width);
var v8 = Math.ceil(v2.height);
if (this.ScreenWidth != v9 || force) {
this.ScreenWidth = v9;
this.ScreenHeight = v8;
this.ScreenX = v6;
this.ScreenY = v4;
v3 = true;
} else {
if (this.ScreenHeight != v8) {
this.ScreenHeight = v8;
this.ScreenX = v6;
this.ScreenY = v4;
v3 = true;
} else {
if (this.ScreenX != v6) {
this.ScreenX = v6;
this.ScreenY = v4;
v3 = true;
} else {
if (this.ScreenY != v4) {
this.ScreenY = v4;
v3 = true;
}
}
}
}
if (!v3) {
return undefined;
}
}
var v5 = this.ScreenWidth / this.AuthoredWidth;
var v7 = this.ScreenHeight / this.AuthoredHeight;
if (v5 >= v7) {
this.ScalingFactors[Lib.ResizeManager.SCALE_BIGGEST] = v5;
this.ScalingFactors[Lib.ResizeManager.SCALE_SMALLEST] = v7;
} else {
this.ScalingFactors[Lib.ResizeManager.SCALE_BIGGEST] = v7;
this.ScalingFactors[Lib.ResizeManager.SCALE_SMALLEST] = v5;
}
this.ScalingFactors[Lib.ResizeManager.SCALE_USING_VERTICAL] = v7;
this.ScalingFactors[Lib.ResizeManager.SCALE_USING_HORIZONTAL] = v5;
this.updateSafeZone();
};
v2.changeUIDevice = function () {
var v4 = this.Listeners.length;
var v3;
var v2 = 0;
while (v2 < v4) {
v3 = this.Listeners[v2];
if (v3.changeUIDevice != undefined) {
this.Listeners[v2].changeUIDevice();
}
v2 += 1;
}
};
v2.GetListenerIndex = function (listener, l) {
var v2 = 0;
if (l == -1) {
l = this.Listeners.length - 1;
}
while (v2 <= l) {
if (this.Listeners[v2] == listener) {
return v2;
} else {
++v2;
}
}
return -1;
};
v2.AddListener = function (listener) {
if (this.GetListenerIndex(listener, -1) == -1) {
this.Listeners.push(listener);
listener.onResize(this);
this.DisableAdditionalScaling = false;
}
};
v2.RemoveListener = function (listener) {
var v3 = this.Listeners.length - 1;
var v2 = this.GetListenerIndex(listener, v3);
if (v2 == -1) {
return undefined;
}
if (v2 == v3) {
this.Listeners.length = v3;
} else {
if (v2 == 0) {
this.Listeners.shift();
} else {
this.Listeners = (this.Listeners.slice(0, v2)).concat(this.Listeners.slice(v2 + 1, v3 + 1));
}
}
};
v1.Init = function () {
if (_global.resizeManager == null) {
var v2 = new Lib.ResizeManager();
var v3 = Stage.originalRect;
if (v3 != null) {
v2.AuthoredWidth = v3.width;
v2.AuthoredHeight = v3.height;
} else {
v2.AuthoredWidth = Stage.width;
v2.AuthoredHeight = Stage.height;
}
v2.onResize();
Stage.addListener(v2);
_global.resizeManager = v2;
}
};
v2.Remove = function () {
this.Listeners.length = 0;
Stage.removeListener(this);
_global.resizeManager = null;
};
v1.ALIGN_NONE = 0;
v1.ALIGN_LEFT = 0;
v1.ALIGN_RIGHT = 1;
v1.ALIGN_TOP = 0;
v1.ALIGN_BOTTOM = 1;
v1.ALIGN_CENTER = 0.5;
v1.POSITION_LEFT = 0;
v1.POSITION_SAFE_LEFT = 0.075;
v1.POSITION_RIGHT = 1;
v1.POSITION_SAFE_RIGHT = 0.925;
v1.POSITION_TOP = 0;
v1.POSITION_SAFE_TOP = 0.075;
v1.POSITION_BOTTOM = 1;
v1.POSITION_SAFE_BOTTOM = 0.925;
v1.POSITION_CENTER = 0.5;
v1.REFERENCE_LEFT = 0;
v1.REFERENCE_TOP = 1;
v1.REFERENCE_SAFE_LEFT = 2;
v1.REFERENCE_SAFE_TOP = 3;
v1.REFERENCE_RIGHT = 4;
v1.REFERENCE_BOTTOM = 5;
v1.REFERENCE_SAFE_RIGHT = 6;
v1.REFERENCE_SAFE_BOTTOM = 7;
v1.REFERENCE_CENTER_X = 8;
v1.REFERENCE_CENTER_Y = 9;
v1.SCALE_NONE = 0;
v1.SCALE_BIGGEST = 1;
v1.SCALE_SMALLEST = 2;
v1.SCALE_USING_VERTICAL = 3;
v1.SCALE_USING_HORIZONTAL = 4;
v1.PC_BORDER_SIZE = 10;
v2.ScalingFactors = new Array();
v2.ReferencePositions = new Array();
v2.ScreenWidth = -1;
v2.ScreenHeight = -1;
v2.ScreenX = -1;
v2.ScreenY = -1;
v2.DisableAdditionalScaling = false;
v2.Listeners = new Array();
ASSetPropFlags(Lib.ResizeManager.prototype, null, 1);
}
#endinitclip
}
}
background.swf is the file we are after so I decompiled the swf into the actionscript code But I'm not familiar with it. Anyone got any idea's ?
the code:
movie 'D:\steam\SteamApps\common\Counter-Strike Global Offensive\csgo\resource\flash\background.swf' {
// flash 8, total frames: 1, frame rate: 30 fps, 1280x720 px, compressed
frame 1 {
function onResize(rm) {
rm.DisableAdditionalScaling = true;
rm.ResetPosition(BackgroundMain, Lib.ResizeManager.SCALE_BIGGEST, Lib.ResizeManager.POSITION_CENTER, Lib.ResizeManager.POSITION_CENTER, Lib.ResizeManager.ALIGN_CENTER, Lib.ResizeManager.ALIGN_CENTER);
}
function onUIHide(mc, rm) {
hideBackground();
}
function onUIShow(mc, rm) {
showBackground();
}
function showBackground() {
var v2 = _global.GameInterface.GetConvarNumber('player_team playedlast') == _global.TeamID_CounterTerrorist;
BackgroundMain.BackgroundHolder.bg_CT._visible = v2;
BackgroundMain.BackgroundHolder.bg_T._visible = !v2;
BackgroundMain.gotoAndPlay('StartShow');
}
function hideBackground() {
BackgroundMain.gotoAndPlay('StartHide');
}
function onUnload(mc) {
_global.FrontEndBackgroundMovie = null;
_global.resizeManager.RemoveListener(this);
return true;
}
_global.FrontEndBackgroundMovie = this;
_global.resizeManager.AddListener(this);
stop();
}
movieClip 3 {
}
movieClip 4 {
}
movieClip 5 {
frame 1 {
}
}
movieClip 7 {
}
movieClip 8 {
frame 2001 {
gotoAndPlay(1);
}
}
movieClip 11 {
}
movieClip 14 {
}
movieClip 15 {
frame 500 {
gotoAndPlay(1);
}
}
movieClip 17 {
}
movieClip 18 {
frame 600 {
gotoAndPlay(1);
}
}
movieClip 21 {
}
movieClip 24 {
}
movieClip 27 {
}
movieClip 30 {
}
movieClip 33 {
}
movieClip 36 {
}
movieClip 39 {
}
movieClip 40 {
}
movieClip 41 {
frame 2500 {
gotoAndPlay(1);
}
}
movieClip 44 {
}
movieClip 46 {
}
movieClip 47 {
frame 1001 {
gotoAndPlay(1);
}
}
movieClip 48 {
frame 1 {
stop();
ct2a._visible = false;
t2a._visible = false;
}
frame 2 {
stop();
}
frame 11 {
stop();
if (bRunFisrtTime == false) {
ct2a._visible = false;
t2a._visible = false;
bRunFisrtTime = true;
}
}
frame 21 {
gotoAndStop(2);
}
}
movieClip 51 {
}
movieClip 52 {
}
movieClip 53 {
frame 1 {
this.stop();
}
frame 22 {
stop();
}
frame 33 {
stop();
}
}
movieClip 54 __Packages.Lib.ResizeManager {
#initclip
if (!_global.Lib) {
_global.Lib = new Object();
}
if (!_global.Lib.ResizeManager) {
var v1 = function () {
var v2 = 0;
while (v2 <= Lib.ResizeManager.SCALE_USING_HORIZONTAL) {
this.ScalingFactors.push(1);
++v2;
}
v2 = 0;
while (v2 <= Lib.ResizeManager.REFERENCE_CENTER_Y) {
this.ReferencePositions.push(0);
++v2;
}
};
Lib.ResizeManager = v1;
var v2 = v1.prototype;
v2.getSafezone = function (name) {
var v2 = 0.85;
if (_global.GameInterface) {
v2 = _global.GameInterface.GetConvarNumber(name);
}
if (v2 == null || v2 == undefined) {
v2 = 0.85;
}
if (v2 <= 0.1) {
v2 = 0.1;
return v2;
}
if (v2 > 1) {
v2 = 1;
}
return v2;
};
v2.UpdateReferencePositions = function () {
var v3 = this.getSafezone('safezonex');
var v4 = this.getSafezone('safezoney');
if (_global.GameInterface) {
this.AdditionalScaling = _global.GameInterface.GetConvarNumber('hud_scaling ');
}
Lib.ResizeManager.POSITION_SAFE_LEFT = (1 - v3) / 2;
Lib.ResizeManager.POSITION_SAFE_RIGHT = Lib.ResizeManager.POSITION_SAFE_LEFT + v3;
Lib.ResizeManager.POSITION_SAFE_TOP = (1 - v4) / 2;
Lib.ResizeManager.POSITION_SAFE_BOTTOM = Lib.ResizeManager.POSITION_SAFE_TOP + v4;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_LEFT] = this.ScreenX;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_RIGHT] = this.ScreenX + this.ScreenWidth;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_TOP] = this.ScreenY;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_BOTTOM] = this.ScreenY + this.ScreenHeight;
this.ReferencePositions[Lib.ResizeManager.REFERENCE_CENTER_X] = Math.floor((this.ReferencePositions[Lib.ResizeManager.REFERENCE_LEFT] + this.ReferencePositions[Lib.ResizeManager.REFERENCE_RIGHT]) / 2);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_CENTER_Y] = Math.floor((this.ReferencePositions[Lib.ResizeManager.REFERENCE_TOP] + this.ReferencePositions[Lib.ResizeManager.REFERENCE_BOTTOM]) / 2);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_SAFE_LEFT] = this.ScreenX + Math.ceil(Lib.ResizeManager.POSITION_SAFE_LEFT * this.ScreenWidth);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_SAFE_TOP] = this.ScreenY + Math.ceil(Lib.ResizeManager.POSITION_SAFE_TOP * this.ScreenHeight);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_SAFE_RIGHT] = this.ScreenX + Math.floor(Lib.ResizeManager.POSITION_SAFE_RIGHT * this.ScreenWidth);
this.ReferencePositions[Lib.ResizeManager.REFERENCE_SAFE_BOTTOM] = this.ScreenY + Math.floor(Lib.ResizeManager.POSITION_SAFE_BOTTOM * this.ScreenHeight);
};
v2.GetScalingValue = function (index, disableAdditionalScaling) {
if (disableAdditionalScaling == null || disableAdditionalScaling == undefined) {
disableAdditionalScaling = this.DisableAdditionalScaling;
}
if (this.ApplyAdditionalScaling && !disableAdditionalScaling) {
return this.ScalingFactors[index] * this.AdditionalScaling;
} else {
return this.ScalingFactors[index];
}
};
v2.SetXYScaling = function (obj, scalingX, disableAdditionalScalingX, scalingY, disableAdditionalScalingY) {
if (obj.originalWidth == null) {
obj.originalWidth = obj._width;
obj.originalHeight = obj._height;
}
var v3 = this.GetScalingValue(scalingX, disableAdditionalScalingX);
var v4 = this.GetScalingValue(scalingY, disableAdditionalScalingY);
obj.scaledWidth = Math.ceil(obj.originalWidth * v3);
obj.scaledHeight = Math.ceil(obj.originalHeight * v4);
return {'x': v3, 'y': v4};
};
v2.SetScaling = function (obj, scaling) {
var v4 = scaling;
if (obj.originalWidth == null) {
obj.originalWidth = obj._width;
obj.originalHeight = obj._height;
}
scaling = this.GetScalingValue(scaling);
obj.scaledWidth = Math.ceil(obj.originalWidth * scaling);
obj.scaledHeight = Math.ceil(obj.originalHeight * scaling);
if (v4 == Lib.ResizeManager.SCALE_BIGGEST) {
if (obj.scaledWidth > this.ScreenWidth + 1 || obj.scaledHeight > this.ScreenHeight + 1) {
if (this.ScreenHeight > 0 && this.ScreenWidth / this.ScreenHeight >= 3) {
scaling = this.SetScaling(obj, Lib.ResizeManager.SCALE_SMALLEST);
}
}
}
return scaling;
};
v2.SetMatrixXY = function (obj, x, y, scaleX, scaleY) {
var v2 = new flash.geom.Matrix(scaleX, 0, 0, scaleY, x, y);
obj.transform.matrix = v2;
obj._width = Math.ceil(obj._width);
obj._height = Math.ceil(obj._height);
};
v2.SetMatrix = function (obj, x, y, scale) {
var v2 = new flash.geom.Matrix(scale, 0, 0, scale, x, y);
obj.transform.matrix = v2;
obj._width = Math.ceil(obj._width);
obj._height = Math.ceil(obj._height);
};
v2.GetPctPosition = function (position, anchor, rectDim, stageDim) {
return Math.floor(stageDim * position - rectDim * anchor);
};
v2.ResetPosition = function (obj, scaling, positiony, positionx, anchory, anchorx) {
var v3 = this.SetScaling(obj, scaling);
var v5 = this.GetPctPosition(positionx, anchorx, obj.scaledWidth, this.ScreenWidth);
var v4 = this.GetPctPosition(positiony, anchory, obj.scaledHeight, this.ScreenHeight);
this.SetMatrix(obj, this.ScreenX + v5, this.ScreenY + v4, v3);
};
v2.GetPixelPosition = function (screenReference, screenOffset, elementAlignment, elementSize) {
return Math.floor(this.ReferencePositions[screenReference] + screenOffset - elementSize * elementAlignment);
};
v2.ResetPositionByPixel = function (obj, scaling, xScreenReference, xScreenOffset, xElementAlign, yScreenReference, yScreenOffset, yElementAlign) {
var v3 = this.SetScaling(obj, scaling);
var v5 = this.GetPixelPosition(xScreenReference, xScreenOffset, xElementAlign, obj.scaledWidth);
var v4 = this.GetPixelPosition(yScreenReference, yScreenOffset, yElementAlign, obj.scaledHeight);
this.SetMatrix(obj, v5, v4, v3);
};
v2.ResetXYPositionByPixel = function (obj, scalingX, includeAdditionalScalingX, scalingY, includeAdditionalScalingY, xScreenReference, xScreenOffset, xElementAlign, yScreenReference, yScreenOffset, yElementAlign) {
var v2 = this.SetXYScaling(obj, scalingX, includeAdditionalScalingX, scalingY, includeAdditionalScalingY);
var v5 = this.GetPixelPosition(xScreenReference, xScreenOffset, xElementAlign, obj.scaledWidth);
var v4 = this.GetPixelPosition(yScreenReference, yScreenOffset, yElementAlign, obj.scaledHeight);
this.SetMatrixXY(obj, v5, v4, v2.x, v2.y);
};
v2.ResetPositionByPercentage = function (obj, scaling, xScreenReference, xScreenOffset, xElementAlign, yScreenReference, yScreenOffset, yElementAlign) {
var v3 = this.SetScaling(obj, scaling);
var v5 = this.GetPixelPosition(xScreenReference, xScreenOffset * this.ScreenWidth, xElementAlign, obj.scaledWidth);
var v4 = this.GetPixelPosition(yScreenReference, yScreenOffset * this.ScreenHeight, yElementAlign, obj.scaledHeight);
this.SetMatrix(obj, v5, v4, v3);
};
v2.updateSafeZone = function () {
this.UpdateReferencePositions();
var v4 = this.Listeners.length;
var v3;
var v2 = 0;
while (v2 < v4) {
v3 = this.Listeners[v2];
if (v3.onResize != undefined) {
this.Listeners[v2].onResize(this);
this.DisableAdditionalScaling = false;
}
v2 += 1;
}
};
v2.onResize = function () {
this.doResize(false);
};
v2.doResize = function (force) {
var v2 = Stage.visibleRect;
if (v2 == null) {
this.ScreenWidth = Stage.width;
this.ScreenHeight = Stage.height;
this.ScreenX = 0;
this.ScreenY = 0;
} else {
var v3 = false;
var v6 = Math.floor(v2.left);
var v4 = Math.floor(v2.top);
var v9 = Math.ceil(v2.width);
var v8 = Math.ceil(v2.height);
if (this.ScreenWidth != v9 || force) {
this.ScreenWidth = v9;
this.ScreenHeight = v8;
this.ScreenX = v6;
this.ScreenY = v4;
v3 = true;
} else {
if (this.ScreenHeight != v8) {
this.ScreenHeight = v8;
this.ScreenX = v6;
this.ScreenY = v4;
v3 = true;
} else {
if (this.ScreenX != v6) {
this.ScreenX = v6;
this.ScreenY = v4;
v3 = true;
} else {
if (this.ScreenY != v4) {
this.ScreenY = v4;
v3 = true;
}
}
}
}
if (!v3) {
return undefined;
}
}
var v5 = this.ScreenWidth / this.AuthoredWidth;
var v7 = this.ScreenHeight / this.AuthoredHeight;
if (v5 >= v7) {
this.ScalingFactors[Lib.ResizeManager.SCALE_BIGGEST] = v5;
this.ScalingFactors[Lib.ResizeManager.SCALE_SMALLEST] = v7;
} else {
this.ScalingFactors[Lib.ResizeManager.SCALE_BIGGEST] = v7;
this.ScalingFactors[Lib.ResizeManager.SCALE_SMALLEST] = v5;
}
this.ScalingFactors[Lib.ResizeManager.SCALE_USING_VERTICAL] = v7;
this.ScalingFactors[Lib.ResizeManager.SCALE_USING_HORIZONTAL] = v5;
this.updateSafeZone();
};
v2.changeUIDevice = function () {
var v4 = this.Listeners.length;
var v3;
var v2 = 0;
while (v2 < v4) {
v3 = this.Listeners[v2];
if (v3.changeUIDevice != undefined) {
this.Listeners[v2].changeUIDevice();
}
v2 += 1;
}
};
v2.GetListenerIndex = function (listener, l) {
var v2 = 0;
if (l == -1) {
l = this.Listeners.length - 1;
}
while (v2 <= l) {
if (this.Listeners[v2] == listener) {
return v2;
} else {
++v2;
}
}
return -1;
};
v2.AddListener = function (listener) {
if (this.GetListenerIndex(listener, -1) == -1) {
this.Listeners.push(listener);
listener.onResize(this);
this.DisableAdditionalScaling = false;
}
};
v2.RemoveListener = function (listener) {
var v3 = this.Listeners.length - 1;
var v2 = this.GetListenerIndex(listener, v3);
if (v2 == -1) {
return undefined;
}
if (v2 == v3) {
this.Listeners.length = v3;
} else {
if (v2 == 0) {
this.Listeners.shift();
} else {
this.Listeners = (this.Listeners.slice(0, v2)).concat(this.Listeners.slice(v2 + 1, v3 + 1));
}
}
};
v1.Init = function () {
if (_global.resizeManager == null) {
var v2 = new Lib.ResizeManager();
var v3 = Stage.originalRect;
if (v3 != null) {
v2.AuthoredWidth = v3.width;
v2.AuthoredHeight = v3.height;
} else {
v2.AuthoredWidth = Stage.width;
v2.AuthoredHeight = Stage.height;
}
v2.onResize();
Stage.addListener(v2);
_global.resizeManager = v2;
}
};
v2.Remove = function () {
this.Listeners.length = 0;
Stage.removeListener(this);
_global.resizeManager = null;
};
v1.ALIGN_NONE = 0;
v1.ALIGN_LEFT = 0;
v1.ALIGN_RIGHT = 1;
v1.ALIGN_TOP = 0;
v1.ALIGN_BOTTOM = 1;
v1.ALIGN_CENTER = 0.5;
v1.POSITION_LEFT = 0;
v1.POSITION_SAFE_LEFT = 0.075;
v1.POSITION_RIGHT = 1;
v1.POSITION_SAFE_RIGHT = 0.925;
v1.POSITION_TOP = 0;
v1.POSITION_SAFE_TOP = 0.075;
v1.POSITION_BOTTOM = 1;
v1.POSITION_SAFE_BOTTOM = 0.925;
v1.POSITION_CENTER = 0.5;
v1.REFERENCE_LEFT = 0;
v1.REFERENCE_TOP = 1;
v1.REFERENCE_SAFE_LEFT = 2;
v1.REFERENCE_SAFE_TOP = 3;
v1.REFERENCE_RIGHT = 4;
v1.REFERENCE_BOTTOM = 5;
v1.REFERENCE_SAFE_RIGHT = 6;
v1.REFERENCE_SAFE_BOTTOM = 7;
v1.REFERENCE_CENTER_X = 8;
v1.REFERENCE_CENTER_Y = 9;
v1.SCALE_NONE = 0;
v1.SCALE_BIGGEST = 1;
v1.SCALE_SMALLEST = 2;
v1.SCALE_USING_VERTICAL = 3;
v1.SCALE_USING_HORIZONTAL = 4;
v1.PC_BORDER_SIZE = 10;
v2.ScalingFactors = new Array();
v2.ReferencePositions = new Array();
v2.ScreenWidth = -1;
v2.ScreenHeight = -1;
v2.ScreenX = -1;
v2.ScreenY = -1;
v2.DisableAdditionalScaling = false;
v2.Listeners = new Array();
ASSetPropFlags(Lib.ResizeManager.prototype, null, 1);
}
#endinitclip
}
}