Section 1
//b2CircleDef (Box2D.Collision.Shapes.b2CircleDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2CircleDef extends b2ShapeDef {
public var radius:Number;
public var localPosition:b2Vec2;
public function b2CircleDef(){
localPosition = new b2Vec2(0, 0);
super();
type = b2Shape.e_circleShape;
radius = 1;
}
}
}//package Box2D.Collision.Shapes
Section 2
//b2CircleShape (Box2D.Collision.Shapes.b2CircleShape)
package Box2D.Collision.Shapes {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2CircleShape extends b2Shape {
public var m_localPosition:b2Vec2;
public var m_radius:Number;
public function b2CircleShape(def:b2ShapeDef){
m_localPosition = new b2Vec2();
super(def);
var circleDef:b2CircleDef = (def as b2CircleDef);
m_type = e_circleShape;
m_localPosition.SetV(circleDef.localPosition);
m_radius = circleDef.radius;
}
override public function TestSegment(transform:b2XForm, lambda:Array, normal:b2Vec2, segment:b2Segment, maxLambda:Number):Boolean{
var sY:Number;
var tMat:b2Mat22 = transform.R;
var positionX:Number = (transform.position.x + ((tMat.col1.x * m_localPosition.x) + (tMat.col2.x * m_localPosition.y)));
var positionY:Number = (transform.position.x + ((tMat.col1.y * m_localPosition.x) + (tMat.col2.y * m_localPosition.y)));
var sX:Number = (segment.p1.x - positionX);
sY = (segment.p1.y - positionY);
var b:Number = (((sX * sX) + (sY * sY)) - (m_radius * m_radius));
if (b < 0){
return (false);
};
var rX:Number = (segment.p2.x - segment.p1.x);
var rY:Number = (segment.p2.y - segment.p1.y);
var c:Number = ((sX * rX) + (sY * rY));
var rr:Number = ((rX * rX) + (rY * rY));
var sigma:Number = ((c * c) - (rr * b));
if ((((sigma < 0)) || ((rr < Number.MIN_VALUE)))){
return (false);
};
var a:Number = -((c + Math.sqrt(sigma)));
if ((((0 <= a)) && ((a <= (maxLambda * rr))))){
a = (a / rr);
lambda[0] = a;
normal.x = (sX + (a * rX));
normal.y = (sY + (a * rY));
normal.Normalize();
return (true);
};
return (false);
}
public function GetLocalPosition():b2Vec2{
return (m_localPosition);
}
public function GetRadius():Number{
return (m_radius);
}
override public function ComputeSweptAABB(aabb:b2AABB, transform1:b2XForm, transform2:b2XForm):void{
var tMat:b2Mat22;
tMat = transform1.R;
var p1X:Number = (transform1.position.x + ((tMat.col1.x * m_localPosition.x) + (tMat.col2.x * m_localPosition.y)));
var p1Y:Number = (transform1.position.y + ((tMat.col1.y * m_localPosition.x) + (tMat.col2.y * m_localPosition.y)));
tMat = transform2.R;
var p2X:Number = (transform2.position.x + ((tMat.col1.x * m_localPosition.x) + (tMat.col2.x * m_localPosition.y)));
var p2Y:Number = (transform2.position.y + ((tMat.col1.y * m_localPosition.x) + (tMat.col2.y * m_localPosition.y)));
aabb.lowerBound.Set((((p1X < p2X)) ? p1X : p2X - m_radius), (((p1Y < p2Y)) ? p1Y : p2Y - m_radius));
aabb.upperBound.Set((((p1X > p2X)) ? p1X : p2X + m_radius), (((p1Y > p2Y)) ? p1Y : p2Y + m_radius));
}
override public function ComputeMass(massData:b2MassData):void{
massData.mass = (((m_density * b2Settings.b2_pi) * m_radius) * m_radius);
massData.center.SetV(m_localPosition);
massData.I = (massData.mass * (((0.5 * m_radius) * m_radius) + ((m_localPosition.x * m_localPosition.x) + (m_localPosition.y * m_localPosition.y))));
}
override public function UpdateSweepRadius(center:b2Vec2):void{
var dX:Number = (m_localPosition.x - center.x);
var dY:Number = (m_localPosition.y - center.y);
dX = Math.sqrt(((dX * dX) + (dY * dY)));
m_sweepRadius = ((dX + m_radius) - b2Settings.b2_toiSlop);
}
override public function ComputeAABB(aabb:b2AABB, transform:b2XForm):void{
var tMat:b2Mat22 = transform.R;
var pX:Number = (transform.position.x + ((tMat.col1.x * m_localPosition.x) + (tMat.col2.x * m_localPosition.y)));
var pY:Number = (transform.position.y + ((tMat.col1.y * m_localPosition.x) + (tMat.col2.y * m_localPosition.y)));
aabb.lowerBound.Set((pX - m_radius), (pY - m_radius));
aabb.upperBound.Set((pX + m_radius), (pY + m_radius));
}
override public function TestPoint(transform:b2XForm, p:b2Vec2):Boolean{
var tMat:b2Mat22 = transform.R;
var dX:Number = (transform.position.x + ((tMat.col1.x * m_localPosition.x) + (tMat.col2.x * m_localPosition.y)));
var dY:Number = (transform.position.y + ((tMat.col1.y * m_localPosition.x) + (tMat.col2.y * m_localPosition.y)));
dX = (p.x - dX);
dY = (p.y - dY);
return ((((dX * dX) + (dY * dY)) <= (m_radius * m_radius)));
}
}
}//package Box2D.Collision.Shapes
Section 3
//b2FilterData (Box2D.Collision.Shapes.b2FilterData)
package Box2D.Collision.Shapes {
public class b2FilterData {
public var maskBits:uint;// = 0xFFFF
public var groupIndex:int;// = 0
public var categoryBits:uint;// = 1
public function b2FilterData(){
super();
}
public function Copy():b2FilterData{
var copy:b2FilterData = new b2FilterData();
copy.categoryBits = categoryBits;
copy.maskBits = maskBits;
copy.groupIndex = groupIndex;
return (copy);
}
}
}//package Box2D.Collision.Shapes
Section 4
//b2MassData (Box2D.Collision.Shapes.b2MassData)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
public class b2MassData {
public var mass:Number;// = 0
public var center:b2Vec2;
public var I:Number;// = 0
public function b2MassData(){
center = new b2Vec2(0, 0);
super();
}
}
}//package Box2D.Collision.Shapes
Section 5
//b2PolygonDef (Box2D.Collision.Shapes.b2PolygonDef)
package Box2D.Collision.Shapes {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PolygonDef extends b2ShapeDef {
public var vertices:Array;
public var vertexCount:int;
private static var s_mat:b2Mat22 = new b2Mat22();
public function b2PolygonDef(){
vertices = new Array(b2Settings.b2_maxPolygonVertices);
super();
type = b2Shape.e_polygonShape;
vertexCount = 0;
var i:int;
while (i < b2Settings.b2_maxPolygonVertices) {
vertices[i] = new b2Vec2();
i++;
};
}
public function SetAsOrientedBox(hx:Number, hy:Number, center:b2Vec2=null, angle:Number=0):void{
var xfPosition:b2Vec2;
var xfR:b2Mat22;
var i:int;
vertexCount = 4;
vertices[0].Set(-(hx), -(hy));
vertices[1].Set(hx, -(hy));
vertices[2].Set(hx, hy);
vertices[3].Set(-(hx), hy);
if (center){
xfPosition = center;
xfR = s_mat;
xfR.Set(angle);
i = 0;
while (i < vertexCount) {
center = vertices[i];
hx = (xfPosition.x + ((xfR.col1.x * center.x) + (xfR.col2.x * center.y)));
center.y = (xfPosition.y + ((xfR.col1.y * center.x) + (xfR.col2.y * center.y)));
center.x = hx;
i++;
};
};
}
public function SetAsBox(hx:Number, hy:Number):void{
vertexCount = 4;
vertices[0].Set(-(hx), -(hy));
vertices[1].Set(hx, -(hy));
vertices[2].Set(hx, hy);
vertices[3].Set(-(hx), hy);
}
}
}//package Box2D.Collision.Shapes
Section 6
//b2PolygonShape (Box2D.Collision.Shapes.b2PolygonShape)
package Box2D.Collision.Shapes {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2PolygonShape extends b2Shape {
public var m_coreVertices:Array;
public var m_vertices:Array;
private var s_supportVec:b2Vec2;
public var m_centroid:b2Vec2;
public var m_normals:Array;
public var m_obb:b2OBB;
public var m_vertexCount:int;
private static var s_computeMat:b2Mat22 = new b2Mat22();
private static var s_sweptAABB1:b2AABB = new b2AABB();
private static var s_sweptAABB2:b2AABB = new b2AABB();
public function b2PolygonShape(def:b2ShapeDef){
var i:int;
var edgeX:Number;
var edgeY:Number;
var len:Number;
var n1X:Number;
var n1Y:Number;
var n2X:Number;
var n2Y:Number;
var vX:Number;
var vY:Number;
var dX:Number;
var dY:Number;
var det:Number;
s_supportVec = new b2Vec2();
m_obb = new b2OBB();
m_vertices = new Array(b2Settings.b2_maxPolygonVertices);
m_normals = new Array(b2Settings.b2_maxPolygonVertices);
m_coreVertices = new Array(b2Settings.b2_maxPolygonVertices);
super(def);
m_type = e_polygonShape;
var poly:b2PolygonDef = (def as b2PolygonDef);
m_vertexCount = poly.vertexCount;
var i1:int = i;
var i2:int = i;
i = 0;
while (i < m_vertexCount) {
m_vertices[i] = poly.vertices[i].Copy();
i++;
};
i = 0;
while (i < m_vertexCount) {
i1 = i;
i2 = (((i + 1) < m_vertexCount)) ? (i + 1) : 0;
edgeX = (m_vertices[i2].x - m_vertices[i1].x);
edgeY = (m_vertices[i2].y - m_vertices[i1].y);
len = Math.sqrt(((edgeX * edgeX) + (edgeY * edgeY)));
m_normals[i] = new b2Vec2((edgeY / len), (-(edgeX) / len));
i++;
};
m_centroid = ComputeCentroid(poly.vertices, poly.vertexCount);
ComputeOBB(m_obb, m_vertices, m_vertexCount);
i = 0;
while (i < m_vertexCount) {
i1 = (((i - 1) >= 0)) ? (i - 1) : (m_vertexCount - 1);
i2 = i;
n1X = m_normals[i1].x;
n1Y = m_normals[i1].y;
n2X = m_normals[i2].x;
n2Y = m_normals[i2].y;
vX = (m_vertices[i].x - m_centroid.x);
vY = (m_vertices[i].y - m_centroid.y);
dX = (((n1X * vX) + (n1Y * vY)) - b2Settings.b2_toiSlop);
dY = (((n2X * vX) + (n2Y * vY)) - b2Settings.b2_toiSlop);
det = (1 / ((n1X * n2Y) - (n1Y * n2X)));
m_coreVertices[i] = new b2Vec2(((det * ((n2Y * dX) - (n1Y * dY))) + m_centroid.x), ((det * ((n1X * dY) - (n2X * dX))) + m_centroid.y));
i++;
};
}
override public function ComputeSweptAABB(aabb:b2AABB, transform1:b2XForm, transform2:b2XForm):void{
var aabb1:b2AABB = s_sweptAABB1;
var aabb2:b2AABB = s_sweptAABB2;
ComputeAABB(aabb1, transform1);
ComputeAABB(aabb2, transform2);
aabb.lowerBound.Set(((aabb1.lowerBound.x < aabb2.lowerBound.x)) ? aabb1.lowerBound.x : aabb2.lowerBound.x, ((aabb1.lowerBound.y < aabb2.lowerBound.y)) ? aabb1.lowerBound.y : aabb2.lowerBound.y);
aabb.upperBound.Set(((aabb1.upperBound.x > aabb2.upperBound.x)) ? aabb1.upperBound.x : aabb2.upperBound.x, ((aabb1.upperBound.y > aabb2.upperBound.y)) ? aabb1.upperBound.y : aabb2.upperBound.y);
}
public function GetVertices():Array{
return (m_vertices);
}
public function GetCoreVertices():Array{
return (m_coreVertices);
}
public function GetCentroid():b2Vec2{
return (m_centroid);
}
public function GetOBB():b2OBB{
return (m_obb);
}
public function GetFirstVertex(xf:b2XForm):b2Vec2{
return (b2Math.b2MulX(xf, m_coreVertices[0]));
}
public function Centroid(xf:b2XForm):b2Vec2{
return (b2Math.b2MulX(xf, m_centroid));
}
override public function TestSegment(xf:b2XForm, lambda:Array, normal:b2Vec2, segment:b2Segment, maxLambda:Number):Boolean{
var tX:Number;
var tY:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var numerator:Number;
var denominator:Number;
var lower:Number = 0;
var upper:Number = maxLambda;
tX = (segment.p1.x - xf.position.x);
tY = (segment.p1.y - xf.position.y);
tMat = xf.R;
var p1X:Number = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
var p1Y:Number = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
tX = (segment.p2.x - xf.position.x);
tY = (segment.p2.y - xf.position.y);
tMat = xf.R;
var p2X:Number = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
var p2Y:Number = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
var index = -1;
var i:int;
while (i < m_vertexCount) {
tVec = m_vertices[i];
tX = (tVec.x - p1X);
tY = (tVec.y - p1Y);
tVec = m_normals[i];
numerator = ((tVec.x * tX) + (tVec.y * tY));
denominator = ((tVec.x * dX) + (tVec.y * dY));
if ((((denominator < 0)) && ((numerator < (lower * denominator))))){
lower = (numerator / denominator);
index = i;
} else {
if ((((denominator > 0)) && ((numerator < (upper * denominator))))){
upper = (numerator / denominator);
};
};
if (upper < lower){
return (false);
};
i++;
};
if (index >= 0){
lambda[0] = lower;
tMat = xf.R;
tVec = m_normals[index];
normal.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
normal.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
return (true);
};
return (false);
}
override public function ComputeMass(massData:b2MassData):void{
var p2:b2Vec2;
var p3:b2Vec2;
var e1X:Number;
var e1Y:Number;
var e2X:Number;
var e2Y:Number;
var D:Number;
var triangleArea:Number;
var px:Number;
var py:Number;
var ex1:Number;
var ey1:Number;
var ex2:Number;
var ey2:Number;
var intx2:Number;
var inty2:Number;
var centerX:Number = 0;
var centerY:Number = 0;
var area:Number = 0;
var I:Number = 0;
var p1X:Number = 0;
var p1Y:Number = 0;
var k_inv3:Number = (1 / 3);
var i:int;
while (i < m_vertexCount) {
p2 = m_vertices[i];
p3 = (((i + 1) < m_vertexCount)) ? m_vertices[int((i + 1))] : m_vertices[0];
e1X = (p2.x - p1X);
e1Y = (p2.y - p1Y);
e2X = (p3.x - p1X);
e2Y = (p3.y - p1Y);
D = ((e1X * e2Y) - (e1Y * e2X));
triangleArea = (0.5 * D);
area = (area + triangleArea);
centerX = (centerX + ((triangleArea * k_inv3) * ((p1X + p2.x) + p3.x)));
centerY = (centerY + ((triangleArea * k_inv3) * ((p1Y + p2.y) + p3.y)));
px = p1X;
py = p1Y;
ex1 = e1X;
ey1 = e1Y;
ex2 = e2X;
ey2 = e2Y;
intx2 = ((k_inv3 * ((0.25 * (((ex1 * ex1) + (ex2 * ex1)) + (ex2 * ex2))) + ((px * ex1) + (px * ex2)))) + ((0.5 * px) * px));
inty2 = ((k_inv3 * ((0.25 * (((ey1 * ey1) + (ey2 * ey1)) + (ey2 * ey2))) + ((py * ey1) + (py * ey2)))) + ((0.5 * py) * py));
I = (I + (D * (intx2 + inty2)));
i++;
};
massData.mass = (m_density * area);
centerX = (centerX * (1 / area));
centerY = (centerY * (1 / area));
massData.center.Set(centerX, centerY);
massData.I = (m_density * I);
}
public function GetNormals():Array{
return (m_normals);
}
public function Support(xf:b2XForm, dX:Number, dY:Number):b2Vec2{
var tVec:b2Vec2;
var tMat:b2Mat22;
var value:Number;
tMat = xf.R;
var dLocalX:Number = ((dX * tMat.col1.x) + (dY * tMat.col1.y));
var dLocalY:Number = ((dX * tMat.col2.x) + (dY * tMat.col2.y));
var bestIndex:int;
tVec = m_coreVertices[0];
var bestValue:Number = ((tVec.x * dLocalX) + (tVec.y * dLocalY));
var i = 1;
while (i < m_vertexCount) {
tVec = m_coreVertices[i];
value = ((tVec.x * dLocalX) + (tVec.y * dLocalY));
if (value > bestValue){
bestIndex = i;
bestValue = value;
};
i++;
};
tMat = xf.R;
tVec = m_coreVertices[bestIndex];
s_supportVec.x = (xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
s_supportVec.y = (xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
return (s_supportVec);
}
public function GetVertexCount():int{
return (m_vertexCount);
}
override public function ComputeAABB(aabb:b2AABB, xf:b2XForm):void{
var tMat:b2Mat22;
var tVec:b2Vec2;
var R:b2Mat22 = s_computeMat;
tMat = xf.R;
tVec = m_obb.R.col1;
R.col1.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
R.col1.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tVec = m_obb.R.col2;
R.col2.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
R.col2.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
R.Abs();
var absR:b2Mat22 = R;
tVec = m_obb.extents;
var hX:Number = ((absR.col1.x * tVec.x) + (absR.col2.x * tVec.y));
var hY:Number = ((absR.col1.y * tVec.x) + (absR.col2.y * tVec.y));
tMat = xf.R;
tVec = m_obb.center;
var positionX:Number = (xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var positionY:Number = (xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
aabb.lowerBound.Set((positionX - hX), (positionY - hY));
aabb.upperBound.Set((positionX + hX), (positionY + hY));
}
override public function UpdateSweepRadius(center:b2Vec2):void{
var tVec:b2Vec2;
var dX:Number;
var dY:Number;
m_sweepRadius = 0;
var i:int;
while (i < m_vertexCount) {
tVec = m_coreVertices[i];
dX = (tVec.x - center.x);
dY = (tVec.y - center.y);
dX = Math.sqrt(((dX * dX) + (dY * dY)));
if (dX > m_sweepRadius){
m_sweepRadius = dX;
};
i++;
};
}
override public function TestPoint(xf:b2XForm, p:b2Vec2):Boolean{
var tVec:b2Vec2;
var dot:Number;
var tMat:b2Mat22 = xf.R;
var tX:Number = (p.x - xf.position.x);
var tY:Number = (p.y - xf.position.y);
var pLocalX:Number = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
var pLocalY:Number = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
var i:int;
while (i < m_vertexCount) {
tVec = m_vertices[i];
tX = (pLocalX - tVec.x);
tY = (pLocalY - tVec.y);
tVec = m_normals[i];
dot = ((tVec.x * tX) + (tVec.y * tY));
if (dot > 0){
return (false);
};
i++;
};
return (true);
}
public static function ComputeCentroid(vs:Array, count:int):b2Vec2{
var c:b2Vec2;
var inv3:Number;
var p2:b2Vec2;
var p3:b2Vec2;
var e1X:Number;
var e1Y:Number;
var e2X:Number;
var e2Y:Number;
var D:Number;
var triangleArea:Number;
c = new b2Vec2();
var area:Number = 0;
var p1X:Number = 0;
var p1Y:Number = 0;
inv3 = (1 / 3);
var i:int;
while (i < count) {
p2 = vs[i];
p3 = (((i + 1) < count)) ? vs[int((i + 1))] : vs[0];
e1X = (p2.x - p1X);
e1Y = (p2.y - p1Y);
e2X = (p3.x - p1X);
e2Y = (p3.y - p1Y);
D = ((e1X * e2Y) - (e1Y * e2X));
triangleArea = (0.5 * D);
area = (area + triangleArea);
c.x = (c.x + ((triangleArea * inv3) * ((p1X + p2.x) + p3.x)));
c.y = (c.y + ((triangleArea * inv3) * ((p1Y + p2.y) + p3.y)));
i++;
};
c.x = (c.x * (1 / area));
c.y = (c.y * (1 / area));
return (c);
}
public static function ComputeOBB(obb:b2OBB, vs:Array, count:int):void{
var i:int;
var root:b2Vec2;
var uxX:Number;
var uxY:Number;
var length:Number;
var uyX:Number;
var uyY:Number;
var lowerX:Number;
var lowerY:Number;
var upperX:Number;
var upperY:Number;
var j:int;
var area:Number;
var dX:Number;
var dY:Number;
var rX:Number;
var rY:Number;
var centerX:Number;
var centerY:Number;
var tMat:b2Mat22;
var p:Array = new Array((b2Settings.b2_maxPolygonVertices + 1));
i = 0;
while (i < count) {
p[i] = vs[i];
i++;
};
p[count] = p[0];
var minArea:Number = Number.MAX_VALUE;
i = 1;
while (i <= count) {
root = p[int((i - 1))];
uxX = (p[i].x - root.x);
uxY = (p[i].y - root.y);
length = Math.sqrt(((uxX * uxX) + (uxY * uxY)));
uxX = (uxX / length);
uxY = (uxY / length);
uyX = -(uxY);
uyY = uxX;
lowerX = Number.MAX_VALUE;
lowerY = Number.MAX_VALUE;
upperX = -(Number.MAX_VALUE);
upperY = -(Number.MAX_VALUE);
j = 0;
while (j < count) {
dX = (p[j].x - root.x);
dY = (p[j].y - root.y);
rX = ((uxX * dX) + (uxY * dY));
rY = ((uyX * dX) + (uyY * dY));
if (rX < lowerX){
lowerX = rX;
};
if (rY < lowerY){
lowerY = rY;
};
if (rX > upperX){
upperX = rX;
};
if (rY > upperY){
upperY = rY;
};
j++;
};
area = ((upperX - lowerX) * (upperY - lowerY));
if (area < (0.95 * minArea)){
minArea = area;
obb.R.col1.x = uxX;
obb.R.col1.y = uxY;
obb.R.col2.x = uyX;
obb.R.col2.y = uyY;
centerX = (0.5 * (lowerX + upperX));
centerY = (0.5 * (lowerY + upperY));
tMat = obb.R;
obb.center.x = (root.x + ((tMat.col1.x * centerX) + (tMat.col2.x * centerY)));
obb.center.y = (root.y + ((tMat.col1.y * centerX) + (tMat.col2.y * centerY)));
obb.extents.x = (0.5 * (upperX - lowerX));
obb.extents.y = (0.5 * (upperY - lowerY));
};
i++;
};
}
}
}//package Box2D.Collision.Shapes
Section 7
//b2Shape (Box2D.Collision.Shapes.b2Shape)
package Box2D.Collision.Shapes {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
public class b2Shape {
public var m_next:b2Shape;
public var m_type:int;
public var m_sweepRadius:Number;
public var m_density:Number;
public var m_filter:b2FilterData;
public var m_friction:Number;
public var m_isSensor:Boolean;
public var m_restitution:Number;
public var m_userData;
public var m_proxyId:uint;
public var m_body:b2Body;
public static const e_polygonShape:int = 1;
public static const e_unknownShape:int = -1;
public static const e_circleShape:int = 0;
public static const e_shapeTypeCount:int = 2;
private static var s_resetAABB:b2AABB = new b2AABB();
private static var s_syncAABB:b2AABB = new b2AABB();
private static var s_proxyAABB:b2AABB = new b2AABB();
public function b2Shape(def:b2ShapeDef){
super();
m_userData = def.userData;
m_friction = def.friction;
m_restitution = def.restitution;
m_density = def.density;
m_body = null;
m_sweepRadius = 0;
m_next = null;
m_proxyId = b2Pair.b2_nullProxy;
m_filter = def.filter.Copy();
m_isSensor = def.isSensor;
}
public function SetUserData(data):void{
m_userData = data;
}
public function GetSweepRadius():Number{
return (m_sweepRadius);
}
public function GetNext():b2Shape{
return (m_next);
}
public function ComputeSweptAABB(aabb:b2AABB, xf1:b2XForm, xf2:b2XForm):void{
}
public function GetType():int{
return (m_type);
}
public function GetRestitution():Number{
return (m_restitution);
}
public function GetFriction():Number{
return (m_friction);
}
public function GetFilterData():b2FilterData{
return (m_filter.Copy());
}
public function TestSegment(xf:b2XForm, lambda:Array, normal:b2Vec2, segment:b2Segment, maxLambda:Number):Boolean{
return (false);
}
public function RefilterProxy(broadPhase:b2BroadPhase, transform:b2XForm):void{
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
broadPhase.DestroyProxy(m_proxyId);
var aabb:b2AABB = s_resetAABB;
ComputeAABB(aabb, transform);
var inRange:Boolean = broadPhase.InRange(aabb);
if (inRange){
m_proxyId = broadPhase.CreateProxy(aabb, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function SetFilterData(filter:b2FilterData):void{
m_filter = filter.Copy();
}
public function GetUserData(){
return (m_userData);
}
public function Synchronize(broadPhase:b2BroadPhase, transform1:b2XForm, transform2:b2XForm):Boolean{
if (m_proxyId == b2Pair.b2_nullProxy){
return (false);
};
var aabb:b2AABB = s_syncAABB;
ComputeSweptAABB(aabb, transform1, transform2);
if (broadPhase.InRange(aabb)){
broadPhase.MoveProxy(m_proxyId, aabb);
return (true);
};
return (false);
}
public function ComputeMass(massData:b2MassData):void{
}
public function IsSensor():Boolean{
return (m_isSensor);
}
public function DestroyProxy(broadPhase:b2BroadPhase):void{
if (m_proxyId != b2Pair.b2_nullProxy){
broadPhase.DestroyProxy(m_proxyId);
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function UpdateSweepRadius(center:b2Vec2):void{
}
public function ComputeAABB(aabb:b2AABB, xf:b2XForm):void{
}
public function GetBody():b2Body{
return (m_body);
}
public function CreateProxy(broadPhase:b2BroadPhase, transform:b2XForm):void{
var aabb:b2AABB = s_proxyAABB;
ComputeAABB(aabb, transform);
var inRange:Boolean = broadPhase.InRange(aabb);
if (inRange){
m_proxyId = broadPhase.CreateProxy(aabb, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
}
public function TestPoint(xf:b2XForm, p:b2Vec2):Boolean{
return (false);
}
public static function Destroy(shape:b2Shape, allocator):void{
}
public static function Create(def:b2ShapeDef, allocator):b2Shape{
switch (def.type){
case e_circleShape:
return (new b2CircleShape(def));
case e_polygonShape:
return (new b2PolygonShape(def));
default:
return (null);
};
}
}
}//package Box2D.Collision.Shapes
Section 8
//b2ShapeDef (Box2D.Collision.Shapes.b2ShapeDef)
package Box2D.Collision.Shapes {
public class b2ShapeDef {
public var friction:Number;// = 0.2
public var isSensor:Boolean;// = false
public var density:Number;// = 0
public var restitution:Number;// = 0
public var userData;// = null
public var filter:b2FilterData;
public var type:int;
public function b2ShapeDef(){
type = b2Shape.e_unknownShape;
filter = new b2FilterData();
super();
}
}
}//package Box2D.Collision.Shapes
Section 9
//b2AABB (Box2D.Collision.b2AABB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2AABB {
public var upperBound:b2Vec2;
public var lowerBound:b2Vec2;
public function b2AABB(){
lowerBound = new b2Vec2();
upperBound = new b2Vec2();
super();
}
public function IsValid():Boolean{
var dX:Number = (upperBound.x - lowerBound.x);
var dY:Number = (upperBound.y - lowerBound.y);
var valid:Boolean = (((dX >= 0)) && ((dY >= 0)));
valid = ((((valid) && (lowerBound.IsValid()))) && (upperBound.IsValid()));
return (valid);
}
}
}//package Box2D.Collision
Section 10
//b2Bound (Box2D.Collision.b2Bound)
package Box2D.Collision {
public class b2Bound {
public var value:uint;
public var proxyId:uint;
public var stabbingCount:uint;
public function b2Bound(){
super();
}
public function Swap(b:b2Bound):void{
var tempValue:uint = value;
var tempProxyId:uint = proxyId;
var tempStabbingCount:uint = stabbingCount;
value = b.value;
proxyId = b.proxyId;
stabbingCount = b.stabbingCount;
b.value = tempValue;
b.proxyId = tempProxyId;
b.stabbingCount = tempStabbingCount;
}
public function IsLower():Boolean{
return (((value & 1) == 0));
}
public function IsUpper():Boolean{
return (((value & 1) == 1));
}
}
}//package Box2D.Collision
Section 11
//b2BoundValues (Box2D.Collision.b2BoundValues)
package Box2D.Collision {
public class b2BoundValues {
public var lowerValues:Array;
public var upperValues:Array;
public function b2BoundValues(){
lowerValues = [0, 0];
upperValues = [0, 0];
super();
}
}
}//package Box2D.Collision
Section 12
//b2BroadPhase (Box2D.Collision.b2BroadPhase)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2BroadPhase {
public var m_bounds:Array;
public var m_quantizationFactor:b2Vec2;
public var m_worldAABB:b2AABB;
public var m_freeProxy:uint;
public var m_proxyCount:int;
public var m_proxyPool:Array;
public var m_queryResultCount:int;
public var m_pairManager:b2PairManager;
public var m_timeStamp:uint;
public var m_queryResults:Array;
public static const b2_nullEdge:uint = 0xFFFF;
public static const b2_invalid:uint = 0xFFFF;
public static var s_validate:Boolean = false;
public function b2BroadPhase(worldAABB:b2AABB, callback:b2PairCallback){
var i:int;
var dY:Number;
var tProxy:b2Proxy;
var j:int;
m_pairManager = new b2PairManager();
m_proxyPool = new Array(b2Settings.b2_maxPairs);
m_bounds = new Array((2 * b2Settings.b2_maxProxies));
m_queryResults = new Array(b2Settings.b2_maxProxies);
m_quantizationFactor = new b2Vec2();
super();
m_pairManager.Initialize(this, callback);
m_worldAABB = worldAABB;
m_proxyCount = 0;
i = 0;
while (i < b2Settings.b2_maxProxies) {
m_queryResults[i] = 0;
i++;
};
m_bounds = new Array(2);
i = 0;
while (i < 2) {
m_bounds[i] = new Array((2 * b2Settings.b2_maxProxies));
j = 0;
while (j < (2 * b2Settings.b2_maxProxies)) {
m_bounds[i][j] = new b2Bound();
j++;
};
i++;
};
var dX:Number = (worldAABB.upperBound.x - worldAABB.lowerBound.x);
dY = (worldAABB.upperBound.y - worldAABB.lowerBound.y);
m_quantizationFactor.x = (b2Settings.USHRT_MAX / dX);
m_quantizationFactor.y = (b2Settings.USHRT_MAX / dY);
i = 0;
while (i < (b2Settings.b2_maxProxies - 1)) {
tProxy = new b2Proxy();
m_proxyPool[i] = tProxy;
tProxy.SetNext((i + 1));
tProxy.timeStamp = 0;
tProxy.overlapCount = b2_invalid;
tProxy.userData = null;
i++;
};
tProxy = new b2Proxy();
m_proxyPool[int((b2Settings.b2_maxProxies - 1))] = tProxy;
tProxy.SetNext(b2Pair.b2_nullProxy);
tProxy.timeStamp = 0;
tProxy.overlapCount = b2_invalid;
tProxy.userData = null;
m_freeProxy = 0;
m_timeStamp = 1;
m_queryResultCount = 0;
}
public function QueryAABB(aabb:b2AABB, userData, maxCount:int):int{
var lowerIndex:uint;
var upperIndex:uint;
var proxy:b2Proxy;
var lowerValues:Array = new Array();
var upperValues:Array = new Array();
ComputeBounds(lowerValues, upperValues, aabb);
var lowerIndexOut:Array = [lowerIndex];
var upperIndexOut:Array = [upperIndex];
Query(lowerIndexOut, upperIndexOut, lowerValues[0], upperValues[0], m_bounds[0], (2 * m_proxyCount), 0);
Query(lowerIndexOut, upperIndexOut, lowerValues[1], upperValues[1], m_bounds[1], (2 * m_proxyCount), 1);
var count:int;
var i:int;
while ((((i < m_queryResultCount)) && ((count < maxCount)))) {
proxy = m_proxyPool[m_queryResults[i]];
userData[i] = proxy.userData;
i++;
count++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (count);
}
public function Commit():void{
m_pairManager.Commit();
}
public function GetProxy(proxyId:int):b2Proxy{
var proxy:b2Proxy = m_proxyPool[proxyId];
if ((((proxyId == b2Pair.b2_nullProxy)) || ((proxy.IsValid() == false)))){
return (null);
};
return (proxy);
}
private function IncrementTimeStamp():void{
var i:uint;
if (m_timeStamp == b2Settings.USHRT_MAX){
i = 0;
while (i < b2Settings.b2_maxProxies) {
(m_proxyPool[i] as b2Proxy).timeStamp = 0;
i++;
};
m_timeStamp = 1;
} else {
m_timeStamp++;
};
}
private function Query(lowerQueryOut:Array, upperQueryOut:Array, lowerValue:uint, upperValue:uint, bounds:Array, boundCount:uint, axis:int):void{
var bound:b2Bound;
var i:int;
var s:int;
var proxy:b2Proxy;
var lowerQuery:uint = BinarySearch(bounds, boundCount, lowerValue);
var upperQuery:uint = BinarySearch(bounds, boundCount, upperValue);
var j:uint = lowerQuery;
while (j < upperQuery) {
bound = bounds[j];
if (bound.IsLower()){
IncrementOverlapCount(bound.proxyId);
};
j++;
};
if (lowerQuery > 0){
i = (lowerQuery - 1);
bound = bounds[i];
s = bound.stabbingCount;
while (s) {
bound = bounds[i];
if (bound.IsLower()){
proxy = m_proxyPool[bound.proxyId];
if (lowerQuery <= proxy.upperBounds[axis]){
IncrementOverlapCount(bound.proxyId);
s--;
};
};
i--;
};
};
lowerQueryOut[0] = lowerQuery;
upperQueryOut[0] = upperQuery;
}
private function TestOverlapValidate(p1:b2Proxy, p2:b2Proxy):Boolean{
var bounds:Array;
var bound1:b2Bound;
var bound2:b2Bound;
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
bound1 = bounds[p1.lowerBounds[axis]];
bound2 = bounds[p2.upperBounds[axis]];
if (bound1.value > bound2.value){
return (false);
};
bound1 = bounds[p1.upperBounds[axis]];
bound2 = bounds[p2.lowerBounds[axis]];
if (bound1.value < bound2.value){
return (false);
};
axis++;
};
return (true);
}
private function ComputeBounds(lowerValues:Array, upperValues:Array, aabb:b2AABB):void{
var minVertexX:Number = aabb.lowerBound.x;
var minVertexY:Number = aabb.lowerBound.y;
minVertexX = b2Math.b2Min(minVertexX, m_worldAABB.upperBound.x);
minVertexY = b2Math.b2Min(minVertexY, m_worldAABB.upperBound.y);
minVertexX = b2Math.b2Max(minVertexX, m_worldAABB.lowerBound.x);
minVertexY = b2Math.b2Max(minVertexY, m_worldAABB.lowerBound.y);
var maxVertexX:Number = aabb.upperBound.x;
var maxVertexY:Number = aabb.upperBound.y;
maxVertexX = b2Math.b2Min(maxVertexX, m_worldAABB.upperBound.x);
maxVertexY = b2Math.b2Min(maxVertexY, m_worldAABB.upperBound.y);
maxVertexX = b2Math.b2Max(maxVertexX, m_worldAABB.lowerBound.x);
maxVertexY = b2Math.b2Max(maxVertexY, m_worldAABB.lowerBound.y);
lowerValues[0] = (uint((m_quantizationFactor.x * (minVertexX - m_worldAABB.lowerBound.x))) & (b2Settings.USHRT_MAX - 1));
upperValues[0] = ((uint((m_quantizationFactor.x * (maxVertexX - m_worldAABB.lowerBound.x))) & 0xFFFF) | 1);
lowerValues[1] = (uint((m_quantizationFactor.y * (minVertexY - m_worldAABB.lowerBound.y))) & (b2Settings.USHRT_MAX - 1));
upperValues[1] = ((uint((m_quantizationFactor.y * (maxVertexY - m_worldAABB.lowerBound.y))) & 0xFFFF) | 1);
}
public function CreateProxy(aabb:b2AABB, userData):uint{
var index:uint;
var proxy:b2Proxy;
var bounds:Array;
var lowerIndex:uint;
var upperIndex:uint;
var lowerIndexOut:Array;
var upperIndexOut:Array;
var tArr:Array;
var j:int;
var tEnd:int;
var tBound1:b2Bound;
var tBound2:b2Bound;
var tBoundAS3:b2Bound;
var tIndex:int;
var proxy2:b2Proxy;
var proxyId:uint = m_freeProxy;
proxy = m_proxyPool[proxyId];
m_freeProxy = proxy.GetNext();
proxy.overlapCount = 0;
proxy.userData = userData;
var boundCount:uint = (2 * m_proxyCount);
var lowerValues:Array = new Array();
var upperValues:Array = new Array();
ComputeBounds(lowerValues, upperValues, aabb);
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
lowerIndexOut = [lowerIndex];
upperIndexOut = [upperIndex];
Query(lowerIndexOut, upperIndexOut, lowerValues[axis], upperValues[axis], bounds, boundCount, axis);
lowerIndex = lowerIndexOut[0];
upperIndex = upperIndexOut[0];
tArr = new Array();
tEnd = (boundCount - upperIndex);
j = 0;
while (j < tEnd) {
tArr[j] = new b2Bound();
tBound1 = tArr[j];
tBound2 = bounds[int((upperIndex + j))];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = tArr.length;
tIndex = (upperIndex + 2);
j = 0;
while (j < tEnd) {
tBound2 = tArr[j];
tBound1 = bounds[int((tIndex + j))];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tArr = new Array();
tEnd = (upperIndex - lowerIndex);
j = 0;
while (j < tEnd) {
tArr[j] = new b2Bound();
tBound1 = tArr[j];
tBound2 = bounds[int((lowerIndex + j))];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = tArr.length;
tIndex = (lowerIndex + 1);
j = 0;
while (j < tEnd) {
tBound2 = tArr[j];
tBound1 = bounds[int((tIndex + j))];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
upperIndex++;
tBound1 = bounds[lowerIndex];
tBound2 = bounds[upperIndex];
tBound1.value = lowerValues[axis];
tBound1.proxyId = proxyId;
tBound2.value = upperValues[axis];
tBound2.proxyId = proxyId;
tBoundAS3 = bounds[int((lowerIndex - 1))];
tBound1.stabbingCount = ((lowerIndex == 0)) ? 0 : tBoundAS3.stabbingCount;
tBoundAS3 = bounds[int((upperIndex - 1))];
tBound2.stabbingCount = tBoundAS3.stabbingCount;
index = lowerIndex;
while (index < upperIndex) {
tBoundAS3 = bounds[index];
tBoundAS3.stabbingCount++;
index++;
};
index = lowerIndex;
while (index < (boundCount + 2)) {
tBound1 = bounds[index];
proxy2 = m_proxyPool[tBound1.proxyId];
if (tBound1.IsLower()){
proxy2.lowerBounds[axis] = index;
} else {
proxy2.upperBounds[axis] = index;
};
index++;
};
axis++;
};
m_proxyCount++;
var i:int;
while (i < m_queryResultCount) {
m_pairManager.AddBufferedPair(proxyId, m_queryResults[i]);
i++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
return (proxyId);
}
public function DestroyProxy(proxyId:uint):void{
var tBound1:b2Bound;
var tBound2:b2Bound;
var bounds:Array;
var lowerIndex:uint;
var upperIndex:uint;
var lowerValue:uint;
var upperValue:uint;
var tArr:Array;
var j:int;
var tEnd:int;
var tIndex:int;
var index:uint;
var index2:int;
var proxy2:b2Proxy;
var proxy:b2Proxy = m_proxyPool[proxyId];
var boundCount:int = (2 * m_proxyCount);
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
lowerIndex = proxy.lowerBounds[axis];
upperIndex = proxy.upperBounds[axis];
tBound1 = bounds[lowerIndex];
lowerValue = tBound1.value;
tBound2 = bounds[upperIndex];
upperValue = tBound2.value;
tArr = new Array();
tEnd = ((upperIndex - lowerIndex) - 1);
j = 0;
while (j < tEnd) {
tArr[j] = new b2Bound();
tBound1 = tArr[j];
tBound2 = bounds[int(((lowerIndex + 1) + j))];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = tArr.length;
tIndex = lowerIndex;
j = 0;
while (j < tEnd) {
tBound2 = tArr[j];
tBound1 = bounds[int((tIndex + j))];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tArr = new Array();
tEnd = ((boundCount - upperIndex) - 1);
j = 0;
while (j < tEnd) {
tArr[j] = new b2Bound();
tBound1 = tArr[j];
tBound2 = bounds[int(((upperIndex + 1) + j))];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = tArr.length;
tIndex = (upperIndex - 1);
j = 0;
while (j < tEnd) {
tBound2 = tArr[j];
tBound1 = bounds[int((tIndex + j))];
tBound1.value = tBound2.value;
tBound1.proxyId = tBound2.proxyId;
tBound1.stabbingCount = tBound2.stabbingCount;
j++;
};
tEnd = (boundCount - 2);
index = lowerIndex;
while (index < tEnd) {
tBound1 = bounds[index];
proxy2 = m_proxyPool[tBound1.proxyId];
if (tBound1.IsLower()){
proxy2.lowerBounds[axis] = index;
} else {
proxy2.upperBounds[axis] = index;
};
index++;
};
tEnd = (upperIndex - 1);
index2 = lowerIndex;
while (index2 < tEnd) {
tBound1 = bounds[index2];
tBound1.stabbingCount--;
index2++;
};
Query([0], [0], lowerValue, upperValue, bounds, (boundCount - 2), axis);
axis++;
};
var i:int;
while (i < m_queryResultCount) {
m_pairManager.RemoveBufferedPair(proxyId, m_queryResults[i]);
i++;
};
m_pairManager.Commit();
m_queryResultCount = 0;
IncrementTimeStamp();
proxy.userData = null;
proxy.overlapCount = b2_invalid;
proxy.lowerBounds[0] = b2_invalid;
proxy.lowerBounds[1] = b2_invalid;
proxy.upperBounds[0] = b2_invalid;
proxy.upperBounds[1] = b2_invalid;
proxy.SetNext(m_freeProxy);
m_freeProxy = proxyId;
m_proxyCount--;
}
public function TestOverlap(b:b2BoundValues, p:b2Proxy):Boolean{
var bounds:Array;
var bound:b2Bound;
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
bound = bounds[p.upperBounds[axis]];
if (b.lowerValues[axis] > bound.value){
return (false);
};
bound = bounds[p.lowerBounds[axis]];
if (b.upperValues[axis] < bound.value){
return (false);
};
axis++;
};
return (true);
}
public function Validate():void{
var pair:b2Pair;
var proxy1:b2Proxy;
var proxy2:b2Proxy;
var overlap:Boolean;
var bounds:b2Bound;
var boundCount:uint;
var stabbingCount:uint;
var i:uint;
var bound:b2Bound;
var axis:int;
while (axis < 2) {
bounds = m_bounds[axis];
boundCount = (2 * m_proxyCount);
stabbingCount = 0;
i = 0;
while (i < boundCount) {
bound = bounds[i];
if (bound.IsLower() == true){
stabbingCount++;
} else {
stabbingCount--;
};
i++;
};
axis++;
};
}
private function IncrementOverlapCount(proxyId:uint):void{
var proxy:b2Proxy = m_proxyPool[proxyId];
if (proxy.timeStamp < m_timeStamp){
proxy.timeStamp = m_timeStamp;
proxy.overlapCount = 1;
} else {
proxy.overlapCount = 2;
m_queryResults[m_queryResultCount] = proxyId;
m_queryResultCount++;
};
}
public function InRange(aabb:b2AABB):Boolean{
var dX:Number;
var dY:Number;
var d2X:Number;
var d2Y:Number;
dX = aabb.lowerBound.x;
dY = aabb.lowerBound.y;
dX = (dX - m_worldAABB.upperBound.x);
dY = (dY - m_worldAABB.upperBound.y);
d2X = m_worldAABB.lowerBound.x;
d2Y = m_worldAABB.lowerBound.y;
d2X = (d2X - aabb.upperBound.x);
d2Y = (d2Y - aabb.upperBound.y);
dX = b2Math.b2Max(dX, d2X);
dY = b2Math.b2Max(dY, d2Y);
return ((b2Math.b2Max(dX, dY) < 0));
}
public function MoveProxy(proxyId:uint, aabb:b2AABB):void{
var as3arr:Array;
var as3int:int;
var axis:uint;
var index:uint;
var bound:b2Bound;
var prevBound:b2Bound;
var nextBound:b2Bound;
var nextProxyId:uint;
var nextProxy:b2Proxy;
var bounds:Array;
var lowerIndex:uint;
var upperIndex:uint;
var lowerValue:uint;
var upperValue:uint;
var deltaLower:int;
var deltaUpper:int;
var prevProxyId:uint;
var prevProxy:b2Proxy;
if ((((proxyId == b2Pair.b2_nullProxy)) || ((b2Settings.b2_maxProxies <= proxyId)))){
return;
};
if (aabb.IsValid() == false){
return;
};
var boundCount:uint = (2 * m_proxyCount);
var proxy:b2Proxy = m_proxyPool[proxyId];
var newValues:b2BoundValues = new b2BoundValues();
ComputeBounds(newValues.lowerValues, newValues.upperValues, aabb);
var oldValues:b2BoundValues = new b2BoundValues();
axis = 0;
while (axis < 2) {
bound = m_bounds[axis][proxy.lowerBounds[axis]];
oldValues.lowerValues[axis] = bound.value;
bound = m_bounds[axis][proxy.upperBounds[axis]];
oldValues.upperValues[axis] = bound.value;
axis++;
};
axis = 0;
while (axis < 2) {
bounds = m_bounds[axis];
lowerIndex = proxy.lowerBounds[axis];
upperIndex = proxy.upperBounds[axis];
lowerValue = newValues.lowerValues[axis];
upperValue = newValues.upperValues[axis];
bound = bounds[lowerIndex];
deltaLower = (lowerValue - bound.value);
bound.value = lowerValue;
bound = bounds[upperIndex];
deltaUpper = (upperValue - bound.value);
bound.value = upperValue;
if (deltaLower < 0){
index = lowerIndex;
while ((((index > 0)) && ((lowerValue < (bounds[int((index - 1))] as b2Bound).value)))) {
bound = bounds[index];
prevBound = bounds[int((index - 1))];
prevProxyId = prevBound.proxyId;
prevProxy = m_proxyPool[prevBound.proxyId];
prevBound.stabbingCount++;
if (prevBound.IsUpper() == true){
if (TestOverlap(newValues, prevProxy)){
m_pairManager.AddBufferedPair(proxyId, prevProxyId);
};
as3arr = prevProxy.upperBounds;
as3int = as3arr[axis];
as3int++;
as3arr[axis] = as3int;
bound.stabbingCount++;
} else {
as3arr = prevProxy.lowerBounds;
as3int = as3arr[axis];
as3int++;
as3arr[axis] = as3int;
bound.stabbingCount--;
};
as3arr = proxy.lowerBounds;
as3int = as3arr[axis];
as3int--;
as3arr[axis] = as3int;
bound.Swap(prevBound);
index--;
};
};
if (deltaUpper > 0){
index = upperIndex;
while ((((index < (boundCount - 1))) && (((bounds[int((index + 1))] as b2Bound).value <= upperValue)))) {
bound = bounds[index];
nextBound = bounds[int((index + 1))];
nextProxyId = nextBound.proxyId;
nextProxy = m_proxyPool[nextProxyId];
nextBound.stabbingCount++;
if (nextBound.IsLower() == true){
if (TestOverlap(newValues, nextProxy)){
m_pairManager.AddBufferedPair(proxyId, nextProxyId);
};
as3arr = nextProxy.lowerBounds;
as3int = as3arr[axis];
as3int--;
as3arr[axis] = as3int;
bound.stabbingCount++;
} else {
as3arr = nextProxy.upperBounds;
as3int = as3arr[axis];
as3int--;
as3arr[axis] = as3int;
bound.stabbingCount--;
};
as3arr = proxy.upperBounds;
as3int = as3arr[axis];
as3int++;
as3arr[axis] = as3int;
bound.Swap(nextBound);
index++;
};
};
if (deltaLower > 0){
index = lowerIndex;
while ((((index < (boundCount - 1))) && (((bounds[int((index + 1))] as b2Bound).value <= lowerValue)))) {
bound = bounds[index];
nextBound = bounds[int((index + 1))];
nextProxyId = nextBound.proxyId;
nextProxy = m_proxyPool[nextProxyId];
nextBound.stabbingCount--;
if (nextBound.IsUpper()){
if (TestOverlap(oldValues, nextProxy)){
m_pairManager.RemoveBufferedPair(proxyId, nextProxyId);
};
as3arr = nextProxy.upperBounds;
as3int = as3arr[axis];
as3int--;
as3arr[axis] = as3int;
bound.stabbingCount--;
} else {
as3arr = nextProxy.lowerBounds;
as3int = as3arr[axis];
as3int--;
as3arr[axis] = as3int;
bound.stabbingCount++;
};
as3arr = proxy.lowerBounds;
as3int = as3arr[axis];
as3int++;
as3arr[axis] = as3int;
bound.Swap(nextBound);
index++;
};
};
if (deltaUpper < 0){
index = upperIndex;
while ((((index > 0)) && ((upperValue < (bounds[int((index - 1))] as b2Bound).value)))) {
bound = bounds[index];
prevBound = bounds[int((index - 1))];
prevProxyId = prevBound.proxyId;
prevProxy = m_proxyPool[prevProxyId];
prevBound.stabbingCount--;
if (prevBound.IsLower() == true){
if (TestOverlap(oldValues, prevProxy)){
m_pairManager.RemoveBufferedPair(proxyId, prevProxyId);
};
as3arr = prevProxy.lowerBounds;
as3int = as3arr[axis];
as3int++;
as3arr[axis] = as3int;
bound.stabbingCount--;
} else {
as3arr = prevProxy.upperBounds;
as3int = as3arr[axis];
as3int++;
as3arr[axis] = as3int;
bound.stabbingCount++;
};
as3arr = proxy.upperBounds;
as3int = as3arr[axis];
as3int--;
as3arr[axis] = as3int;
bound.Swap(prevBound);
index--;
};
};
axis++;
};
}
public static function BinarySearch(bounds:Array, count:int, value:uint):uint{
var mid:int;
var bound:b2Bound;
var low:int;
var high:int = (count - 1);
while (low <= high) {
mid = ((low + high) / 2);
bound = bounds[mid];
if (bound.value > value){
high = (mid - 1);
} else {
if (bound.value < value){
low = (mid + 1);
} else {
return (uint(mid));
};
};
};
return (uint(low));
}
}
}//package Box2D.Collision
Section 13
//b2BufferedPair (Box2D.Collision.b2BufferedPair)
package Box2D.Collision {
public class b2BufferedPair {
public var proxyId1:uint;
public var proxyId2:uint;
public function b2BufferedPair(){
super();
}
}
}//package Box2D.Collision
Section 14
//b2Collision (Box2D.Collision.b2Collision)
package Box2D.Collision {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Collision {
public static const b2_nullFeature:uint = 0xFF;
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
public function b2Collision(){
super();
}
public static function EdgeSeparation(poly1:b2PolygonShape, xf1:b2XForm, edge1:int, poly2:b2PolygonShape, xf2:b2XForm):Number{
var tMat:b2Mat22;
var tVec:b2Vec2;
var dot:Number;
var count1:int = poly1.m_vertexCount;
var vertices1:Array = poly1.m_vertices;
var normals1:Array = poly1.m_normals;
var count2:int = poly2.m_vertexCount;
var vertices2:Array = poly2.m_vertices;
tMat = xf1.R;
tVec = normals1[edge1];
var normal1WorldX:Number = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
var normal1WorldY:Number = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = xf2.R;
var normal1X:Number = ((tMat.col1.x * normal1WorldX) + (tMat.col1.y * normal1WorldY));
var normal1Y:Number = ((tMat.col2.x * normal1WorldX) + (tMat.col2.y * normal1WorldY));
var index:int;
var minDot:Number = Number.MAX_VALUE;
var i:int;
while (i < count2) {
tVec = vertices2[i];
dot = ((tVec.x * normal1X) + (tVec.y * normal1Y));
if (dot < minDot){
minDot = dot;
index = i;
};
i++;
};
tVec = vertices1[edge1];
tMat = xf1.R;
var v1X:Number = (xf1.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var v1Y:Number = (xf1.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tVec = vertices2[index];
tMat = xf2.R;
var v2X:Number = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var v2Y:Number = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
v2X = (v2X - v1X);
v2Y = (v2Y - v1Y);
var separation:Number = ((v2X * normal1WorldX) + (v2Y * normal1WorldY));
return (separation);
}
public static function b2TestOverlap(a:b2AABB, b:b2AABB):Boolean{
var t1:b2Vec2 = b.lowerBound;
var t2:b2Vec2 = a.upperBound;
var d1X:Number = (t1.x - t2.x);
var d1Y:Number = (t1.y - t2.y);
t1 = a.lowerBound;
t2 = b.upperBound;
var d2X:Number = (t1.x - t2.x);
var d2Y:Number = (t1.y - t2.y);
if ((((d1X > 0)) || ((d1Y > 0)))){
return (false);
};
if ((((d2X > 0)) || ((d2Y > 0)))){
return (false);
};
return (true);
}
public static function FindIncidentEdge(c:Array, poly1:b2PolygonShape, xf1:b2XForm, edge1:int, poly2:b2PolygonShape, xf2:b2XForm):void{
var tMat:b2Mat22;
var tVec:b2Vec2;
var tClip:ClipVertex;
var dot:Number;
var count1:int = poly1.m_vertexCount;
var normals1:Array = poly1.m_normals;
var count2:int = poly2.m_vertexCount;
var vertices2:Array = poly2.m_vertices;
var normals2:Array = poly2.m_normals;
tMat = xf1.R;
tVec = normals1[edge1];
var normal1X:Number = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
var normal1Y:Number = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = xf2.R;
var tX:Number = ((tMat.col1.x * normal1X) + (tMat.col1.y * normal1Y));
normal1Y = ((tMat.col2.x * normal1X) + (tMat.col2.y * normal1Y));
normal1X = tX;
var index:int;
var minDot:Number = Number.MAX_VALUE;
var i:int;
while (i < count2) {
tVec = normals2[i];
dot = ((normal1X * tVec.x) + (normal1Y * tVec.y));
if (dot < minDot){
minDot = dot;
index = i;
};
i++;
};
var i1:int = index;
var i2:int = (((i1 + 1) < count2)) ? (i1 + 1) : 0;
tClip = c[0];
tVec = vertices2[i1];
tMat = xf2.R;
tClip.v.x = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
tClip.v.y = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tClip.id.features.referenceEdge = edge1;
tClip.id.features.incidentEdge = i1;
tClip.id.features.incidentVertex = 0;
tClip = c[1];
tVec = vertices2[i2];
tMat = xf2.R;
tClip.v.x = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
tClip.v.y = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tClip.id.features.referenceEdge = edge1;
tClip.id.features.incidentEdge = i2;
tClip.id.features.incidentVertex = 1;
}
public static function b2CollidePolygons(manifold:b2Manifold, polyA:b2PolygonShape, xfA:b2XForm, polyB:b2PolygonShape, xfB:b2XForm):void{
var cv:ClipVertex;
var poly1:b2PolygonShape;
var poly2:b2PolygonShape;
var edge1:int;
var flip:uint;
var np:int;
var v12:b2Vec2;
var separation:Number;
var cp:b2ManifoldPoint;
manifold.pointCount = 0;
var edgeA:int;
var edgeAO:Array = [edgeA];
var separationA:Number = FindMaxSeparation(edgeAO, polyA, xfA, polyB, xfB);
edgeA = edgeAO[0];
if (separationA > 0){
return;
};
var edgeB:int;
var edgeBO:Array = [edgeB];
var separationB:Number = FindMaxSeparation(edgeBO, polyB, xfB, polyA, xfA);
edgeB = edgeBO[0];
if (separationB > 0){
return;
};
var xf1:b2XForm = new b2XForm();
var xf2:b2XForm = new b2XForm();
var k_relativeTol:Number = 0.98;
var k_absoluteTol:Number = 0.001;
if (separationB > ((k_relativeTol * separationA) + k_absoluteTol)){
poly1 = polyB;
poly2 = polyA;
xf1.Set(xfB);
xf2.Set(xfA);
edge1 = edgeB;
flip = 1;
} else {
poly1 = polyA;
poly2 = polyB;
xf1.Set(xfA);
xf2.Set(xfB);
edge1 = edgeA;
flip = 0;
};
var incidentEdge:Array = [new ClipVertex(), new ClipVertex()];
FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);
var count1:int = poly1.m_vertexCount;
var vertices1:Array = poly1.m_vertices;
var tVec:b2Vec2 = vertices1[edge1];
var v11:b2Vec2 = tVec.Copy();
if ((edge1 + 1) < count1){
tVec = vertices1[int((edge1 + 1))];
v12 = tVec.Copy();
} else {
tVec = vertices1[0];
v12 = tVec.Copy();
};
var dv:b2Vec2 = b2Math.SubtractVV(v12, v11);
var sideNormal:b2Vec2 = b2Math.b2MulMV(xf1.R, b2Math.SubtractVV(v12, v11));
sideNormal.Normalize();
var frontNormal:b2Vec2 = b2Math.b2CrossVF(sideNormal, 1);
v11 = b2Math.b2MulX(xf1, v11);
v12 = b2Math.b2MulX(xf1, v12);
var frontOffset:Number = b2Math.b2Dot(frontNormal, v11);
var sideOffset1:Number = -(b2Math.b2Dot(sideNormal, v11));
var sideOffset2:Number = b2Math.b2Dot(sideNormal, v12);
var clipPoints1:Array = [new ClipVertex(), new ClipVertex()];
var clipPoints2:Array = [new ClipVertex(), new ClipVertex()];
np = ClipSegmentToLine(clipPoints1, incidentEdge, sideNormal.Negative(), sideOffset1);
if (np < 2){
return;
};
np = ClipSegmentToLine(clipPoints2, clipPoints1, sideNormal, sideOffset2);
if (np < 2){
return;
};
manifold.normal = (flip) ? frontNormal.Negative() : frontNormal.Copy();
var pointCount:int;
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
cv = clipPoints2[i];
separation = (b2Math.b2Dot(frontNormal, cv.v) - frontOffset);
if (separation <= 0){
cp = manifold.points[pointCount];
cp.separation = separation;
cp.localPoint1 = b2Math.b2MulXT(xfA, cv.v);
cp.localPoint2 = b2Math.b2MulXT(xfB, cv.v);
cp.id.key = cv.id._key;
cp.id.features.flip = flip;
pointCount++;
};
i++;
};
manifold.pointCount = pointCount;
}
public static function FindMaxSeparation(edgeIndex:Array, poly1:b2PolygonShape, xf1:b2XForm, poly2:b2PolygonShape, xf2:b2XForm):Number{
var tVec:b2Vec2;
var tMat:b2Mat22;
var bestEdge:int;
var bestSeparation:Number;
var increment:int;
var dot:Number;
var count1:int = poly1.m_vertexCount;
var normals1:Array = poly1.m_normals;
tMat = xf2.R;
tVec = poly2.m_centroid;
var dX:Number = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var dY:Number = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tMat = xf1.R;
tVec = poly1.m_centroid;
dX = (dX - (xf1.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y))));
dY = (dY - (xf1.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y))));
var dLocal1X:Number = ((dX * xf1.R.col1.x) + (dY * xf1.R.col1.y));
var dLocal1Y:Number = ((dX * xf1.R.col2.x) + (dY * xf1.R.col2.y));
var edge:int;
var maxDot:Number = -(Number.MAX_VALUE);
var i:int;
while (i < count1) {
tVec = normals1[i];
dot = ((tVec.x * dLocal1X) + (tVec.y * dLocal1Y));
if (dot > maxDot){
maxDot = dot;
edge = i;
};
i++;
};
var s:Number = EdgeSeparation(poly1, xf1, edge, poly2, xf2);
if (s > 0){
return (s);
};
var prevEdge:int = (((edge - 1) >= 0)) ? (edge - 1) : (count1 - 1);
var sPrev:Number = EdgeSeparation(poly1, xf1, prevEdge, poly2, xf2);
if (sPrev > 0){
return (sPrev);
};
var nextEdge:int = (((edge + 1) < count1)) ? (edge + 1) : 0;
var sNext:Number = EdgeSeparation(poly1, xf1, nextEdge, poly2, xf2);
if (sNext > 0){
return (sNext);
};
if ((((sPrev > s)) && ((sPrev > sNext)))){
increment = -1;
bestEdge = prevEdge;
bestSeparation = sPrev;
} else {
if (sNext > s){
increment = 1;
bestEdge = nextEdge;
bestSeparation = sNext;
} else {
edgeIndex[0] = edge;
return (s);
};
};
while (true) {
if (increment == -1){
edge = (((bestEdge - 1) >= 0)) ? (bestEdge - 1) : (count1 - 1);
} else {
edge = (((bestEdge + 1) < count1)) ? (bestEdge + 1) : 0;
};
s = EdgeSeparation(poly1, xf1, edge, poly2, xf2);
if (s > 0){
return (s);
};
if (s > bestSeparation){
bestEdge = edge;
bestSeparation = s;
} else {
break;
};
};
edgeIndex[0] = bestEdge;
return (bestSeparation);
}
public static function ClipSegmentToLine(vOut:Array, vIn:Array, normal:b2Vec2, offset:Number):int{
var cv:ClipVertex;
var numOut:int;
var vIn0:b2Vec2;
var vIn1:b2Vec2;
var distance0:Number;
var interp:Number;
var tVec:b2Vec2;
var cv2:ClipVertex;
numOut = 0;
cv = vIn[0];
vIn0 = cv.v;
cv = vIn[1];
vIn1 = cv.v;
distance0 = (b2Math.b2Dot(normal, vIn0) - offset);
var distance1:Number = (b2Math.b2Dot(normal, vIn1) - offset);
if (distance0 <= 0){
var _temp1 = numOut;
numOut = (numOut + 1);
var _local14 = _temp1;
vOut[_local14] = vIn[0];
};
if (distance1 <= 0){
var _temp2 = numOut;
numOut = (numOut + 1);
_local14 = _temp2;
vOut[_local14] = vIn[1];
};
if ((distance0 * distance1) < 0){
interp = (distance0 / (distance0 - distance1));
cv = vOut[numOut];
tVec = cv.v;
tVec.x = (vIn0.x + (interp * (vIn1.x - vIn0.x)));
tVec.y = (vIn0.y + (interp * (vIn1.y - vIn0.y)));
cv = vOut[numOut];
if (distance0 > 0){
cv2 = vIn[0];
cv.id = cv2.id;
} else {
cv2 = vIn[1];
cv.id = cv2.id;
};
numOut++;
};
return (numOut);
}
public static function b2CollideCircles(manifold:b2Manifold, circle1:b2CircleShape, xf1:b2XForm, circle2:b2CircleShape, xf2:b2XForm):void{
var tMat:b2Mat22;
var tVec:b2Vec2;
var separation:Number;
var dist:Number;
var a:Number;
manifold.pointCount = 0;
tMat = xf1.R;
tVec = circle1.m_localPosition;
var p1X:Number = (xf1.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var p1Y:Number = (xf1.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tMat = xf2.R;
tVec = circle2.m_localPosition;
var p2X:Number = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var p2Y:Number = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
var distSqr:Number = ((dX * dX) + (dY * dY));
var r1:Number = circle1.m_radius;
var r2:Number = circle2.m_radius;
var radiusSum:Number = (r1 + r2);
if (distSqr > (radiusSum * radiusSum)){
return;
};
if (distSqr < Number.MIN_VALUE){
separation = -(radiusSum);
manifold.normal.Set(0, 1);
} else {
dist = Math.sqrt(distSqr);
separation = (dist - radiusSum);
a = (1 / dist);
manifold.normal.x = (a * dX);
manifold.normal.y = (a * dY);
};
manifold.pointCount = 1;
var tPoint:b2ManifoldPoint = manifold.points[0];
tPoint.id.key = 0;
tPoint.separation = separation;
p1X = (p1X + (r1 * manifold.normal.x));
p1Y = (p1Y + (r1 * manifold.normal.y));
p2X = (p2X - (r2 * manifold.normal.x));
p2Y = (p2Y - (r2 * manifold.normal.y));
var pX:Number = (0.5 * (p1X + p2X));
var pY:Number = (0.5 * (p1Y + p2Y));
var tX:Number = (pX - xf1.position.x);
var tY:Number = (pY - xf1.position.y);
tPoint.localPoint1.x = ((tX * xf1.R.col1.x) + (tY * xf1.R.col1.y));
tPoint.localPoint1.y = ((tX * xf1.R.col2.x) + (tY * xf1.R.col2.y));
tX = (pX - xf2.position.x);
tY = (pY - xf2.position.y);
tPoint.localPoint2.x = ((tX * xf2.R.col1.x) + (tY * xf2.R.col1.y));
tPoint.localPoint2.y = ((tX * xf2.R.col2.x) + (tY * xf2.R.col2.y));
}
public static function b2CollidePolygonAndCircle(manifold:b2Manifold, polygon:b2PolygonShape, xf1:b2XForm, circle:b2CircleShape, xf2:b2XForm):void{
var tPoint:b2ManifoldPoint;
var dX:Number;
var dY:Number;
var positionX:Number;
var positionY:Number;
var tVec:b2Vec2;
var tMat:b2Mat22;
var dist:Number;
var pX:Number;
var pY:Number;
var s:Number;
manifold.pointCount = 0;
tMat = xf2.R;
tVec = circle.m_localPosition;
var cX:Number = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var cY:Number = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
dX = (cX - xf1.position.x);
dY = (cY - xf1.position.y);
tMat = xf1.R;
var cLocalX:Number = ((dX * tMat.col1.x) + (dY * tMat.col1.y));
var cLocalY:Number = ((dX * tMat.col2.x) + (dY * tMat.col2.y));
var normalIndex:int;
var separation:Number = -(Number.MAX_VALUE);
var radius:Number = circle.m_radius;
var vertexCount:int = polygon.m_vertexCount;
var vertices:Array = polygon.m_vertices;
var normals:Array = polygon.m_normals;
var i:int;
while (i < vertexCount) {
tVec = vertices[i];
dX = (cLocalX - tVec.x);
dY = (cLocalY - tVec.y);
tVec = normals[i];
s = ((tVec.x * dX) + (tVec.y * dY));
if (s > radius){
return;
};
if (s > separation){
separation = s;
normalIndex = i;
};
i++;
};
if (separation < Number.MIN_VALUE){
manifold.pointCount = 1;
tVec = normals[normalIndex];
tMat = xf1.R;
manifold.normal.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
manifold.normal.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tPoint = manifold.points[0];
tPoint.id.features.incidentEdge = normalIndex;
tPoint.id.features.incidentVertex = b2_nullFeature;
tPoint.id.features.referenceEdge = 0;
tPoint.id.features.flip = 0;
positionX = (cX - (radius * manifold.normal.x));
positionY = (cY - (radius * manifold.normal.y));
dX = (positionX - xf1.position.x);
dY = (positionY - xf1.position.y);
tMat = xf1.R;
tPoint.localPoint1.x = ((dX * tMat.col1.x) + (dY * tMat.col1.y));
tPoint.localPoint1.y = ((dX * tMat.col2.x) + (dY * tMat.col2.y));
dX = (positionX - xf2.position.x);
dY = (positionY - xf2.position.y);
tMat = xf2.R;
tPoint.localPoint2.x = ((dX * tMat.col1.x) + (dY * tMat.col1.y));
tPoint.localPoint2.y = ((dX * tMat.col2.x) + (dY * tMat.col2.y));
tPoint.separation = (separation - radius);
return;
};
var vertIndex1:int = normalIndex;
var vertIndex2:int = (((vertIndex1 + 1) < vertexCount)) ? (vertIndex1 + 1) : 0;
tVec = vertices[vertIndex1];
var tVec2:b2Vec2 = vertices[vertIndex2];
var eX:Number = (tVec2.x - tVec.x);
var eY:Number = (tVec2.y - tVec.y);
var length:Number = Math.sqrt(((eX * eX) + (eY * eY)));
eX = (eX / length);
eY = (eY / length);
dX = (cLocalX - tVec.x);
dY = (cLocalY - tVec.y);
var u:Number = ((dX * eX) + (dY * eY));
tPoint = manifold.points[0];
if (u <= 0){
pX = tVec.x;
pY = tVec.y;
tPoint.id.features.incidentEdge = b2_nullFeature;
tPoint.id.features.incidentVertex = vertIndex1;
} else {
if (u >= length){
pX = tVec2.x;
pY = tVec2.y;
tPoint.id.features.incidentEdge = b2_nullFeature;
tPoint.id.features.incidentVertex = vertIndex2;
} else {
pX = ((eX * u) + tVec.x);
pY = ((eY * u) + tVec.y);
tPoint.id.features.incidentEdge = normalIndex;
tPoint.id.features.incidentVertex = 0;
};
};
dX = (cLocalX - pX);
dY = (cLocalY - pY);
dist = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / dist);
dY = (dY / dist);
if (dist > radius){
return;
};
manifold.pointCount = 1;
tMat = xf1.R;
manifold.normal.x = ((tMat.col1.x * dX) + (tMat.col2.x * dY));
manifold.normal.y = ((tMat.col1.y * dX) + (tMat.col2.y * dY));
positionX = (cX - (radius * manifold.normal.x));
positionY = (cY - (radius * manifold.normal.y));
dX = (positionX - xf1.position.x);
dY = (positionY - xf1.position.y);
tMat = xf1.R;
tPoint.localPoint1.x = ((dX * tMat.col1.x) + (dY * tMat.col1.y));
tPoint.localPoint1.y = ((dX * tMat.col2.x) + (dY * tMat.col2.y));
dX = (positionX - xf2.position.x);
dY = (positionY - xf2.position.y);
tMat = xf2.R;
tPoint.localPoint2.x = ((dX * tMat.col1.x) + (dY * tMat.col1.y));
tPoint.localPoint2.y = ((dX * tMat.col2.x) + (dY * tMat.col2.y));
tPoint.separation = (dist - radius);
tPoint.id.features.referenceEdge = 0;
tPoint.id.features.flip = 0;
}
}
}//package Box2D.Collision
Section 15
//b2ContactID (Box2D.Collision.b2ContactID)
package Box2D.Collision {
public class b2ContactID {
public var _key:uint;
public var features:Features;
public function b2ContactID(){
features = new Features();
super();
features._m_id = this;
}
public function Set(id:b2ContactID):void{
key = id._key;
}
public function Copy():b2ContactID{
var id:b2ContactID = new b2ContactID();
id.key = key;
return (id);
}
public function set key(value:uint):void{
_key = value;
features._referenceEdge = (_key & 0xFF);
features._incidentEdge = (((_key & 0xFF00) >> 8) & 0xFF);
features._incidentVertex = (((_key & 0xFF0000) >> 16) & 0xFF);
features._flip = (((_key & 4278190080) >> 24) & 0xFF);
}
public function get key():uint{
return (_key);
}
}
}//package Box2D.Collision
Section 16
//b2ContactPoint (Box2D.Collision.b2ContactPoint)
package Box2D.Collision {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
public class b2ContactPoint {
public var friction:Number;
public var separation:Number;
public var normal:b2Vec2;
public var position:b2Vec2;
public var restitution:Number;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var id:b2ContactID;
public var velocity:b2Vec2;
public function b2ContactPoint(){
position = new b2Vec2();
velocity = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 17
//b2Distance (Box2D.Collision.b2Distance)
package Box2D.Collision {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Distance {
private static var s_p2s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var s_p1s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var s_points:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()];
private static var gPoint:b2Point = new b2Point();
public static var g_GJK_Iterations:int = 0;
public function b2Distance(){
super();
}
public static function InPoints(w:b2Vec2, points:Array, pointCount:int):Boolean{
var points_i:b2Vec2;
var dX:Number;
var dY:Number;
var mX:Number;
var mY:Number;
var k_tolerance:Number = (100 * Number.MIN_VALUE);
var i:int;
while (i < pointCount) {
points_i = points[i];
dX = Math.abs((w.x - points_i.x));
dY = Math.abs((w.y - points_i.y));
mX = Math.max(Math.abs(w.x), Math.abs(points_i.x));
mY = Math.max(Math.abs(w.y), Math.abs(points_i.y));
if ((((dX < (k_tolerance * (mX + 1)))) && ((dY < (k_tolerance * (mY + 1)))))){
return (true);
};
i++;
};
return (false);
}
public static function DistanceGeneric(x1:b2Vec2, x2:b2Vec2, shape1, xf1:b2XForm, shape2, xf2:b2XForm):Number{
var tVec:b2Vec2;
var vX:Number;
var vY:Number;
var w1:b2Vec2;
var w2:b2Vec2;
var wX:Number;
var wY:Number;
var vw:Number;
var maxSqr:Number;
var i:int;
var p1s:Array = s_p1s;
var p2s:Array = s_p2s;
var points:Array = s_points;
var pointCount:int;
x1.SetV(shape1.GetFirstVertex(xf1));
x2.SetV(shape2.GetFirstVertex(xf2));
var vSqr:Number = 0;
var maxIterations = 20;
var iter:int;
while (iter < maxIterations) {
vX = (x2.x - x1.x);
vY = (x2.y - x1.y);
w1 = shape1.Support(xf1, vX, vY);
w2 = shape2.Support(xf2, -(vX), -(vY));
vSqr = ((vX * vX) + (vY * vY));
wX = (w2.x - w1.x);
wY = (w2.y - w1.y);
vw = ((vX * wX) + (vY * wY));
if ((vSqr - ((vX * wX) + (vY * wY))) <= (0.01 * vSqr)){
if (pointCount == 0){
x1.SetV(w1);
x2.SetV(w2);
};
g_GJK_Iterations = iter;
return (Math.sqrt(vSqr));
};
switch (pointCount){
case 0:
tVec = p1s[0];
tVec.SetV(w1);
tVec = p2s[0];
tVec.SetV(w2);
tVec = points[0];
tVec.x = wX;
tVec.y = wY;
x1.SetV(p1s[0]);
x2.SetV(p2s[0]);
pointCount++;
break;
case 1:
tVec = p1s[1];
tVec.SetV(w1);
tVec = p2s[1];
tVec.SetV(w2);
tVec = points[1];
tVec.x = wX;
tVec.y = wY;
pointCount = ProcessTwo(x1, x2, p1s, p2s, points);
break;
case 2:
tVec = p1s[2];
tVec.SetV(w1);
tVec = p2s[2];
tVec.SetV(w2);
tVec = points[2];
tVec.x = wX;
tVec.y = wY;
pointCount = ProcessThree(x1, x2, p1s, p2s, points);
break;
};
if (pointCount == 3){
g_GJK_Iterations = iter;
return (0);
};
maxSqr = -(Number.MAX_VALUE);
i = 0;
while (i < pointCount) {
tVec = points[i];
maxSqr = b2Math.b2Max(maxSqr, ((tVec.x * tVec.x) + (tVec.y * tVec.y)));
i++;
};
if ((((pointCount == 3)) || ((vSqr <= ((100 * Number.MIN_VALUE) * maxSqr))))){
g_GJK_Iterations = iter;
vX = (x2.x - x1.x);
vY = (x2.y - x1.y);
vSqr = ((vX * vX) + (vY * vY));
return (Math.sqrt(vSqr));
};
iter++;
};
g_GJK_Iterations = maxIterations;
return (Math.sqrt(vSqr));
}
public static function DistanceCC(x1:b2Vec2, x2:b2Vec2, circle1:b2CircleShape, xf1:b2XForm, circle2:b2CircleShape, xf2:b2XForm):Number{
var tMat:b2Mat22;
var tVec:b2Vec2;
var dLen:Number;
var distance:Number;
tMat = xf1.R;
tVec = circle1.m_localPosition;
var p1X:Number = (xf1.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var p1Y:Number = (xf1.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
tMat = xf2.R;
tVec = circle2.m_localPosition;
var p2X:Number = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
var p2Y:Number = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
var dSqr:Number = ((dX * dX) + (dY * dY));
var r1:Number = (circle1.m_radius - b2Settings.b2_toiSlop);
var r2:Number = (circle2.m_radius - b2Settings.b2_toiSlop);
var r:Number = (r1 + r2);
if (dSqr > (r * r)){
dLen = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / dLen);
dY = (dY / dLen);
distance = (dLen - r);
x1.x = (p1X + (r1 * dX));
x1.y = (p1Y + (r1 * dY));
x2.x = (p2X - (r2 * dX));
x2.y = (p2Y - (r2 * dY));
return (distance);
};
if (dSqr > (Number.MIN_VALUE * Number.MIN_VALUE)){
dLen = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / dLen);
dY = (dY / dLen);
x1.x = (p1X + (r1 * dX));
x1.y = (p1Y + (r1 * dY));
x2.x = x1.x;
x2.y = x1.y;
return (0);
};
x1.x = p1X;
x1.y = p1Y;
x2.x = x1.x;
x2.y = x1.y;
return (0);
}
public static function ProcessThree(x1:b2Vec2, x2:b2Vec2, p1s:Array, p2s:Array, points:Array):int{
var points_0:b2Vec2;
var points_1:b2Vec2;
var points_2:b2Vec2;
var p1s_0:b2Vec2;
var p1s_1:b2Vec2;
var p1s_2:b2Vec2;
var p2s_0:b2Vec2;
var p2s_1:b2Vec2;
var lambda:Number;
points_0 = points[0];
points_1 = points[1];
points_2 = points[2];
p1s_0 = p1s[0];
p1s_1 = p1s[1];
p1s_2 = p1s[2];
p2s_0 = p2s[0];
p2s_1 = p2s[1];
var p2s_2:b2Vec2 = p2s[2];
var aX:Number = points_0.x;
var aY:Number = points_0.y;
var bX:Number = points_1.x;
var bY:Number = points_1.y;
var cX:Number = points_2.x;
var cY:Number = points_2.y;
var abX:Number = (bX - aX);
var abY:Number = (bY - aY);
var acX:Number = (cX - aX);
var acY:Number = (cY - aY);
var bcX:Number = (cX - bX);
var bcY:Number = (cY - bY);
var sn:Number = -(((aX * abX) + (aY * abY)));
var sd:Number = ((bX * abX) + (bY * abY));
var tn:Number = -(((aX * acX) + (aY * acY)));
var td:Number = ((cX * acX) + (cY * acY));
var un:Number = -(((bX * bcX) + (bY * bcY)));
var ud:Number = ((cX * bcX) + (cY * bcY));
if ((((td <= 0)) && ((ud <= 0)))){
x1.SetV(p1s_2);
x2.SetV(p2s_2);
p1s_0.SetV(p1s_2);
p2s_0.SetV(p2s_2);
points_0.SetV(points_2);
return (1);
};
var n:Number = ((abX * acY) - (abY * acX));
var vc:Number = (n * ((aX * bY) - (aY * bX)));
var va:Number = (n * ((bX * cY) - (bY * cX)));
if ((((((((va <= 0)) && ((un >= 0)))) && ((ud >= 0)))) && (((un + ud) > 0)))){
lambda = (un / (un + ud));
x1.x = (p1s_1.x + (lambda * (p1s_2.x - p1s_1.x)));
x1.y = (p1s_1.y + (lambda * (p1s_2.y - p1s_1.y)));
x2.x = (p2s_1.x + (lambda * (p2s_2.x - p2s_1.x)));
x2.y = (p2s_1.y + (lambda * (p2s_2.y - p2s_1.y)));
p1s_0.SetV(p1s_2);
p2s_0.SetV(p2s_2);
points_0.SetV(points_2);
return (2);
};
var vb:Number = (n * ((cX * aY) - (cY * aX)));
if ((((((((vb <= 0)) && ((tn >= 0)))) && ((td >= 0)))) && (((tn + td) > 0)))){
lambda = (tn / (tn + td));
x1.x = (p1s_0.x + (lambda * (p1s_2.x - p1s_0.x)));
x1.y = (p1s_0.y + (lambda * (p1s_2.y - p1s_0.y)));
x2.x = (p2s_0.x + (lambda * (p2s_2.x - p2s_0.x)));
x2.y = (p2s_0.y + (lambda * (p2s_2.y - p2s_0.y)));
p1s_1.SetV(p1s_2);
p2s_1.SetV(p2s_2);
points_1.SetV(points_2);
return (2);
};
var denom:Number = ((va + vb) + vc);
denom = (1 / denom);
var u:Number = (va * denom);
var v:Number = (vb * denom);
var w:Number = ((1 - u) - v);
x1.x = (((u * p1s_0.x) + (v * p1s_1.x)) + (w * p1s_2.x));
x1.y = (((u * p1s_0.y) + (v * p1s_1.y)) + (w * p1s_2.y));
x2.x = (((u * p2s_0.x) + (v * p2s_1.x)) + (w * p2s_2.x));
x2.y = (((u * p2s_0.y) + (v * p2s_1.y)) + (w * p2s_2.y));
return (3);
}
public static function DistancePC(x1:b2Vec2, x2:b2Vec2, polygon:b2PolygonShape, xf1:b2XForm, circle:b2CircleShape, xf2:b2XForm):Number{
var tMat:b2Mat22;
var tVec:b2Vec2;
var dX:Number;
var dY:Number;
var dLen:Number;
var point:b2Point = gPoint;
tVec = circle.m_localPosition;
tMat = xf2.R;
point.p.x = (xf2.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
point.p.y = (xf2.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
var distance:Number = DistanceGeneric(x1, x2, polygon, xf1, point, b2Math.b2XForm_identity);
var r:Number = (circle.m_radius - b2Settings.b2_toiSlop);
if (distance > r){
distance = (distance - r);
dX = (x2.x - x1.x);
dY = (x2.y - x1.y);
dLen = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / dLen);
dY = (dY / dLen);
x2.x = (x2.x - (r * dX));
x2.y = (x2.y - (r * dY));
} else {
distance = 0;
x2.x = x1.x;
x2.y = x1.y;
};
return (distance);
}
public static function Distance(x1:b2Vec2, x2:b2Vec2, shape1:b2Shape, xf1:b2XForm, shape2:b2Shape, xf2:b2XForm):Number{
var type1:int = shape1.m_type;
var type2:int = shape2.m_type;
if ((((type1 == b2Shape.e_circleShape)) && ((type2 == b2Shape.e_circleShape)))){
return (DistanceCC(x1, x2, (shape1 as b2CircleShape), xf1, (shape2 as b2CircleShape), xf2));
};
if ((((type1 == b2Shape.e_polygonShape)) && ((type2 == b2Shape.e_circleShape)))){
return (DistancePC(x1, x2, (shape1 as b2PolygonShape), xf1, (shape2 as b2CircleShape), xf2));
};
if ((((type1 == b2Shape.e_circleShape)) && ((type2 == b2Shape.e_polygonShape)))){
return (DistancePC(x2, x1, (shape2 as b2PolygonShape), xf2, (shape1 as b2CircleShape), xf1));
};
if ((((type1 == b2Shape.e_polygonShape)) && ((type2 == b2Shape.e_polygonShape)))){
return (DistanceGeneric(x1, x2, (shape1 as b2PolygonShape), xf1, (shape2 as b2PolygonShape), xf2));
};
return (0);
}
public static function ProcessTwo(x1:b2Vec2, x2:b2Vec2, p1s:Array, p2s:Array, points:Array):int{
var p1s_1:b2Vec2;
var p2s_0:b2Vec2;
var p2s_1:b2Vec2;
var lambda:Number;
var points_0:b2Vec2 = points[0];
var points_1:b2Vec2 = points[1];
var p1s_0:b2Vec2 = p1s[0];
p1s_1 = p1s[1];
p2s_0 = p2s[0];
p2s_1 = p2s[1];
var rX:Number = -(points_1.x);
var rY:Number = -(points_1.y);
var dX:Number = (points_0.x - points_1.x);
var dY:Number = (points_0.y - points_1.y);
var length:Number = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / length);
dY = (dY / length);
lambda = ((rX * dX) + (rY * dY));
if ((((lambda <= 0)) || ((length < Number.MIN_VALUE)))){
x1.SetV(p1s_1);
x2.SetV(p2s_1);
p1s_0.SetV(p1s_1);
p2s_0.SetV(p2s_1);
points_0.SetV(points_1);
return (1);
};
lambda = (lambda / length);
x1.x = (p1s_1.x + (lambda * (p1s_0.x - p1s_1.x)));
x1.y = (p1s_1.y + (lambda * (p1s_0.y - p1s_1.y)));
x2.x = (p2s_1.x + (lambda * (p2s_0.x - p2s_1.x)));
x2.y = (p2s_1.y + (lambda * (p2s_0.y - p2s_1.y)));
return (2);
}
}
}//package Box2D.Collision
Section 18
//b2Manifold (Box2D.Collision.b2Manifold)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Manifold {
public var pointCount:int;// = 0
public var normal:b2Vec2;
public var points:Array;
public function b2Manifold(){
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
points[i] = new b2ManifoldPoint();
i++;
};
normal = new b2Vec2();
}
public function Set(m:b2Manifold):void{
pointCount = m.pointCount;
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
(points[i] as b2ManifoldPoint).Set(m.points[i]);
i++;
};
normal.SetV(m.normal);
}
public function Reset():void{
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
(points[i] as b2ManifoldPoint).Reset();
i++;
};
normal.SetZero();
pointCount = 0;
}
}
}//package Box2D.Collision
Section 19
//b2ManifoldPoint (Box2D.Collision.b2ManifoldPoint)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2ManifoldPoint {
public var separation:Number;
public var localPoint2:b2Vec2;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var localPoint1:b2Vec2;
public var id:b2ContactID;
public function b2ManifoldPoint(){
localPoint1 = new b2Vec2();
localPoint2 = new b2Vec2();
id = new b2ContactID();
super();
}
public function Set(m:b2ManifoldPoint):void{
localPoint1.SetV(m.localPoint1);
localPoint2.SetV(m.localPoint2);
separation = m.separation;
normalImpulse = m.normalImpulse;
tangentImpulse = m.tangentImpulse;
id.key = m.id.key;
}
public function Reset():void{
localPoint1.SetZero();
localPoint2.SetZero();
separation = 0;
normalImpulse = 0;
tangentImpulse = 0;
id.key = 0;
}
}
}//package Box2D.Collision
Section 20
//b2OBB (Box2D.Collision.b2OBB)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2OBB {
public var R:b2Mat22;
public var center:b2Vec2;
public var extents:b2Vec2;
public function b2OBB(){
R = new b2Mat22();
center = new b2Vec2();
extents = new b2Vec2();
super();
}
}
}//package Box2D.Collision
Section 21
//b2Pair (Box2D.Collision.b2Pair)
package Box2D.Collision {
import Box2D.Common.*;
public class b2Pair {
public var proxyId1:uint;
public var userData;// = null
public var proxyId2:uint;
public var status:uint;
public var next:uint;
public static var e_pairFinal:uint = 4;
public static var b2_tableMask:int = (b2_tableCapacity - 1);
public static var e_pairRemoved:uint = 2;
public static var b2_nullPair:uint = b2Settings.USHRT_MAX;
public static var e_pairBuffered:uint = 1;
public static var b2_nullProxy:uint = b2Settings.USHRT_MAX;
public static var b2_tableCapacity:int = b2Settings.b2_maxPairs;
public function b2Pair(){
super();
}
public function SetBuffered():void{
status = (status | e_pairBuffered);
}
public function IsBuffered():Boolean{
return (((status & e_pairBuffered) == e_pairBuffered));
}
public function IsFinal():Boolean{
return (((status & e_pairFinal) == e_pairFinal));
}
public function ClearRemoved():void{
status = (status & ~(e_pairRemoved));
}
public function SetFinal():void{
status = (status | e_pairFinal);
}
public function IsRemoved():Boolean{
return (((status & e_pairRemoved) == e_pairRemoved));
}
public function ClearBuffered():void{
status = (status & ~(e_pairBuffered));
}
public function SetRemoved():void{
status = (status | e_pairRemoved);
}
}
}//package Box2D.Collision
Section 22
//b2PairCallback (Box2D.Collision.b2PairCallback)
package Box2D.Collision {
public class b2PairCallback {
public function b2PairCallback(){
super();
}
public function PairRemoved(proxyUserData1, proxyUserData2, pairUserData):void{
}
public function PairAdded(proxyUserData1, proxyUserData2){
return (null);
}
}
}//package Box2D.Collision
Section 23
//b2PairManager (Box2D.Collision.b2PairManager)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PairManager {
public var m_pairCount:int;
public var m_pairBuffer:Array;
public var m_hashTable:Array;
public var m_callback:b2PairCallback;
public var m_pairs:Array;
public var m_pairBufferCount:int;
public var m_broadPhase:b2BroadPhase;
public var m_freePair:uint;
public function b2PairManager(){
var i:uint;
super();
m_hashTable = new Array(b2Pair.b2_tableCapacity);
i = 0;
while (i < b2Pair.b2_tableCapacity) {
m_hashTable[i] = b2Pair.b2_nullPair;
i++;
};
m_pairs = new Array(b2Settings.b2_maxPairs);
i = 0;
while (i < b2Settings.b2_maxPairs) {
m_pairs[i] = new b2Pair();
i++;
};
m_pairBuffer = new Array(b2Settings.b2_maxPairs);
i = 0;
while (i < b2Settings.b2_maxPairs) {
m_pairBuffer[i] = new b2BufferedPair();
i++;
};
i = 0;
while (i < b2Settings.b2_maxPairs) {
m_pairs[i].proxyId1 = b2Pair.b2_nullProxy;
m_pairs[i].proxyId2 = b2Pair.b2_nullProxy;
m_pairs[i].userData = null;
m_pairs[i].status = 0;
m_pairs[i].next = (i + 1);
i++;
};
m_pairs[int((b2Settings.b2_maxPairs - 1))].next = b2Pair.b2_nullPair;
m_pairCount = 0;
m_pairBufferCount = 0;
}
private function FindHash(proxyId1:uint, proxyId2:uint, hash:uint):b2Pair{
var pair:b2Pair;
var index:uint = m_hashTable[hash];
pair = m_pairs[index];
while (((!((index == b2Pair.b2_nullPair))) && ((Equals(pair, proxyId1, proxyId2) == false)))) {
index = pair.next;
pair = m_pairs[index];
};
if (index == b2Pair.b2_nullPair){
return (null);
};
return (pair);
}
private function Find(proxyId1:uint, proxyId2:uint):b2Pair{
var temp:uint;
if (proxyId1 > proxyId2){
temp = proxyId1;
proxyId1 = proxyId2;
proxyId2 = temp;
};
var hash:uint = (Hash(proxyId1, proxyId2) & b2Pair.b2_tableMask);
return (FindHash(proxyId1, proxyId2, hash));
}
private function ValidateBuffer():void{
}
public function Commit():void{
var bufferedPair:b2BufferedPair;
var i:int;
var pair:b2Pair;
var proxy1:b2Proxy;
var proxy2:b2Proxy;
var removeCount:int;
var proxies:Array = m_broadPhase.m_proxyPool;
i = 0;
while (i < m_pairBufferCount) {
bufferedPair = m_pairBuffer[i];
pair = Find(bufferedPair.proxyId1, bufferedPair.proxyId2);
pair.ClearBuffered();
proxy1 = proxies[pair.proxyId1];
proxy2 = proxies[pair.proxyId2];
if (pair.IsRemoved()){
if (pair.IsFinal() == true){
m_callback.PairRemoved(proxy1.userData, proxy2.userData, pair.userData);
};
bufferedPair = m_pairBuffer[removeCount];
bufferedPair.proxyId1 = pair.proxyId1;
bufferedPair.proxyId2 = pair.proxyId2;
removeCount++;
} else {
if (pair.IsFinal() == false){
pair.userData = m_callback.PairAdded(proxy1.userData, proxy2.userData);
pair.SetFinal();
};
};
i++;
};
i = 0;
while (i < removeCount) {
bufferedPair = m_pairBuffer[i];
RemovePair(bufferedPair.proxyId1, bufferedPair.proxyId2);
i++;
};
m_pairBufferCount = 0;
if (b2BroadPhase.s_validate){
ValidateTable();
};
}
public function RemoveBufferedPair(proxyId1:int, proxyId2:int):void{
var bufferedPair:b2BufferedPair;
var pair:b2Pair = Find(proxyId1, proxyId2);
if (pair == null){
return;
};
if (pair.IsBuffered() == false){
pair.SetBuffered();
bufferedPair = m_pairBuffer[m_pairBufferCount];
bufferedPair.proxyId1 = pair.proxyId1;
bufferedPair.proxyId2 = pair.proxyId2;
m_pairBufferCount++;
};
pair.SetRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function RemovePair(proxyId1:uint, proxyId2:uint){
var pair:b2Pair;
var temp:uint;
var index:uint;
var userData:*;
if (proxyId1 > proxyId2){
temp = proxyId1;
proxyId1 = proxyId2;
proxyId2 = temp;
};
var hash:uint = (Hash(proxyId1, proxyId2) & b2Pair.b2_tableMask);
var node:uint = m_hashTable[hash];
var pNode:b2Pair;
while (node != b2Pair.b2_nullPair) {
if (Equals(m_pairs[node], proxyId1, proxyId2)){
index = node;
pair = m_pairs[node];
if (pNode){
pNode.next = pair.next;
} else {
m_hashTable[hash] = pair.next;
};
pair = m_pairs[index];
userData = pair.userData;
pair.next = m_freePair;
pair.proxyId1 = b2Pair.b2_nullProxy;
pair.proxyId2 = b2Pair.b2_nullProxy;
pair.userData = null;
pair.status = 0;
m_freePair = index;
m_pairCount--;
return (userData);
} else {
pNode = m_pairs[node];
node = pNode.next;
};
};
return (null);
}
public function Initialize(broadPhase:b2BroadPhase, callback:b2PairCallback):void{
m_broadPhase = broadPhase;
m_callback = callback;
}
public function AddBufferedPair(proxyId1:int, proxyId2:int):void{
var bufferedPair:b2BufferedPair;
var pair:b2Pair = AddPair(proxyId1, proxyId2);
if (pair.IsBuffered() == false){
pair.SetBuffered();
bufferedPair = m_pairBuffer[m_pairBufferCount];
bufferedPair.proxyId1 = pair.proxyId1;
bufferedPair.proxyId2 = pair.proxyId2;
m_pairBufferCount++;
};
pair.ClearRemoved();
if (b2BroadPhase.s_validate){
ValidateBuffer();
};
}
private function AddPair(proxyId1:uint, proxyId2:uint):b2Pair{
var temp:uint;
if (proxyId1 > proxyId2){
temp = proxyId1;
proxyId1 = proxyId2;
proxyId2 = temp;
};
var hash:uint = (Hash(proxyId1, proxyId2) & b2Pair.b2_tableMask);
var pair = FindHash(proxyId1, proxyId2, hash);
if (pair != null){
return (pair);
};
var pIndex:uint = m_freePair;
pair = m_pairs[pIndex];
m_freePair = pair.next;
pair.proxyId1 = proxyId1;
pair.proxyId2 = proxyId2;
pair.status = 0;
pair.userData = null;
pair.next = m_hashTable[hash];
m_hashTable[hash] = pIndex;
m_pairCount++;
return (pair);
}
private function ValidateTable():void{
}
public static function EqualsPair(pair1:b2BufferedPair, pair2:b2BufferedPair):Boolean{
return ((((pair1.proxyId1 == pair2.proxyId1)) && ((pair1.proxyId2 == pair2.proxyId2))));
}
public static function Hash(proxyId1:uint, proxyId2:uint):uint{
var key:uint = (((proxyId2 << 16) & 4294901760) | proxyId1);
key = (~(key) + ((key << 15) & 4294934528));
key = (key ^ ((key >> 12) & 1048575));
key = (key + ((key << 2) & 4294967292));
key = (key ^ ((key >> 4) & 268435455));
key = (key * 2057);
key = (key ^ ((key >> 16) & 0xFFFF));
return (key);
}
public static function Equals(pair:b2Pair, proxyId1:uint, proxyId2:uint):Boolean{
return ((((pair.proxyId1 == proxyId1)) && ((pair.proxyId2 == proxyId2))));
}
}
}//package Box2D.Collision
Section 24
//b2Point (Box2D.Collision.b2Point)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class b2Point {
public var p:b2Vec2;
public function b2Point(){
p = new b2Vec2();
super();
}
public function GetFirstVertex(xf:b2XForm):b2Vec2{
return (p);
}
public function Support(xf:b2XForm, vX:Number, vY:Number):b2Vec2{
return (p);
}
}
}//package Box2D.Collision
Section 25
//b2Proxy (Box2D.Collision.b2Proxy)
package Box2D.Collision {
public class b2Proxy {
public var overlapCount:uint;
public var userData;// = null
public var lowerBounds:Array;
public var upperBounds:Array;
public var timeStamp:uint;
public function b2Proxy(){
lowerBounds = [uint(0), uint(0)];
upperBounds = [uint(0), uint(0)];
super();
}
public function GetNext():uint{
return (lowerBounds[0]);
}
public function IsValid():Boolean{
return (!((overlapCount == b2BroadPhase.b2_invalid)));
}
public function SetNext(next:uint):void{
lowerBounds[0] = (next & 0xFFFF);
}
}
}//package Box2D.Collision
Section 26
//b2Segment (Box2D.Collision.b2Segment)
package Box2D.Collision {
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2Segment {
public var p1:b2Vec2;
public var p2:b2Vec2;
public function b2Segment(){
p1 = new b2Vec2();
p2 = new b2Vec2();
super();
}
public function TestSegment(lambda:Array, normal:b2Vec2, segment:b2Segment, maxLambda:Number):Boolean{
var bX:Number;
var bY:Number;
var a:Number;
var mu2:Number;
var nLen:Number;
var s:b2Vec2 = segment.p1;
var rX:Number = (segment.p2.x - s.x);
var rY:Number = (segment.p2.y - s.y);
var dX:Number = (p2.x - p1.x);
var dY:Number = (p2.y - p1.y);
var nX:Number = dY;
var nY:Number = -(dX);
var k_slop:Number = (100 * Number.MIN_VALUE);
var denom:Number = -(((rX * nX) + (rY * nY)));
if (denom > k_slop){
bX = (s.x - p1.x);
bY = (s.y - p1.y);
a = ((bX * nX) + (bY * nY));
if ((((0 <= a)) && ((a <= (maxLambda * denom))))){
mu2 = ((-(rY) * bY) + (rY * bX));
if (((((-(k_slop) * denom) <= mu2)) && ((mu2 <= (denom * (1 + k_slop)))))){
a = (a / denom);
nLen = Math.sqrt(((nX * nX) + (nY * nY)));
nX = (nX / nLen);
nY = (nY / nLen);
lambda[0] = a;
normal.Set(nX, nY);
return (true);
};
};
};
return (false);
}
}
}//package Box2D.Collision
Section 27
//b2TimeOfImpact (Box2D.Collision.b2TimeOfImpact)
package Box2D.Collision {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2TimeOfImpact {
public static var s_xf1:b2XForm = new b2XForm();
public static var s_xf2:b2XForm = new b2XForm();
public static var s_p1:b2Vec2 = new b2Vec2();
public static var s_p2:b2Vec2 = new b2Vec2();
public function b2TimeOfImpact(){
super();
}
public static function TimeOfImpact(shape1:b2Shape, sweep1:b2Sweep, shape2:b2Shape, sweep2:b2Sweep):Number{
var math1:Number;
var math2:Number;
var t:Number;
var xf1:b2XForm;
var xf2:b2XForm;
var nLen:Number;
var approachVelocityBound:Number;
var dAlpha:Number;
var newAlpha:Number;
var r1:Number = shape1.m_sweepRadius;
var r2:Number = shape2.m_sweepRadius;
var t0:Number = sweep1.t0;
var v1X:Number = (sweep1.c.x - sweep1.c0.x);
var v1Y:Number = (sweep1.c.y - sweep1.c0.y);
var v2X:Number = (sweep2.c.x - sweep2.c0.x);
var v2Y:Number = (sweep2.c.y - sweep2.c0.y);
var omega1:Number = (sweep1.a - sweep1.a0);
var omega2:Number = (sweep2.a - sweep2.a0);
var alpha:Number = 0;
var p1:b2Vec2 = s_p1;
var p2:b2Vec2 = s_p2;
var k_maxIterations = 20;
var iter:int;
var normalX:Number = 0;
var normalY:Number = 0;
var distance:Number = 0;
var targetDistance:Number = 0;
while (true) {
t = (((1 - alpha) * t0) + alpha);
xf1 = s_xf1;
xf2 = s_xf2;
sweep1.GetXForm(xf1, t);
sweep2.GetXForm(xf2, t);
distance = b2Distance.Distance(p1, p2, shape1, xf1, shape2, xf2);
if (iter == 0){
if (distance > (2 * b2Settings.b2_toiSlop)){
targetDistance = (1.5 * b2Settings.b2_toiSlop);
} else {
math1 = (0.05 * b2Settings.b2_toiSlop);
math2 = (distance - (0.5 * b2Settings.b2_toiSlop));
targetDistance = ((math1 > math2)) ? math1 : math2;
};
};
if (((((distance - targetDistance) < (0.05 * b2Settings.b2_toiSlop))) || ((iter == k_maxIterations)))){
break;
};
normalX = (p2.x - p1.x);
normalY = (p2.y - p1.y);
nLen = Math.sqrt(((normalX * normalX) + (normalY * normalY)));
normalX = (normalX / nLen);
normalY = (normalY / nLen);
approachVelocityBound = ((((normalX * (v1X - v2X)) + (normalY * (v1Y - v2Y))) + (((omega1 < 0)) ? -(omega1) : omega1 * r1)) + (((omega2 < 0)) ? -(omega2) : omega2 * r2));
if (approachVelocityBound == 0){
alpha = 1;
break;
};
dAlpha = ((distance - targetDistance) / approachVelocityBound);
newAlpha = (alpha + dAlpha);
if ((((newAlpha < 0)) || ((1 < newAlpha)))){
alpha = 1;
break;
};
if (newAlpha < ((1 + (100 * Number.MIN_VALUE)) * alpha)){
break;
};
alpha = newAlpha;
iter++;
};
return (alpha);
}
}
}//package Box2D.Collision
Section 28
//ClipVertex (Box2D.Collision.ClipVertex)
package Box2D.Collision {
import Box2D.Common.Math.*;
public class ClipVertex {
public var id:b2ContactID;
public var v:b2Vec2;
public function ClipVertex(){
v = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Collision
Section 29
//Features (Box2D.Collision.Features)
package Box2D.Collision {
public class Features {
public var _referenceEdge:int;
public var _incidentEdge:int;
public var _flip:int;
public var _incidentVertex:int;
public var _m_id:b2ContactID;
public function Features(){
super();
}
public function get referenceEdge():int{
return (_referenceEdge);
}
public function set incidentVertex(value:int):void{
_incidentVertex = value;
_m_id._key = ((_m_id._key & 4278255615) | ((_incidentVertex << 16) & 0xFF0000));
}
public function get flip():int{
return (_flip);
}
public function get incidentEdge():int{
return (_incidentEdge);
}
public function set referenceEdge(value:int):void{
_referenceEdge = value;
_m_id._key = ((_m_id._key & 4294967040) | (_referenceEdge & 0xFF));
}
public function get incidentVertex():int{
return (_incidentVertex);
}
public function set flip(value:int):void{
_flip = value;
_m_id._key = ((_m_id._key & 0xFFFFFF) | ((_flip << 24) & 4278190080));
}
public function set incidentEdge(value:int):void{
_incidentEdge = value;
_m_id._key = ((_m_id._key & 4294902015) | ((_incidentEdge << 8) & 0xFF00));
}
}
}//package Box2D.Collision
Section 30
//b2Mat22 (Box2D.Common.Math.b2Mat22)
package Box2D.Common.Math {
public class b2Mat22 {
public var col1:b2Vec2;
public var col2:b2Vec2;
public function b2Mat22(angle:Number=0, c1:b2Vec2=null, c2:b2Vec2=null){
var c:Number;
var s:Number;
col1 = new b2Vec2();
col2 = new b2Vec2();
super();
if (((!((c1 == null))) && (!((c2 == null))))){
col1.SetV(c1);
col2.SetV(c2);
} else {
c = Math.cos(angle);
s = Math.sin(angle);
col1.x = c;
col2.x = -(s);
col1.y = s;
col2.y = c;
};
}
public function SetIdentity():void{
col1.x = 1;
col2.x = 0;
col1.y = 0;
col2.y = 1;
}
public function SetVV(c1:b2Vec2, c2:b2Vec2):void{
col1.SetV(c1);
col2.SetV(c2);
}
public function Set(angle:Number):void{
var c:Number;
c = Math.cos(angle);
var s:Number = Math.sin(angle);
col1.x = c;
col2.x = -(s);
col1.y = s;
col2.y = c;
}
public function SetZero():void{
col1.x = 0;
col2.x = 0;
col1.y = 0;
col2.y = 0;
}
public function SetM(m:b2Mat22):void{
col1.SetV(m.col1);
col2.SetV(m.col2);
}
public function AddM(m:b2Mat22):void{
col1.x = (col1.x + m.col1.x);
col1.y = (col1.y + m.col1.y);
col2.x = (col2.x + m.col2.x);
col2.y = (col2.y + m.col2.y);
}
public function Abs():void{
col1.Abs();
col2.Abs();
}
public function Copy():b2Mat22{
return (new b2Mat22(0, col1, col2));
}
public function Invert(out:b2Mat22):b2Mat22{
var a:Number;
var c:Number;
var det:Number;
a = col1.x;
var b:Number = col2.x;
c = col1.y;
var d:Number = col2.y;
det = ((a * d) - (b * c));
det = (1 / det);
out.col1.x = (det * d);
out.col2.x = (-(det) * b);
out.col1.y = (-(det) * c);
out.col2.y = (det * a);
return (out);
}
public function GetAngle():Number{
return (Math.atan2(col1.y, col1.x));
}
public function Solve(out:b2Vec2, bX:Number, bY:Number):b2Vec2{
var a11:Number = col1.x;
var a12:Number = col2.x;
var a21:Number = col1.y;
var a22:Number = col2.y;
var det:Number = ((a11 * a22) - (a12 * a21));
det = (1 / det);
out.x = (det * ((a22 * bX) - (a12 * bY)));
out.y = (det * ((a11 * bY) - (a21 * bX)));
return (out);
}
}
}//package Box2D.Common.Math
Section 31
//b2Math (Box2D.Common.Math.b2Math)
package Box2D.Common.Math {
public class b2Math {
public static const b2Mat22_identity:b2Mat22 = new b2Mat22(0, new b2Vec2(1, 0), new b2Vec2(0, 1));
public static const b2XForm_identity:b2XForm = new b2XForm(b2Vec2_zero, b2Mat22_identity);
public static const b2Vec2_zero:b2Vec2 = new b2Vec2(0, 0);
public function b2Math(){
super();
}
public static function b2CrossVF(a:b2Vec2, s:Number):b2Vec2{
var v:b2Vec2 = new b2Vec2((s * a.y), (-(s) * a.x));
return (v);
}
public static function AddVV(a:b2Vec2, b:b2Vec2):b2Vec2{
var v:b2Vec2 = new b2Vec2((a.x + b.x), (a.y + b.y));
return (v);
}
public static function b2IsValid(x:Number):Boolean{
return (isFinite(x));
}
public static function b2MinV(a:b2Vec2, b:b2Vec2):b2Vec2{
var c:b2Vec2 = new b2Vec2(b2Min(a.x, b.x), b2Min(a.y, b.y));
return (c);
}
public static function b2MulX(T:b2XForm, v:b2Vec2):b2Vec2{
var a:b2Vec2;
a = b2MulMV(T.R, v);
a.x = (a.x + T.position.x);
a.y = (a.y + T.position.y);
return (a);
}
public static function b2DistanceSquared(a:b2Vec2, b:b2Vec2):Number{
var cX:Number = (a.x - b.x);
var cY:Number = (a.y - b.y);
return (((cX * cX) + (cY * cY)));
}
public static function b2Swap(a:Array, b:Array):void{
var tmp:* = a[0];
a[0] = b[0];
b[0] = tmp;
}
public static function b2AbsM(A:b2Mat22):b2Mat22{
var B:b2Mat22 = new b2Mat22(0, b2AbsV(A.col1), b2AbsV(A.col2));
return (B);
}
public static function SubtractVV(a:b2Vec2, b:b2Vec2):b2Vec2{
var v:b2Vec2 = new b2Vec2((a.x - b.x), (a.y - b.y));
return (v);
}
public static function b2MulXT(T:b2XForm, v:b2Vec2):b2Vec2{
var a:b2Vec2;
var tX:Number;
a = SubtractVV(v, T.position);
tX = ((a.x * T.R.col1.x) + (a.y * T.R.col1.y));
a.y = ((a.x * T.R.col2.x) + (a.y * T.R.col2.y));
a.x = tX;
return (a);
}
public static function b2Abs(a:Number):Number{
return (((a > 0)) ? a : -(a));
}
public static function b2Clamp(a:Number, low:Number, high:Number):Number{
return (b2Max(low, b2Min(a, high)));
}
public static function b2AbsV(a:b2Vec2):b2Vec2{
var b:b2Vec2 = new b2Vec2(b2Abs(a.x), b2Abs(a.y));
return (b);
}
public static function MulFV(s:Number, a:b2Vec2):b2Vec2{
var v:b2Vec2 = new b2Vec2((s * a.x), (s * a.y));
return (v);
}
public static function b2CrossVV(a:b2Vec2, b:b2Vec2):Number{
return (((a.x * b.y) - (a.y * b.x)));
}
public static function b2Dot(a:b2Vec2, b:b2Vec2):Number{
return (((a.x * b.x) + (a.y * b.y)));
}
public static function b2CrossFV(s:Number, a:b2Vec2):b2Vec2{
var v:b2Vec2 = new b2Vec2((-(s) * a.y), (s * a.x));
return (v);
}
public static function AddMM(A:b2Mat22, B:b2Mat22):b2Mat22{
var C:b2Mat22 = new b2Mat22(0, AddVV(A.col1, B.col1), AddVV(A.col2, B.col2));
return (C);
}
public static function b2Distance(a:b2Vec2, b:b2Vec2):Number{
var cX:Number = (a.x - b.x);
var cY:Number = (a.y - b.y);
return (Math.sqrt(((cX * cX) + (cY * cY))));
}
public static function b2MulTMM(A:b2Mat22, B:b2Mat22):b2Mat22{
var c1:b2Vec2 = new b2Vec2(b2Dot(A.col1, B.col1), b2Dot(A.col2, B.col1));
var c2:b2Vec2 = new b2Vec2(b2Dot(A.col1, B.col2), b2Dot(A.col2, B.col2));
var C:b2Mat22 = new b2Mat22(0, c1, c2);
return (C);
}
public static function b2MaxV(a:b2Vec2, b:b2Vec2):b2Vec2{
var c:b2Vec2 = new b2Vec2(b2Max(a.x, b.x), b2Max(a.y, b.y));
return (c);
}
public static function b2IsPowerOfTwo(x:uint):Boolean{
var result:Boolean = (((x > 0)) && (((x & (x - 1)) == 0)));
return (result);
}
public static function b2ClampV(a:b2Vec2, low:b2Vec2, high:b2Vec2):b2Vec2{
return (b2MaxV(low, b2MinV(a, high)));
}
public static function b2RandomRange(lo:Number, hi:Number):Number{
var r:Number = Math.random();
r = (((hi - lo) * r) + lo);
return (r);
}
public static function b2MulTMV(A:b2Mat22, v:b2Vec2):b2Vec2{
var u:b2Vec2 = new b2Vec2(b2Dot(v, A.col1), b2Dot(v, A.col2));
return (u);
}
public static function b2Min(a:Number, b:Number):Number{
return (((a < b)) ? a : b);
}
public static function b2Random():Number{
return (((Math.random() * 2) - 1));
}
public static function b2MulMM(A:b2Mat22, B:b2Mat22):b2Mat22{
var C:b2Mat22 = new b2Mat22(0, b2MulMV(A, B.col1), b2MulMV(A, B.col2));
return (C);
}
public static function b2NextPowerOfTwo(x:uint):uint{
x = (x | ((x >> 1) & 2147483647));
x = (x | ((x >> 2) & 1073741823));
x = (x | ((x >> 4) & 268435455));
x = (x | ((x >> 8) & 0xFFFFFF));
x = (x | ((x >> 16) & 0xFFFF));
return ((x + 1));
}
public static function b2Max(a:Number, b:Number):Number{
return (((a > b)) ? a : b);
}
public static function b2MulMV(A:b2Mat22, v:b2Vec2):b2Vec2{
var u:b2Vec2 = new b2Vec2(((A.col1.x * v.x) + (A.col2.x * v.y)), ((A.col1.y * v.x) + (A.col2.y * v.y)));
return (u);
}
}
}//package Box2D.Common.Math
Section 32
//b2Sweep (Box2D.Common.Math.b2Sweep)
package Box2D.Common.Math {
public class b2Sweep {
public var localCenter:b2Vec2;
public var a:Number;
public var c:b2Vec2;
public var a0:Number;
public var c0:b2Vec2;
public var t0:Number;
public function b2Sweep(){
localCenter = new b2Vec2();
c0 = new b2Vec2();
c = new b2Vec2();
super();
}
public function Advance(t:Number):void{
var alpha:Number;
if ((((t0 < t)) && (((1 - t0) > Number.MIN_VALUE)))){
alpha = ((t - t0) / (1 - t0));
c0.x = (((1 - alpha) * c0.x) + (alpha * c.x));
c0.y = (((1 - alpha) * c0.y) + (alpha * c.y));
a0 = (((1 - alpha) * a0) + (alpha * a));
t0 = t;
};
}
public function GetXForm(xf:b2XForm, t:Number):void{
var alpha:Number;
var angle:Number;
if ((1 - t0) > Number.MIN_VALUE){
alpha = ((t - t0) / (1 - t0));
xf.position.x = (((1 - alpha) * c0.x) + (alpha * c.x));
xf.position.y = (((1 - alpha) * c0.y) + (alpha * c.y));
angle = (((1 - alpha) * a0) + (alpha * a));
xf.R.Set(angle);
} else {
xf.position.SetV(c);
xf.R.Set(a);
};
var tMat:b2Mat22 = xf.R;
xf.position.x = (xf.position.x - ((tMat.col1.x * localCenter.x) + (tMat.col2.x * localCenter.y)));
xf.position.y = (xf.position.y - ((tMat.col1.y * localCenter.x) + (tMat.col2.y * localCenter.y)));
}
}
}//package Box2D.Common.Math
Section 33
//b2Vec2 (Box2D.Common.Math.b2Vec2)
package Box2D.Common.Math {
public class b2Vec2 {
public var y:Number;
public var x:Number;
public function b2Vec2(x_:Number=0, y_:Number=0):void{
super();
x = x_;
y = y_;
}
public function Add(v:b2Vec2):void{
x = (x + v.x);
y = (y + v.y);
}
public function Set(x_:Number=0, y_:Number=0):void{
x = x_;
y = y_;
}
public function Multiply(a:Number):void{
x = (x * a);
y = (y * a);
}
public function Length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function LengthSquared():Number{
return (((x * x) + (y * y)));
}
public function MulM(A:b2Mat22):void{
var tX:Number = x;
x = ((A.col1.x * tX) + (A.col2.x * y));
y = ((A.col1.y * tX) + (A.col2.y * y));
}
public function SetZero():void{
x = 0;
y = 0;
}
public function MinV(b:b2Vec2):void{
x = ((x < b.x)) ? x : b.x;
y = ((y < b.y)) ? y : b.y;
}
public function Normalize():Number{
var length:Number = Math.sqrt(((x * x) + (y * y)));
if (length < Number.MIN_VALUE){
return (0);
};
var invLength:Number = (1 / length);
x = (x * invLength);
y = (y * invLength);
return (length);
}
public function CrossVF(s:Number):void{
var tX:Number = x;
x = (s * y);
y = (-(s) * tX);
}
public function MaxV(b:b2Vec2):void{
x = ((x > b.x)) ? x : b.x;
y = ((y > b.y)) ? y : b.y;
}
public function SetV(v:b2Vec2):void{
x = v.x;
y = v.y;
}
public function Negative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function CrossFV(s:Number):void{
var tX:Number = x;
x = (-(s) * y);
y = (s * tX);
}
public function Abs():void{
if (x < 0){
x = -(x);
};
if (y < 0){
y = -(y);
};
}
public function Subtract(v:b2Vec2):void{
x = (x - v.x);
y = (y - v.y);
}
public function Copy():b2Vec2{
return (new b2Vec2(x, y));
}
public function MulTM(A:b2Mat22):void{
var tX:Number = b2Math.b2Dot(this, A.col1);
y = b2Math.b2Dot(this, A.col2);
x = tX;
}
public function IsValid():Boolean{
return (((b2Math.b2IsValid(x)) && (b2Math.b2IsValid(y))));
}
public static function Make(x_:Number, y_:Number):b2Vec2{
return (new b2Vec2(x_, y_));
}
}
}//package Box2D.Common.Math
Section 34
//b2XForm (Box2D.Common.Math.b2XForm)
package Box2D.Common.Math {
public class b2XForm {
public var position:b2Vec2;
public var R:b2Mat22;
public function b2XForm(pos:b2Vec2=null, r:b2Mat22=null):void{
position = new b2Vec2();
R = new b2Mat22();
super();
if (pos){
position.SetV(pos);
R.SetM(r);
};
}
public function Initialize(pos:b2Vec2, r:b2Mat22):void{
position.SetV(pos);
R.SetM(r);
}
public function Set(x:b2XForm):void{
position.SetV(x.position);
R.SetM(x.R);
}
public function SetIdentity():void{
position.SetZero();
R.SetIdentity();
}
}
}//package Box2D.Common.Math
Section 35
//b2Color (Box2D.Common.b2Color)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Color {
private var _r:uint;// = 0
private var _g:uint;// = 0
private var _b:uint;// = 0
public function b2Color(rr:Number, gg:Number, bb:Number){
super();
_r = uint((0xFF * b2Math.b2Clamp(rr, 0, 1)));
_g = uint((0xFF * b2Math.b2Clamp(gg, 0, 1)));
_b = uint((0xFF * b2Math.b2Clamp(bb, 0, 1)));
}
public function Set(rr:Number, gg:Number, bb:Number):void{
_r = uint((0xFF * b2Math.b2Clamp(rr, 0, 1)));
_g = uint((0xFF * b2Math.b2Clamp(gg, 0, 1)));
_b = uint((0xFF * b2Math.b2Clamp(bb, 0, 1)));
}
public function set b(bb:Number):void{
_b = uint((0xFF * b2Math.b2Clamp(bb, 0, 1)));
}
public function get color():uint{
return (((_r | (_g << 8)) | (_b << 16)));
}
public function set r(rr:Number):void{
_r = uint((0xFF * b2Math.b2Clamp(rr, 0, 1)));
}
public function set g(gg:Number):void{
_g = uint((0xFF * b2Math.b2Clamp(gg, 0, 1)));
}
}
}//package Box2D.Common
Section 36
//b2Settings (Box2D.Common.b2Settings)
package Box2D.Common {
import Box2D.Common.Math.*;
public class b2Settings {
public static const b2_angularSleepTolerance:Number = 0.0111111111111111;
public static const b2_linearSleepTolerance:Number = 0.01;
public static const b2_angularSlop:Number = 0.0349065850398866;
public static const b2_linearSlop:Number = 0.005;
public static const b2_pi:Number = 3.14159265358979;
public static const b2_maxProxies:int = 0x0200;
public static const b2_maxAngularVelocitySquared:Number = 62500;
public static const b2_maxPolygonVertices:int = 8;
public static const b2_velocityThreshold:Number = 1;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxPairs:int = 4096;
public static const b2_maxTOIContactsPerIsland:int = 32;
public static const b2_timeToSleep:Number = 0.5;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_maxAngularVelocity:Number = 250;
public static const b2_maxAngularCorrection:Number = 0.139626340159546;
public static const USHRT_MAX:int = 0xFFFF;
public static const b2_maxLinearVelocity:Number = 200;
public static const b2_maxLinearCorrection:Number = 0.2;
public static const b2_toiSlop:Number = 0.04;
public static const b2_maxLinearVelocitySquared:Number = 40000;
public function b2Settings(){
super();
}
public static function b2Assert(a:Boolean):void{
var nullVec:b2Vec2;
if (!a){
nullVec.x++;
};
}
}
}//package Box2D.Common
Section 37
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2CircleContact extends b2Contact {
private var m_manifolds:Array;
public var m_manifold:b2Manifold;
private var m0:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2CircleContact(shape1:b2Shape, shape2:b2Shape){
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(shape1, shape2);
m_manifold = m_manifolds[0];
m_manifold.pointCount = 0;
var point:b2ManifoldPoint = m_manifold.points[0];
point.normalImpulse = 0;
point.tangentImpulse = 0;
}
override public function Evaluate(listener:b2ContactListener):void{
var v1:b2Vec2;
var v2:b2Vec2;
var mp0:b2ManifoldPoint;
var mp:b2ManifoldPoint;
var b1:b2Body = m_shape1.m_body;
var b2:b2Body = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollideCircles(m_manifold, (m_shape1 as b2CircleShape), b1.m_xf, (m_shape2 as b2CircleShape), b2.m_xf);
var cp:b2ContactPoint = s_evalCP;
cp.shape1 = m_shape1;
cp.shape2 = m_shape2;
cp.friction = m_friction;
cp.restitution = m_restitution;
if (m_manifold.pointCount > 0){
m_manifoldCount = 1;
mp = m_manifold.points[0];
if (m0.pointCount == 0){
mp.normalImpulse = 0;
mp.tangentImpulse = 0;
if (listener){
cp.position = b1.GetWorldPoint(mp.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.normal.SetV(m_manifold.normal);
cp.separation = mp.separation;
cp.id.key = mp.id._key;
listener.Add(cp);
};
} else {
mp0 = m0.points[0];
mp.normalImpulse = mp0.normalImpulse;
mp.tangentImpulse = mp0.tangentImpulse;
if (listener){
cp.position = b1.GetWorldPoint(mp.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.normal.SetV(m_manifold.normal);
cp.separation = mp.separation;
cp.id.key = mp.id._key;
listener.Persist(cp);
};
};
} else {
m_manifoldCount = 0;
if ((((m0.pointCount > 0)) && (listener))){
mp0 = m0.points[0];
cp.position = b1.GetWorldPoint(mp0.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp0.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp0.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.normal.SetV(m0.normal);
cp.separation = mp0.separation;
cp.id.key = mp0.id._key;
listener.Remove(cp);
};
};
}
override public function GetManifolds():Array{
return (m_manifolds);
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(shape1:b2Shape, shape2:b2Shape, allocator):b2Contact{
return (new b2CircleContact(shape1, shape2));
}
}
}//package Box2D.Dynamics.Contacts
Section 38
//b2Contact (Box2D.Dynamics.Contacts.b2Contact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2Contact {
public var m_shape1:b2Shape;
public var m_shape2:b2Shape;
public var m_prev:b2Contact;
public var m_toi:Number;
public var m_next:b2Contact;
public var m_friction:Number;
public var m_manifoldCount:int;
public var m_node1:b2ContactEdge;
public var m_node2:b2ContactEdge;
public var m_restitution:Number;
public var m_flags:uint;
public static var e_toiFlag:uint = 8;
public static var e_nonSolidFlag:uint = 1;
public static var e_slowFlag:uint = 2;
public static var e_islandFlag:uint = 4;
public static var s_registers:Array;
public static var s_initialized:Boolean = false;
public function b2Contact(s1:b2Shape=null, s2:b2Shape=null){
m_node1 = new b2ContactEdge();
m_node2 = new b2ContactEdge();
super();
m_flags = 0;
if (((!(s1)) || (!(s2)))){
m_shape1 = null;
m_shape2 = null;
return;
};
if (((s1.IsSensor()) || (s2.IsSensor()))){
m_flags = (m_flags | e_nonSolidFlag);
};
m_shape1 = s1;
m_shape2 = s2;
m_manifoldCount = 0;
m_friction = Math.sqrt((m_shape1.m_friction * m_shape2.m_friction));
m_restitution = b2Math.b2Max(m_shape1.m_restitution, m_shape2.m_restitution);
m_prev = null;
m_next = null;
m_node1.contact = null;
m_node1.prev = null;
m_node1.next = null;
m_node1.other = null;
m_node2.contact = null;
m_node2.prev = null;
m_node2.next = null;
m_node2.other = null;
}
public function IsSolid():Boolean{
return (((m_flags & e_nonSolidFlag) == 0));
}
public function GetShape1():b2Shape{
return (m_shape1);
}
public function GetShape2():b2Shape{
return (m_shape2);
}
public function GetNext():b2Contact{
return (m_next);
}
public function GetManifoldCount():int{
return (m_manifoldCount);
}
public function GetManifolds():Array{
return (null);
}
public function Update(listener:b2ContactListener):void{
var oldCount:int = m_manifoldCount;
Evaluate(listener);
var newCount:int = m_manifoldCount;
var body1:b2Body = m_shape1.m_body;
var body2:b2Body = m_shape2.m_body;
if ((((newCount == 0)) && ((oldCount > 0)))){
body1.WakeUp();
body2.WakeUp();
};
if (((((((body1.IsStatic()) || (body1.IsBullet()))) || (body2.IsStatic()))) || (body2.IsBullet()))){
m_flags = (m_flags & ~(e_slowFlag));
} else {
m_flags = (m_flags | e_slowFlag);
};
}
public function Evaluate(listener:b2ContactListener):void{
}
public static function InitializeRegisters():void{
var j:int;
s_registers = new Array(b2Shape.e_shapeTypeCount);
var i:int;
while (i < b2Shape.e_shapeTypeCount) {
s_registers[i] = new Array(b2Shape.e_shapeTypeCount);
j = 0;
while (j < b2Shape.e_shapeTypeCount) {
s_registers[i][j] = new b2ContactRegister();
j++;
};
i++;
};
AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape);
AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_circleShape);
AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape);
}
public static function Destroy(contact:b2Contact, allocator):void{
if (contact.m_manifoldCount > 0){
contact.m_shape1.m_body.WakeUp();
contact.m_shape2.m_body.WakeUp();
};
var type1:int = contact.m_shape1.m_type;
var type2:int = contact.m_shape2.m_type;
var reg:b2ContactRegister = s_registers[type1][type2];
var destroyFcn:Function = reg.destroyFcn;
destroyFcn(contact, allocator);
}
public static function AddType(createFcn:Function, destroyFcn:Function, type1:int, type2:int):void{
s_registers[type1][type2].createFcn = createFcn;
s_registers[type1][type2].destroyFcn = destroyFcn;
s_registers[type1][type2].primary = true;
if (type1 != type2){
s_registers[type2][type1].createFcn = createFcn;
s_registers[type2][type1].destroyFcn = destroyFcn;
s_registers[type2][type1].primary = false;
};
}
public static function Create(shape1:b2Shape, shape2:b2Shape, allocator):b2Contact{
var c:b2Contact;
var i:int;
var m:b2Manifold;
if (s_initialized == false){
InitializeRegisters();
s_initialized = true;
};
var type1:int = shape1.m_type;
var type2:int = shape2.m_type;
var reg:b2ContactRegister = s_registers[type1][type2];
var createFcn:Function = reg.createFcn;
if (createFcn != null){
if (reg.primary){
return (createFcn(shape1, shape2, allocator));
};
c = createFcn(shape2, shape1, allocator);
i = 0;
while (i < c.m_manifoldCount) {
m = c.GetManifolds()[i];
m.normal = m.normal.Negative();
i++;
};
return (c);
//unresolved jump
};
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 39
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2ContactConstraint {
public var points:Array;
public var normal:b2Vec2;
public var restitution:Number;
public var body1:b2Body;
public var manifold:b2Manifold;
public var body2:b2Body;
public var friction:Number;
public var pointCount:int;
public function b2ContactConstraint(){
normal = new b2Vec2();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
var i:int;
while (i < b2Settings.b2_maxManifoldPoints) {
points[i] = new b2ContactConstraintPoint();
i++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 40
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint)
package Box2D.Dynamics.Contacts {
import Box2D.Common.Math.*;
public class b2ContactConstraintPoint {
public var r2:b2Vec2;
public var separation:Number;
public var positionImpulse:Number;
public var normalImpulse:Number;
public var tangentMass:Number;
public var equalizedMass:Number;
public var tangentImpulse:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var normalMass:Number;
public var velocityBias:Number;
public var r1:b2Vec2;
public function b2ContactConstraintPoint(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
r1 = new b2Vec2();
r2 = new b2Vec2();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 41
//b2ContactEdge (Box2D.Dynamics.Contacts.b2ContactEdge)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2ContactEdge {
public var other:b2Body;
public var prev:b2ContactEdge;
public var contact:b2Contact;
public var next:b2ContactEdge;
public function b2ContactEdge(){
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 42
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister)
package Box2D.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var createFcn:Function;
public var destroyFcn:Function;
public function b2ContactRegister(){
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 43
//b2ContactResult (Box2D.Dynamics.Contacts.b2ContactResult)
package Box2D.Dynamics.Contacts {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
public class b2ContactResult {
public var position:b2Vec2;
public var shape1:b2Shape;
public var shape2:b2Shape;
public var normalImpulse:Number;
public var normal:b2Vec2;
public var tangentImpulse:Number;
public var id:b2ContactID;
public function b2ContactResult(){
position = new b2Vec2();
normal = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Box2D.Dynamics.Contacts
Section 44
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2ContactSolver {
public var m_constraintCount:int;
public var m_constraints:Array;
public var m_allocator;
public var m_step:b2TimeStep;
public function b2ContactSolver(step:b2TimeStep, contacts:Array, contactCount:int, allocator){
var contact:b2Contact;
var i:int;
var tVec:b2Vec2;
var tMat:b2Mat22;
var b1:b2Body;
var b2:b2Body;
var manifoldCount:int;
var manifolds:Array;
var friction:Number;
var restitution:Number;
var v1X:Number;
var v1Y:Number;
var v2X:Number;
var v2Y:Number;
var w1:Number;
var w2:Number;
var j:int;
var manifold:b2Manifold;
var normalX:Number;
var normalY:Number;
var c:b2ContactConstraint;
var k:uint;
var cp:b2ManifoldPoint;
var ccp:b2ContactConstraintPoint;
var tX:Number;
var tY:Number;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var r1Sqr:Number;
var r2Sqr:Number;
var rn1:Number;
var rn2:Number;
var kNormal:Number;
var kEqualized:Number;
var tangentX:Number;
var tangentY:Number;
var rt1:Number;
var rt2:Number;
var kTangent:Number;
var vRel:Number;
m_step = new b2TimeStep();
m_constraints = new Array();
super();
m_step.dt = step.dt;
m_step.inv_dt = step.inv_dt;
m_step.maxIterations = step.maxIterations;
m_allocator = allocator;
m_constraintCount = 0;
i = 0;
while (i < contactCount) {
contact = contacts[i];
m_constraintCount = (m_constraintCount + contact.m_manifoldCount);
i++;
};
i = 0;
while (i < m_constraintCount) {
m_constraints[i] = new b2ContactConstraint();
i++;
};
var count:int;
i = 0;
while (i < contactCount) {
contact = contacts[i];
b1 = contact.m_shape1.m_body;
b2 = contact.m_shape2.m_body;
manifoldCount = contact.m_manifoldCount;
manifolds = contact.GetManifolds();
friction = contact.m_friction;
restitution = contact.m_restitution;
v1X = b1.m_linearVelocity.x;
v1Y = b1.m_linearVelocity.y;
v2X = b2.m_linearVelocity.x;
v2Y = b2.m_linearVelocity.y;
w1 = b1.m_angularVelocity;
w2 = b2.m_angularVelocity;
j = 0;
while (j < manifoldCount) {
manifold = manifolds[j];
normalX = manifold.normal.x;
normalY = manifold.normal.y;
c = m_constraints[count];
c.body1 = b1;
c.body2 = b2;
c.manifold = manifold;
c.normal.x = normalX;
c.normal.y = normalY;
c.pointCount = manifold.pointCount;
c.friction = friction;
c.restitution = restitution;
k = 0;
while (k < c.pointCount) {
cp = manifold.points[k];
ccp = c.points[k];
ccp.normalImpulse = cp.normalImpulse;
ccp.tangentImpulse = cp.tangentImpulse;
ccp.separation = cp.separation;
ccp.positionImpulse = 0;
ccp.localAnchor1.SetV(cp.localPoint1);
ccp.localAnchor2.SetV(cp.localPoint2);
tMat = b1.m_xf.R;
r1X = (cp.localPoint1.x - b1.m_sweep.localCenter.x);
r1Y = (cp.localPoint1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
ccp.r1.Set(r1X, r1Y);
tMat = b2.m_xf.R;
r2X = (cp.localPoint2.x - b2.m_sweep.localCenter.x);
r2Y = (cp.localPoint2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
ccp.r2.Set(r2X, r2Y);
r1Sqr = ((r1X * r1X) + (r1Y * r1Y));
r2Sqr = ((r2X * r2X) + (r2Y * r2Y));
rn1 = ((r1X * normalX) + (r1Y * normalY));
rn2 = ((r2X * normalX) + (r2Y * normalY));
kNormal = (b1.m_invMass + b2.m_invMass);
kNormal = (kNormal + ((b1.m_invI * (r1Sqr - (rn1 * rn1))) + (b2.m_invI * (r2Sqr - (rn2 * rn2)))));
ccp.normalMass = (1 / kNormal);
kEqualized = ((b1.m_mass * b1.m_invMass) + (b2.m_mass * b2.m_invMass));
kEqualized = (kEqualized + (((b1.m_mass * b1.m_invI) * (r1Sqr - (rn1 * rn1))) + ((b2.m_mass * b2.m_invI) * (r2Sqr - (rn2 * rn2)))));
ccp.equalizedMass = (1 / kEqualized);
tangentX = normalY;
tangentY = -(normalX);
rt1 = ((r1X * tangentX) + (r1Y * tangentY));
rt2 = ((r2X * tangentX) + (r2Y * tangentY));
kTangent = (b1.m_invMass + b2.m_invMass);
kTangent = (kTangent + ((b1.m_invI * (r1Sqr - (rt1 * rt1))) + (b2.m_invI * (r2Sqr - (rt2 * rt2)))));
ccp.tangentMass = (1 / kTangent);
ccp.velocityBias = 0;
if (ccp.separation > 0){
ccp.velocityBias = (-60 * ccp.separation);
};
tX = (((v2X + (-(w2) * r2Y)) - v1X) - (-(w1) * r1Y));
tY = (((v2Y + (w2 * r2X)) - v1Y) - (w1 * r1X));
vRel = ((c.normal.x * tX) + (c.normal.y * tY));
if (vRel < -(b2Settings.b2_velocityThreshold)){
ccp.velocityBias = (ccp.velocityBias + (-(c.restitution) * vRel));
};
k++;
};
count++;
j++;
};
i++;
};
}
public function InitVelocityConstraints(step:b2TimeStep):void{
var tVec:b2Vec2;
var tVec2:b2Vec2;
var tMat:b2Mat22;
var c:b2ContactConstraint;
var b1:b2Body;
var b2:b2Body;
var invMass1:Number;
var invI1:Number;
var invMass2:Number;
var invI2:Number;
var normalX:Number;
var normalY:Number;
var tangentX:Number;
var tangentY:Number;
var tX:Number;
var j:int;
var tCount:int;
var ccp:b2ContactConstraintPoint;
var PX:Number;
var PY:Number;
var ccp2:b2ContactConstraintPoint;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
b1 = c.body1;
b2 = c.body2;
invMass1 = b1.m_invMass;
invI1 = b1.m_invI;
invMass2 = b2.m_invMass;
invI2 = b2.m_invI;
normalX = c.normal.x;
normalY = c.normal.y;
tangentX = normalY;
tangentY = -(normalX);
if (step.warmStarting){
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp = c.points[j];
ccp.normalImpulse = (ccp.normalImpulse * step.dtRatio);
ccp.tangentImpulse = (ccp.tangentImpulse * step.dtRatio);
PX = ((ccp.normalImpulse * normalX) + (ccp.tangentImpulse * tangentX));
PY = ((ccp.normalImpulse * normalY) + (ccp.tangentImpulse * tangentY));
b1.m_angularVelocity = (b1.m_angularVelocity - (invI1 * ((ccp.r1.x * PY) - (ccp.r1.y * PX))));
b1.m_linearVelocity.x = (b1.m_linearVelocity.x - (invMass1 * PX));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y - (invMass1 * PY));
b2.m_angularVelocity = (b2.m_angularVelocity + (invI2 * ((ccp.r2.x * PY) - (ccp.r2.y * PX))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (invMass2 * PX));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (invMass2 * PY));
j++;
};
} else {
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp2 = c.points[j];
ccp2.normalImpulse = 0;
ccp2.tangentImpulse = 0;
j++;
};
};
i++;
};
}
public function SolvePositionConstraints(baumgarte:Number):Boolean{
var tMat:b2Mat22;
var tVec:b2Vec2;
var c:b2ContactConstraint;
var b1:b2Body;
var b2:b2Body;
var b1_sweep_c:b2Vec2;
var b1_sweep_a:Number;
var b2_sweep_c:b2Vec2;
var b2_sweep_a:Number;
var invMass1:Number;
var invI1:Number;
var invMass2:Number;
var invI2:Number;
var normalX:Number;
var normalY:Number;
var tCount:int;
var j:int;
var ccp:b2ContactConstraintPoint;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var tX:Number;
var p1X:Number;
var p1Y:Number;
var p2X:Number;
var p2Y:Number;
var dpX:Number;
var dpY:Number;
var separation:Number;
var C:Number;
var dImpulse:Number;
var impulse0:Number;
var impulseX:Number;
var impulseY:Number;
var minSeparation:Number = 0;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
b1 = c.body1;
b2 = c.body2;
b1_sweep_c = b1.m_sweep.c;
b1_sweep_a = b1.m_sweep.a;
b2_sweep_c = b2.m_sweep.c;
b2_sweep_a = b2.m_sweep.a;
invMass1 = (b1.m_mass * b1.m_invMass);
invI1 = (b1.m_mass * b1.m_invI);
invMass2 = (b2.m_mass * b2.m_invMass);
invI2 = (b2.m_mass * b2.m_invI);
normalX = c.normal.x;
normalY = c.normal.y;
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp = c.points[j];
tMat = b1.m_xf.R;
tVec = b1.m_sweep.localCenter;
r1X = (ccp.localAnchor1.x - tVec.x);
r1Y = (ccp.localAnchor1.y - tVec.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
tVec = b2.m_sweep.localCenter;
r2X = (ccp.localAnchor2.x - tVec.x);
r2Y = (ccp.localAnchor2.y - tVec.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
p1X = (b1_sweep_c.x + r1X);
p1Y = (b1_sweep_c.y + r1Y);
p2X = (b2_sweep_c.x + r2X);
p2Y = (b2_sweep_c.y + r2Y);
dpX = (p2X - p1X);
dpY = (p2Y - p1Y);
separation = (((dpX * normalX) + (dpY * normalY)) + ccp.separation);
minSeparation = b2Math.b2Min(minSeparation, separation);
C = (baumgarte * b2Math.b2Clamp((separation + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0));
dImpulse = (-(ccp.equalizedMass) * C);
impulse0 = ccp.positionImpulse;
ccp.positionImpulse = b2Math.b2Max((impulse0 + dImpulse), 0);
dImpulse = (ccp.positionImpulse - impulse0);
impulseX = (dImpulse * normalX);
impulseY = (dImpulse * normalY);
b1_sweep_c.x = (b1_sweep_c.x - (invMass1 * impulseX));
b1_sweep_c.y = (b1_sweep_c.y - (invMass1 * impulseY));
b1_sweep_a = (b1_sweep_a - (invI1 * ((r1X * impulseY) - (r1Y * impulseX))));
b1.m_sweep.a = b1_sweep_a;
b1.SynchronizeTransform();
b2_sweep_c.x = (b2_sweep_c.x + (invMass2 * impulseX));
b2_sweep_c.y = (b2_sweep_c.y + (invMass2 * impulseY));
b2_sweep_a = (b2_sweep_a + (invI2 * ((r2X * impulseY) - (r2Y * impulseX))));
b2.m_sweep.a = b2_sweep_a;
b2.SynchronizeTransform();
j++;
};
i++;
};
return ((minSeparation >= (-1.5 * b2Settings.b2_linearSlop)));
}
public function SolveVelocityConstraints():void{
var j:int;
var ccp:b2ContactConstraintPoint;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var dvX:Number;
var dvY:Number;
var vn:Number;
var vt:Number;
var lambda_n:Number;
var lambda_t:Number;
var newImpulse_n:Number;
var newImpulse_t:Number;
var PX:Number;
var PY:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var c:b2ContactConstraint;
var b1:b2Body;
var b2:b2Body;
var w1:Number;
var w2:Number;
var v1:b2Vec2;
var v2:b2Vec2;
var invMass1:Number;
var invI1:Number;
var invMass2:Number;
var invI2:Number;
var normalX:Number;
var normalY:Number;
var tangentX:Number;
var tangentY:Number;
var friction:Number;
var tX:Number;
var tCount:int;
var maxFriction:Number;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
b1 = c.body1;
b2 = c.body2;
w1 = b1.m_angularVelocity;
w2 = b2.m_angularVelocity;
v1 = b1.m_linearVelocity;
v2 = b2.m_linearVelocity;
invMass1 = b1.m_invMass;
invI1 = b1.m_invI;
invMass2 = b2.m_invMass;
invI2 = b2.m_invI;
normalX = c.normal.x;
normalY = c.normal.y;
tangentX = normalY;
tangentY = -(normalX);
friction = c.friction;
tCount = c.pointCount;
j = 0;
while (j < tCount) {
ccp = c.points[j];
dvX = (((v2.x + (-(w2) * ccp.r2.y)) - v1.x) - (-(w1) * ccp.r1.y));
dvY = (((v2.y + (w2 * ccp.r2.x)) - v1.y) - (w1 * ccp.r1.x));
vn = ((dvX * normalX) + (dvY * normalY));
lambda_n = (-(ccp.normalMass) * (vn - ccp.velocityBias));
vt = ((dvX * tangentX) + (dvY * tangentY));
lambda_t = (ccp.tangentMass * -(vt));
newImpulse_n = b2Math.b2Max((ccp.normalImpulse + lambda_n), 0);
lambda_n = (newImpulse_n - ccp.normalImpulse);
maxFriction = (friction * ccp.normalImpulse);
newImpulse_t = b2Math.b2Clamp((ccp.tangentImpulse + lambda_t), -(maxFriction), maxFriction);
lambda_t = (newImpulse_t - ccp.tangentImpulse);
PX = ((lambda_n * normalX) + (lambda_t * tangentX));
PY = ((lambda_n * normalY) + (lambda_t * tangentY));
v1.x = (v1.x - (invMass1 * PX));
v1.y = (v1.y - (invMass1 * PY));
w1 = (w1 - (invI1 * ((ccp.r1.x * PY) - (ccp.r1.y * PX))));
v2.x = (v2.x + (invMass2 * PX));
v2.y = (v2.y + (invMass2 * PY));
w2 = (w2 + (invI2 * ((ccp.r2.x * PY) - (ccp.r2.y * PX))));
ccp.normalImpulse = newImpulse_n;
ccp.tangentImpulse = newImpulse_t;
j++;
};
b1.m_angularVelocity = w1;
b2.m_angularVelocity = w2;
i++;
};
}
public function FinalizeVelocityConstraints():void{
var c:b2ContactConstraint;
var m:b2Manifold;
var j:int;
var point1:b2ManifoldPoint;
var point2:b2ContactConstraintPoint;
var i:int;
while (i < m_constraintCount) {
c = m_constraints[i];
m = c.manifold;
j = 0;
while (j < c.pointCount) {
point1 = m.points[j];
point2 = c.points[j];
point1.normalImpulse = point2.normalImpulse;
point1.tangentImpulse = point2.tangentImpulse;
j++;
};
i++;
};
}
}
}//package Box2D.Dynamics.Contacts
Section 45
//b2NullContact (Box2D.Dynamics.Contacts.b2NullContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
public class b2NullContact extends b2Contact {
public function b2NullContact(){
super();
}
override public function Evaluate(l:b2ContactListener):void{
}
override public function GetManifolds():Array{
return (null);
}
}
}//package Box2D.Dynamics.Contacts
Section 46
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2PolyAndCircleContact extends b2Contact {
private var m_manifolds:Array;
public var m_manifold:b2Manifold;
private var m0:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2PolyAndCircleContact(shape1:b2Shape, shape2:b2Shape){
m_manifolds = [new b2Manifold()];
m0 = new b2Manifold();
super(shape1, shape2);
m_manifold = m_manifolds[0];
b2Settings.b2Assert((m_shape1.m_type == b2Shape.e_polygonShape));
b2Settings.b2Assert((m_shape2.m_type == b2Shape.e_circleShape));
m_manifold.pointCount = 0;
var point:b2ManifoldPoint = m_manifold.points[0];
point.normalImpulse = 0;
point.tangentImpulse = 0;
}
override public function Evaluate(listener:b2ContactListener):void{
var i:int;
var v1:b2Vec2;
var v2:b2Vec2;
var mp0:b2ManifoldPoint;
var mp:b2ManifoldPoint;
var found:Boolean;
var idKey:uint;
var j:int;
var b1:b2Body = m_shape1.m_body;
var b2:b2Body = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollidePolygonAndCircle(m_manifold, (m_shape1 as b2PolygonShape), b1.m_xf, (m_shape2 as b2CircleShape), b2.m_xf);
var persisted:Array = [false, false];
var cp:b2ContactPoint = s_evalCP;
cp.shape1 = m_shape1;
cp.shape2 = m_shape2;
cp.friction = m_friction;
cp.restitution = m_restitution;
if (m_manifold.pointCount > 0){
i = 0;
while (i < m_manifold.pointCount) {
mp = m_manifold.points[i];
mp.normalImpulse = 0;
mp.tangentImpulse = 0;
found = false;
idKey = mp.id._key;
j = 0;
while (j < m0.pointCount) {
if (persisted[j] == true){
} else {
mp0 = m0.points[j];
if (mp0.id._key == idKey){
persisted[j] = true;
mp.normalImpulse = mp0.normalImpulse;
mp.tangentImpulse = mp0.tangentImpulse;
found = true;
if (listener != null){
cp.position = b1.GetWorldPoint(mp.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.normal.SetV(m_manifold.normal);
cp.separation = mp.separation;
cp.id.key = idKey;
listener.Persist(cp);
};
break;
};
};
j++;
};
if ((((found == false)) && (!((listener == null))))){
cp.position = b1.GetWorldPoint(mp.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.normal.SetV(m_manifold.normal);
cp.separation = mp.separation;
cp.id.key = idKey;
listener.Add(cp);
};
i++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
if (listener == null){
return;
};
i = 0;
while (i < m0.pointCount) {
if (persisted[i]){
} else {
mp0 = m0.points[i];
cp.position = b1.GetWorldPoint(mp0.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp0.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp0.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.normal.SetV(m0.normal);
cp.separation = mp0.separation;
cp.id.key = mp0.id._key;
listener.Remove(cp);
};
i++;
};
}
override public function GetManifolds():Array{
return (m_manifolds);
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(shape1:b2Shape, shape2:b2Shape, allocator):b2Contact{
return (new b2PolyAndCircleContact(shape1, shape2));
}
}
}//package Box2D.Dynamics.Contacts
Section 47
//b2PolygonContact (Box2D.Dynamics.Contacts.b2PolygonContact)
package Box2D.Dynamics.Contacts {
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
public class b2PolygonContact extends b2Contact {
private var m_manifolds:Array;
private var m0:b2Manifold;
public var m_manifold:b2Manifold;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2PolygonContact(shape1:b2Shape, shape2:b2Shape):void{
m0 = new b2Manifold();
m_manifolds = [new b2Manifold()];
super(shape1, shape2);
m_manifold = m_manifolds[0];
m_manifold.pointCount = 0;
}
override public function Evaluate(listener:b2ContactListener):void{
var v1:b2Vec2;
var v2:b2Vec2;
var mp0:b2ManifoldPoint;
var cp:b2ContactPoint;
var i:int;
var mp:b2ManifoldPoint;
var found:Boolean;
var idKey:uint;
var j:int;
var b1:b2Body = m_shape1.m_body;
var b2:b2Body = m_shape2.m_body;
m0.Set(m_manifold);
b2Collision.b2CollidePolygons(m_manifold, (m_shape1 as b2PolygonShape), b1.m_xf, (m_shape2 as b2PolygonShape), b2.m_xf);
var persisted:Array = [false, false];
cp = s_evalCP;
cp.shape1 = m_shape1;
cp.shape2 = m_shape2;
cp.friction = m_friction;
cp.restitution = m_restitution;
if (m_manifold.pointCount > 0){
i = 0;
while (i < m_manifold.pointCount) {
mp = m_manifold.points[i];
mp.normalImpulse = 0;
mp.tangentImpulse = 0;
found = false;
idKey = mp.id._key;
j = 0;
while (j < m0.pointCount) {
if (persisted[j] == true){
} else {
mp0 = m0.points[j];
if (mp0.id._key == idKey){
persisted[j] = true;
mp.normalImpulse = mp0.normalImpulse;
mp.tangentImpulse = mp0.tangentImpulse;
found = true;
if (listener != null){
cp.position = b1.GetWorldPoint(mp.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.normal.SetV(m_manifold.normal);
cp.separation = mp.separation;
cp.id.key = idKey;
listener.Persist(cp);
};
break;
};
};
j++;
};
if ((((found == false)) && (!((listener == null))))){
cp.position = b1.GetWorldPoint(mp.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.normal.SetV(m_manifold.normal);
cp.separation = mp.separation;
cp.id.key = idKey;
listener.Add(cp);
};
i++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
if (listener == null){
return;
};
i = 0;
while (i < m0.pointCount) {
if (persisted[i]){
} else {
mp0 = m0.points[i];
cp.position = b1.GetWorldPoint(mp0.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp0.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp0.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.normal.SetV(m0.normal);
cp.separation = mp0.separation;
cp.id.key = mp0.id._key;
listener.Remove(cp);
};
i++;
};
}
override public function GetManifolds():Array{
return (m_manifolds);
}
public static function Destroy(contact:b2Contact, allocator):void{
}
public static function Create(shape1:b2Shape, shape2:b2Shape, allocator):b2Contact{
return (new b2PolygonContact(shape1, shape2));
}
}
}//package Box2D.Dynamics.Contacts
Section 48
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2DistanceJoint extends b2Joint {
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_bias:Number;
public var m_gamma:Number;
public var m_u:b2Vec2;
public var m_mass:Number;
public var m_impulse:Number;
public var m_dampingRatio:Number;
public var m_frequencyHz:Number;
public var m_length:Number;
public function b2DistanceJoint(def:b2DistanceJointDef){
var tMat:b2Mat22;
var tX:Number;
var tY:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u = new b2Vec2();
super(def);
m_localAnchor1.SetV(def.localAnchor1);
m_localAnchor2.SetV(def.localAnchor2);
m_length = def.length;
m_frequencyHz = def.frequencyHz;
m_dampingRatio = def.dampingRatio;
m_impulse = 0;
m_gamma = 0;
m_bias = 0;
m_inv_dt = 0;
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function InitVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var b1:b2Body;
var b2:b2Body;
var r1X:Number;
var r2X:Number;
var C:Number;
var omega:Number;
var d:Number;
var k:Number;
var PX:Number;
var PY:Number;
m_inv_dt = step.inv_dt;
b1 = m_body1;
b2 = m_body2;
tMat = b1.m_xf.R;
r1X = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
r2X = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
m_u.x = (((b2.m_sweep.c.x + r2X) - b1.m_sweep.c.x) - r1X);
m_u.y = (((b2.m_sweep.c.y + r2Y) - b1.m_sweep.c.y) - r1Y);
var length:Number = Math.sqrt(((m_u.x * m_u.x) + (m_u.y * m_u.y)));
if (length > b2Settings.b2_linearSlop){
m_u.Multiply((1 / length));
} else {
m_u.SetZero();
};
var cr1u:Number = ((r1X * m_u.y) - (r1Y * m_u.x));
var cr2u:Number = ((r2X * m_u.y) - (r2Y * m_u.x));
var invMass:Number = (((b1.m_invMass + ((b1.m_invI * cr1u) * cr1u)) + b2.m_invMass) + ((b2.m_invI * cr2u) * cr2u));
m_mass = (1 / invMass);
if (m_frequencyHz > 0){
C = (length - m_length);
omega = ((2 * Math.PI) * m_frequencyHz);
d = (((2 * m_mass) * m_dampingRatio) * omega);
k = ((m_mass * omega) * omega);
m_gamma = (1 / (step.dt * (d + (step.dt * k))));
m_bias = (((C * step.dt) * k) * m_gamma);
m_mass = (1 / (invMass + m_gamma));
};
if (step.warmStarting){
m_impulse = (m_impulse * step.dtRatio);
PX = (m_impulse * m_u.x);
PY = (m_impulse * m_u.y);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x - (b1.m_invMass * PX));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y - (b1.m_invMass * PY));
b1.m_angularVelocity = (b1.m_angularVelocity - (b1.m_invI * ((r1X * PY) - (r1Y * PX))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * PX));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * PY));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * PY) - (r2Y * PX))));
} else {
m_impulse = 0;
};
}
override public function GetReactionTorque():Number{
return (0);
}
override public function GetReactionForce():b2Vec2{
var F:b2Vec2 = new b2Vec2();
F.SetV(m_u);
F.Multiply((m_inv_dt * m_impulse));
return (F);
}
override public function SolvePositionConstraints():Boolean{
var tMat:b2Mat22;
if (m_frequencyHz > 0){
return (true);
};
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var dX:Number = (((b2.m_sweep.c.x + r2X) - b1.m_sweep.c.x) - r1X);
var dY:Number = (((b2.m_sweep.c.y + r2Y) - b1.m_sweep.c.y) - r1Y);
var length:Number = Math.sqrt(((dX * dX) + (dY * dY)));
dX = (dX / length);
dY = (dY / length);
var C:Number = (length - m_length);
C = b2Math.b2Clamp(C, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var impulse:Number = (-(m_mass) * C);
m_u.Set(dX, dY);
var PX:Number = (impulse * m_u.x);
var PY:Number = (impulse * m_u.y);
b1.m_sweep.c.x = (b1.m_sweep.c.x - (b1.m_invMass * PX));
b1.m_sweep.c.y = (b1.m_sweep.c.y - (b1.m_invMass * PY));
b1.m_sweep.a = (b1.m_sweep.a - (b1.m_invI * ((r1X * PY) - (r1Y * PX))));
b2.m_sweep.c.x = (b2.m_sweep.c.x + (b2.m_invMass * PX));
b2.m_sweep.c.y = (b2.m_sweep.c.y + (b2.m_invMass * PY));
b2.m_sweep.a = (b2.m_sweep.a + (b2.m_invI * ((r2X * PY) - (r2Y * PX))));
b1.SynchronizeTransform();
b2.SynchronizeTransform();
return ((b2Math.b2Abs(C) < b2Settings.b2_linearSlop));
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var v1X:Number = (b1.m_linearVelocity.x + (-(b1.m_angularVelocity) * r1Y));
var v1Y:Number = (b1.m_linearVelocity.y + (b1.m_angularVelocity * r1X));
var v2X:Number = (b2.m_linearVelocity.x + (-(b2.m_angularVelocity) * r2Y));
var v2Y:Number = (b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X));
var Cdot:Number = ((m_u.x * (v2X - v1X)) + (m_u.y * (v2Y - v1Y)));
var impulse:Number = (-(m_mass) * ((Cdot + m_bias) + (m_gamma * m_impulse)));
m_impulse = (m_impulse + impulse);
var PX:Number = (impulse * m_u.x);
var PY:Number = (impulse * m_u.y);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x - (b1.m_invMass * PX));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y - (b1.m_invMass * PY));
b1.m_angularVelocity = (b1.m_angularVelocity - (b1.m_invI * ((r1X * PY) - (r1Y * PX))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * PX));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * PY));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * PY) - (r2Y * PX))));
}
}
}//package Box2D.Dynamics.Joints
Section 49
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2DistanceJointDef extends b2JointDef {
public var localAnchor1:b2Vec2;
public var length:Number;
public var dampingRatio:Number;
public var localAnchor2:b2Vec2;
public var frequencyHz:Number;
public function b2DistanceJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_distanceJoint;
length = 1;
frequencyHz = 0;
dampingRatio = 0;
}
public function Initialize(b1:b2Body, b2:b2Body, anchor1:b2Vec2, anchor2:b2Vec2):void{
body1 = b1;
body2 = b2;
localAnchor1.SetV(body1.GetLocalPoint(anchor1));
localAnchor2.SetV(body2.GetLocalPoint(anchor2));
var dX:Number = (anchor2.x - anchor1.x);
var dY:Number = (anchor2.y - anchor1.y);
length = Math.sqrt(((dX * dX) + (dY * dY)));
frequencyHz = 0;
dampingRatio = 0;
}
}
}//package Box2D.Dynamics.Joints
Section 50
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2GearJoint extends b2Joint {
public var m_ground2:b2Body;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_ratio:Number;
public var m_revolute2:b2RevoluteJoint;
public var m_force:Number;
public var m_mass:Number;
public var m_prismatic2:b2PrismaticJoint;
public var m_ground1:b2Body;
public var m_revolute1:b2RevoluteJoint;
public var m_prismatic1:b2PrismaticJoint;
public var m_constant:Number;
public var m_J:b2Jacobian;
public function b2GearJoint(def:b2GearJointDef){
var coordinate1:Number;
var coordinate2:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_J = new b2Jacobian();
super(def);
var type1:int = def.joint1.m_type;
var type2:int = def.joint2.m_type;
m_revolute1 = null;
m_prismatic1 = null;
m_revolute2 = null;
m_prismatic2 = null;
m_ground1 = def.joint1.m_body1;
m_body1 = def.joint1.m_body2;
if (type1 == b2Joint.e_revoluteJoint){
m_revolute1 = (def.joint1 as b2RevoluteJoint);
m_groundAnchor1.SetV(m_revolute1.m_localAnchor1);
m_localAnchor1.SetV(m_revolute1.m_localAnchor2);
coordinate1 = m_revolute1.GetJointAngle();
} else {
m_prismatic1 = (def.joint1 as b2PrismaticJoint);
m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1);
m_localAnchor1.SetV(m_prismatic1.m_localAnchor2);
coordinate1 = m_prismatic1.GetJointTranslation();
};
m_ground2 = def.joint2.m_body1;
m_body2 = def.joint2.m_body2;
if (type2 == b2Joint.e_revoluteJoint){
m_revolute2 = (def.joint2 as b2RevoluteJoint);
m_groundAnchor2.SetV(m_revolute2.m_localAnchor1);
m_localAnchor2.SetV(m_revolute2.m_localAnchor2);
coordinate2 = m_revolute2.GetJointAngle();
} else {
m_prismatic2 = (def.joint2 as b2PrismaticJoint);
m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1);
m_localAnchor2.SetV(m_prismatic2.m_localAnchor2);
coordinate2 = m_prismatic2.GetJointTranslation();
};
m_ratio = def.ratio;
m_constant = (coordinate1 + (m_ratio * coordinate2));
m_force = 0;
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function InitVelocityConstraints(step:b2TimeStep):void{
var ugX:Number;
var ugY:Number;
var rX:Number;
var rY:Number;
var tMat:b2Mat22;
var tVec:b2Vec2;
var crug:Number;
var tX:Number;
var P:Number;
var g1:b2Body = m_ground1;
var g2:b2Body = m_ground2;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var K:Number = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angular1 = -1;
K = (K + b1.m_invI);
} else {
tMat = g1.m_xf.R;
tVec = m_prismatic1.m_localXAxis1;
ugX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
ugY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = b1.m_xf.R;
rX = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
rY = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
crug = ((rX * ugY) - (rY * ugX));
m_J.linear1.Set(-(ugX), -(ugY));
m_J.angular1 = -(crug);
K = (K + (b1.m_invMass + ((b1.m_invI * crug) * crug)));
};
if (m_revolute2){
m_J.angular2 = -(m_ratio);
K = (K + ((m_ratio * m_ratio) * b2.m_invI));
} else {
tMat = g2.m_xf.R;
tVec = m_prismatic2.m_localXAxis1;
ugX = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
ugY = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
tMat = b2.m_xf.R;
rX = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
rY = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
crug = ((rX * ugY) - (rY * ugX));
m_J.linear2.Set((-(m_ratio) * ugX), (-(m_ratio) * ugY));
m_J.angular2 = (-(m_ratio) * crug);
K = (K + ((m_ratio * m_ratio) * (b2.m_invMass + ((b2.m_invI * crug) * crug))));
};
m_mass = (1 / K);
if (step.warmStarting){
P = (step.dt * m_force);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((b1.m_invMass * P) * m_J.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((b1.m_invMass * P) * m_J.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((b1.m_invI * P) * m_J.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((b2.m_invMass * P) * m_J.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((b2.m_invMass * P) * m_J.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((b2.m_invI * P) * m_J.angular2));
} else {
m_force = 0;
};
}
override public function GetReactionTorque():Number{
var tMat:b2Mat22 = m_body2.m_xf.R;
var rX:Number = (m_localAnchor1.x - m_body2.m_sweep.localCenter.x);
var rY:Number = (m_localAnchor1.y - m_body2.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
tX = ((m_force * m_J.angular2) - ((rX * (m_force * m_J.linear2.y)) - (rY * (m_force * m_J.linear2.x))));
return (tX);
}
override public function GetReactionForce():b2Vec2{
var F:b2Vec2 = new b2Vec2((m_force * m_J.linear2.x), (m_force * m_J.linear2.y));
return (F);
}
override public function SolvePositionConstraints():Boolean{
var coordinate1:Number;
var coordinate2:Number;
var linearError:Number = 0;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
if (m_revolute1){
coordinate1 = m_revolute1.GetJointAngle();
} else {
coordinate1 = m_prismatic1.GetJointTranslation();
};
if (m_revolute2){
coordinate2 = m_revolute2.GetJointAngle();
} else {
coordinate2 = m_prismatic2.GetJointTranslation();
};
var C:Number = (m_constant - (coordinate1 + (m_ratio * coordinate2)));
var impulse:Number = (-(m_mass) * C);
b1.m_sweep.c.x = (b1.m_sweep.c.x + ((b1.m_invMass * impulse) * m_J.linear1.x));
b1.m_sweep.c.y = (b1.m_sweep.c.y + ((b1.m_invMass * impulse) * m_J.linear1.y));
b1.m_sweep.a = (b1.m_sweep.a + ((b1.m_invI * impulse) * m_J.angular1));
b2.m_sweep.c.x = (b2.m_sweep.c.x + ((b2.m_invMass * impulse) * m_J.linear2.x));
b2.m_sweep.c.y = (b2.m_sweep.c.y + ((b2.m_invMass * impulse) * m_J.linear2.y));
b2.m_sweep.a = (b2.m_sweep.a + ((b2.m_invI * impulse) * m_J.angular2));
b1.SynchronizeTransform();
b2.SynchronizeTransform();
return ((linearError < b2Settings.b2_linearSlop));
}
public function GetRatio():Number{
return (m_ratio);
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var Cdot:Number = m_J.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity);
var force:Number = ((-(step.inv_dt) * m_mass) * Cdot);
m_force = (m_force + force);
var P:Number = (step.dt * force);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((b1.m_invMass * P) * m_J.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((b1.m_invMass * P) * m_J.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((b1.m_invI * P) * m_J.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((b2.m_invMass * P) * m_J.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((b2.m_invMass * P) * m_J.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((b2.m_invI * P) * m_J.angular2));
}
}
}//package Box2D.Dynamics.Joints
Section 51
//b2GearJointDef (Box2D.Dynamics.Joints.b2GearJointDef)
package Box2D.Dynamics.Joints {
public class b2GearJointDef extends b2JointDef {
public var joint1:b2Joint;
public var joint2:b2Joint;
public var ratio:Number;
public function b2GearJointDef(){
super();
type = b2Joint.e_gearJoint;
joint1 = null;
joint2 = null;
ratio = 1;
}
}
}//package Box2D.Dynamics.Joints
Section 52
//b2Jacobian (Box2D.Dynamics.Joints.b2Jacobian)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2Jacobian {
public var linear1:b2Vec2;
public var linear2:b2Vec2;
public var angular1:Number;
public var angular2:Number;
public function b2Jacobian(){
linear1 = new b2Vec2();
linear2 = new b2Vec2();
super();
}
public function Set(x1:b2Vec2, a1:Number, x2:b2Vec2, a2:Number):void{
linear1.SetV(x1);
angular1 = a1;
linear2.SetV(x2);
angular2 = a2;
}
public function SetZero():void{
linear1.SetZero();
angular1 = 0;
linear2.SetZero();
angular2 = 0;
}
public function Compute(x1:b2Vec2, a1:Number, x2:b2Vec2, a2:Number):Number{
return ((((((linear1.x * x1.x) + (linear1.y * x1.y)) + (angular1 * a1)) + ((linear2.x * x2.x) + (linear2.y * x2.y))) + (angular2 * a2)));
}
}
}//package Box2D.Dynamics.Joints
Section 53
//b2Joint (Box2D.Dynamics.Joints.b2Joint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2Joint {
public var m_islandFlag:Boolean;
public var m_body1:b2Body;
public var m_prev:b2Joint;
public var m_next:b2Joint;
public var m_type:int;
public var m_collideConnected:Boolean;
public var m_node1:b2JointEdge;
public var m_node2:b2JointEdge;
public var m_inv_dt:Number;
public var m_userData;
public var m_body2:b2Body;
public static const e_unknownJoint:int = 0;
public static const e_inactiveLimit:int = 0;
public static const e_atUpperLimit:int = 2;
public static const e_atLowerLimit:int = 1;
public static const e_gearJoint:int = 6;
public static const e_revoluteJoint:int = 1;
public static const e_equalLimits:int = 3;
public static const e_distanceJoint:int = 3;
public static const e_pulleyJoint:int = 4;
public static const e_prismaticJoint:int = 2;
public static const e_mouseJoint:int = 5;
public function b2Joint(def:b2JointDef){
m_node1 = new b2JointEdge();
m_node2 = new b2JointEdge();
super();
m_type = def.type;
m_prev = null;
m_next = null;
m_body1 = def.body1;
m_body2 = def.body2;
m_collideConnected = def.collideConnected;
m_islandFlag = false;
m_userData = def.userData;
}
public function GetBody2():b2Body{
return (m_body2);
}
public function GetAnchor1():b2Vec2{
return (null);
}
public function GetAnchor2():b2Vec2{
return (null);
}
public function GetNext():b2Joint{
return (m_next);
}
public function GetType():int{
return (m_type);
}
public function InitVelocityConstraints(step:b2TimeStep):void{
}
public function GetReactionTorque():Number{
return (0);
}
public function GetUserData(){
return (m_userData);
}
public function GetReactionForce():b2Vec2{
return (null);
}
public function SolvePositionConstraints():Boolean{
return (false);
}
public function SetUserData(data):void{
m_userData = data;
}
public function GetBody1():b2Body{
return (m_body1);
}
public function SolveVelocityConstraints(step:b2TimeStep):void{
}
public function InitPositionConstraints():void{
}
public static function Destroy(joint:b2Joint, allocator):void{
}
public static function Create(def:b2JointDef, allocator):b2Joint{
var joint:b2Joint;
switch (def.type){
case e_distanceJoint:
joint = new b2DistanceJoint((def as b2DistanceJointDef));
break;
case e_mouseJoint:
joint = new b2MouseJoint((def as b2MouseJointDef));
break;
case e_prismaticJoint:
joint = new b2PrismaticJoint((def as b2PrismaticJointDef));
break;
case e_revoluteJoint:
joint = new b2RevoluteJoint((def as b2RevoluteJointDef));
break;
case e_pulleyJoint:
joint = new b2PulleyJoint((def as b2PulleyJointDef));
break;
case e_gearJoint:
joint = new b2GearJoint((def as b2GearJointDef));
break;
default:
break;
};
return (joint);
}
}
}//package Box2D.Dynamics.Joints
Section 54
//b2JointDef (Box2D.Dynamics.Joints.b2JointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointDef {
public var body2:b2Body;
public var type:int;
public var userData;
public var collideConnected:Boolean;
public var body1:b2Body;
public function b2JointDef(){
super();
type = b2Joint.e_unknownJoint;
userData = null;
body1 = null;
body2 = null;
collideConnected = false;
}
}
}//package Box2D.Dynamics.Joints
Section 55
//b2JointEdge (Box2D.Dynamics.Joints.b2JointEdge)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
public class b2JointEdge {
public var other:b2Body;
public var next:b2JointEdge;
public var prev:b2JointEdge;
public var joint:b2Joint;
public function b2JointEdge(){
super();
}
}
}//package Box2D.Dynamics.Joints
Section 56
//b2MouseJoint (Box2D.Dynamics.Joints.b2MouseJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2MouseJoint extends b2Joint {
private var K1:b2Mat22;
private var K:b2Mat22;
public var m_beta:Number;
public var m_mass:b2Mat22;
private var K2:b2Mat22;
public var m_target:b2Vec2;
public var m_gamma:Number;
public var m_impulse:b2Vec2;
public var m_C:b2Vec2;
public var m_localAnchor:b2Vec2;
public var m_maxForce:Number;
public function b2MouseJoint(def:b2MouseJointDef){
var tY:Number;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
m_localAnchor = new b2Vec2();
m_target = new b2Vec2();
m_impulse = new b2Vec2();
m_mass = new b2Mat22();
m_C = new b2Vec2();
super(def);
m_target.SetV(def.target);
var tX:Number = (m_target.x - m_body2.m_xf.position.x);
tY = (m_target.y - m_body2.m_xf.position.y);
var tMat:b2Mat22 = m_body2.m_xf.R;
m_localAnchor.x = ((tX * tMat.col1.x) + (tY * tMat.col1.y));
m_localAnchor.y = ((tX * tMat.col2.x) + (tY * tMat.col2.y));
m_maxForce = def.maxForce;
m_impulse.SetZero();
var mass:Number = m_body2.m_mass;
var omega:Number = ((2 * b2Settings.b2_pi) * def.frequencyHz);
var d:Number = (((2 * mass) * def.dampingRatio) * omega);
var k:Number = ((def.timeStep * mass) * (omega * omega));
m_gamma = (1 / (d + k));
m_beta = (k / (d + k));
}
public function SetTarget(target:b2Vec2):void{
if (m_body2.IsSleeping()){
m_body2.WakeUp();
};
m_target = target;
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor));
}
override public function InitVelocityConstraints(step:b2TimeStep):void{
var b:b2Body;
var tMat:b2Mat22;
var rX:Number;
var rY:Number;
var invMass:Number;
var invI:Number;
b = m_body2;
tMat = b.m_xf.R;
rX = (m_localAnchor.x - b.m_sweep.localCenter.x);
rY = (m_localAnchor.y - b.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
invMass = b.m_invMass;
invI = b.m_invI;
K1.col1.x = invMass;
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = invMass;
K2.col1.x = ((invI * rY) * rY);
K2.col2.x = ((-(invI) * rX) * rY);
K2.col1.y = ((-(invI) * rX) * rY);
K2.col2.y = ((invI * rX) * rX);
K.SetM(K1);
K.AddM(K2);
K.col1.x = (K.col1.x + m_gamma);
K.col2.y = (K.col2.y + m_gamma);
K.Invert(m_mass);
m_C.x = ((b.m_sweep.c.x + rX) - m_target.x);
m_C.y = ((b.m_sweep.c.y + rY) - m_target.y);
b.m_angularVelocity = (b.m_angularVelocity * 0.98);
var PX:Number = (step.dt * m_impulse.x);
var PY:Number = (step.dt * m_impulse.y);
b.m_linearVelocity.x = (b.m_linearVelocity.x + (invMass * PX));
b.m_linearVelocity.y = (b.m_linearVelocity.y + (invMass * PY));
b.m_angularVelocity = (b.m_angularVelocity + (invI * ((rX * PY) - (rY * PX))));
}
override public function GetAnchor1():b2Vec2{
return (m_target);
}
override public function GetReactionTorque():Number{
return (0);
}
override public function GetReactionForce():b2Vec2{
return (m_impulse);
}
override public function SolvePositionConstraints():Boolean{
return (true);
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var tY:Number;
var b:b2Body = m_body2;
tMat = b.m_xf.R;
var rX:Number = (m_localAnchor.x - b.m_sweep.localCenter.x);
var rY:Number = (m_localAnchor.y - b.m_sweep.localCenter.y);
tX = ((tMat.col1.x * rX) + (tMat.col2.x * rY));
rY = ((tMat.col1.y * rX) + (tMat.col2.y * rY));
rX = tX;
var CdotX:Number = (b.m_linearVelocity.x + (-(b.m_angularVelocity) * rY));
var CdotY:Number = (b.m_linearVelocity.y + (b.m_angularVelocity * rX));
tMat = m_mass;
tX = ((CdotX + ((m_beta * step.inv_dt) * m_C.x)) + ((m_gamma * step.dt) * m_impulse.x));
tY = ((CdotY + ((m_beta * step.inv_dt) * m_C.y)) + ((m_gamma * step.dt) * m_impulse.y));
var forceX:Number = (-(step.inv_dt) * ((tMat.col1.x * tX) + (tMat.col2.x * tY)));
var forceY:Number = (-(step.inv_dt) * ((tMat.col1.y * tX) + (tMat.col2.y * tY)));
var oldForceX:Number = m_impulse.x;
var oldForceY:Number = m_impulse.y;
m_impulse.x = (m_impulse.x + forceX);
m_impulse.y = (m_impulse.y + forceY);
var forceMagnitude:Number = m_impulse.Length();
if (forceMagnitude > m_maxForce){
m_impulse.Multiply((m_maxForce / forceMagnitude));
};
forceX = (m_impulse.x - oldForceX);
forceY = (m_impulse.y - oldForceY);
var PX:Number = (step.dt * forceX);
var PY:Number = (step.dt * forceY);
b.m_linearVelocity.x = (b.m_linearVelocity.x + (b.m_invMass * PX));
b.m_linearVelocity.y = (b.m_linearVelocity.y + (b.m_invMass * PY));
b.m_angularVelocity = (b.m_angularVelocity + (b.m_invI * ((rX * PY) - (rY * PX))));
}
}
}//package Box2D.Dynamics.Joints
Section 57
//b2MouseJointDef (Box2D.Dynamics.Joints.b2MouseJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Common.Math.*;
public class b2MouseJointDef extends b2JointDef {
public var timeStep:Number;
public var target:b2Vec2;
public var maxForce:Number;
public var dampingRatio:Number;
public var frequencyHz:Number;
public function b2MouseJointDef(){
target = new b2Vec2();
super();
type = b2Joint.e_mouseJoint;
maxForce = 0;
frequencyHz = 5;
dampingRatio = 0.7;
timeStep = (1 / 60);
}
}
}//package Box2D.Dynamics.Joints
Section 58
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PrismaticJoint extends b2Joint {
public var m_limitForce:Number;
public var m_lowerTranslation:Number;
public var m_localXAxis1:b2Vec2;
public var m_refAngle:Number;
public var m_torque:Number;
public var m_motorForce:Number;
public var m_enableLimit:Boolean;
public var m_angularMass:Number;
public var m_maxMotorForce:Number;
public var m_localYAxis1:b2Vec2;
public var m_force:Number;
public var m_motorMass:Number;
public var m_upperTranslation:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_limitState:int;
public var m_linearMass:Number;
public var m_motorJacobian:b2Jacobian;
public var m_limitPositionImpulse:Number;
public var m_motorSpeed:Number;
public var m_enableMotor:Boolean;
public var m_linearJacobian:b2Jacobian;
public function b2PrismaticJoint(def:b2PrismaticJointDef){
var tMat:b2Mat22;
var tX:Number;
var tY:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_localXAxis1 = new b2Vec2();
m_localYAxis1 = new b2Vec2();
m_linearJacobian = new b2Jacobian();
m_motorJacobian = new b2Jacobian();
super(def);
m_localAnchor1.SetV(def.localAnchor1);
m_localAnchor2.SetV(def.localAnchor2);
m_localXAxis1.SetV(def.localAxis1);
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_refAngle = def.referenceAngle;
m_linearJacobian.SetZero();
m_linearMass = 0;
m_force = 0;
m_angularMass = 0;
m_torque = 0;
m_motorJacobian.SetZero();
m_motorMass = 0;
m_motorForce = 0;
m_limitForce = 0;
m_limitPositionImpulse = 0;
m_lowerTranslation = def.lowerTranslation;
m_upperTranslation = def.upperTranslation;
m_maxMotorForce = def.maxMotorForce;
m_motorSpeed = def.motorSpeed;
m_enableLimit = def.enableLimit;
m_enableMotor = def.enableMotor;
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var oldLimitForce:Number;
var motorCdot:Number;
var motorForce:Number;
var oldMotorForce:Number;
var limitCdot:Number;
var limitForce:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
var linearCdot:Number = m_linearJacobian.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity);
var force:Number = ((-(step.inv_dt) * m_linearMass) * linearCdot);
m_force = (m_force + force);
var P:Number = (step.dt * force);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((invMass1 * P) * m_linearJacobian.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((invMass1 * P) * m_linearJacobian.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((invI1 * P) * m_linearJacobian.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((invMass2 * P) * m_linearJacobian.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((invMass2 * P) * m_linearJacobian.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((invI2 * P) * m_linearJacobian.angular2));
var angularCdot:Number = (b2.m_angularVelocity - b1.m_angularVelocity);
var torque:Number = ((-(step.inv_dt) * m_angularMass) * angularCdot);
m_torque = (m_torque + torque);
var L:Number = (step.dt * torque);
b1.m_angularVelocity = (b1.m_angularVelocity - (invI1 * L));
b2.m_angularVelocity = (b2.m_angularVelocity + (invI2 * L));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
motorCdot = (m_motorJacobian.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity) - m_motorSpeed);
motorForce = ((-(step.inv_dt) * m_motorMass) * motorCdot);
oldMotorForce = m_motorForce;
m_motorForce = b2Math.b2Clamp((m_motorForce + motorForce), -(m_maxMotorForce), m_maxMotorForce);
motorForce = (m_motorForce - oldMotorForce);
P = (step.dt * motorForce);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((invMass1 * P) * m_motorJacobian.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((invMass1 * P) * m_motorJacobian.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((invI1 * P) * m_motorJacobian.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((invMass2 * P) * m_motorJacobian.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((invMass2 * P) * m_motorJacobian.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((invI2 * P) * m_motorJacobian.angular2));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
limitCdot = m_motorJacobian.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity);
limitForce = ((-(step.inv_dt) * m_motorMass) * limitCdot);
if (m_limitState == e_equalLimits){
m_limitForce = (m_limitForce + limitForce);
} else {
if (m_limitState == e_atLowerLimit){
oldLimitForce = m_limitForce;
m_limitForce = b2Math.b2Max((m_limitForce + limitForce), 0);
limitForce = (m_limitForce - oldLimitForce);
} else {
if (m_limitState == e_atUpperLimit){
oldLimitForce = m_limitForce;
m_limitForce = b2Math.b2Min((m_limitForce + limitForce), 0);
limitForce = (m_limitForce - oldLimitForce);
};
};
};
P = (step.dt * limitForce);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + ((invMass1 * P) * m_motorJacobian.linear1.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + ((invMass1 * P) * m_motorJacobian.linear1.y));
b1.m_angularVelocity = (b1.m_angularVelocity + ((invI1 * P) * m_motorJacobian.angular1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((invMass2 * P) * m_motorJacobian.linear2.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((invMass2 * P) * m_motorJacobian.linear2.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((invI2 * P) * m_motorJacobian.angular2));
};
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function GetUpperLimit():Number{
return (m_upperTranslation);
}
public function GetLowerLimit():Number{
return (m_lowerTranslation);
}
public function EnableMotor(flag:Boolean):void{
m_enableMotor = flag;
}
public function GetJointTranslation():Number{
var tMat:b2Mat22;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var p1:b2Vec2 = b1.GetWorldPoint(m_localAnchor1);
var p2:b2Vec2 = b2.GetWorldPoint(m_localAnchor2);
var dX:Number = (p2.x - p1.x);
var dY:Number = (p2.y - p1.y);
var axis:b2Vec2 = b1.GetWorldVector(m_localXAxis1);
var translation:Number = ((axis.x * dX) + (axis.y * dY));
return (translation);
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce():b2Vec2{
var tMat:b2Mat22 = m_body1.m_xf.R;
var ax1X:Number = (m_limitForce * ((tMat.col1.x * m_localXAxis1.x) + (tMat.col2.x * m_localXAxis1.y)));
var ax1Y:Number = (m_limitForce * ((tMat.col1.y * m_localXAxis1.x) + (tMat.col2.y * m_localXAxis1.y)));
var ay1X:Number = (m_force * ((tMat.col1.x * m_localYAxis1.x) + (tMat.col2.x * m_localYAxis1.y)));
var ay1Y:Number = (m_force * ((tMat.col1.y * m_localYAxis1.x) + (tMat.col2.y * m_localYAxis1.y)));
return (new b2Vec2(((m_limitForce * ax1X) + (m_force * ay1X)), ((m_limitForce * ax1Y) + (m_force * ay1Y))));
}
override public function SolvePositionConstraints():Boolean{
var limitC:Number;
var oldLimitImpulse:Number;
var tMat:b2Mat22;
var tX:Number;
var ax1X:Number;
var ax1Y:Number;
var translation:Number;
var limitImpulse:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var p1X:Number = (b1.m_sweep.c.x + r1X);
var p1Y:Number = (b1.m_sweep.c.y + r1Y);
var p2X:Number = (b2.m_sweep.c.x + r2X);
var p2Y:Number = (b2.m_sweep.c.y + r2Y);
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
tMat = b1.m_xf.R;
var ay1X:Number = ((tMat.col1.x * m_localYAxis1.x) + (tMat.col2.x * m_localYAxis1.y));
var ay1Y:Number = ((tMat.col1.y * m_localYAxis1.x) + (tMat.col2.y * m_localYAxis1.y));
var linearC:Number = ((ay1X * dX) + (ay1Y * dY));
linearC = b2Math.b2Clamp(linearC, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
var linearImpulse:Number = (-(m_linearMass) * linearC);
b1.m_sweep.c.x = (b1.m_sweep.c.x + ((invMass1 * linearImpulse) * m_linearJacobian.linear1.x));
b1.m_sweep.c.y = (b1.m_sweep.c.y + ((invMass1 * linearImpulse) * m_linearJacobian.linear1.y));
b1.m_sweep.a = (b1.m_sweep.a + ((invI1 * linearImpulse) * m_linearJacobian.angular1));
b2.m_sweep.c.x = (b2.m_sweep.c.x + ((invMass2 * linearImpulse) * m_linearJacobian.linear2.x));
b2.m_sweep.c.y = (b2.m_sweep.c.y + ((invMass2 * linearImpulse) * m_linearJacobian.linear2.y));
b2.m_sweep.a = (b2.m_sweep.a + ((invI2 * linearImpulse) * m_linearJacobian.angular2));
var positionError:Number = b2Math.b2Abs(linearC);
var angularC:Number = ((b2.m_sweep.a - b1.m_sweep.a) - m_refAngle);
angularC = b2Math.b2Clamp(angularC, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
var angularImpulse:Number = (-(m_angularMass) * angularC);
b1.m_sweep.a = (b1.m_sweep.a - (b1.m_invI * angularImpulse));
b2.m_sweep.a = (b2.m_sweep.a + (b2.m_invI * angularImpulse));
b1.SynchronizeTransform();
b2.SynchronizeTransform();
var angularError:Number = b2Math.b2Abs(angularC);
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
tMat = b1.m_xf.R;
r1X = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
r2X = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
r2Y = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
p1X = (b1.m_sweep.c.x + r1X);
p1Y = (b1.m_sweep.c.y + r1Y);
p2X = (b2.m_sweep.c.x + r2X);
p2Y = (b2.m_sweep.c.y + r2Y);
dX = (p2X - p1X);
dY = (p2Y - p1Y);
tMat = b1.m_xf.R;
ax1X = ((tMat.col1.x * m_localXAxis1.x) + (tMat.col2.x * m_localXAxis1.y));
ax1Y = ((tMat.col1.y * m_localXAxis1.x) + (tMat.col2.y * m_localXAxis1.y));
translation = ((ax1X * dX) + (ax1Y * dY));
limitImpulse = 0;
if (m_limitState == e_equalLimits){
limitC = b2Math.b2Clamp(translation, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
limitImpulse = (-(m_motorMass) * limitC);
positionError = b2Math.b2Max(positionError, b2Math.b2Abs(angularC));
} else {
if (m_limitState == e_atLowerLimit){
limitC = (translation - m_lowerTranslation);
positionError = b2Math.b2Max(positionError, -(limitC));
limitC = b2Math.b2Clamp((limitC + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
limitImpulse = (-(m_motorMass) * limitC);
oldLimitImpulse = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + limitImpulse), 0);
limitImpulse = (m_limitPositionImpulse - oldLimitImpulse);
} else {
if (m_limitState == e_atUpperLimit){
limitC = (translation - m_upperTranslation);
positionError = b2Math.b2Max(positionError, limitC);
limitC = b2Math.b2Clamp((limitC - b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
limitImpulse = (-(m_motorMass) * limitC);
oldLimitImpulse = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + limitImpulse), 0);
limitImpulse = (m_limitPositionImpulse - oldLimitImpulse);
};
};
};
b1.m_sweep.c.x = (b1.m_sweep.c.x + ((invMass1 * limitImpulse) * m_motorJacobian.linear1.x));
b1.m_sweep.c.y = (b1.m_sweep.c.y + ((invMass1 * limitImpulse) * m_motorJacobian.linear1.y));
b1.m_sweep.a = (b1.m_sweep.a + ((invI1 * limitImpulse) * m_motorJacobian.angular1));
b2.m_sweep.c.x = (b2.m_sweep.c.x + ((invMass2 * limitImpulse) * m_motorJacobian.linear2.x));
b2.m_sweep.c.y = (b2.m_sweep.c.y + ((invMass2 * limitImpulse) * m_motorJacobian.linear2.y));
b2.m_sweep.a = (b2.m_sweep.a + ((invI2 * limitImpulse) * m_motorJacobian.angular2));
b1.SynchronizeTransform();
b2.SynchronizeTransform();
};
return ((((positionError <= b2Settings.b2_linearSlop)) && ((angularError <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(speed:Number):void{
m_motorSpeed = speed;
}
public function GetJointSpeed():Number{
var tMat:b2Mat22;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var p1X:Number = (b1.m_sweep.c.x + r1X);
var p1Y:Number = (b1.m_sweep.c.y + r1Y);
var p2X:Number = (b2.m_sweep.c.x + r2X);
var p2Y:Number = (b2.m_sweep.c.y + r2Y);
var dX:Number = (p2X - p1X);
var dY:Number = (p2Y - p1Y);
var axis:b2Vec2 = b1.GetWorldVector(m_localXAxis1);
var v1:b2Vec2 = b1.m_linearVelocity;
var v2:b2Vec2 = b2.m_linearVelocity;
var w1:Number = b1.m_angularVelocity;
var w2:Number = b2.m_angularVelocity;
var speed:Number = (((dX * (-(w1) * axis.y)) + (dY * (w1 * axis.x))) + ((axis.x * (((v2.x + (-(w2) * r2Y)) - v1.x) - (-(w1) * r1Y))) + (axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X)))));
return (speed);
}
override public function InitVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var ax1X:Number;
var ax1Y:Number;
var dX:Number;
var dY:Number;
var jointTranslation:Number;
var P1X:Number;
var P1Y:Number;
var P2X:Number;
var P2Y:Number;
var L1:Number;
var L2:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
tMat = b1.m_xf.R;
var ay1X:Number = ((tMat.col1.x * m_localYAxis1.x) + (tMat.col2.x * m_localYAxis1.y));
var ay1Y:Number = ((tMat.col1.y * m_localYAxis1.x) + (tMat.col2.y * m_localYAxis1.y));
var eX:Number = ((b2.m_sweep.c.x + r2X) - b1.m_sweep.c.x);
var eY:Number = ((b2.m_sweep.c.y + r2Y) - b1.m_sweep.c.y);
m_linearJacobian.linear1.x = -(ay1X);
m_linearJacobian.linear1.y = -(ay1Y);
m_linearJacobian.linear2.x = ay1X;
m_linearJacobian.linear2.y = ay1Y;
m_linearJacobian.angular1 = -(((eX * ay1Y) - (eY * ay1X)));
m_linearJacobian.angular2 = ((r2X * ay1Y) - (r2Y * ay1X));
m_linearMass = (((invMass1 + ((invI1 * m_linearJacobian.angular1) * m_linearJacobian.angular1)) + invMass2) + ((invI2 * m_linearJacobian.angular2) * m_linearJacobian.angular2));
m_linearMass = (1 / m_linearMass);
m_angularMass = (invI1 + invI2);
if (m_angularMass > Number.MIN_VALUE){
m_angularMass = (1 / m_angularMass);
};
if (((m_enableLimit) || (m_enableMotor))){
tMat = b1.m_xf.R;
ax1X = ((tMat.col1.x * m_localXAxis1.x) + (tMat.col2.x * m_localXAxis1.y));
ax1Y = ((tMat.col1.y * m_localXAxis1.x) + (tMat.col2.y * m_localXAxis1.y));
m_motorJacobian.linear1.x = -(ax1X);
m_motorJacobian.linear1.y = -(ax1Y);
m_motorJacobian.linear2.x = ax1X;
m_motorJacobian.linear2.y = ax1Y;
m_motorJacobian.angular1 = -(((eX * ax1Y) - (eY * ax1X)));
m_motorJacobian.angular2 = ((r2X * ax1Y) - (r2Y * ax1X));
m_motorMass = (((invMass1 + ((invI1 * m_motorJacobian.angular1) * m_motorJacobian.angular1)) + invMass2) + ((invI2 * m_motorJacobian.angular2) * m_motorJacobian.angular2));
m_motorMass = (1 / m_motorMass);
if (m_enableLimit){
dX = (eX - r1X);
dY = (eY - r1Y);
jointTranslation = ((ax1X * dX) + (ax1Y * dY));
if (b2Math.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (jointTranslation <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitForce = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (jointTranslation >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitForce = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitForce = 0;
};
};
};
};
};
if (m_enableMotor == false){
m_motorForce = 0;
};
if (m_enableLimit == false){
m_limitForce = 0;
};
if (step.warmStarting){
P1X = (step.dt * ((m_force * m_linearJacobian.linear1.x) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear1.x)));
P1Y = (step.dt * ((m_force * m_linearJacobian.linear1.y) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear1.y)));
P2X = (step.dt * ((m_force * m_linearJacobian.linear2.x) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear2.x)));
P2Y = (step.dt * ((m_force * m_linearJacobian.linear2.y) + ((m_motorForce + m_limitForce) * m_motorJacobian.linear2.y)));
L1 = (step.dt * (((m_force * m_linearJacobian.angular1) - m_torque) + ((m_motorForce + m_limitForce) * m_motorJacobian.angular1)));
L2 = (step.dt * (((m_force * m_linearJacobian.angular2) + m_torque) + ((m_motorForce + m_limitForce) * m_motorJacobian.angular2)));
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + (invMass1 * P1X));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + (invMass1 * P1Y));
b1.m_angularVelocity = (b1.m_angularVelocity + (invI1 * L1));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (invMass2 * P2X));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (invMass2 * P2Y));
b2.m_angularVelocity = (b2.m_angularVelocity + (invI2 * L2));
} else {
m_force = 0;
m_torque = 0;
m_limitForce = 0;
m_motorForce = 0;
};
m_limitPositionImpulse = 0;
}
public function GetMotorForce():Number{
return (m_motorForce);
}
public function EnableLimit(flag:Boolean):void{
m_enableLimit = flag;
}
public function SetMaxMotorForce(force:Number):void{
m_maxMotorForce = force;
}
override public function GetReactionTorque():Number{
return (m_torque);
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(lower:Number, upper:Number):void{
m_lowerTranslation = lower;
m_upperTranslation = upper;
}
}
}//package Box2D.Dynamics.Joints
Section 59
//b2PrismaticJointDef (Box2D.Dynamics.Joints.b2PrismaticJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2PrismaticJointDef extends b2JointDef {
public var motorSpeed:Number;
public var localAxis1:b2Vec2;
public var referenceAngle:Number;
public var upperTranslation:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var enableLimit:Boolean;
public var enableMotor:Boolean;
public var maxMotorForce:Number;
public var lowerTranslation:Number;
public function b2PrismaticJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
localAxis1 = new b2Vec2();
super();
type = b2Joint.e_prismaticJoint;
localAxis1.Set(1, 0);
referenceAngle = 0;
enableLimit = false;
lowerTranslation = 0;
upperTranslation = 0;
enableMotor = false;
maxMotorForce = 0;
motorSpeed = 0;
}
public function Initialize(b1:b2Body, b2:b2Body, anchor:b2Vec2, axis:b2Vec2):void{
body1 = b1;
body2 = b2;
localAnchor1 = body1.GetLocalPoint(anchor);
localAnchor2 = body2.GetLocalPoint(anchor);
localAxis1 = body1.GetLocalVector(axis);
referenceAngle = (body2.GetAngle() - body1.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 60
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2PulleyJoint extends b2Joint {
public var m_limitState1:int;
public var m_limitState2:int;
public var m_ground:b2Body;
public var m_maxLength2:Number;
public var m_maxLength1:Number;
public var m_limitPositionImpulse1:Number;
public var m_limitPositionImpulse2:Number;
public var m_force:Number;
public var m_constant:Number;
public var m_positionImpulse:Number;
public var m_state:int;
public var m_ratio:Number;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_limitMass1:Number;
public var m_limitMass2:Number;
public var m_pulleyMass:Number;
public var m_u1:b2Vec2;
public var m_limitForce1:Number;
public var m_limitForce2:Number;
public var m_u2:b2Vec2;
public static const b2_minPulleyLength:Number = 2;
public function b2PulleyJoint(def:b2PulleyJointDef){
var tMat:b2Mat22;
var tX:Number;
var tY:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u1 = new b2Vec2();
m_u2 = new b2Vec2();
super(def);
m_ground = m_body1.m_world.m_groundBody;
m_groundAnchor1.x = (def.groundAnchor1.x - m_ground.m_xf.position.x);
m_groundAnchor1.y = (def.groundAnchor1.y - m_ground.m_xf.position.y);
m_groundAnchor2.x = (def.groundAnchor2.x - m_ground.m_xf.position.x);
m_groundAnchor2.y = (def.groundAnchor2.y - m_ground.m_xf.position.y);
m_localAnchor1.SetV(def.localAnchor1);
m_localAnchor2.SetV(def.localAnchor2);
m_ratio = def.ratio;
m_constant = (def.length1 + (m_ratio * def.length2));
m_maxLength1 = b2Math.b2Min(def.maxLength1, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.b2Min(def.maxLength2, ((m_constant - b2_minPulleyLength) / m_ratio));
m_force = 0;
m_limitForce1 = 0;
m_limitForce2 = 0;
}
public function GetGroundAnchor2():b2Vec2{
var a:b2Vec2 = m_ground.m_xf.position.Copy();
a.Add(m_groundAnchor2);
return (a);
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
override public function GetReactionForce():b2Vec2{
var F:b2Vec2 = m_u2.Copy();
F.Multiply(m_force);
return (F);
}
override public function SolvePositionConstraints():Boolean{
var tMat:b2Mat22;
var r1X:Number;
var r1Y:Number;
var r2X:Number;
var r2Y:Number;
var p1X:Number;
var p1Y:Number;
var p2X:Number;
var p2Y:Number;
var length1:Number;
var length2:Number;
var C:Number;
var impulse:Number;
var oldImpulse:Number;
var oldLimitPositionImpulse:Number;
var tX:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var s1X:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var s1Y:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var s2X:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var s2Y:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var linearError:Number = 0;
if (m_state == e_atUpperLimit){
tMat = b1.m_xf.R;
r1X = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
r2X = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
r2Y = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
p1X = (b1.m_sweep.c.x + r1X);
p1Y = (b1.m_sweep.c.y + r1Y);
p2X = (b2.m_sweep.c.x + r2X);
p2Y = (b2.m_sweep.c.y + r2Y);
m_u1.Set((p1X - s1X), (p1Y - s1Y));
m_u2.Set((p2X - s2X), (p2Y - s2Y));
length1 = m_u1.Length();
length2 = m_u2.Length();
if (length1 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / length1));
} else {
m_u1.SetZero();
};
if (length2 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / length2));
} else {
m_u2.SetZero();
};
C = ((m_constant - length1) - (m_ratio * length2));
linearError = b2Math.b2Max(linearError, -(C));
C = b2Math.b2Clamp((C + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
impulse = (-(m_pulleyMass) * C);
oldImpulse = m_positionImpulse;
m_positionImpulse = b2Math.b2Max(0, (m_positionImpulse + impulse));
impulse = (m_positionImpulse - oldImpulse);
p1X = (-(impulse) * m_u1.x);
p1Y = (-(impulse) * m_u1.y);
p2X = ((-(m_ratio) * impulse) * m_u2.x);
p2Y = ((-(m_ratio) * impulse) * m_u2.y);
b1.m_sweep.c.x = (b1.m_sweep.c.x + (b1.m_invMass * p1X));
b1.m_sweep.c.y = (b1.m_sweep.c.y + (b1.m_invMass * p1Y));
b1.m_sweep.a = (b1.m_sweep.a + (b1.m_invI * ((r1X * p1Y) - (r1Y * p1X))));
b2.m_sweep.c.x = (b2.m_sweep.c.x + (b2.m_invMass * p2X));
b2.m_sweep.c.y = (b2.m_sweep.c.y + (b2.m_invMass * p2Y));
b2.m_sweep.a = (b2.m_sweep.a + (b2.m_invI * ((r2X * p2Y) - (r2Y * p2X))));
b1.SynchronizeTransform();
b2.SynchronizeTransform();
};
if (m_limitState1 == e_atUpperLimit){
tMat = b1.m_xf.R;
r1X = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
p1X = (b1.m_sweep.c.x + r1X);
p1Y = (b1.m_sweep.c.y + r1Y);
m_u1.Set((p1X - s1X), (p1Y - s1Y));
length1 = m_u1.Length();
if (length1 > b2Settings.b2_linearSlop){
m_u1.x = (m_u1.x * (1 / length1));
m_u1.y = (m_u1.y * (1 / length1));
} else {
m_u1.SetZero();
};
C = (m_maxLength1 - length1);
linearError = b2Math.b2Max(linearError, -(C));
C = b2Math.b2Clamp((C + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
impulse = (-(m_limitMass1) * C);
oldLimitPositionImpulse = m_limitPositionImpulse1;
m_limitPositionImpulse1 = b2Math.b2Max(0, (m_limitPositionImpulse1 + impulse));
impulse = (m_limitPositionImpulse1 - oldLimitPositionImpulse);
p1X = (-(impulse) * m_u1.x);
p1Y = (-(impulse) * m_u1.y);
b1.m_sweep.c.x = (b1.m_sweep.c.x + (b1.m_invMass * p1X));
b1.m_sweep.c.y = (b1.m_sweep.c.y + (b1.m_invMass * p1Y));
b1.m_sweep.a = (b1.m_sweep.a + (b1.m_invI * ((r1X * p1Y) - (r1Y * p1X))));
b1.SynchronizeTransform();
};
if (m_limitState2 == e_atUpperLimit){
tMat = b2.m_xf.R;
r2X = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
r2Y = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
p2X = (b2.m_sweep.c.x + r2X);
p2Y = (b2.m_sweep.c.y + r2Y);
m_u2.Set((p2X - s2X), (p2Y - s2Y));
length2 = m_u2.Length();
if (length2 > b2Settings.b2_linearSlop){
m_u2.x = (m_u2.x * (1 / length2));
m_u2.y = (m_u2.y * (1 / length2));
} else {
m_u2.SetZero();
};
C = (m_maxLength2 - length2);
linearError = b2Math.b2Max(linearError, -(C));
C = b2Math.b2Clamp((C + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
impulse = (-(m_limitMass2) * C);
oldLimitPositionImpulse = m_limitPositionImpulse2;
m_limitPositionImpulse2 = b2Math.b2Max(0, (m_limitPositionImpulse2 + impulse));
impulse = (m_limitPositionImpulse2 - oldLimitPositionImpulse);
p2X = (-(impulse) * m_u2.x);
p2Y = (-(impulse) * m_u2.y);
b2.m_sweep.c.x = (b2.m_sweep.c.x + (b2.m_invMass * p2X));
b2.m_sweep.c.y = (b2.m_sweep.c.y + (b2.m_invMass * p2Y));
b2.m_sweep.a = (b2.m_sweep.a + (b2.m_invI * ((r2X * p2Y) - (r2Y * p2X))));
b2.SynchronizeTransform();
};
return ((linearError < b2Settings.b2_linearSlop));
}
override public function InitVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var P1X:Number;
var P1Y:Number;
var P2X:Number;
var P2Y:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var p1X:Number = (b1.m_sweep.c.x + r1X);
var p1Y:Number = (b1.m_sweep.c.y + r1Y);
var p2X:Number = (b2.m_sweep.c.x + r2X);
var p2Y:Number = (b2.m_sweep.c.y + r2Y);
var s1X:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var s1Y:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var s2X:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var s2Y:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
m_u1.Set((p1X - s1X), (p1Y - s1Y));
m_u2.Set((p2X - s2X), (p2Y - s2Y));
var length1:Number = m_u1.Length();
var length2:Number = m_u2.Length();
if (length1 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / length1));
} else {
m_u1.SetZero();
};
if (length2 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / length2));
} else {
m_u2.SetZero();
};
var C:Number = ((m_constant - length1) - (m_ratio * length2));
if (C > 0){
m_state = e_inactiveLimit;
m_force = 0;
} else {
m_state = e_atUpperLimit;
m_positionImpulse = 0;
};
if (length1 < m_maxLength1){
m_limitState1 = e_inactiveLimit;
m_limitForce1 = 0;
} else {
m_limitState1 = e_atUpperLimit;
m_limitPositionImpulse1 = 0;
};
if (length2 < m_maxLength2){
m_limitState2 = e_inactiveLimit;
m_limitForce2 = 0;
} else {
m_limitState2 = e_atUpperLimit;
m_limitPositionImpulse2 = 0;
};
var cr1u1:Number = ((r1X * m_u1.y) - (r1Y * m_u1.x));
var cr2u2:Number = ((r2X * m_u2.y) - (r2Y * m_u2.x));
m_limitMass1 = (b1.m_invMass + ((b1.m_invI * cr1u1) * cr1u1));
m_limitMass2 = (b2.m_invMass + ((b2.m_invI * cr2u2) * cr2u2));
m_pulleyMass = (m_limitMass1 + ((m_ratio * m_ratio) * m_limitMass2));
m_limitMass1 = (1 / m_limitMass1);
m_limitMass2 = (1 / m_limitMass2);
m_pulleyMass = (1 / m_pulleyMass);
if (step.warmStarting){
P1X = ((step.dt * (-(m_force) - m_limitForce1)) * m_u1.x);
P1Y = ((step.dt * (-(m_force) - m_limitForce1)) * m_u1.y);
P2X = ((step.dt * ((-(m_ratio) * m_force) - m_limitForce2)) * m_u2.x);
P2Y = ((step.dt * ((-(m_ratio) * m_force) - m_limitForce2)) * m_u2.y);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + (b1.m_invMass * P1X));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + (b1.m_invMass * P1Y));
b1.m_angularVelocity = (b1.m_angularVelocity + (b1.m_invI * ((r1X * P1Y) - (r1Y * P1X))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * P2X));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * P2Y));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * P2Y) - (r2Y * P2X))));
} else {
m_force = 0;
m_limitForce1 = 0;
m_limitForce2 = 0;
};
}
override public function GetReactionTorque():Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var v1X:Number;
var v1Y:Number;
var v2X:Number;
var v2Y:Number;
var P1X:Number;
var P1Y:Number;
var P2X:Number;
var P2Y:Number;
var Cdot:Number;
var force:Number;
var oldForce:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
if (m_state == e_atUpperLimit){
v1X = (b1.m_linearVelocity.x + (-(b1.m_angularVelocity) * r1Y));
v1Y = (b1.m_linearVelocity.y + (b1.m_angularVelocity * r1X));
v2X = (b2.m_linearVelocity.x + (-(b2.m_angularVelocity) * r2Y));
v2Y = (b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X));
Cdot = (-(((m_u1.x * v1X) + (m_u1.y * v1Y))) - (m_ratio * ((m_u2.x * v2X) + (m_u2.y * v2Y))));
force = ((-(step.inv_dt) * m_pulleyMass) * Cdot);
oldForce = m_force;
m_force = b2Math.b2Max(0, (m_force + force));
force = (m_force - oldForce);
P1X = ((-(step.dt) * force) * m_u1.x);
P1Y = ((-(step.dt) * force) * m_u1.y);
P2X = (((-(step.dt) * m_ratio) * force) * m_u2.x);
P2Y = (((-(step.dt) * m_ratio) * force) * m_u2.y);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + (b1.m_invMass * P1X));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + (b1.m_invMass * P1Y));
b1.m_angularVelocity = (b1.m_angularVelocity + (b1.m_invI * ((r1X * P1Y) - (r1Y * P1X))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * P2X));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * P2Y));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * P2Y) - (r2Y * P2X))));
};
if (m_limitState1 == e_atUpperLimit){
v1X = (b1.m_linearVelocity.x + (-(b1.m_angularVelocity) * r1Y));
v1Y = (b1.m_linearVelocity.y + (b1.m_angularVelocity * r1X));
Cdot = -(((m_u1.x * v1X) + (m_u1.y * v1Y)));
force = ((-(step.inv_dt) * m_limitMass1) * Cdot);
oldForce = m_limitForce1;
m_limitForce1 = b2Math.b2Max(0, (m_limitForce1 + force));
force = (m_limitForce1 - oldForce);
P1X = ((-(step.dt) * force) * m_u1.x);
P1Y = ((-(step.dt) * force) * m_u1.y);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x + (b1.m_invMass * P1X));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y + (b1.m_invMass * P1Y));
b1.m_angularVelocity = (b1.m_angularVelocity + (b1.m_invI * ((r1X * P1Y) - (r1Y * P1X))));
};
if (m_limitState2 == e_atUpperLimit){
v2X = (b2.m_linearVelocity.x + (-(b2.m_angularVelocity) * r2Y));
v2Y = (b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X));
Cdot = -(((m_u2.x * v2X) + (m_u2.y * v2Y)));
force = ((-(step.inv_dt) * m_limitMass2) * Cdot);
oldForce = m_limitForce2;
m_limitForce2 = b2Math.b2Max(0, (m_limitForce2 + force));
force = (m_limitForce2 - oldForce);
P2X = ((-(step.dt) * force) * m_u2.x);
P2Y = ((-(step.dt) * force) * m_u2.y);
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * P2X));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * P2Y));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * P2Y) - (r2Y * P2X))));
};
}
public function GetLength1():Number{
var p:b2Vec2 = m_body1.GetWorldPoint(m_localAnchor1);
var sX:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x);
var sY:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y);
var dX:Number = (p.x - sX);
var dY:Number = (p.y - sY);
return (Math.sqrt(((dX * dX) + (dY * dY))));
}
public function GetLength2():Number{
var p:b2Vec2 = m_body2.GetWorldPoint(m_localAnchor2);
var sX:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x);
var sY:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y);
var dX:Number = (p.x - sX);
var dY:Number = (p.y - sY);
return (Math.sqrt(((dX * dX) + (dY * dY))));
}
public function GetGroundAnchor1():b2Vec2{
var a:b2Vec2 = m_ground.m_xf.position.Copy();
a.Add(m_groundAnchor1);
return (a);
}
}
}//package Box2D.Dynamics.Joints
Section 61
//b2PulleyJointDef (Box2D.Dynamics.Joints.b2PulleyJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2PulleyJointDef extends b2JointDef {
public var maxLength1:Number;
public var maxLength2:Number;
public var length1:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var groundAnchor1:b2Vec2;
public var groundAnchor2:b2Vec2;
public var ratio:Number;
public var length2:Number;
public function b2PulleyJointDef(){
groundAnchor1 = new b2Vec2();
groundAnchor2 = new b2Vec2();
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundAnchor1.Set(-1, 1);
groundAnchor2.Set(1, 1);
localAnchor1.Set(-1, 0);
localAnchor2.Set(1, 0);
length1 = 0;
maxLength1 = 0;
length2 = 0;
maxLength2 = 0;
ratio = 1;
collideConnected = true;
}
public function Initialize(b1:b2Body, b2:b2Body, ga1:b2Vec2, ga2:b2Vec2, anchor1:b2Vec2, anchor2:b2Vec2, r:Number):void{
body1 = b1;
body2 = b2;
groundAnchor1.SetV(ga1);
groundAnchor2.SetV(ga2);
localAnchor1 = body1.GetLocalPoint(anchor1);
localAnchor2 = body2.GetLocalPoint(anchor2);
var d1X:Number = (anchor1.x - ga1.x);
var d1Y:Number = (anchor1.y - ga1.y);
length1 = Math.sqrt(((d1X * d1X) + (d1Y * d1Y)));
var d2X:Number = (anchor2.x - ga2.x);
var d2Y:Number = (anchor2.y - ga2.y);
length2 = Math.sqrt(((d2X * d2X) + (d2Y * d2Y)));
ratio = r;
var C:Number = (length1 + (ratio * length2));
maxLength1 = (C - (ratio * b2PulleyJoint.b2_minPulleyLength));
maxLength2 = ((C - b2PulleyJoint.b2_minPulleyLength) / ratio);
}
}
}//package Box2D.Dynamics.Joints
Section 62
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
import Box2D.Common.*;
public class b2RevoluteJoint extends b2Joint {
public var m_limitForce:Number;
public var m_pivotMass:b2Mat22;
public var m_motorForce:Number;
public var m_enableLimit:Boolean;
public var m_limitState:int;
public var m_motorMass:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K3:b2Mat22;
private var K:b2Mat22;
public var m_pivotForce:b2Vec2;
public var m_enableMotor:Boolean;
public var m_referenceAngle:Number;
public var m_limitPositionImpulse:Number;
public var m_motorSpeed:Number;
public var m_upperAngle:Number;
public var m_lowerAngle:Number;
public var m_maxMotorTorque:Number;
public static var tImpulse:b2Vec2 = new b2Vec2();
public function b2RevoluteJoint(def:b2RevoluteJointDef){
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
K3 = new b2Mat22();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_pivotForce = new b2Vec2();
m_pivotMass = new b2Mat22();
super(def);
m_localAnchor1.SetV(def.localAnchor1);
m_localAnchor2.SetV(def.localAnchor2);
m_referenceAngle = def.referenceAngle;
m_pivotForce.Set(0, 0);
m_motorForce = 0;
m_limitForce = 0;
m_limitPositionImpulse = 0;
m_lowerAngle = def.lowerAngle;
m_upperAngle = def.upperAngle;
m_maxMotorTorque = def.maxMotorTorque;
m_motorSpeed = def.motorSpeed;
m_enableLimit = def.enableLimit;
m_enableMotor = def.enableMotor;
}
override public function SolveVelocityConstraints(step:b2TimeStep):void{
var tMat:b2Mat22;
var tX:Number;
var oldLimitForce:Number;
var PY:Number;
var motorCdot:Number;
var motorForce:Number;
var oldMotorForce:Number;
var limitCdot:Number;
var limitForce:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var pivotCdotX:Number = (((b2.m_linearVelocity.x + (-(b2.m_angularVelocity) * r2Y)) - b1.m_linearVelocity.x) - (-(b1.m_angularVelocity) * r1Y));
var pivotCdotY:Number = (((b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X)) - b1.m_linearVelocity.y) - (b1.m_angularVelocity * r1X));
var pivotForceX:Number = (-(step.inv_dt) * ((m_pivotMass.col1.x * pivotCdotX) + (m_pivotMass.col2.x * pivotCdotY)));
var pivotForceY:Number = (-(step.inv_dt) * ((m_pivotMass.col1.y * pivotCdotX) + (m_pivotMass.col2.y * pivotCdotY)));
m_pivotForce.x = (m_pivotForce.x + pivotForceX);
m_pivotForce.y = (m_pivotForce.y + pivotForceY);
var PX:Number = (step.dt * pivotForceX);
PY = (step.dt * pivotForceY);
b1.m_linearVelocity.x = (b1.m_linearVelocity.x - (b1.m_invMass * PX));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y - (b1.m_invMass * PY));
b1.m_angularVelocity = (b1.m_angularVelocity - (b1.m_invI * ((r1X * PY) - (r1Y * PX))));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + (b2.m_invMass * PX));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + (b2.m_invMass * PY));
b2.m_angularVelocity = (b2.m_angularVelocity + (b2.m_invI * ((r2X * PY) - (r2Y * PX))));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
motorCdot = ((b2.m_angularVelocity - b1.m_angularVelocity) - m_motorSpeed);
motorForce = ((-(step.inv_dt) * m_motorMass) * motorCdot);
oldMotorForce = m_motorForce;
m_motorForce = b2Math.b2Clamp((m_motorForce + motorForce), -(m_maxMotorTorque), m_maxMotorTorque);
motorForce = (m_motorForce - oldMotorForce);
b1.m_angularVelocity = (b1.m_angularVelocity - ((b1.m_invI * step.dt) * motorForce));
b2.m_angularVelocity = (b2.m_angularVelocity + ((b2.m_invI * step.dt) * motorForce));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
limitCdot = (b2.m_angularVelocity - b1.m_angularVelocity);
limitForce = ((-(step.inv_dt) * m_motorMass) * limitCdot);
if (m_limitState == e_equalLimits){
m_limitForce = (m_limitForce + limitForce);
} else {
if (m_limitState == e_atLowerLimit){
oldLimitForce = m_limitForce;
m_limitForce = b2Math.b2Max((m_limitForce + limitForce), 0);
limitForce = (m_limitForce - oldLimitForce);
} else {
if (m_limitState == e_atUpperLimit){
oldLimitForce = m_limitForce;
m_limitForce = b2Math.b2Min((m_limitForce + limitForce), 0);
limitForce = (m_limitForce - oldLimitForce);
};
};
};
b1.m_angularVelocity = (b1.m_angularVelocity - ((b1.m_invI * step.dt) * limitForce));
b2.m_angularVelocity = (b2.m_angularVelocity + ((b2.m_invI * step.dt) * limitForce));
};
}
override public function GetAnchor1():b2Vec2{
return (m_body1.GetWorldPoint(m_localAnchor1));
}
override public function GetAnchor2():b2Vec2{
return (m_body2.GetWorldPoint(m_localAnchor2));
}
public function GetUpperLimit():Number{
return (m_upperAngle);
}
public function GetLowerLimit():Number{
return (m_lowerAngle);
}
public function EnableMotor(flag:Boolean):void{
m_enableMotor = flag;
}
public function GetMotorSpeed():Number{
return (m_motorSpeed);
}
override public function GetReactionForce():b2Vec2{
return (m_pivotForce);
}
override public function SolvePositionConstraints():Boolean{
var oldLimitImpulse:Number;
var limitC:Number;
var tMat:b2Mat22;
var angle:Number;
var limitImpulse:Number;
var b1:b2Body = m_body1;
var b2:b2Body = m_body2;
var positionError:Number = 0;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
var r1Y:Number = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
var tX:Number = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var p1X:Number = (b1.m_sweep.c.x + r1X);
var p1Y:Number = (b1.m_sweep.c.y + r1Y);
var p2X:Number = (b2.m_sweep.c.x + r2X);
var p2Y:Number = (b2.m_sweep.c.y + r2Y);
var ptpCX:Number = (p2X - p1X);
var ptpCY:Number = (p2Y - p1Y);
positionError = Math.sqrt(((ptpCX * ptpCX) + (ptpCY * ptpCY)));
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
K1.col1.x = (invMass1 + invMass2);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (invMass1 + invMass2);
K2.col1.x = ((invI1 * r1Y) * r1Y);
K2.col2.x = ((-(invI1) * r1X) * r1Y);
K2.col1.y = ((-(invI1) * r1X) * r1Y);
K2.col2.y = ((invI1 * r1X) * r1X);
K3.col1.x = ((invI2 * r2Y) * r2Y);
K3.col2.x = ((-(invI2) * r2X) * r2Y);
K3.col1.y = ((-(invI2) * r2X) * r2Y);
K3.col2.y = ((invI2 * r2X) * r2X);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Solve(tImpulse, -(ptpCX), -(ptpCY));
var impulseX:Number = tImpulse.x;
var impulseY:Number = tImpulse.y;
b1.m_sweep.c.x = (b1.m_sweep.c.x - (b1.m_invMass * impulseX));
b1.m_sweep.c.y = (b1.m_sweep.c.y - (b1.m_invMass * impulseY));
b1.m_sweep.a = (b1.m_sweep.a - (b1.m_invI * ((r1X * impulseY) - (r1Y * impulseX))));
b2.m_sweep.c.x = (b2.m_sweep.c.x + (b2.m_invMass * impulseX));
b2.m_sweep.c.y = (b2.m_sweep.c.y + (b2.m_invMass * impulseY));
b2.m_sweep.a = (b2.m_sweep.a + (b2.m_invI * ((r2X * impulseY) - (r2Y * impulseX))));
b1.SynchronizeTransform();
b2.SynchronizeTransform();
var angularError:Number = 0;
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
angle = ((b2.m_sweep.a - b1.m_sweep.a) - m_referenceAngle);
limitImpulse = 0;
if (m_limitState == e_equalLimits){
limitC = b2Math.b2Clamp(angle, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
limitImpulse = (-(m_motorMass) * limitC);
angularError = b2Math.b2Abs(limitC);
} else {
if (m_limitState == e_atLowerLimit){
limitC = (angle - m_lowerAngle);
angularError = b2Math.b2Max(0, -(limitC));
limitC = b2Math.b2Clamp((limitC + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0);
limitImpulse = (-(m_motorMass) * limitC);
oldLimitImpulse = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + limitImpulse), 0);
limitImpulse = (m_limitPositionImpulse - oldLimitImpulse);
} else {
if (m_limitState == e_atUpperLimit){
limitC = (angle - m_upperAngle);
angularError = b2Math.b2Max(0, limitC);
limitC = b2Math.b2Clamp((limitC - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection);
limitImpulse = (-(m_motorMass) * limitC);
oldLimitImpulse = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + limitImpulse), 0);
limitImpulse = (m_limitPositionImpulse - oldLimitImpulse);
};
};
};
b1.m_sweep.a = (b1.m_sweep.a - (b1.m_invI * limitImpulse));
b2.m_sweep.a = (b2.m_sweep.a + (b2.m_invI * limitImpulse));
b1.SynchronizeTransform();
b2.SynchronizeTransform();
};
return ((((positionError <= b2Settings.b2_linearSlop)) && ((angularError <= b2Settings.b2_angularSlop))));
}
public function SetMotorSpeed(speed:Number):void{
m_motorSpeed = speed;
}
public function GetJointSpeed():Number{
return ((m_body2.m_angularVelocity - m_body1.m_angularVelocity));
}
public function SetMaxMotorTorque(torque:Number):void{
m_maxMotorTorque = torque;
}
public function GetJointAngle():Number{
return (((m_body2.m_sweep.a - m_body1.m_sweep.a) - m_referenceAngle));
}
public function GetMotorTorque():Number{
return (m_motorForce);
}
override public function InitVelocityConstraints(step:b2TimeStep):void{
var b1:b2Body;
var b2:b2Body;
var tMat:b2Mat22;
var tX:Number;
var r1Y:Number;
var jointAngle:Number;
b1 = m_body1;
b2 = m_body2;
tMat = b1.m_xf.R;
var r1X:Number = (m_localAnchor1.x - b1.m_sweep.localCenter.x);
r1Y = (m_localAnchor1.y - b1.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r1X) + (tMat.col2.x * r1Y));
r1Y = ((tMat.col1.y * r1X) + (tMat.col2.y * r1Y));
r1X = tX;
tMat = b2.m_xf.R;
var r2X:Number = (m_localAnchor2.x - b2.m_sweep.localCenter.x);
var r2Y:Number = (m_localAnchor2.y - b2.m_sweep.localCenter.y);
tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y));
r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y));
r2X = tX;
var invMass1:Number = b1.m_invMass;
var invMass2:Number = b2.m_invMass;
var invI1:Number = b1.m_invI;
var invI2:Number = b2.m_invI;
K1.col1.x = (invMass1 + invMass2);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (invMass1 + invMass2);
K2.col1.x = ((invI1 * r1Y) * r1Y);
K2.col2.x = ((-(invI1) * r1X) * r1Y);
K2.col1.y = ((-(invI1) * r1X) * r1Y);
K2.col2.y = ((invI1 * r1X) * r1X);
K3.col1.x = ((invI2 * r2Y) * r2Y);
K3.col2.x = ((-(invI2) * r2X) * r2Y);
K3.col1.y = ((-(invI2) * r2X) * r2Y);
K3.col2.y = ((invI2 * r2X) * r2X);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Invert(m_pivotMass);
m_motorMass = (1 / (invI1 + invI2));
if (m_enableMotor == false){
m_motorForce = 0;
};
if (m_enableLimit){
jointAngle = ((b2.m_sweep.a - b1.m_sweep.a) - m_referenceAngle);
if (b2Math.b2Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){
m_limitState = e_equalLimits;
} else {
if (jointAngle <= m_lowerAngle){
if (m_limitState != e_atLowerLimit){
m_limitForce = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (jointAngle >= m_upperAngle){
if (m_limitState != e_atUpperLimit){
m_limitForce = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitForce = 0;
};
};
};
} else {
m_limitForce = 0;
};
if (step.warmStarting){
b1.m_linearVelocity.x = (b1.m_linearVelocity.x - ((step.dt * invMass1) * m_pivotForce.x));
b1.m_linearVelocity.y = (b1.m_linearVelocity.y - ((step.dt * invMass1) * m_pivotForce.y));
b1.m_angularVelocity = (b1.m_angularVelocity - ((step.dt * invI1) * ((((r1X * m_pivotForce.y) - (r1Y * m_pivotForce.x)) + m_motorForce) + m_limitForce)));
b2.m_linearVelocity.x = (b2.m_linearVelocity.x + ((step.dt * invMass2) * m_pivotForce.x));
b2.m_linearVelocity.y = (b2.m_linearVelocity.y + ((step.dt * invMass2) * m_pivotForce.y));
b2.m_angularVelocity = (b2.m_angularVelocity + ((step.dt * invI2) * ((((r2X * m_pivotForce.y) - (r2Y * m_pivotForce.x)) + m_motorForce) + m_limitForce)));
} else {
m_pivotForce.SetZero();
m_motorForce = 0;
m_limitForce = 0;
};
m_limitPositionImpulse = 0;
}
public function EnableLimit(flag:Boolean):void{
m_enableLimit = flag;
}
override public function GetReactionTorque():Number{
return (m_limitForce);
}
public function IsLimitEnabled():Boolean{
return (m_enableLimit);
}
public function IsMotorEnabled():Boolean{
return (m_enableMotor);
}
public function SetLimits(lower:Number, upper:Number):void{
m_lowerAngle = lower;
m_upperAngle = upper;
}
}
}//package Box2D.Dynamics.Joints
Section 63
//b2RevoluteJointDef (Box2D.Dynamics.Joints.b2RevoluteJointDef)
package Box2D.Dynamics.Joints {
import Box2D.Dynamics.*;
import Box2D.Common.Math.*;
public class b2RevoluteJointDef extends b2JointDef {
public var upperAngle:Number;
public var enableMotor:Boolean;
public var referenceAngle:Number;
public var motorSpeed:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var enableLimit:Boolean;
public var lowerAngle:Number;
public var maxMotorTorque:Number;
public function b2RevoluteJointDef(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
type = b2Joint.e_revoluteJoint;
localAnchor1.Set(0, 0);
localAnchor2.Set(0, 0);
referenceAngle = 0;
lowerAngle = 0;
upperAngle = 0;
maxMotorTorque = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
public function Initialize(b1:b2Body, b2:b2Body, anchor:b2Vec2):void{
body1 = b1;
body2 = b2;
localAnchor1 = body1.GetLocalPoint(anchor);
localAnchor2 = body2.GetLocalPoint(anchor);
referenceAngle = (body2.GetAngle() - body1.GetAngle());
}
}
}//package Box2D.Dynamics.Joints
Section 64
//b2Body (Box2D.Dynamics.b2Body)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
public class b2Body {
public var m_next:b2Body;
public var m_xf:b2XForm;
public var m_contactList:b2ContactEdge;
public var m_angularVelocity:Number;
public var m_shapeList:b2Shape;
public var m_force:b2Vec2;
public var m_mass:Number;
public var m_sweep:b2Sweep;
public var m_torque:Number;
public var m_userData;
public var m_flags:uint;
public var m_world:b2World;
public var m_prev:b2Body;
public var m_invMass:Number;
public var m_type:int;
public var m_linearDamping:Number;
public var m_shapeCount:int;
public var m_angularDamping:Number;
public var m_invI:Number;
public var m_linearVelocity:b2Vec2;
public var m_sleepTime:Number;
public var m_jointList:b2JointEdge;
public var m_I:Number;
public static var e_fixedRotationFlag:uint = 64;
public static var e_frozenFlag:uint = 2;
public static var e_maxTypes:uint = 3;
public static var e_sleepFlag:uint = 8;
private static var s_massData:b2MassData = new b2MassData();
public static var e_bulletFlag:uint = 32;
public static var e_staticType:uint = 1;
public static var e_islandFlag:uint = 4;
public static var e_allowSleepFlag:uint = 16;
private static var s_xf1:b2XForm = new b2XForm();
public static var e_dynamicType:uint = 2;
public function b2Body(bd:b2BodyDef, world:b2World){
m_xf = new b2XForm();
m_sweep = new b2Sweep();
m_linearVelocity = new b2Vec2();
m_force = new b2Vec2();
super();
m_flags = 0;
if (bd.isBullet){
m_flags = (m_flags | e_bulletFlag);
};
if (bd.fixedRotation){
m_flags = (m_flags | e_fixedRotationFlag);
};
if (bd.allowSleep){
m_flags = (m_flags | e_allowSleepFlag);
};
if (bd.isSleeping){
m_flags = (m_flags | e_sleepFlag);
};
m_world = world;
m_xf.position.SetV(bd.position);
m_xf.R.Set(bd.angle);
m_sweep.localCenter.SetV(bd.massData.center);
m_sweep.t0 = 1;
m_sweep.a0 = (m_sweep.a = bd.angle);
var tMat:b2Mat22 = m_xf.R;
var tVec:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
m_sweep.c.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_jointList = null;
m_contactList = null;
m_prev = null;
m_next = null;
m_linearDamping = bd.linearDamping;
m_angularDamping = bd.angularDamping;
m_force.Set(0, 0);
m_torque = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_sleepTime = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = bd.massData.mass;
if (m_mass > 0){
m_invMass = (1 / m_mass);
};
if ((m_flags & b2Body.e_fixedRotationFlag) == 0){
m_I = bd.massData.I;
};
if (m_I > 0){
m_invI = (1 / m_I);
};
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
m_userData = bd.userData;
m_shapeList = null;
m_shapeCount = 0;
}
public function GetLinearVelocityFromWorldPoint(worldPoint:b2Vec2):b2Vec2{
return (new b2Vec2((m_linearVelocity.x + (m_angularVelocity * (worldPoint.y - m_sweep.c.y))), (m_linearVelocity.x - (m_angularVelocity * (worldPoint.x - m_sweep.c.x)))));
}
public function SetLinearVelocity(v:b2Vec2):void{
m_linearVelocity.SetV(v);
}
public function WakeUp():void{
m_flags = (m_flags & ~(e_sleepFlag));
m_sleepTime = 0;
}
public function GetLocalCenter():b2Vec2{
return (m_sweep.localCenter);
}
public function ApplyTorque(torque:Number):void{
if (IsSleeping()){
WakeUp();
};
m_torque = (m_torque + torque);
}
public function IsFrozen():Boolean{
return (((m_flags & e_frozenFlag) == e_frozenFlag));
}
public function IsDynamic():Boolean{
return ((m_type == e_dynamicType));
}
public function GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
public function SynchronizeTransform():void{
m_xf.R.Set(m_sweep.a);
var tMat:b2Mat22 = m_xf.R;
var tVec:b2Vec2 = m_sweep.localCenter;
m_xf.position.x = (m_sweep.c.x - ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
m_xf.position.y = (m_sweep.c.y - ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
}
public function GetInertia():Number{
return (m_I);
}
public function IsSleeping():Boolean{
return (((m_flags & e_sleepFlag) == e_sleepFlag));
}
public function SetMassFromShapes():void{
var s:b2Shape;
if (m_world.m_lock == true){
return;
};
m_mass = 0;
m_invMass = 0;
m_I = 0;
m_invI = 0;
var centerX:Number = 0;
var centerY:Number = 0;
var massData:b2MassData = s_massData;
s = m_shapeList;
while (s) {
s.ComputeMass(massData);
m_mass = (m_mass + massData.mass);
centerX = (centerX + (massData.mass * massData.center.x));
centerY = (centerY + (massData.mass * massData.center.y));
m_I = (m_I + massData.I);
s = s.m_next;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
centerX = (centerX * m_invMass);
centerY = (centerY * m_invMass);
};
if ((((m_I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){
m_I = (m_I - (m_mass * ((centerX * centerX) + (centerY * centerY))));
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
m_sweep.localCenter.Set(centerX, centerY);
var tMat:b2Mat22 = m_xf.R;
var tVec:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
m_sweep.c.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
s = m_shapeList;
while (s) {
s.UpdateSweepRadius(m_sweep.localCenter);
s = s.m_next;
};
var oldType:int = m_type;
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
if (oldType != m_type){
s = m_shapeList;
while (s) {
s.RefilterProxy(m_world.m_broadPhase, m_xf);
s = s.m_next;
};
};
}
public function PutToSleep():void{
m_flags = (m_flags | e_sleepFlag);
m_sleepTime = 0;
m_linearVelocity.SetZero();
m_angularVelocity = 0;
m_force.SetZero();
m_torque = 0;
}
public function GetJointList():b2JointEdge{
return (m_jointList);
}
public function SetXForm(position:b2Vec2, angle:Number):Boolean{
var s:b2Shape;
var inRange:Boolean;
if (m_world.m_lock == true){
return (true);
};
if (IsFrozen()){
return (false);
};
m_xf.R.Set(angle);
m_xf.position.SetV(position);
var tMat:b2Mat22 = m_xf.R;
var tVec:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
m_sweep.c.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
m_sweep.a0 = (m_sweep.a = angle);
var freeze:Boolean;
s = m_shapeList;
while (s) {
inRange = s.Synchronize(m_world.m_broadPhase, m_xf, m_xf);
if (inRange == false){
freeze = true;
break;
};
s = s.m_next;
};
if (freeze == true){
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
s = m_shapeList;
while (s) {
s.DestroyProxy(m_world.m_broadPhase);
s = s.m_next;
};
return (false);
};
m_world.m_broadPhase.Commit();
return (true);
}
public function GetLocalPoint(worldPoint:b2Vec2):b2Vec2{
return (b2Math.b2MulXT(m_xf, worldPoint));
}
public function ApplyForce(force:b2Vec2, point:b2Vec2):void{
if (IsSleeping()){
WakeUp();
};
m_force.x = (m_force.x + force.x);
m_force.y = (m_force.y + force.y);
m_torque = (m_torque + (((point.x - m_sweep.c.x) * force.y) - ((point.y - m_sweep.c.y) * force.x)));
}
public function SynchronizeShapes():Boolean{
var s:b2Shape;
var xf1:b2XForm = s_xf1;
xf1.R.Set(m_sweep.a0);
var tMat:b2Mat22 = xf1.R;
var tVec:b2Vec2 = m_sweep.localCenter;
xf1.position.x = (m_sweep.c0.x - ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
xf1.position.y = (m_sweep.c0.y - ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
var inRange:Boolean;
s = m_shapeList;
while (s) {
inRange = s.Synchronize(m_world.m_broadPhase, xf1, m_xf);
if (inRange == false){
break;
};
s = s.m_next;
};
if (inRange == false){
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
s = m_shapeList;
while (s) {
s.DestroyProxy(m_world.m_broadPhase);
s = s.m_next;
};
return (false);
};
return (true);
}
public function GetAngle():Number{
return (m_sweep.a);
}
public function GetXForm():b2XForm{
return (m_xf);
}
public function GetLinearVelocityFromLocalPoint(localPoint:b2Vec2):b2Vec2{
var A:b2Mat22 = m_xf.R;
var worldPoint:b2Vec2 = new b2Vec2(((A.col1.x * localPoint.x) + (A.col2.x * localPoint.y)), ((A.col1.y * localPoint.x) + (A.col2.y * localPoint.y)));
worldPoint.x = (worldPoint.x + m_xf.position.x);
worldPoint.y = (worldPoint.y + m_xf.position.y);
return (new b2Vec2((m_linearVelocity.x + (m_angularVelocity * (worldPoint.y - m_sweep.c.y))), (m_linearVelocity.x - (m_angularVelocity * (worldPoint.x - m_sweep.c.x)))));
}
public function GetNext():b2Body{
return (m_next);
}
public function GetMass():Number{
return (m_mass);
}
public function ApplyImpulse(impulse:b2Vec2, point:b2Vec2):void{
if (IsSleeping()){
WakeUp();
};
m_linearVelocity.x = (m_linearVelocity.x + (m_invMass * impulse.x));
m_linearVelocity.y = (m_linearVelocity.y + (m_invMass * impulse.y));
m_angularVelocity = (m_angularVelocity + (m_invI * (((point.x - m_sweep.c.x) * impulse.y) - ((point.y - m_sweep.c.y) * impulse.x))));
}
public function GetAngularVelocity():Number{
return (m_angularVelocity);
}
public function SetAngularVelocity(omega:Number):void{
m_angularVelocity = omega;
}
public function SetMass(massData:b2MassData):void{
var s:b2Shape;
if (m_world.m_lock == true){
return;
};
m_invMass = 0;
m_I = 0;
m_invI = 0;
m_mass = massData.mass;
if (m_mass > 0){
m_invMass = (1 / m_mass);
};
if ((m_flags & b2Body.e_fixedRotationFlag) == 0){
m_I = massData.I;
};
if (m_I > 0){
m_invI = (1 / m_I);
};
m_sweep.localCenter.SetV(massData.center);
var tMat:b2Mat22 = m_xf.R;
var tVec:b2Vec2 = m_sweep.localCenter;
m_sweep.c.x = ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y));
m_sweep.c.y = ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y));
m_sweep.c.x = (m_sweep.c.x + m_xf.position.x);
m_sweep.c.y = (m_sweep.c.y + m_xf.position.y);
m_sweep.c0.SetV(m_sweep.c);
s = m_shapeList;
while (s) {
s.UpdateSweepRadius(m_sweep.localCenter);
s = s.m_next;
};
var oldType:int = m_type;
if ((((m_invMass == 0)) && ((m_invI == 0)))){
m_type = e_staticType;
} else {
m_type = e_dynamicType;
};
if (oldType != m_type){
s = m_shapeList;
while (s) {
s.RefilterProxy(m_world.m_broadPhase, m_xf);
s = s.m_next;
};
};
}
public function IsStatic():Boolean{
return ((m_type == e_staticType));
}
public function GetWorldVector(localVector:b2Vec2):b2Vec2{
return (b2Math.b2MulMV(m_xf.R, localVector));
}
public function GetShapeList():b2Shape{
return (m_shapeList);
}
public function Advance(t:Number):void{
m_sweep.Advance(t);
m_sweep.c.SetV(m_sweep.c0);
m_sweep.a = m_sweep.a0;
SynchronizeTransform();
}
public function SetBullet(flag:Boolean):void{
if (flag){
m_flags = (m_flags | e_bulletFlag);
} else {
m_flags = (m_flags & ~(e_bulletFlag));
};
}
public function CreateShape(def:b2ShapeDef):b2Shape{
var s:b2Shape;
if (m_world.m_lock == true){
return (null);
};
s = b2Shape.Create(def, m_world.m_blockAllocator);
s.m_next = m_shapeList;
m_shapeList = s;
m_shapeCount++;
s.m_body = this;
s.CreateProxy(m_world.m_broadPhase, m_xf);
s.UpdateSweepRadius(m_sweep.localCenter);
return (s);
}
public function IsConnected(other:b2Body):Boolean{
var jn:b2JointEdge = m_jointList;
while (jn) {
if (jn.other == other){
return ((jn.joint.m_collideConnected == false));
};
jn = jn.next;
};
return (false);
}
public function DestroyShape(s:b2Shape):void{
if (m_world.m_lock == true){
return;
};
s.DestroyProxy(m_world.m_broadPhase);
var node:b2Shape = m_shapeList;
var ppS:b2Shape;
var found:Boolean;
while (node != null) {
if (node == s){
if (ppS){
ppS.m_next = s.m_next;
} else {
m_shapeList = s.m_next;
};
found = true;
break;
};
ppS = node;
node = node.m_next;
};
s.m_body = null;
s.m_next = null;
m_shapeCount--;
b2Shape.Destroy(s, m_world.m_blockAllocator);
}
public function GetUserData(){
return (m_userData);
}
public function IsBullet():Boolean{
return (((m_flags & e_bulletFlag) == e_bulletFlag));
}
public function GetWorldCenter():b2Vec2{
return (m_sweep.c);
}
public function AllowSleeping(flag:Boolean):void{
if (flag){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
WakeUp();
};
}
public function SetUserData(data):void{
m_userData = data;
}
public function GetLocalVector(worldVector:b2Vec2):b2Vec2{
return (b2Math.b2MulTMV(m_xf.R, worldVector));
}
public function GetWorldPoint(localPoint:b2Vec2):b2Vec2{
var A:b2Mat22 = m_xf.R;
var u:b2Vec2 = new b2Vec2(((A.col1.x * localPoint.x) + (A.col2.x * localPoint.y)), ((A.col1.y * localPoint.x) + (A.col2.y * localPoint.y)));
u.x = (u.x + m_xf.position.x);
u.y = (u.y + m_xf.position.y);
return (u);
}
public function GetWorld():b2World{
return (m_world);
}
public function GetPosition():b2Vec2{
return (m_xf.position);
}
}
}//package Box2D.Dynamics
Section 65
//b2BodyDef (Box2D.Dynamics.b2BodyDef)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
public class b2BodyDef {
public var angularDamping:Number;
public var angle:Number;
public var isSleeping:Boolean;
public var position:b2Vec2;
public var isBullet:Boolean;
public var allowSleep:Boolean;
public var userData;
public var fixedRotation:Boolean;
public var linearDamping:Number;
public var massData:b2MassData;
public function b2BodyDef(){
massData = new b2MassData();
position = new b2Vec2();
super();
massData.center.SetZero();
massData.mass = 0;
massData.I = 0;
userData = null;
position.Set(0, 0);
angle = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
isSleeping = false;
fixedRotation = false;
isBullet = false;
}
}
}//package Box2D.Dynamics
Section 66
//b2BoundaryListener (Box2D.Dynamics.b2BoundaryListener)
package Box2D.Dynamics {
public class b2BoundaryListener {
public function b2BoundaryListener(){
super();
}
public function Violation(body:b2Body):void{
}
}
}//package Box2D.Dynamics
Section 67
//b2ContactFilter (Box2D.Dynamics.b2ContactFilter)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
public class b2ContactFilter {
public static var b2_defaultFilter:b2ContactFilter = new (b2ContactFilter);
;
public function b2ContactFilter(){
super();
}
public function ShouldCollide(shape1:b2Shape, shape2:b2Shape):Boolean{
var filter1:b2FilterData = shape1.GetFilterData();
var filter2:b2FilterData = shape2.GetFilterData();
if ((((filter1.groupIndex == filter2.groupIndex)) && (!((filter1.groupIndex == 0))))){
return ((filter1.groupIndex > 0));
};
var collide:Boolean = ((!(((filter1.maskBits & filter2.categoryBits) == 0))) && (!(((filter1.categoryBits & filter2.maskBits) == 0))));
return (collide);
}
}
}//package Box2D.Dynamics
Section 68
//b2ContactListener (Box2D.Dynamics.b2ContactListener)
package Box2D.Dynamics {
import Box2D.Collision.*;
import Box2D.Dynamics.Contacts.*;
public class b2ContactListener {
public function b2ContactListener(){
super();
}
public function Add(point:b2ContactPoint):void{
}
public function Remove(point:b2ContactPoint):void{
}
public function Persist(point:b2ContactPoint):void{
}
public function Result(point:b2ContactResult):void{
}
}
}//package Box2D.Dynamics
Section 69
//b2ContactManager (Box2D.Dynamics.b2ContactManager)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2ContactManager extends b2PairCallback {
public var m_world:b2World;
public var m_destroyImmediate:Boolean;
public var m_nullContact:b2NullContact;
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
public function b2ContactManager(){
m_nullContact = new b2NullContact();
super();
m_world = null;
m_destroyImmediate = false;
}
override public function PairRemoved(proxyUserData1, proxyUserData2, pairUserData):void{
if (pairUserData == null){
return;
};
var c:b2Contact = (pairUserData as b2Contact);
if (c == m_nullContact){
return;
};
Destroy(c);
}
public function Destroy(c:b2Contact):void{
var b1:b2Body;
var b2:b2Body;
var manifolds:Array;
var cp:b2ContactPoint;
var i:int;
var manifold:b2Manifold;
var j:int;
var mp:b2ManifoldPoint;
var v1:b2Vec2;
var v2:b2Vec2;
var shape1:b2Shape = c.m_shape1;
var shape2:b2Shape = c.m_shape2;
var manifoldCount:int = c.m_manifoldCount;
if ((((manifoldCount > 0)) && (m_world.m_contactListener))){
b1 = shape1.m_body;
b2 = shape2.m_body;
manifolds = c.GetManifolds();
cp = s_evalCP;
cp.shape1 = c.m_shape1;
cp.shape2 = c.m_shape1;
cp.friction = c.m_friction;
cp.restitution = c.m_restitution;
i = 0;
while (i < manifoldCount) {
manifold = manifolds[i];
cp.normal.SetV(manifold.normal);
j = 0;
while (j < manifold.pointCount) {
mp = manifold.points[j];
cp.position = b1.GetWorldPoint(mp.localPoint1);
v1 = b1.GetLinearVelocityFromLocalPoint(mp.localPoint1);
v2 = b2.GetLinearVelocityFromLocalPoint(mp.localPoint2);
cp.velocity.Set((v2.x - v1.x), (v2.y - v1.y));
cp.separation = mp.separation;
cp.id.key = mp.id._key;
m_world.m_contactListener.Remove(cp);
j++;
};
i++;
};
};
if (c.m_prev){
c.m_prev.m_next = c.m_next;
};
if (c.m_next){
c.m_next.m_prev = c.m_prev;
};
if (c == m_world.m_contactList){
m_world.m_contactList = c.m_next;
};
var body1:b2Body = shape1.m_body;
var body2:b2Body = shape2.m_body;
if (c.m_node1.prev){
c.m_node1.prev.next = c.m_node1.next;
};
if (c.m_node1.next){
c.m_node1.next.prev = c.m_node1.prev;
};
if (c.m_node1 == body1.m_contactList){
body1.m_contactList = c.m_node1.next;
};
if (c.m_node2.prev){
c.m_node2.prev.next = c.m_node2.next;
};
if (c.m_node2.next){
c.m_node2.next.prev = c.m_node2.prev;
};
if (c.m_node2 == body2.m_contactList){
body2.m_contactList = c.m_node2.next;
};
b2Contact.Destroy(c, m_world.m_blockAllocator);
m_world.m_contactCount--;
}
override public function PairAdded(proxyUserData1, proxyUserData2){
var shape1:b2Shape = (proxyUserData1 as b2Shape);
var shape2:b2Shape = (proxyUserData2 as b2Shape);
var body1:b2Body = shape1.m_body;
var body2:b2Body = shape2.m_body;
if (((body1.IsStatic()) && (body2.IsStatic()))){
return (m_nullContact);
};
if (shape1.m_body == shape2.m_body){
return (m_nullContact);
};
if (body2.IsConnected(body1)){
return (m_nullContact);
};
if (((!((m_world.m_contactFilter == null))) && ((m_world.m_contactFilter.ShouldCollide(shape1, shape2) == false)))){
return (m_nullContact);
};
var c:b2Contact = b2Contact.Create(shape1, shape2, m_world.m_blockAllocator);
if (c == null){
return (m_nullContact);
};
shape1 = c.m_shape1;
shape2 = c.m_shape2;
body1 = shape1.m_body;
body2 = shape2.m_body;
c.m_prev = null;
c.m_next = m_world.m_contactList;
if (m_world.m_contactList != null){
m_world.m_contactList.m_prev = c;
};
m_world.m_contactList = c;
c.m_node1.contact = c;
c.m_node1.other = body2;
c.m_node1.prev = null;
c.m_node1.next = body1.m_contactList;
if (body1.m_contactList != null){
body1.m_contactList.prev = c.m_node1;
};
body1.m_contactList = c.m_node1;
c.m_node2.contact = c;
c.m_node2.other = body1;
c.m_node2.prev = null;
c.m_node2.next = body2.m_contactList;
if (body2.m_contactList != null){
body2.m_contactList.prev = c.m_node2;
};
body2.m_contactList = c.m_node2;
m_world.m_contactCount++;
return (c);
}
public function Collide():void{
var body1:b2Body;
var body2:b2Body;
var c:b2Contact = m_world.m_contactList;
while (c) {
body1 = c.m_shape1.m_body;
body2 = c.m_shape2.m_body;
if (((body1.IsSleeping()) && (body2.IsSleeping()))){
} else {
c.Update(m_world.m_contactListener);
};
c = c.m_next;
};
}
}
}//package Box2D.Dynamics
Section 70
//b2DebugDraw (Box2D.Dynamics.b2DebugDraw)
package Box2D.Dynamics {
import flash.display.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Collision.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2DebugDraw {
public var m_xformScale:Number;// = 1
public var m_fillAlpha:Number;// = 1
public var m_alpha:Number;// = 1
public var m_drawFlags:uint;
public var m_lineThickness:Number;// = 1
public var m_drawScale:Number;// = 1
public var m_sprite:Sprite;
public static var e_coreShapeBit:uint = 4;
public static var e_shapeBit:uint = 1;
public static var e_centerOfMassBit:uint = 64;
public static var e_aabbBit:uint = 8;
public static var e_obbBit:uint = 16;
public static var e_pairBit:uint = 32;
public static var e_jointBit:uint = 2;
public function b2DebugDraw(){
super();
m_drawFlags = 0;
}
public function ClearFlags(flags:uint):void{
m_drawFlags = (m_drawFlags & ~(flags));
}
public function SetFlags(flags:uint):void{
m_drawFlags = flags;
}
public function AppendFlags(flags:uint):void{
m_drawFlags = (m_drawFlags | flags);
}
public function DrawSegment(p1:b2Vec2, p2:b2Vec2, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.moveTo((p1.x * m_drawScale), (p1.y * m_drawScale));
m_sprite.graphics.lineTo((p2.x * m_drawScale), (p2.y * m_drawScale));
}
public function DrawSolidPolygon(vertices:Array, vertexCount:int, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.moveTo((vertices[0].x * m_drawScale), (vertices[0].y * m_drawScale));
m_sprite.graphics.beginFill(color.color, m_fillAlpha);
var i = 1;
while (i < vertexCount) {
m_sprite.graphics.lineTo((vertices[i].x * m_drawScale), (vertices[i].y * m_drawScale));
i++;
};
m_sprite.graphics.lineTo((vertices[0].x * m_drawScale), (vertices[0].y * m_drawScale));
m_sprite.graphics.endFill();
}
public function DrawCircle(center:b2Vec2, radius:Number, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.drawCircle((center.x * m_drawScale), (center.y * m_drawScale), (radius * m_drawScale));
}
public function DrawPolygon(vertices:Array, vertexCount:int, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.moveTo((vertices[0].x * m_drawScale), (vertices[0].y * m_drawScale));
var i = 1;
while (i < vertexCount) {
m_sprite.graphics.lineTo((vertices[i].x * m_drawScale), (vertices[i].y * m_drawScale));
i++;
};
m_sprite.graphics.lineTo((vertices[0].x * m_drawScale), (vertices[0].y * m_drawScale));
}
public function DrawSolidCircle(center:b2Vec2, radius:Number, axis:b2Vec2, color:b2Color):void{
m_sprite.graphics.lineStyle(m_lineThickness, color.color, m_alpha);
m_sprite.graphics.moveTo(0, 0);
m_sprite.graphics.beginFill(color.color, m_fillAlpha);
m_sprite.graphics.drawCircle((center.x * m_drawScale), (center.y * m_drawScale), (radius * m_drawScale));
m_sprite.graphics.endFill();
m_sprite.graphics.moveTo((center.x * m_drawScale), (center.y * m_drawScale));
m_sprite.graphics.lineTo(((center.x + (axis.x * radius)) * m_drawScale), ((center.y + (axis.y * radius)) * m_drawScale));
}
public function GetFlags():uint{
return (m_drawFlags);
}
public function DrawXForm(xf:b2XForm):void{
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF0000, m_alpha);
m_sprite.graphics.moveTo((xf.position.x * m_drawScale), (xf.position.y * m_drawScale));
m_sprite.graphics.lineTo(((xf.position.x + (m_xformScale * xf.R.col1.x)) * m_drawScale), ((xf.position.y + (m_xformScale * xf.R.col1.y)) * m_drawScale));
m_sprite.graphics.lineStyle(m_lineThickness, 0xFF00, m_alpha);
m_sprite.graphics.moveTo((xf.position.x * m_drawScale), (xf.position.y * m_drawScale));
m_sprite.graphics.lineTo(((xf.position.x + (m_xformScale * xf.R.col2.x)) * m_drawScale), ((xf.position.y + (m_xformScale * xf.R.col2.y)) * m_drawScale));
}
}
}//package Box2D.Dynamics
Section 71
//b2DestructionListener (Box2D.Dynamics.b2DestructionListener)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Joints.*;
public class b2DestructionListener {
public function b2DestructionListener(){
super();
}
public function SayGoodbyeShape(shape:b2Shape):void{
}
public function SayGoodbyeJoint(joint:b2Joint):void{
}
}
}//package Box2D.Dynamics
Section 72
//b2Island (Box2D.Dynamics.b2Island)
package Box2D.Dynamics {
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2Island {
public var m_listener:b2ContactListener;
public var m_positionIterationCount:int;
public var m_bodyCapacity:int;
public var m_bodies:Array;
public var m_joints:Array;
public var m_jointCapacity:int;
public var m_contactCount:int;
public var m_contacts:Array;
public var m_contactCapacity:int;
public var m_jointCount:int;
public var m_allocator;
public var m_bodyCount:int;
private static var s_reportCR:b2ContactResult = new b2ContactResult();
public function b2Island(bodyCapacity:int, contactCapacity:int, jointCapacity:int, allocator, listener:b2ContactListener){
var i:int;
super();
m_bodyCapacity = bodyCapacity;
m_contactCapacity = contactCapacity;
m_jointCapacity = jointCapacity;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_allocator = allocator;
m_listener = listener;
m_bodies = new Array(bodyCapacity);
i = 0;
while (i < bodyCapacity) {
m_bodies[i] = null;
i++;
};
m_contacts = new Array(contactCapacity);
i = 0;
while (i < contactCapacity) {
m_contacts[i] = null;
i++;
};
m_joints = new Array(jointCapacity);
i = 0;
while (i < jointCapacity) {
m_joints[i] = null;
i++;
};
m_positionIterationCount = 0;
}
public function AddBody(body:b2Body):void{
var _local2 = m_bodyCount++;
m_bodies[_local2] = body;
}
public function AddJoint(joint:b2Joint):void{
var _local2 = m_jointCount++;
m_joints[_local2] = joint;
}
public function Report(constraints:Array):void{
var tMat:b2Mat22;
var tVec:b2Vec2;
var c:b2Contact;
var cc:b2ContactConstraint;
var cr:b2ContactResult;
var b1:b2Body;
var manifoldCount:int;
var manifolds:Array;
var j:int;
var manifold:b2Manifold;
var k:int;
var point:b2ManifoldPoint;
var ccp:b2ContactConstraintPoint;
if (m_listener == null){
return;
};
var i:int;
while (i < m_contactCount) {
c = m_contacts[i];
cc = constraints[i];
cr = s_reportCR;
cr.shape1 = c.m_shape1;
cr.shape2 = c.m_shape2;
b1 = cr.shape1.m_body;
manifoldCount = c.m_manifoldCount;
manifolds = c.GetManifolds();
j = 0;
while (j < manifoldCount) {
manifold = manifolds[j];
cr.normal.SetV(manifold.normal);
k = 0;
while (k < manifold.pointCount) {
point = manifold.points[k];
ccp = cc.points[k];
cr.position = b1.GetWorldPoint(point.localPoint1);
cr.normalImpulse = ccp.normalImpulse;
cr.tangentImpulse = ccp.tangentImpulse;
cr.id.key = point.id.key;
m_listener.Result(cr);
k++;
};
j++;
};
i++;
};
}
public function AddContact(contact:b2Contact):void{
var _local2 = m_contactCount++;
m_contacts[_local2] = contact;
}
public function Solve(step:b2TimeStep, gravity:b2Vec2, correctPositions:Boolean, allowSleep:Boolean):void{
var i:int;
var b:b2Body;
var joint:b2Joint;
var j:int;
var contactsOkay:Boolean;
var jointsOkay:Boolean;
var jointOkay:Boolean;
var minSleepTime:Number;
var linTolSqr:Number;
var angTolSqr:Number;
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.IsStatic()){
} else {
b.m_linearVelocity.x = (b.m_linearVelocity.x + (step.dt * (gravity.x + (b.m_invMass * b.m_force.x))));
b.m_linearVelocity.y = (b.m_linearVelocity.y + (step.dt * (gravity.y + (b.m_invMass * b.m_force.y))));
b.m_angularVelocity = (b.m_angularVelocity + ((step.dt * b.m_invI) * b.m_torque));
b.m_force.SetZero();
b.m_torque = 0;
b.m_linearVelocity.Multiply(b2Math.b2Clamp((1 - (step.dt * b.m_linearDamping)), 0, 1));
b.m_angularVelocity = (b.m_angularVelocity * b2Math.b2Clamp((1 - (step.dt * b.m_angularDamping)), 0, 1));
if (b.m_linearVelocity.LengthSquared() > b2Settings.b2_maxLinearVelocitySquared){
b.m_linearVelocity.Normalize();
b.m_linearVelocity.x = (b.m_linearVelocity.x * b2Settings.b2_maxLinearVelocity);
b.m_linearVelocity.y = (b.m_linearVelocity.y * b2Settings.b2_maxLinearVelocity);
};
if ((b.m_angularVelocity * b.m_angularVelocity) > b2Settings.b2_maxAngularVelocitySquared){
if (b.m_angularVelocity < 0){
b.m_angularVelocity = -(b2Settings.b2_maxAngularVelocity);
} else {
b.m_angularVelocity = b2Settings.b2_maxAngularVelocity;
};
};
};
i++;
};
var contactSolver:b2ContactSolver = new b2ContactSolver(step, m_contacts, m_contactCount, m_allocator);
contactSolver.InitVelocityConstraints(step);
i = 0;
while (i < m_jointCount) {
joint = m_joints[i];
joint.InitVelocityConstraints(step);
i++;
};
i = 0;
while (i < step.maxIterations) {
contactSolver.SolveVelocityConstraints();
j = 0;
while (j < m_jointCount) {
joint = m_joints[j];
joint.SolveVelocityConstraints(step);
j++;
};
i++;
};
contactSolver.FinalizeVelocityConstraints();
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.IsStatic()){
} else {
b.m_sweep.c0.SetV(b.m_sweep.c);
b.m_sweep.a0 = b.m_sweep.a;
b.m_sweep.c.x = (b.m_sweep.c.x + (step.dt * b.m_linearVelocity.x));
b.m_sweep.c.y = (b.m_sweep.c.y + (step.dt * b.m_linearVelocity.y));
b.m_sweep.a = (b.m_sweep.a + (step.dt * b.m_angularVelocity));
b.SynchronizeTransform();
};
i++;
};
if (correctPositions){
i = 0;
while (i < m_jointCount) {
joint = m_joints[i];
joint.InitPositionConstraints();
i++;
};
m_positionIterationCount = 0;
while (m_positionIterationCount < step.maxIterations) {
contactsOkay = contactSolver.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
jointsOkay = true;
i = 0;
while (i < m_jointCount) {
joint = m_joints[i];
jointOkay = joint.SolvePositionConstraints();
jointsOkay = ((jointsOkay) && (jointOkay));
i++;
};
if (((contactsOkay) && (jointsOkay))){
break;
};
m_positionIterationCount++;
};
};
Report(contactSolver.m_constraints);
if (allowSleep){
minSleepTime = Number.MAX_VALUE;
linTolSqr = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
angTolSqr = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.m_invMass == 0){
} else {
if ((b.m_flags & b2Body.e_allowSleepFlag) == 0){
b.m_sleepTime = 0;
minSleepTime = 0;
};
if (((((((b.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((b.m_angularVelocity * b.m_angularVelocity) > angTolSqr)))) || ((b2Math.b2Dot(b.m_linearVelocity, b.m_linearVelocity) > linTolSqr)))){
b.m_sleepTime = 0;
minSleepTime = 0;
} else {
b.m_sleepTime = (b.m_sleepTime + step.dt);
minSleepTime = b2Math.b2Min(minSleepTime, b.m_sleepTime);
};
};
i++;
};
if (minSleepTime >= b2Settings.b2_timeToSleep){
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
b.m_flags = (b.m_flags | b2Body.e_sleepFlag);
b.m_linearVelocity.SetZero();
b.m_angularVelocity = 0;
i++;
};
};
};
}
public function Clear():void{
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
}
public function SolveTOI(subStep:b2TimeStep):void{
var i:int;
var b:b2Body;
var contactsOkay:Boolean;
var contactSolver:b2ContactSolver = new b2ContactSolver(subStep, m_contacts, m_contactCount, m_allocator);
i = 0;
while (i < subStep.maxIterations) {
contactSolver.SolveVelocityConstraints();
i++;
};
i = 0;
while (i < m_bodyCount) {
b = m_bodies[i];
if (b.IsStatic()){
} else {
b.m_sweep.c0.SetV(b.m_sweep.c);
b.m_sweep.a0 = b.m_sweep.a;
b.m_sweep.c.x = (b.m_sweep.c.x + (subStep.dt * b.m_linearVelocity.x));
b.m_sweep.c.y = (b.m_sweep.c.y + (subStep.dt * b.m_linearVelocity.y));
b.m_sweep.a = (b.m_sweep.a + (subStep.dt * b.m_angularVelocity));
b.SynchronizeTransform();
};
i++;
};
var k_toiBaumgarte:Number = 0.75;
i = 0;
while (i < subStep.maxIterations) {
contactsOkay = contactSolver.SolvePositionConstraints(k_toiBaumgarte);
if (contactsOkay){
break;
};
i++;
};
Report(contactSolver.m_constraints);
}
}
}//package Box2D.Dynamics
Section 73
//b2TimeStep (Box2D.Dynamics.b2TimeStep)
package Box2D.Dynamics {
public class b2TimeStep {
public var warmStarting:Boolean;
public var positionCorrection:Boolean;
public var dt:Number;
public var maxIterations:int;
public var dtRatio:Number;
public var inv_dt:Number;
public function b2TimeStep(){
super();
}
}
}//package Box2D.Dynamics
Section 74
//b2World (Box2D.Dynamics.b2World)
package Box2D.Dynamics {
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.*;
import Box2D.Common.*;
import Box2D.Dynamics.Contacts.*;
public class b2World {
public var m_inv_dt0:Number;
public var m_boundaryListener:b2BoundaryListener;
public var m_contactList:b2Contact;
public var m_blockAllocator;
public var m_contactListener:b2ContactListener;
public var m_allowSleep:Boolean;
public var m_broadPhase:b2BroadPhase;
public var m_destructionListener:b2DestructionListener;
public var m_jointCount:int;
public var m_bodyCount:int;
public var m_lock:Boolean;
public var m_positionIterationCount:int;
public var m_groundBody:b2Body;
public var m_contactCount:int;
public var m_debugDraw:b2DebugDraw;
public var m_contactFilter:b2ContactFilter;
public var m_bodyList:b2Body;
public var m_stackAllocator;
public var m_jointList:b2Joint;
public var m_gravity:b2Vec2;
public var m_contactManager:b2ContactManager;
private static var s_jointColor:b2Color = new b2Color(0.5, 0.8, 0.8);
public static var m_continuousPhysics:Boolean;
public static var m_warmStarting:Boolean;
private static var s_coreColor:b2Color = new b2Color(0.9, 0.6, 0.6);
public static var m_positionCorrection:Boolean;
private static var s_xf:b2XForm = new b2XForm();
public function b2World(worldAABB:b2AABB, gravity:b2Vec2, doSleep:Boolean){
m_contactManager = new b2ContactManager();
super();
m_destructionListener = null;
m_boundaryListener = null;
m_contactFilter = b2ContactFilter.b2_defaultFilter;
m_contactListener = null;
m_debugDraw = null;
m_bodyList = null;
m_contactList = null;
m_jointList = null;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_positionCorrection = true;
m_warmStarting = true;
m_continuousPhysics = true;
m_allowSleep = doSleep;
m_gravity = gravity;
m_lock = false;
m_inv_dt0 = 0;
m_contactManager.m_world = this;
m_broadPhase = new b2BroadPhase(worldAABB, m_contactManager);
var bd:b2BodyDef = new b2BodyDef();
m_groundBody = CreateBody(bd);
}
public function DrawJoint(joint:b2Joint):void{
var pulley:b2PulleyJoint;
var s1:b2Vec2;
var s2:b2Vec2;
var b1:b2Body = joint.m_body1;
var b2:b2Body = joint.m_body2;
var xf1:b2XForm = b1.m_xf;
var xf2:b2XForm = b2.m_xf;
var x1:b2Vec2 = xf1.position;
var x2:b2Vec2 = xf2.position;
var p1:b2Vec2 = joint.GetAnchor1();
var p2:b2Vec2 = joint.GetAnchor2();
var color:b2Color = s_jointColor;
switch (joint.m_type){
case b2Joint.e_distanceJoint:
m_debugDraw.DrawSegment(p1, p2, color);
break;
case b2Joint.e_pulleyJoint:
pulley = (joint as b2PulleyJoint);
s1 = pulley.GetGroundAnchor1();
s2 = pulley.GetGroundAnchor2();
m_debugDraw.DrawSegment(s1, p1, color);
m_debugDraw.DrawSegment(s2, p2, color);
m_debugDraw.DrawSegment(s1, s2, color);
break;
case b2Joint.e_mouseJoint:
m_debugDraw.DrawSegment(p1, p2, color);
break;
default:
if (b1 != m_groundBody){
m_debugDraw.DrawSegment(x1, p1, color);
};
m_debugDraw.DrawSegment(p1, p2, color);
if (b2 != m_groundBody){
m_debugDraw.DrawSegment(x2, p2, color);
};
};
}
public function Refilter(shape:b2Shape):void{
shape.RefilterProxy(m_broadPhase, shape.m_body.m_xf);
}
public function SetDebugDraw(debugDraw:b2DebugDraw):void{
m_debugDraw = debugDraw;
}
public function SetContinuousPhysics(flag:Boolean):void{
m_continuousPhysics = flag;
}
public function GetProxyCount():int{
return (m_broadPhase.m_proxyCount);
}
public function DrawDebugData():void{
var i:int;
var b:b2Body;
var s:b2Shape;
var j:b2Joint;
var bp:b2BroadPhase;
var xf:b2XForm;
var core:Boolean;
var index:uint;
var pair:b2Pair;
var p1:b2Proxy;
var p2:b2Proxy;
var worldLower:b2Vec2;
var worldUpper:b2Vec2;
var p:b2Proxy;
var poly:b2PolygonShape;
var obb:b2OBB;
var h:b2Vec2;
var tMat:b2Mat22;
var tVec:b2Vec2;
var tX:Number;
if (m_debugDraw == null){
return;
};
m_debugDraw.m_sprite.graphics.clear();
var flags:uint = m_debugDraw.GetFlags();
var invQ:b2Vec2 = new b2Vec2();
var x1:b2Vec2 = new b2Vec2();
var x2:b2Vec2 = new b2Vec2();
var color:b2Color = new b2Color(0, 0, 0);
var b1:b2AABB = new b2AABB();
var b2:b2AABB = new b2AABB();
var vs:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
if ((flags & b2DebugDraw.e_shapeBit)){
core = ((flags & b2DebugDraw.e_coreShapeBit) == b2DebugDraw.e_coreShapeBit);
b = m_bodyList;
while (b) {
xf = b.m_xf;
s = b.GetShapeList();
while (s) {
if (b.IsStatic()){
DrawShape(s, xf, new b2Color(0.5, 0.9, 0.5), core);
} else {
if (b.IsSleeping()){
DrawShape(s, xf, new b2Color(0.5, 0.5, 0.9), core);
} else {
DrawShape(s, xf, new b2Color(0.9, 0.9, 0.9), core);
};
};
s = s.m_next;
};
b = b.m_next;
};
};
if ((flags & b2DebugDraw.e_jointBit)){
j = m_jointList;
while (j) {
DrawJoint(j);
j = j.m_next;
};
};
if ((flags & b2DebugDraw.e_pairBit)){
bp = m_broadPhase;
invQ.Set((1 / bp.m_quantizationFactor.x), (1 / bp.m_quantizationFactor.y));
color.Set(0.9, 0.9, 0.3);
i = 0;
while (i < b2Pair.b2_tableCapacity) {
index = bp.m_pairManager.m_hashTable[i];
while (index != b2Pair.b2_nullPair) {
pair = bp.m_pairManager.m_pairs[index];
p1 = bp.m_proxyPool[pair.proxyId1];
p2 = bp.m_proxyPool[pair.proxyId2];
b1.lowerBound.x = (bp.m_worldAABB.lowerBound.x + (invQ.x * bp.m_bounds[0][p1.lowerBounds[0]].value));
b1.lowerBound.y = (bp.m_worldAABB.lowerBound.y + (invQ.y * bp.m_bounds[1][p1.lowerBounds[1]].value));
b1.upperBound.x = (bp.m_worldAABB.lowerBound.x + (invQ.x * bp.m_bounds[0][p1.upperBounds[0]].value));
b1.upperBound.y = (bp.m_worldAABB.lowerBound.y + (invQ.y * bp.m_bounds[1][p1.upperBounds[1]].value));
b2.lowerBound.x = (bp.m_worldAABB.lowerBound.x + (invQ.x * bp.m_bounds[0][p2.lowerBounds[0]].value));
b2.lowerBound.y = (bp.m_worldAABB.lowerBound.y + (invQ.y * bp.m_bounds[1][p2.lowerBounds[1]].value));
b2.upperBound.x = (bp.m_worldAABB.lowerBound.x + (invQ.x * bp.m_bounds[0][p2.upperBounds[0]].value));
b2.upperBound.y = (bp.m_worldAABB.lowerBound.y + (invQ.y * bp.m_bounds[1][p2.upperBounds[1]].value));
x1.x = (0.5 * (b1.lowerBound.x + b1.upperBound.x));
x1.y = (0.5 * (b1.lowerBound.y + b1.upperBound.y));
x2.x = (0.5 * (b2.lowerBound.x + b2.upperBound.x));
x2.y = (0.5 * (b2.lowerBound.y + b2.upperBound.y));
m_debugDraw.DrawSegment(x1, x2, color);
index = pair.next;
};
i++;
};
};
if ((flags & b2DebugDraw.e_aabbBit)){
bp = m_broadPhase;
worldLower = bp.m_worldAABB.lowerBound;
worldUpper = bp.m_worldAABB.upperBound;
invQ.Set((1 / bp.m_quantizationFactor.x), (1 / bp.m_quantizationFactor.y));
color.Set(0.9, 0.3, 0.9);
i = 0;
while (i < b2Settings.b2_maxProxies) {
p = bp.m_proxyPool[i];
if (p.IsValid() == false){
} else {
b1.lowerBound.x = (worldLower.x + (invQ.x * bp.m_bounds[0][p.lowerBounds[0]].value));
b1.lowerBound.y = (worldLower.y + (invQ.y * bp.m_bounds[1][p.lowerBounds[1]].value));
b1.upperBound.x = (worldLower.x + (invQ.x * bp.m_bounds[0][p.upperBounds[0]].value));
b1.upperBound.y = (worldLower.y + (invQ.y * bp.m_bounds[1][p.upperBounds[1]].value));
vs[0].Set(b1.lowerBound.x, b1.lowerBound.y);
vs[1].Set(b1.upperBound.x, b1.lowerBound.y);
vs[2].Set(b1.upperBound.x, b1.upperBound.y);
vs[3].Set(b1.lowerBound.x, b1.upperBound.y);
m_debugDraw.DrawPolygon(vs, 4, color);
};
i++;
};
vs[0].Set(worldLower.x, worldLower.y);
vs[1].Set(worldUpper.x, worldLower.y);
vs[2].Set(worldUpper.x, worldUpper.y);
vs[3].Set(worldLower.x, worldUpper.y);
m_debugDraw.DrawPolygon(vs, 4, new b2Color(0.3, 0.9, 0.9));
};
if ((flags & b2DebugDraw.e_obbBit)){
color.Set(0.5, 0.3, 0.5);
b = m_bodyList;
while (b) {
xf = b.m_xf;
s = b.GetShapeList();
while (s) {
if (s.m_type != b2Shape.e_polygonShape){
} else {
poly = (s as b2PolygonShape);
obb = poly.GetOBB();
h = obb.extents;
vs[0].Set(-(h.x), -(h.y));
vs[1].Set(h.x, -(h.y));
vs[2].Set(h.x, h.y);
vs[3].Set(-(h.x), h.y);
i = 0;
while (i < 4) {
tMat = obb.R;
tVec = vs[i];
tX = (obb.center.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
vs[i].y = (obb.center.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
vs[i].x = tX;
tMat = xf.R;
tX = (xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y)));
vs[i].y = (xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y)));
vs[i].x = tX;
i++;
};
m_debugDraw.DrawPolygon(vs, 4, color);
};
s = s.m_next;
};
b = b.m_next;
};
};
if ((flags & b2DebugDraw.e_centerOfMassBit)){
b = m_bodyList;
while (b) {
xf = s_xf;
xf.R = b.m_xf.R;
xf.position = b.GetWorldCenter();
m_debugDraw.DrawXForm(xf);
b = b.m_next;
};
};
}
public function DestroyBody(b:b2Body):void{
var jn0:b2JointEdge;
var s0:b2Shape;
if (m_lock == true){
return;
};
var jn:b2JointEdge = b.m_jointList;
while (jn) {
jn0 = jn;
jn = jn.next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeJoint(jn0.joint);
};
DestroyJoint(jn0.joint);
};
var s:b2Shape = b.m_shapeList;
while (s) {
s0 = s;
s = s.m_next;
if (m_destructionListener){
m_destructionListener.SayGoodbyeShape(s0);
};
s0.DestroyProxy(m_broadPhase);
b2Shape.Destroy(s0, m_blockAllocator);
};
if (b.m_prev){
b.m_prev.m_next = b.m_next;
};
if (b.m_next){
b.m_next.m_prev = b.m_prev;
};
if (b == m_bodyList){
m_bodyList = b.m_next;
};
m_bodyCount--;
}
public function SetContactFilter(filter:b2ContactFilter):void{
m_contactFilter = filter;
}
public function GetGroundBody():b2Body{
return (m_groundBody);
}
public function DrawShape(shape:b2Shape, xf:b2XForm, color:b2Color, core:Boolean):void{
var circle:b2CircleShape;
var center:b2Vec2;
var radius:Number;
var axis:b2Vec2;
var i:int;
var poly:b2PolygonShape;
var vertexCount:int;
var localVertices:Array;
var vertices:Array;
var localCoreVertices:Array;
var coreColor:b2Color = s_coreColor;
switch (shape.m_type){
case b2Shape.e_circleShape:
circle = (shape as b2CircleShape);
center = b2Math.b2MulX(xf, circle.m_localPosition);
radius = circle.m_radius;
axis = xf.R.col1;
m_debugDraw.DrawSolidCircle(center, radius, axis, color);
if (core){
m_debugDraw.DrawCircle(center, (radius - b2Settings.b2_toiSlop), coreColor);
};
break;
case b2Shape.e_polygonShape:
poly = (shape as b2PolygonShape);
vertexCount = poly.GetVertexCount();
localVertices = poly.GetVertices();
vertices = new Array(b2Settings.b2_maxPolygonVertices);
i = 0;
while (i < vertexCount) {
vertices[i] = b2Math.b2MulX(xf, localVertices[i]);
i++;
};
m_debugDraw.DrawSolidPolygon(vertices, vertexCount, color);
if (core){
localCoreVertices = poly.GetCoreVertices();
i = 0;
while (i < vertexCount) {
vertices[i] = b2Math.b2MulX(xf, localCoreVertices[i]);
i++;
};
m_debugDraw.DrawPolygon(vertices, vertexCount, coreColor);
};
break;
};
}
public function GetContactCount():int{
return (m_contactCount);
}
public function Solve(step:b2TimeStep):void{
var b:b2Body;
var stackCount:int;
var i:int;
var other:b2Body;
var cn:b2ContactEdge;
var jn:b2JointEdge;
var inRange:Boolean;
m_positionIterationCount = 0;
var island:b2Island = new b2Island(m_bodyCount, m_contactCount, m_jointCount, m_stackAllocator, m_contactListener);
b = m_bodyList;
while (b) {
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
b = b.m_next;
};
var c:b2Contact = m_contactList;
while (c) {
c.m_flags = (c.m_flags & ~(b2Contact.e_islandFlag));
c = c.m_next;
};
var j:b2Joint = m_jointList;
while (j) {
j.m_islandFlag = false;
j = j.m_next;
};
var stackSize:int = m_bodyCount;
var stack:Array = new Array(stackSize);
var seed:b2Body = m_bodyList;
while (seed) {
if ((seed.m_flags & ((b2Body.e_islandFlag | b2Body.e_sleepFlag) | b2Body.e_frozenFlag))){
} else {
if (seed.IsStatic()){
} else {
island.Clear();
stackCount = 0;
var _temp1 = stackCount;
stackCount = (stackCount + 1);
var _local15 = _temp1;
stack[_local15] = seed;
seed.m_flags = (seed.m_flags | b2Body.e_islandFlag);
while (stackCount > 0) {
--stackCount;
b = stack[stackCount];
island.AddBody(b);
b.m_flags = (b.m_flags & ~(b2Body.e_sleepFlag));
if (b.IsStatic()){
} else {
cn = b.m_contactList;
while (cn) {
if ((cn.contact.m_flags & (b2Contact.e_islandFlag | b2Contact.e_nonSolidFlag))){
} else {
if (cn.contact.m_manifoldCount == 0){
} else {
island.AddContact(cn.contact);
cn.contact.m_flags = (cn.contact.m_flags | b2Contact.e_islandFlag);
other = cn.other;
if ((other.m_flags & b2Body.e_islandFlag)){
} else {
var _temp2 = stackCount;
stackCount = (stackCount + 1);
var _local16 = _temp2;
stack[_local16] = other;
other.m_flags = (other.m_flags | b2Body.e_islandFlag);
};
};
};
cn = cn.next;
};
jn = b.m_jointList;
while (jn) {
if (jn.joint.m_islandFlag == true){
} else {
island.AddJoint(jn.joint);
jn.joint.m_islandFlag = true;
other = jn.other;
if ((other.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = stackCount;
stackCount = (stackCount + 1);
_local16 = _temp3;
stack[_local16] = other;
other.m_flags = (other.m_flags | b2Body.e_islandFlag);
};
};
jn = jn.next;
};
};
};
island.Solve(step, m_gravity, m_positionCorrection, m_allowSleep);
if (island.m_positionIterationCount > m_positionIterationCount){
m_positionIterationCount = island.m_positionIterationCount;
};
i = 0;
while (i < island.m_bodyCount) {
b = island.m_bodies[i];
if (b.IsStatic()){
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
};
i++;
};
};
};
seed = seed.m_next;
};
b = m_bodyList;
while (b) {
if ((b.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){
} else {
if (b.IsStatic()){
} else {
inRange = b.SynchronizeShapes();
if ((((inRange == false)) && (!((m_boundaryListener == null))))){
m_boundaryListener.Violation(b);
};
};
};
b = b.m_next;
};
m_broadPhase.Commit();
}
public function Query(aabb:b2AABB, shapes:Array, maxCount:int):int{
var results:Array = new Array(maxCount);
var count:int = m_broadPhase.QueryAABB(aabb, results, maxCount);
var i:int;
while (i < count) {
shapes[i] = results[i];
i++;
};
return (count);
}
public function SetGravity(gravity:b2Vec2):void{
m_gravity = gravity;
}
public function SolveTOI(step:b2TimeStep):void{
var b:b2Body;
var s1:b2Shape;
var s2:b2Shape;
var b1:b2Body;
var b2:b2Body;
var cn:b2ContactEdge;
var c:b2Contact;
var minContact:b2Contact;
var minTOI:Number;
var seed:b2Body;
var stackCount:int;
var subStep:b2TimeStep;
var i:int;
var toi:Number;
var t0:Number;
var other:b2Body;
var inRange:Boolean;
var island:b2Island = new b2Island(m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, 0, m_stackAllocator, m_contactListener);
var stackSize:int = m_bodyCount;
var stack:Array = new Array(stackSize);
b = m_bodyList;
while (b) {
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
b.m_sweep.t0 = 0;
b = b.m_next;
};
c = m_contactList;
while (c) {
c.m_flags = (c.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
c = c.m_next;
};
while (true) {
minContact = null;
minTOI = 1;
c = m_contactList;
for (;c;(c = c.m_next)) {
if ((c.m_flags & (b2Contact.e_slowFlag | b2Contact.e_nonSolidFlag))){
} else {
toi = 1;
if ((c.m_flags & b2Contact.e_toiFlag)){
toi = c.m_toi;
} else {
s1 = c.m_shape1;
s2 = c.m_shape2;
b1 = s1.m_body;
b2 = s2.m_body;
if (((((b1.IsStatic()) || (b1.IsSleeping()))) && (((b2.IsStatic()) || (b2.IsSleeping()))))){
continue;
};
t0 = b1.m_sweep.t0;
if (b1.m_sweep.t0 < b2.m_sweep.t0){
t0 = b2.m_sweep.t0;
b1.m_sweep.Advance(t0);
} else {
if (b2.m_sweep.t0 < b1.m_sweep.t0){
t0 = b1.m_sweep.t0;
b2.m_sweep.Advance(t0);
};
};
toi = b2TimeOfImpact.TimeOfImpact(c.m_shape1, b1.m_sweep, c.m_shape2, b2.m_sweep);
if ((((toi > 0)) && ((toi < 1)))){
toi = (((1 - toi) * t0) + toi);
if (toi > 1){
toi = 1;
};
};
c.m_toi = toi;
c.m_flags = (c.m_flags | b2Contact.e_toiFlag);
};
if ((((Number.MIN_VALUE < toi)) && ((toi < minTOI)))){
minContact = c;
minTOI = toi;
};
};
};
if ((((minContact == null)) || (((1 - (100 * Number.MIN_VALUE)) < minTOI)))){
break;
};
s1 = minContact.m_shape1;
s2 = minContact.m_shape2;
b1 = s1.m_body;
b2 = s2.m_body;
b1.Advance(minTOI);
b2.Advance(minTOI);
minContact.Update(m_contactListener);
minContact.m_flags = (minContact.m_flags & ~(b2Contact.e_toiFlag));
if (minContact.m_manifoldCount == 0){
} else {
seed = b1;
if (seed.IsStatic()){
seed = b2;
};
island.Clear();
stackCount = 0;
var _temp1 = stackCount;
stackCount = (stackCount + 1);
var _local22 = _temp1;
stack[_local22] = seed;
seed.m_flags = (seed.m_flags | b2Body.e_islandFlag);
while (stackCount > 0) {
--stackCount;
b = stack[stackCount];
island.AddBody(b);
b.m_flags = (b.m_flags & ~(b2Body.e_sleepFlag));
if (b.IsStatic()){
} else {
cn = b.m_contactList;
while (cn) {
if (island.m_contactCount == island.m_contactCapacity){
} else {
if ((cn.contact.m_flags & ((b2Contact.e_islandFlag | b2Contact.e_slowFlag) | b2Contact.e_nonSolidFlag))){
} else {
if (cn.contact.m_manifoldCount == 0){
} else {
island.AddContact(cn.contact);
cn.contact.m_flags = (cn.contact.m_flags | b2Contact.e_islandFlag);
other = cn.other;
if ((other.m_flags & b2Body.e_islandFlag)){
} else {
if (other.IsStatic() == false){
other.Advance(minTOI);
other.WakeUp();
};
var _temp2 = stackCount;
stackCount = (stackCount + 1);
var _local23 = _temp2;
stack[_local23] = other;
other.m_flags = (other.m_flags | b2Body.e_islandFlag);
};
};
};
};
cn = cn.next;
};
};
};
subStep = new b2TimeStep();
subStep.dt = ((1 - minTOI) * step.dt);
subStep.inv_dt = (1 / subStep.dt);
subStep.maxIterations = step.maxIterations;
island.SolveTOI(subStep);
i = 0;
while (i < island.m_bodyCount) {
b = island.m_bodies[i];
b.m_flags = (b.m_flags & ~(b2Body.e_islandFlag));
if ((b.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){
} else {
if (b.IsStatic()){
} else {
inRange = b.SynchronizeShapes();
if ((((inRange == false)) && (!((m_boundaryListener == null))))){
m_boundaryListener.Violation(b);
};
cn = b.m_contactList;
while (cn) {
cn.contact.m_flags = (cn.contact.m_flags & ~(b2Contact.e_toiFlag));
cn = cn.next;
};
};
};
i++;
};
i = 0;
while (i < island.m_contactCount) {
c = island.m_contacts[i];
c.m_flags = (c.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag)));
i++;
};
m_broadPhase.Commit();
};
};
}
public function GetJointList():b2Joint{
return (m_jointList);
}
public function GetBodyList():b2Body{
return (m_bodyList);
}
public function GetPairCount():int{
return (m_broadPhase.m_pairManager.m_pairCount);
}
public function Validate():void{
m_broadPhase.Validate();
}
public function SetWarmStarting(flag:Boolean):void{
m_warmStarting = flag;
}
public function SetPositionCorrection(flag:Boolean):void{
m_positionCorrection = flag;
}
public function CreateJoint(def:b2JointDef):b2Joint{
var b:b2Body;
var s:b2Shape;
var j:b2Joint = b2Joint.Create(def, m_blockAllocator);
j.m_prev = null;
j.m_next = m_jointList;
if (m_jointList){
m_jointList.m_prev = j;
};
m_jointList = j;
m_jointCount++;
j.m_node1.joint = j;
j.m_node1.other = j.m_body2;
j.m_node1.prev = null;
j.m_node1.next = j.m_body1.m_jointList;
if (j.m_body1.m_jointList){
j.m_body1.m_jointList.prev = j.m_node1;
};
j.m_body1.m_jointList = j.m_node1;
j.m_node2.joint = j;
j.m_node2.other = j.m_body1;
j.m_node2.prev = null;
j.m_node2.next = j.m_body2.m_jointList;
if (j.m_body2.m_jointList){
j.m_body2.m_jointList.prev = j.m_node2;
};
j.m_body2.m_jointList = j.m_node2;
if (def.collideConnected == false){
b = ((def.body1.m_shapeCount < def.body2.m_shapeCount)) ? def.body1 : def.body2;
s = b.m_shapeList;
while (s) {
s.RefilterProxy(m_broadPhase, b.m_xf);
s = s.m_next;
};
};
return (j);
}
public function DestroyJoint(j:b2Joint):void{
var b:b2Body;
var s:b2Shape;
var collideConnected:Boolean = j.m_collideConnected;
if (j.m_prev){
j.m_prev.m_next = j.m_next;
};
if (j.m_next){
j.m_next.m_prev = j.m_prev;
};
if (j == m_jointList){
m_jointList = j.m_next;
};
var body1:b2Body = j.m_body1;
var body2:b2Body = j.m_body2;
body1.WakeUp();
body2.WakeUp();
if (j.m_node1.prev){
j.m_node1.prev.next = j.m_node1.next;
};
if (j.m_node1.next){
j.m_node1.next.prev = j.m_node1.prev;
};
if (j.m_node1 == body1.m_jointList){
body1.m_jointList = j.m_node1.next;
};
j.m_node1.prev = null;
j.m_node1.next = null;
if (j.m_node2.prev){
j.m_node2.prev.next = j.m_node2.next;
};
if (j.m_node2.next){
j.m_node2.next.prev = j.m_node2.prev;
};
if (j.m_node2 == body2.m_jointList){
body2.m_jointList = j.m_node2.next;
};
j.m_node2.prev = null;
j.m_node2.next = null;
b2Joint.Destroy(j, m_blockAllocator);
m_jointCount--;
if (collideConnected == false){
b = ((body1.m_shapeCount < body2.m_shapeCount)) ? body1 : body2;
s = b.m_shapeList;
while (s) {
s.RefilterProxy(m_broadPhase, b.m_xf);
s = s.m_next;
};
};
}
public function SetContactListener(listener:b2ContactListener):void{
m_contactListener = listener;
}
public function CreateBody(def:b2BodyDef):b2Body{
if (m_lock == true){
return (null);
};
var b:b2Body = new b2Body(def, this);
b.m_prev = null;
b.m_next = m_bodyList;
if (m_bodyList){
m_bodyList.m_prev = b;
};
m_bodyList = b;
m_bodyCount++;
return (b);
}
public function SetBoundaryListener(listener:b2BoundaryListener):void{
m_boundaryListener = listener;
}
public function SetDestructionListener(listener:b2DestructionListener):void{
m_destructionListener = listener;
}
public function Step(dt:Number, iterations:int):void{
m_lock = true;
var step:b2TimeStep = new b2TimeStep();
step.dt = dt;
step.maxIterations = iterations;
if (dt > 0){
step.inv_dt = (1 / dt);
} else {
step.inv_dt = 0;
};
step.dtRatio = (m_inv_dt0 * dt);
step.positionCorrection = m_positionCorrection;
step.warmStarting = m_warmStarting;
m_contactManager.Collide();
if (step.dt > 0){
Solve(step);
};
if (((m_continuousPhysics) && ((step.dt > 0)))){
SolveTOI(step);
};
DrawDebugData();
m_inv_dt0 = step.inv_dt;
m_lock = false;
}
public function GetBodyCount():int{
return (m_bodyCount);
}
public function GetJointCount():int{
return (m_jointCount);
}
}
}//package Box2D.Dynamics
Section 75
//PNGEncoder (com.adobe.images.PNGEncoder)
package com.adobe.images {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
public class PNGEncoder {
private static var crcTableComputed:Boolean = false;
private static var crcTable:Array;
public function PNGEncoder(){
super();
}
private static function writeChunk(png:ByteArray, type:uint, data:ByteArray):void{
var c:uint;
var n:uint;
var k:uint;
if (!crcTableComputed){
crcTableComputed = true;
crcTable = [];
n = 0;
while (n < 0x0100) {
c = n;
k = 0;
while (k < 8) {
if ((c & 1)){
c = uint((uint(3988292384) ^ uint((c >>> 1))));
} else {
c = uint((c >>> 1));
};
k++;
};
crcTable[n] = c;
n++;
};
};
var len:uint;
if (data != null){
len = data.length;
};
png.writeUnsignedInt(len);
var p:uint = png.position;
png.writeUnsignedInt(type);
if (data != null){
png.writeBytes(data);
};
var e:uint = png.position;
png.position = p;
c = 4294967295;
var i:int;
while (i < (e - p)) {
c = uint((crcTable[((c ^ png.readUnsignedByte()) & uint(0xFF))] ^ uint((c >>> 8))));
i++;
};
c = uint((c ^ uint(4294967295)));
png.position = e;
png.writeUnsignedInt(c);
}
public static function encode(img:BitmapData):ByteArray{
var p:uint;
var j:int;
var png:ByteArray = new ByteArray();
png.writeUnsignedInt(2303741511);
png.writeUnsignedInt(218765834);
var IHDR:ByteArray = new ByteArray();
IHDR.writeInt(img.width);
IHDR.writeInt(img.height);
IHDR.writeUnsignedInt(134610944);
IHDR.writeByte(0);
writeChunk(png, 1229472850, IHDR);
var IDAT:ByteArray = new ByteArray();
var i:int;
while (i < img.height) {
IDAT.writeByte(0);
if (!img.transparent){
j = 0;
while (j < img.width) {
p = img.getPixel(j, i);
IDAT.writeUnsignedInt(uint((((p & 0xFFFFFF) << 8) | 0xFF)));
j++;
};
} else {
j = 0;
while (j < img.width) {
p = img.getPixel32(j, i);
IDAT.writeUnsignedInt(uint((((p & 0xFFFFFF) << 8) | (p >>> 24))));
j++;
};
};
i++;
};
IDAT.compress();
writeChunk(png, 1229209940, IDAT);
writeChunk(png, 1229278788, null);
return (png);
}
}
}//package com.adobe.images
Section 76
//CampaignInfo (com.google.analytics.campaign.CampaignInfo)
package com.google.analytics.campaign {
import com.google.analytics.utils.*;
public class CampaignInfo {
private var _new:Boolean;
private var _empty:Boolean;
public function CampaignInfo(empty:Boolean=true, newCampaign:Boolean=false){
super();
_empty = empty;
_new = newCampaign;
}
public function toURLString():String{
var v:Variables = toVariables();
return (v.toString());
}
public function isNew():Boolean{
return (_new);
}
public function get utmcn():String{
return ("1");
}
public function isEmpty():Boolean{
return (_empty);
}
public function toVariables():Variables{
var variables:Variables = new Variables();
variables.URIencode = true;
if (((!(isEmpty())) && (isNew()))){
variables.utmcn = utmcn;
};
if (((!(isEmpty())) && (!(isNew())))){
variables.utmcr = utmcr;
};
return (variables);
}
public function get utmcr():String{
return ("1");
}
}
}//package com.google.analytics.campaign
Section 77
//CampaignKey (com.google.analytics.campaign.CampaignKey)
package com.google.analytics.campaign {
public class CampaignKey {
public var UCMD:String;// = "utm_medium"
public var UCID:String;// = "utm_id"
public var UCTR:String;// = "utm_term"
public var UCSR:String;// = "utm_source"
public var UCNO:String;// = "utm_nooverride"
public var UCCN:String;// = "utm_campaign"
public var UGCLID:String;// = "gclid"
public var UCCT:String;// = "utm_content"
public function CampaignKey(){
super();
}
}
}//package com.google.analytics.campaign
Section 78
//CampaignManager (com.google.analytics.campaign.CampaignManager)
package com.google.analytics.campaign {
import com.google.analytics.core.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import com.google.analytics.utils.*;
public class CampaignManager {
private var _config:Configuration;
private var _domainHash:Number;
private var _debug:DebugConfiguration;
private var _timeStamp:Number;
private var _referrer:String;
private var _buffer:Buffer;
public static const trackingDelimiter:String = "|";
public function CampaignManager(config:Configuration, debug:DebugConfiguration, buffer:Buffer, domainHash:Number, referrer:String, timeStamp:Number){
super();
_config = config;
_debug = debug;
_buffer = buffer;
_domainHash = domainHash;
_referrer = referrer;
_timeStamp = timeStamp;
}
public function getCampaignInformation(search:String, noSessionInformation:Boolean):CampaignInfo{
var campaignTracker:CampaignTracker;
var oldTracker:CampaignTracker;
var sessionCount:int;
var campInfo:CampaignInfo = new CampaignInfo();
var duplicateCampaign:Boolean;
var campNoOverride:Boolean;
var responseCount:int;
if (((_config.allowLinker) && (_buffer.isGenuine()))){
if (!_buffer.hasUTMZ()){
return (campInfo);
};
};
campaignTracker = getTrackerFromSearchString(search);
if (isValid(campaignTracker)){
campNoOverride = hasNoOverride(search);
if (((campNoOverride) && (!(_buffer.hasUTMZ())))){
return (campInfo);
};
};
if (!isValid(campaignTracker)){
campaignTracker = getOrganicCampaign();
if (((!(_buffer.hasUTMZ())) && (isIgnoredKeyword(campaignTracker)))){
return (campInfo);
};
};
if (((!(isValid(campaignTracker))) && (noSessionInformation))){
campaignTracker = getReferrerCampaign();
if (((!(_buffer.hasUTMZ())) && (isIgnoredReferral(campaignTracker)))){
return (campInfo);
};
};
if (!isValid(campaignTracker)){
if (((!(_buffer.hasUTMZ())) && (noSessionInformation))){
campaignTracker = getDirectCampaign();
};
};
if (!isValid(campaignTracker)){
return (campInfo);
};
if (((_buffer.hasUTMZ()) && (!(_buffer.utmz.isEmpty())))){
oldTracker = new CampaignTracker();
oldTracker.fromTrackerString(_buffer.utmz.campaignTracking);
duplicateCampaign = (oldTracker.toTrackerString() == campaignTracker.toTrackerString());
responseCount = _buffer.utmz.responseCount;
};
if (((!(duplicateCampaign)) || (noSessionInformation))){
sessionCount = _buffer.utma.sessionCount;
responseCount++;
if (sessionCount == 0){
sessionCount = 1;
};
_buffer.utmz.domainHash = _domainHash;
_buffer.utmz.campaignCreation = _timeStamp;
_buffer.utmz.campaignSessions = sessionCount;
_buffer.utmz.responseCount = responseCount;
_buffer.utmz.campaignTracking = campaignTracker.toTrackerString();
_debug.info(_buffer.utmz.toString(), VisualDebugMode.geek);
campInfo = new CampaignInfo(false, true);
} else {
campInfo = new CampaignInfo(false, false);
};
return (campInfo);
}
public function hasNoOverride(search:String):Boolean{
var key:CampaignKey = _config.campaignKey;
if (search == ""){
return (false);
};
var variables:Variables = new Variables(search);
var value:String = "";
if (variables.hasOwnProperty(key.UCNO)){
value = variables[key.UCNO];
switch (value){
case "1":
return (true);
case "":
case "0":
default:
return (false);
};
};
return (false);
}
public function getTrackerFromSearchString(search:String):CampaignTracker{
var organicCampaign:CampaignTracker = getOrganicCampaign();
var camp:CampaignTracker = new CampaignTracker();
var key:CampaignKey = _config.campaignKey;
if (search == ""){
return (camp);
};
var variables:Variables = new Variables(search);
if (variables.hasOwnProperty(key.UCID)){
camp.id = variables[key.UCID];
};
if (variables.hasOwnProperty(key.UCSR)){
camp.source = variables[key.UCSR];
};
if (variables.hasOwnProperty(key.UGCLID)){
camp.clickId = variables[key.UGCLID];
};
if (variables.hasOwnProperty(key.UCCN)){
camp.name = variables[key.UCCN];
} else {
camp.name = "(not set)";
};
if (variables.hasOwnProperty(key.UCMD)){
camp.medium = variables[key.UCMD];
} else {
camp.medium = "(not set)";
};
if (variables.hasOwnProperty(key.UCTR)){
camp.term = variables[key.UCTR];
} else {
if (((organicCampaign) && (!((organicCampaign.term == ""))))){
camp.term = organicCampaign.term;
};
};
if (variables.hasOwnProperty(key.UCCT)){
camp.content = variables[key.UCCT];
};
return (camp);
}
public function getOrganicCampaign():CampaignTracker{
var camp:CampaignTracker;
var tmp:Array;
var currentOrganicSource:OrganicReferrer;
var keyword:String;
if (((isInvalidReferrer(_referrer)) || (isFromGoogleCSE(_referrer, _config)))){
return (camp);
};
var ref:URL = new URL(_referrer);
var name:String = "";
if (ref.hostName != ""){
if (ref.hostName.indexOf(".") > -1){
tmp = ref.hostName.split(".");
switch (tmp.length){
case 2:
name = tmp[0];
break;
case 3:
name = tmp[1];
break;
};
};
};
if (_config.organic.match(name)){
currentOrganicSource = _config.organic.getReferrerByName(name);
keyword = _config.organic.getKeywordValue(currentOrganicSource, ref.search);
camp = new CampaignTracker();
camp.source = currentOrganicSource.engine;
camp.name = "(organic)";
camp.medium = "organic";
camp.term = keyword;
};
return (camp);
}
public function getDirectCampaign():CampaignTracker{
var camp:CampaignTracker = new CampaignTracker();
camp.source = "(direct)";
camp.name = "(direct)";
camp.medium = "(none)";
return (camp);
}
public function isIgnoredKeyword(tracker:CampaignTracker):Boolean{
if (((tracker) && ((tracker.medium == "organic")))){
return (_config.organic.isIgnoredKeyword(tracker.term));
};
return (false);
}
public function isIgnoredReferral(tracker:CampaignTracker):Boolean{
if (((tracker) && ((tracker.medium == "referral")))){
return (_config.organic.isIgnoredReferral(tracker.source));
};
return (false);
}
public function isValid(tracker:CampaignTracker):Boolean{
if (((tracker) && (tracker.isValid()))){
return (true);
};
return (false);
}
public function getReferrerCampaign():CampaignTracker{
var camp:CampaignTracker;
if (((isInvalidReferrer(_referrer)) || (isFromGoogleCSE(_referrer, _config)))){
return (camp);
};
var ref:URL = new URL(_referrer);
var hostname:String = ref.hostName;
var content:String = ref.path;
if (hostname.indexOf("www.") == 0){
hostname = hostname.substr(4);
};
camp = new CampaignTracker();
camp.source = hostname;
camp.name = "(referral)";
camp.medium = "referral";
camp.content = content;
return (camp);
}
public static function isInvalidReferrer(referrer:String):Boolean{
var url:URL;
if ((((((referrer == "")) || ((referrer == "-")))) || ((referrer == "0")))){
return (true);
};
if (referrer.indexOf("://") > -1){
url = new URL(referrer);
if ((((url.protocol == Protocols.file)) || ((url.protocol == Protocols.none)))){
return (true);
};
};
return (false);
}
public static function isFromGoogleCSE(referrer:String, config:Configuration):Boolean{
var url:URL = new URL(referrer);
if (url.hostName.indexOf(config.google) > -1){
if (url.search.indexOf((config.googleSearchParam + "=")) > -1){
if (url.path == ("/" + config.googleCsePath)){
return (true);
};
};
};
return (false);
}
}
}//package com.google.analytics.campaign
Section 79
//CampaignTracker (com.google.analytics.campaign.CampaignTracker)
package com.google.analytics.campaign {
import com.google.analytics.utils.*;
public class CampaignTracker {
public var content:String;
public var source:String;
public var clickId:String;
public var name:String;
public var term:String;
public var medium:String;
public var id:String;
public function CampaignTracker(id:String="", source:String="", clickId:String="", name:String="", medium:String="", term:String="", content:String=""){
super();
this.id = id;
this.source = source;
this.clickId = clickId;
this.name = name;
this.medium = medium;
this.term = term;
this.content = content;
}
public function isValid():Boolean{
if (((((!((id == ""))) || (!((source == ""))))) || (!((clickId == ""))))){
return (true);
};
return (false);
}
public function toTrackerString():String{
var data:Array = [];
_addIfNotEmpty(data, "utmcid=", id);
_addIfNotEmpty(data, "utmcsr=", source);
_addIfNotEmpty(data, "utmgclid=", clickId);
_addIfNotEmpty(data, "utmccn=", name);
_addIfNotEmpty(data, "utmcmd=", medium);
_addIfNotEmpty(data, "utmctr=", term);
_addIfNotEmpty(data, "utmcct=", content);
return (data.join(CampaignManager.trackingDelimiter));
}
private function _addIfNotEmpty(arr:Array, field:String, value:String):void{
if (value != ""){
value = value.split("+").join("%20");
value = value.split(" ").join("%20");
arr.push((field + value));
};
}
public function fromTrackerString(tracker:String):void{
var data:String = tracker.split(CampaignManager.trackingDelimiter).join("&");
var vars:Variables = new Variables(data);
if (vars.hasOwnProperty("utmcid")){
this.id = vars["utmcid"];
};
if (vars.hasOwnProperty("utmcsr")){
this.source = vars["utmcsr"];
};
if (vars.hasOwnProperty("utmccn")){
this.name = vars["utmccn"];
};
if (vars.hasOwnProperty("utmcmd")){
this.medium = vars["utmcmd"];
};
if (vars.hasOwnProperty("utmctr")){
this.term = vars["utmctr"];
};
if (vars.hasOwnProperty("utmcct")){
this.content = vars["utmcct"];
};
if (vars.hasOwnProperty("utmgclid")){
this.clickId = vars["utmgclid"];
};
}
}
}//package com.google.analytics.campaign
Section 80
//BrowserInfo (com.google.analytics.core.BrowserInfo)
package com.google.analytics.core {
import com.google.analytics.v4.*;
import com.google.analytics.utils.*;
public class BrowserInfo {
private var _config:Configuration;
private var _info:Environment;
public function BrowserInfo(config:Configuration, info:Environment){
super();
_config = config;
_info = info;
}
public function get utmul():String{
return (_info.language.toLowerCase());
}
public function get utmje():String{
return ("0");
}
public function toURLString():String{
var v:Variables = toVariables();
return (v.toString());
}
public function get utmsr():String{
return (((_info.screenWidth + "x") + _info.screenHeight));
}
public function get utmfl():String{
var v:Version;
if (_config.detectFlash){
v = _info.flashVersion;
return (((((v.major + ".") + v.minor) + " r") + v.build));
};
return ("-");
}
public function get utmcs():String{
return (_info.languageEncoding);
}
public function toVariables():Variables{
var variables:Variables = new Variables();
variables.URIencode = true;
variables.utmcs = utmcs;
variables.utmsr = utmsr;
variables.utmsc = utmsc;
variables.utmul = utmul;
variables.utmje = utmje;
variables.utmfl = utmfl;
return (variables);
}
public function get utmsc():String{
return ((_info.screenColorDepth + "-bit"));
}
}
}//package com.google.analytics.core
Section 81
//Buffer (com.google.analytics.core.Buffer)
package com.google.analytics.core {
import flash.events.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import flash.net.*;
import com.google.analytics.data.*;
public dynamic class Buffer {
private var _SO:SharedObject;
private var _data:Object;
private var _OBJ:Object;
private var _utmb:UTMB;
private var _utmc:UTMC;
private var _utma:UTMA;
private var _debug:DebugConfiguration;
private var _utmk:UTMK;
private var _config:Configuration;
private var _utmv:UTMV;
private var _utmx:UTMX;
private var _utmz:UTMZ;
private var _volatile:Boolean;
public function Buffer(config:Configuration, debug:DebugConfiguration, volatile:Boolean=false, data:Object=null){
var prop:String;
super();
_config = config;
_debug = debug;
_data = data;
_volatile = volatile;
if (_volatile){
_OBJ = new Object();
if (_data){
for (prop in _data) {
_OBJ[prop] = _data[prop];
};
};
};
}
public function save():void{
var flushStatus:String;
if (!isVolatile()){
flushStatus = null;
flushStatus = _SO.flush();
//unresolved jump
var _slot1 = e;
_debug.warning("Error...Could not write SharedObject to disk");
switch (flushStatus){
case SharedObjectFlushStatus.PENDING:
_debug.info("Requesting permission to save object...");
_SO.addEventListener(NetStatusEvent.NET_STATUS, _onFlushStatus);
break;
case SharedObjectFlushStatus.FLUSHED:
_debug.info("Value flushed to disk.");
break;
};
};
}
public function get utmv():UTMV{
if (!hasUTMV()){
_createUMTV();
};
return (_utmv);
}
public function get utmx():UTMX{
if (!hasUTMX()){
_createUMTX();
};
return (_utmx);
}
public function get utmz():UTMZ{
if (!hasUTMZ()){
_createUMTZ();
};
return (_utmz);
}
public function hasUTMA():Boolean{
if (_utma){
return (true);
};
return (false);
}
public function hasUTMB():Boolean{
if (_utmb){
return (true);
};
return (false);
}
public function hasUTMC():Boolean{
if (_utmc){
return (true);
};
return (false);
}
public function clearCookies():void{
utma.reset();
utmb.reset();
utmc.reset();
utmz.reset();
utmv.reset();
utmk.reset();
}
public function resetCurrentSession():void{
_clearUTMB();
_clearUTMC();
save();
}
public function hasUTMK():Boolean{
if (_utmk){
return (true);
};
return (false);
}
public function getLinkerUrl(targetUrl:String="", useHash:Boolean=false):String{
var linkerParams:String = toLinkerParams();
var formattedUrl:String = targetUrl;
var urlFields:Array = targetUrl.split("#");
if (linkerParams){
if (useHash){
if (1 >= urlFields.length){
formattedUrl = (formattedUrl + ("#" + linkerParams));
} else {
formattedUrl = (formattedUrl + ("&" + linkerParams));
};
} else {
if (1 >= urlFields.length){
if (targetUrl.indexOf("?") > -1){
formattedUrl = (formattedUrl + "&");
} else {
formattedUrl = (formattedUrl + "?");
};
formattedUrl = (formattedUrl + linkerParams);
} else {
formattedUrl = urlFields[0];
if (targetUrl.indexOf("?") > -1){
formattedUrl = (formattedUrl + "&");
} else {
formattedUrl = (formattedUrl + "?");
};
formattedUrl = (formattedUrl + ((linkerParams + "#") + urlFields[1]));
};
};
};
return (formattedUrl);
}
public function generateCookiesHash():Number{
var value:String = "";
value = (value + utma.valueOf());
value = (value + utmb.valueOf());
value = (value + utmc.valueOf());
value = (value + utmx.valueOf());
value = (value + utmz.valueOf());
value = (value + utmv.valueOf());
return (Utils.generateHash(value));
}
private function _createUMTA():void{
_utma = new UTMA();
_utma.proxy = this;
}
private function _createUMTB():void{
_utmb = new UTMB();
_utmb.proxy = this;
}
private function _createUMTC():void{
_utmc = new UTMC();
}
public function hasUTMV():Boolean{
if (_utmv){
return (true);
};
return (false);
}
private function _createUMTK():void{
_utmk = new UTMK();
_utmk.proxy = this;
}
public function hasUTMX():Boolean{
if (_utmx){
return (true);
};
return (false);
}
public function hasUTMZ():Boolean{
if (_utmz){
return (true);
};
return (false);
}
private function _createUMTV():void{
_utmv = new UTMV();
_utmv.proxy = this;
}
private function _createUMTX():void{
_utmx = new UTMX();
_utmx.proxy = this;
}
private function _createUMTZ():void{
_utmz = new UTMZ();
_utmz.proxy = this;
}
public function updateUTMA(timestamp:Number):void{
if (_debug.verbose){
_debug.info((("updateUTMA( " + timestamp) + " )"), VisualDebugMode.advanced);
};
if (!utma.isEmpty()){
if (isNaN(utma.sessionCount)){
utma.sessionCount = 1;
} else {
utma.sessionCount = (utma.sessionCount + 1);
};
utma.lastTime = utma.currentTime;
utma.currentTime = timestamp;
};
}
public function isGenuine():Boolean{
if (!hasUTMK()){
return (true);
};
return ((utmk.hash == generateCookiesHash()));
}
private function _onFlushStatus(event:NetStatusEvent):void{
_debug.info("User closed permission dialog...");
switch (event.info.code){
case "SharedObject.Flush.Success":
_debug.info("User granted permission -- value saved.");
break;
case "SharedObject.Flush.Failed":
_debug.info("User denied permission -- value not saved.");
break;
};
_SO.removeEventListener(NetStatusEvent.NET_STATUS, _onFlushStatus);
}
public function toLinkerParams():String{
var output:String = "";
output = (output + utma.toURLString());
output = (output + ("&" + utmb.toURLString()));
output = (output + ("&" + utmc.toURLString()));
output = (output + ("&" + utmx.toURLString()));
output = (output + ("&" + utmz.toURLString()));
output = (output + ("&" + utmv.toURLString()));
output = (output + ("&__utmk=" + generateCookiesHash()));
return (output);
}
private function _clearUTMA():void{
_utma = null;
if (!isVolatile()){
_SO.data.utma = null;
delete _SO.data.utma;
};
}
private function _clearUTMC():void{
_utmc = null;
}
private function _clearUTMB():void{
_utmb = null;
if (!isVolatile()){
_SO.data.utmb = null;
delete _SO.data.utmb;
};
}
public function update(name:String, value):void{
if (isVolatile()){
_OBJ[name] = value;
} else {
_SO.data[name] = value;
};
}
public function createSO():void{
var saveSO:Boolean;
UTMZ.defaultTimespan = _config.conversionTimeout;
UTMB.defaultTimespan = _config.sessionTimeout;
if (!_volatile){
_SO = SharedObject.getLocal(_config.cookieName, _config.cookiePath);
//unresolved jump
var _slot1 = e;
if (_debug.active){
_debug.warning(((("Shared Object " + _config.cookieName) + " failed to be set\nreason: ") + _slot1.message));
};
saveSO = false;
if (_SO.data.utma){
if (!hasUTMA()){
_createUMTA();
};
_utma.fromSharedObject(_SO.data.utma);
if (_debug.verbose){
_debug.info(("found: " + _utma.toString(true)), VisualDebugMode.geek);
};
if (_utma.isExpired()){
if (_debug.verbose){
_debug.warning("UTMA has expired", VisualDebugMode.advanced);
};
_clearUTMA();
saveSO = true;
};
};
if (_SO.data.utmb){
if (!hasUTMB()){
_createUMTB();
};
_utmb.fromSharedObject(_SO.data.utmb);
if (_debug.verbose){
_debug.info(("found: " + _utmb.toString(true)), VisualDebugMode.geek);
};
if (_utmb.isExpired()){
if (_debug.verbose){
_debug.warning("UTMB has expired", VisualDebugMode.advanced);
};
_clearUTMB();
saveSO = true;
};
};
if (_SO.data.utmc){
delete _SO.data.utmc;
saveSO = true;
};
if (_SO.data.utmk){
if (!hasUTMK()){
_createUMTK();
};
_utmk.fromSharedObject(_SO.data.utmk);
if (_debug.verbose){
_debug.info(("found: " + _utmk.toString()), VisualDebugMode.geek);
};
};
if (!hasUTMX()){
_createUMTX();
};
if (_SO.data.utmv){
if (!hasUTMV()){
_createUMTV();
};
_utmv.fromSharedObject(_SO.data.utmv);
if (_debug.verbose){
_debug.info(("found: " + _utmv.toString(true)), VisualDebugMode.geek);
};
if (_utmv.isExpired()){
if (_debug.verbose){
_debug.warning("UTMV has expired", VisualDebugMode.advanced);
};
_clearUTMV();
saveSO = true;
};
};
if (_SO.data.utmz){
if (!hasUTMZ()){
_createUMTZ();
};
_utmz.fromSharedObject(_SO.data.utmz);
if (_debug.verbose){
_debug.info(("found: " + _utmz.toString(true)), VisualDebugMode.geek);
};
if (_utmz.isExpired()){
if (_debug.verbose){
_debug.warning("UTMZ has expired", VisualDebugMode.advanced);
};
_clearUTMZ();
saveSO = true;
};
};
if (saveSO){
save();
};
};
}
private function _clearUTMZ():void{
_utmz = null;
if (!isVolatile()){
_SO.data.utmz = null;
delete _SO.data.utmz;
};
}
private function _clearUTMV():void{
_utmv = null;
if (!isVolatile()){
_SO.data.utmv = null;
delete _SO.data.utmv;
};
}
public function isVolatile():Boolean{
return (_volatile);
}
public function get utma():UTMA{
if (!hasUTMA()){
_createUMTA();
};
return (_utma);
}
public function get utmb():UTMB{
if (!hasUTMB()){
_createUMTB();
};
return (_utmb);
}
public function get utmc():UTMC{
if (!hasUTMC()){
_createUMTC();
};
return (_utmc);
}
public function get utmk():UTMK{
if (!hasUTMK()){
_createUMTK();
};
return (_utmk);
}
}
}//package com.google.analytics.core
Section 82
//DocumentInfo (com.google.analytics.core.DocumentInfo)
package com.google.analytics.core {
import com.google.analytics.v4.*;
import com.google.analytics.external.*;
import com.google.analytics.utils.*;
public class DocumentInfo {
private var _pageURL:String;
private var _utmr:String;
private var _config:Configuration;
private var _adSense:AdSenseGlobals;
private var _info:Environment;
public function DocumentInfo(config:Configuration, info:Environment, formatedReferrer:String, pageURL:String=null, adSense:AdSenseGlobals=null){
super();
_config = config;
_info = info;
_utmr = formatedReferrer;
_pageURL = pageURL;
_adSense = adSense;
}
public function get utmr():String{
if (!_utmr){
return ("-");
};
return (_utmr);
}
public function toURLString():String{
var v:Variables = toVariables();
return (v.toString());
}
private function _renderPageURL(pageURL:String=""):String{
var pathname:String = _info.locationPath;
var search:String = _info.locationSearch;
if (((!(pageURL)) || ((pageURL == "")))){
pageURL = (pathname + unescape(search));
if (pageURL == ""){
pageURL = "/";
};
};
return (pageURL);
}
public function get utmp():String{
return (_renderPageURL(_pageURL));
}
public function get utmhid():String{
return (String(_generateHitId()));
}
private function _generateHitId():Number{
var hid:Number;
if (((_adSense.hid) && (!((_adSense.hid == ""))))){
hid = Number(_adSense.hid);
} else {
hid = Math.round((Math.random() * 2147483647));
_adSense.hid = String(hid);
};
return (hid);
}
public function toVariables():Variables{
var variables:Variables = new Variables();
variables.URIencode = true;
if (((_config.detectTitle) && (!((utmdt == ""))))){
variables.utmdt = utmdt;
};
variables.utmhid = utmhid;
variables.utmr = utmr;
variables.utmp = utmp;
return (variables);
}
public function get utmdt():String{
return (_info.documentTitle);
}
}
}//package com.google.analytics.core
Section 83
//Domain (com.google.analytics.core.Domain)
package com.google.analytics.core {
import com.google.analytics.debug.*;
public class Domain {
private var _mode:DomainNameMode;
private var _debug:DebugConfiguration;
private var _name:String;
public function Domain(mode:DomainNameMode=null, name:String="", debug:DebugConfiguration=null){
super();
_debug = debug;
if (mode == null){
mode = DomainNameMode.auto;
};
_mode = mode;
if (mode == DomainNameMode.custom){
this.name = name;
} else {
_name = name;
};
}
public function get mode():DomainNameMode{
return (_mode);
}
public function set mode(value:DomainNameMode):void{
_mode = value;
if (_mode == DomainNameMode.none){
_name = "";
};
}
public function get name():String{
return (_name);
}
public function set name(value:String):void{
if (((!((value.charAt(0) == "."))) && (_debug))){
_debug.warning(("missing leading period \".\", cookie will only be accessible on " + value), VisualDebugMode.geek);
};
_name = value;
}
}
}//package com.google.analytics.core
Section 84
//DomainNameMode (com.google.analytics.core.DomainNameMode)
package com.google.analytics.core {
public class DomainNameMode {
private var _value:int;
private var _name:String;
public static const custom:DomainNameMode = new DomainNameMode(2, "custom");
;
public static const none:DomainNameMode = new DomainNameMode(0, "none");
;
public static const auto:DomainNameMode = new DomainNameMode(1, "auto");
;
public function DomainNameMode(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.core
Section 85
//Ecommerce (com.google.analytics.core.Ecommerce)
package com.google.analytics.core {
import com.google.analytics.debug.*;
import com.google.analytics.ecommerce.*;
public class Ecommerce {
private var _debug:DebugConfiguration;
private var _trans:Array;
public function Ecommerce(debug:DebugConfiguration){
super();
this._debug = debug;
_trans = new Array();
}
public function getTransLength():Number{
return (_trans.length);
}
public function getTransFromArray(i:Number):Transaction{
return (_trans[i]);
}
public function addTransaction(id:String, affiliation:String, total:String, tax:String, shipping:String, city:String, state:String, country:String):Transaction{
var newTrans:Transaction;
newTrans = getTransaction(id);
if (newTrans == null){
newTrans = new Transaction(id, affiliation, total, tax, shipping, city, state, country);
_trans.push(newTrans);
} else {
newTrans.affiliation = affiliation;
newTrans.total = total;
newTrans.tax = tax;
newTrans.shipping = shipping;
newTrans.city = city;
newTrans.state = state;
newTrans.country = country;
};
return (newTrans);
}
public function getTransaction(orderId:String):Transaction{
var i:Number;
i = 0;
while (i < _trans.length) {
if (_trans[i].id == orderId){
return (_trans[i]);
};
i++;
};
return (null);
}
}
}//package com.google.analytics.core
Section 86
//EventInfo (com.google.analytics.core.EventInfo)
package com.google.analytics.core {
import com.google.analytics.data.*;
import com.google.analytics.utils.*;
public class EventInfo {
private var _ext10:X10;
private var _isEventHit:Boolean;
private var _x10:X10;
public function EventInfo(isEventHit:Boolean, xObject:X10, extObject:X10=null){
super();
_isEventHit = isEventHit;
_x10 = xObject;
_ext10 = extObject;
}
public function toURLString():String{
var v:Variables = toVariables();
return (v.toString());
}
public function get utmt():String{
return ("event");
}
public function get utme():String{
return (_x10.renderMergedUrlString(_ext10));
}
public function toVariables():Variables{
var variables:Variables = new Variables();
variables.URIencode = true;
if (_isEventHit){
variables.utmt = utmt;
};
variables.utme = utme;
return (variables);
}
}
}//package com.google.analytics.core
Section 87
//EventTracker (com.google.analytics.core.EventTracker)
package com.google.analytics.core {
import com.google.analytics.v4.*;
public class EventTracker {
private var _parent:GoogleAnalyticsAPI;
public var name:String;
public function EventTracker(name:String, parent:GoogleAnalyticsAPI){
super();
this.name = name;
_parent = parent;
}
public function trackEvent(action:String, label:String=null, value:Number=NaN):Boolean{
return (_parent.trackEvent(name, action, label, value));
}
}
}//package com.google.analytics.core
Section 88
//ga_internal (com.google.analytics.core.ga_internal)
package com.google.analytics.core {
public namespace ga_internal;
}//package com.google.analytics.core
Section 89
//GIFRequest (com.google.analytics.core.GIFRequest)
package com.google.analytics.core {
import flash.display.*;
import flash.events.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import flash.net.*;
import com.google.analytics.utils.*;
import flash.system.*;
public class GIFRequest {
private var _info:Environment;
private var _count:int;
private var _utmac:String;
private var _alertcount:int;
private var _debug:DebugConfiguration;
private var _lastRequest:URLRequest;
private var _buffer:Buffer;
private var _config:Configuration;
private var _requests:Array;
public function GIFRequest(config:Configuration, debug:DebugConfiguration, buffer:Buffer, info:Environment){
super();
_config = config;
_debug = debug;
_buffer = buffer;
_info = info;
_count = 0;
_alertcount = 0;
_requests = [];
}
public function get utmn():String{
return ((Utils.generate32bitRandom() as String));
}
public function onIOError(event:IOErrorEvent):void{
var url:String = _lastRequest.url;
var id:String = String((_requests.length - 1));
var msg = (("Gif Request #" + id) + " failed");
if (_debug.GIFRequests){
if (!_debug.verbose){
if (url.indexOf("?") > -1){
url = url.split("?")[0];
};
url = _shortenURL(url);
};
if (int(_debug.mode) > int(VisualDebugMode.basic)){
msg = (msg + ((" \"" + url) + "\" does not exists or is unreachable"));
};
_debug.failure(msg);
} else {
_debug.warning(msg);
};
_removeListeners(event.target);
}
public function send(account:String, variables:Variables=null, force:Boolean=false, rateLimit:Boolean=false):void{
var localPath:String;
var localImage:URLRequest;
var remoteImage:URLRequest;
_utmac = account;
if (!variables){
variables = new Variables();
};
variables.URIencode = false;
variables.pre = ["utmwv", "utmn", "utmhn", "utmt", "utme", "utmcs", "utmsr", "utmsc", "utmul", "utmje", "utmfl", "utmdt", "utmhid", "utmr", "utmp"];
variables.post = ["utmcc"];
if (_debug.verbose){
_debug.info(((("tracking: " + _buffer.utmb.trackCount) + "/") + _config.trackingLimitPerSession), VisualDebugMode.geek);
};
if ((((_buffer.utmb.trackCount < _config.trackingLimitPerSession)) || (force))){
if (rateLimit){
updateToken();
};
if (((((force) || (!(rateLimit)))) || ((_buffer.utmb.token >= 1)))){
if (((!(force)) && (rateLimit))){
_buffer.utmb.token = (_buffer.utmb.token - 1);
};
_buffer.utmb.trackCount = (_buffer.utmb.trackCount + 1);
if (_debug.verbose){
_debug.info(_buffer.utmb.toString(), VisualDebugMode.geek);
};
variables.utmwv = utmwv;
variables.utmn = Utils.generate32bitRandom();
if (_info.domainName != ""){
variables.utmhn = _info.domainName;
};
if (_config.sampleRate < 1){
variables.utmsp = (_config.sampleRate * 100);
};
if ((((_config.serverMode == ServerOperationMode.local)) || ((_config.serverMode == ServerOperationMode.both)))){
localPath = _info.locationSWFPath;
if (localPath.lastIndexOf("/") > 0){
localPath = localPath.substring(0, localPath.lastIndexOf("/"));
};
localImage = new URLRequest();
if (_config.localGIFpath.indexOf("http") == 0){
localImage.url = _config.localGIFpath;
} else {
localImage.url = (localPath + _config.localGIFpath);
};
localImage.url = (localImage.url + ("?" + variables.toString()));
if (((_debug.active) && (_debug.GIFRequests))){
_debugSend(localImage);
} else {
sendRequest(localImage);
};
};
if ((((_config.serverMode == ServerOperationMode.remote)) || ((_config.serverMode == ServerOperationMode.both)))){
remoteImage = new URLRequest();
if (_info.protocol == Protocols.HTTPS){
remoteImage.url = _config.secureRemoteGIFpath;
} else {
if (_info.protocol == Protocols.HTTP){
remoteImage.url = _config.remoteGIFpath;
} else {
remoteImage.url = _config.remoteGIFpath;
};
};
variables.utmac = utmac;
variables.utmcc = encodeURIComponent(utmcc);
remoteImage.url = (remoteImage.url + ("?" + variables.toString()));
if (((_debug.active) && (_debug.GIFRequests))){
_debugSend(remoteImage);
} else {
sendRequest(remoteImage);
};
};
};
};
}
public function onSecurityError(event:SecurityErrorEvent):void{
if (_debug.GIFRequests){
_debug.failure(event.text);
};
}
public function get utmsp():String{
return (((_config.sampleRate * 100) as String));
}
public function get utmcc():String{
var cookies:Array = [];
if (_buffer.hasUTMA()){
cookies.push((_buffer.utma.toURLString() + ";"));
};
if (_buffer.hasUTMZ()){
cookies.push((_buffer.utmz.toURLString() + ";"));
};
if (_buffer.hasUTMV()){
cookies.push((_buffer.utmv.toURLString() + ";"));
};
return (cookies.join("+"));
}
public function get utmac():String{
return (_utmac);
}
public function get utmwv():String{
return (_config.version);
}
public function sendRequest(request:URLRequest):void{
var request = request;
var loader:Loader = new Loader();
loader.name = String(_count++);
var context:LoaderContext = new LoaderContext(false);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
_lastRequest = request;
_requests[loader.name] = new RequestObject(request);
loader.load(request, context);
//unresolved jump
var _slot1 = e;
_debug.failure("\"Loader.load()\" could not instanciate Gif Request");
}
private function _removeListeners(target:Object):void{
target.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
target.removeEventListener(Event.COMPLETE, onComplete);
}
public function updateToken():void{
var tokenDelta:Number;
var timestamp:Number = new Date().getTime();
tokenDelta = ((timestamp - _buffer.utmb.lastTime) * (_config.tokenRate / 1000));
if (_debug.verbose){
_debug.info(("tokenDelta: " + tokenDelta), VisualDebugMode.geek);
};
if (tokenDelta >= 1){
_buffer.utmb.token = Math.min(Math.floor((_buffer.utmb.token + tokenDelta)), _config.bucketCapacity);
_buffer.utmb.lastTime = timestamp;
if (_debug.verbose){
_debug.info(_buffer.utmb.toString(), VisualDebugMode.geek);
};
};
}
public function get utmhn():String{
return (_info.domainName);
}
private function _shortenURL(url:String):String{
var paths:Array;
if (url.length > 60){
paths = url.split("/");
while (url.length > 60) {
paths.shift();
url = ("../" + paths.join("/"));
};
};
return (url);
}
private function _debugSend(request:URLRequest):void{
var _local3:String;
var data:String = "";
switch (_debug.mode){
case VisualDebugMode.geek:
data = ((("Gif Request #" + _alertcount) + ":\n") + request.url);
break;
case VisualDebugMode.advanced:
_local3 = request.url;
if (_local3.indexOf("?") > -1){
_local3 = _local3.split("?")[0];
};
_local3 = _shortenURL(_local3);
data = (((("Send Gif Request #" + _alertcount) + ":\n") + _local3) + " ?");
break;
case VisualDebugMode.basic:
default:
data = (((("Send " + _config.serverMode.toString()) + " Gif Request #") + _alertcount) + " ?");
};
_debug.alertGifRequest(data, request, this);
_alertcount++;
}
public function onComplete(event:Event):void{
var id:String = event.target.loader.name;
_requests[id].complete();
var msg = (("Gif Request #" + id) + " sent");
var url:String = _requests[id].request.url;
if (_debug.GIFRequests){
if (!_debug.verbose){
if (url.indexOf("?") > -1){
url = url.split("?")[0];
};
url = _shortenURL(url);
};
if (int(_debug.mode) > int(VisualDebugMode.basic)){
msg = (msg + ((" to \"" + url) + "\""));
};
_debug.success(msg);
} else {
_debug.info(msg);
};
_removeListeners(event.target);
}
}
}//package com.google.analytics.core
Section 90
//IdleTimer (com.google.analytics.core.IdleTimer)
package com.google.analytics.core {
import flash.display.*;
import flash.events.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import flash.utils.*;
public class IdleTimer {
private var _stage:Stage;
private var _loop:Timer;
private var _lastMove:int;
private var _inactivity:Number;
private var _debug:DebugConfiguration;
private var _session:Timer;
private var _buffer:Buffer;
public function IdleTimer(config:Configuration, debug:DebugConfiguration, display:DisplayObject, buffer:Buffer){
super();
var delay:Number = config.idleLoop;
var inactivity:Number = config.idleTimeout;
var sessionTimeout:Number = config.sessionTimeout;
_loop = new Timer((delay * 1000));
_session = new Timer((sessionTimeout * 1000), 1);
_debug = debug;
_stage = display.stage;
_buffer = buffer;
_lastMove = getTimer();
_inactivity = (inactivity * 1000);
_loop.addEventListener(TimerEvent.TIMER, checkForIdle);
_session.addEventListener(TimerEvent.TIMER_COMPLETE, endSession);
_stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
_debug.info(((((("delay: " + delay) + "sec , inactivity: ") + inactivity) + "sec, sessionTimeout: ") + sessionTimeout), VisualDebugMode.geek);
_loop.start();
}
private function onMouseMove(event:MouseEvent):void{
_lastMove = getTimer();
if (_session.running){
_debug.info("session timer reset", VisualDebugMode.geek);
_session.reset();
};
}
public function endSession(event:TimerEvent):void{
_session.removeEventListener(TimerEvent.TIMER_COMPLETE, endSession);
_debug.info("session timer end session", VisualDebugMode.geek);
_session.reset();
_buffer.resetCurrentSession();
_debug.info(_buffer.utmb.toString(), VisualDebugMode.geek);
_debug.info(_buffer.utmc.toString(), VisualDebugMode.geek);
_session.addEventListener(TimerEvent.TIMER_COMPLETE, endSession);
}
public function checkForIdle(event:TimerEvent):void{
var current:int = getTimer();
if ((current - _lastMove) >= _inactivity){
if (!_session.running){
_debug.info("session timer start", VisualDebugMode.geek);
_session.start();
};
};
}
}
}//package com.google.analytics.core
Section 91
//Organic (com.google.analytics.core.Organic)
package com.google.analytics.core {
import com.google.analytics.utils.*;
public class Organic {
private var _sourcesCache:Array;
private var _sourcesEngine:Array;
private var _ignoredKeywords:Array;
private var _ignoredReferralsCache:Object;
private var _ignoredReferrals:Array;
private var _ignoredKeywordsCache:Object;
private var _sources:Array;
public static var throwErrors:Boolean = false;
public function Organic(){
super();
_sources = [];
_sourcesCache = [];
_sourcesEngine = [];
_ignoredReferrals = [];
_ignoredReferralsCache = {};
_ignoredKeywords = [];
_ignoredKeywordsCache = {};
}
public function isIgnoredKeyword(keyword:String):Boolean{
if (_ignoredKeywordsCache.hasOwnProperty(keyword)){
return (true);
};
return (false);
}
public function getKeywordValue(or:OrganicReferrer, path:String):String{
var keyword:String = or.keyword;
return (getKeywordValueFromPath(keyword, path));
}
public function isIgnoredReferral(referrer:String):Boolean{
if (_ignoredReferralsCache.hasOwnProperty(referrer)){
return (true);
};
return (false);
}
public function clear():void{
clearEngines();
clearIgnoredReferrals();
clearIgnoredKeywords();
}
public function get count():int{
return (_sources.length);
}
public function get ignoredKeywordsCount():int{
return (_ignoredKeywords.length);
}
public function match(name:String):Boolean{
if (name == ""){
return (false);
};
name = name.toLowerCase();
if (_sourcesEngine[name] != undefined){
return (true);
};
return (false);
}
public function clearIgnoredKeywords():void{
_ignoredKeywords = [];
_ignoredKeywordsCache = {};
}
public function addSource(engine:String, keyword:String):void{
var orgref:OrganicReferrer = new OrganicReferrer(engine, keyword);
if (_sourcesCache[orgref.toString()] == undefined){
_sources.push(orgref);
_sourcesCache[orgref.toString()] = (_sources.length - 1);
if (_sourcesEngine[orgref.engine] == undefined){
_sourcesEngine[orgref.engine] = [(_sources.length - 1)];
} else {
_sourcesEngine[orgref.engine].push((_sources.length - 1));
};
} else {
if (throwErrors){
throw (new Error((orgref.toString() + " already exists, we don't add it.")));
};
};
}
public function clearEngines():void{
_sources = [];
_sourcesCache = [];
_sourcesEngine = [];
}
public function get ignoredReferralsCount():int{
return (_ignoredReferrals.length);
}
public function addIgnoredReferral(referrer:String):void{
if (_ignoredReferralsCache[referrer] == undefined){
_ignoredReferrals.push(referrer);
_ignoredReferralsCache[referrer] = (_ignoredReferrals.length - 1);
} else {
if (throwErrors){
throw (new Error((("\"" + referrer) + "\" already exists, we don't add it.")));
};
};
}
public function clearIgnoredReferrals():void{
_ignoredReferrals = [];
_ignoredReferralsCache = {};
}
public function getReferrerByName(name:String):OrganicReferrer{
var index:int;
if (match(name)){
index = _sourcesEngine[name][0];
return (_sources[index]);
};
return (null);
}
public function addIgnoredKeyword(keyword:String):void{
if (_ignoredKeywordsCache[keyword] == undefined){
_ignoredKeywords.push(keyword);
_ignoredKeywordsCache[keyword] = (_ignoredKeywords.length - 1);
} else {
if (throwErrors){
throw (new Error((("\"" + keyword) + "\" already exists, we don't add it.")));
};
};
}
public function get sources():Array{
return (_sources);
}
public static function getKeywordValueFromPath(keyword:String, path:String):String{
var value:String;
var vars:Variables;
if (path.indexOf((keyword + "=")) > -1){
if (path.charAt(0) == "?"){
path = path.substr(1);
};
path = path.split("+").join("%20");
vars = new Variables(path);
value = vars[keyword];
};
return (value);
}
}
}//package com.google.analytics.core
Section 92
//OrganicReferrer (com.google.analytics.core.OrganicReferrer)
package com.google.analytics.core {
public class OrganicReferrer {
private var _engine:String;
private var _keyword:String;
public function OrganicReferrer(engine:String, keyword:String){
super();
this.engine = engine;
this.keyword = keyword;
}
public function get keyword():String{
return (_keyword);
}
public function get engine():String{
return (_engine);
}
public function set engine(value:String):void{
_engine = value.toLowerCase();
}
public function toString():String{
return (((engine + "?") + keyword));
}
public function set keyword(value:String):void{
_keyword = value.toLowerCase();
}
}
}//package com.google.analytics.core
Section 93
//RequestObject (com.google.analytics.core.RequestObject)
package com.google.analytics.core {
import flash.net.*;
import flash.utils.*;
public class RequestObject {
public var start:int;
public var end:int;
public var request:URLRequest;
public function RequestObject(request:URLRequest){
super();
start = getTimer();
this.request = request;
}
public function hasCompleted():Boolean{
return ((end > 0));
}
public function toString():String{
var data:Array = [];
data.push((("duration: " + duration) + "ms"));
data.push(("url: " + request.url));
return ((("{ " + data.join(", ")) + " }"));
}
public function complete():void{
end = getTimer();
}
public function get duration():int{
if (!hasCompleted()){
return (0);
};
return ((end - start));
}
}
}//package com.google.analytics.core
Section 94
//ServerOperationMode (com.google.analytics.core.ServerOperationMode)
package com.google.analytics.core {
public class ServerOperationMode {
private var _value:int;
private var _name:String;
public static const both:ServerOperationMode = new ServerOperationMode(2, "both");
;
public static const remote:ServerOperationMode = new ServerOperationMode(1, "remote");
;
public static const local:ServerOperationMode = new ServerOperationMode(0, "local");
;
public function ServerOperationMode(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.core
Section 95
//TrackerCache (com.google.analytics.core.TrackerCache)
package com.google.analytics.core {
import com.google.analytics.v4.*;
import flash.errors.*;
public class TrackerCache implements GoogleAnalyticsAPI {
public var tracker:GoogleAnalyticsAPI;
private var _ar:Array;
public static var CACHE_THROW_ERROR:Boolean;
public function TrackerCache(tracker:GoogleAnalyticsAPI=null){
super();
this.tracker = tracker;
_ar = [];
}
public function size():uint{
return (_ar.length);
}
public function flush():void{
var o:Object;
var name:String;
var args:Array;
var l:int;
var i:int;
if (tracker == null){
return;
};
if (size() > 0){
l = _ar.length;
while (i < l) {
o = _ar.shift();
name = (o.name as String);
args = (o.args as Array);
if (((!((name == null))) && ((name in tracker)))){
(tracker[name] as Function).apply(tracker, args);
};
i++;
};
};
}
public function enqueue(name:String, ... _args):Boolean{
if (name == null){
return (false);
};
_ar.push({name:name, args:_args});
return (true);
}
public function link(targetUrl:String, useHash:Boolean=false):void{
enqueue("link", targetUrl, useHash);
}
public function addOrganic(newOrganicEngine:String, newOrganicKeyword:String):void{
enqueue("addOrganic", newOrganicEngine, newOrganicKeyword);
}
public function setAllowLinker(enable:Boolean):void{
enqueue("setAllowLinker", enable);
}
public function trackEvent(category:String, action:String, label:String=null, value:Number=NaN):Boolean{
enqueue("trackEvent", category, action, label, value);
return (true);
}
public function getLinkerUrl(url:String="", useHash:Boolean=false):String{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getLinkerUrl' method for the moment."));
};
return ("");
}
public function getClientInfo():Boolean{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getClientInfo' method for the moment."));
};
return (false);
}
public function trackTrans():void{
enqueue("trackTrans");
}
public function trackPageview(pageURL:String=""):void{
enqueue("trackPageview", pageURL);
}
public function setClientInfo(enable:Boolean):void{
enqueue("setClientInfo", enable);
}
public function linkByPost(formObject:Object, useHash:Boolean=false):void{
enqueue("linkByPost", formObject, useHash);
}
public function setCookieTimeout(newDefaultTimeout:int):void{
enqueue("setCookieTimeout", newDefaultTimeout);
}
public function isEmpty():Boolean{
return ((_ar.length == 0));
}
public function getDetectTitle():Boolean{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getDetectTitle' method for the moment."));
};
return (false);
}
public function resetSession():void{
enqueue("resetSession");
}
public function setDetectFlash(enable:Boolean):void{
enqueue("setDetectFlash", enable);
}
public function clear():void{
_ar = [];
}
public function setCampNameKey(newCampNameKey:String):void{
enqueue("setCampNameKey", newCampNameKey);
}
public function addItem(item:String, sku:String, name:String, category:String, price:Number, quantity:int):void{
enqueue("addItem", item, sku, name, category, price, quantity);
}
public function createEventTracker(objName:String):EventTracker{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'createEventTracker' method for the moment."));
};
return (null);
}
public function clearIgnoredOrganic():void{
enqueue("clearIgnoredOrganic");
}
public function setVar(newVal:String):void{
enqueue("setVar", newVal);
}
public function setDomainName(newDomainName:String):void{
enqueue("setDomainName", newDomainName);
}
public function setCampSourceKey(newCampSrcKey:String):void{
enqueue("setCampSourceKey", newCampSrcKey);
}
public function addTrans(orderId:String, affiliation:String, total:Number, tax:Number, shipping:Number, city:String, state:String, country:String):void{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'addTrans' method for the moment."));
};
}
public function setCampContentKey(newCampContentKey:String):void{
enqueue("setCampContentKey", newCampContentKey);
}
public function setLocalServerMode():void{
enqueue("setLocalServerMode");
}
public function getLocalGifPath():String{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getLocalGifPath' method for the moment."));
};
return ("");
}
public function setAllowAnchor(enable:Boolean):void{
enqueue("setAllowAnchor", enable);
}
public function clearIgnoredRef():void{
enqueue("clearIgnoredRef");
}
public function setLocalGifPath(newLocalGifPath:String):void{
enqueue("setLocalGifPath", newLocalGifPath);
}
public function getVersion():String{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getVersion' method for the moment."));
};
return ("");
}
public function setCookiePath(newCookiePath:String):void{
enqueue("setCookiePath", newCookiePath);
}
public function setSampleRate(newRate:Number):void{
enqueue("setSampleRate", newRate);
}
public function setDetectTitle(enable:Boolean):void{
enqueue("setDetectTitle", enable);
}
public function setAllowHash(enable:Boolean):void{
enqueue("setAllowHash", enable);
}
public function addIgnoredOrganic(newIgnoredOrganicKeyword:String):void{
enqueue("addIgnoredOrganic", newIgnoredOrganicKeyword);
}
public function setCampNOKey(newCampNOKey:String):void{
enqueue("setCampNOKey", newCampNOKey);
}
public function getServiceMode():ServerOperationMode{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getServiceMode' method for the moment."));
};
return (null);
}
public function setLocalRemoteServerMode():void{
enqueue("setLocalRemoteServerMode");
}
public function cookiePathCopy(newPath:String):void{
enqueue("cookiePathCopy", newPath);
}
public function getDetectFlash():Boolean{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getDetectFlash' method for the moment."));
};
return (false);
}
public function setCampaignTrack(enable:Boolean):void{
enqueue("setCampaignTrack", enable);
}
public function clearOrganic():void{
enqueue("clearOrganic");
}
public function setCampTermKey(newCampTermKey:String):void{
enqueue("setCampTermKey", newCampTermKey);
}
public function addIgnoredRef(newIgnoredReferrer:String):void{
enqueue("addIgnoredRef", newIgnoredReferrer);
}
public function setCampMediumKey(newCampMedKey:String):void{
enqueue("setCampMediumKey", newCampMedKey);
}
public function setSessionTimeout(newTimeout:int):void{
enqueue("setSessionTimeout", newTimeout);
}
public function setRemoteServerMode():void{
enqueue("setRemoteServerMode");
}
public function element(){
return (_ar[0]);
}
public function getAccount():String{
if (CACHE_THROW_ERROR){
throw (new IllegalOperationError("The tracker is not ready and you can use the 'getAccount' method for the moment."));
};
return ("");
}
}
}//package com.google.analytics.core
Section 96
//TrackerMode (com.google.analytics.core.TrackerMode)
package com.google.analytics.core {
public class TrackerMode {
public static const BRIDGE:String = "Bridge";
public static const AS3:String = "AS3";
public function TrackerMode(){
super();
}
}
}//package com.google.analytics.core
Section 97
//Utils (com.google.analytics.core.Utils)
package com.google.analytics.core {
public class Utils {
public function Utils(){
super();
}
public static function trim(raw:String, everything:Boolean=false):String{
var i:int;
var iLeft:int;
var iRight:int;
if (raw == ""){
return ("");
};
var whitespaces:Array = [" ", "\n", "\r", "\t"];
var str:String = raw;
if (everything){
i = 0;
while ((((i < whitespaces.length)) && ((str.indexOf(whitespaces[i]) > -1)))) {
str = str.split(whitespaces[i]).join("");
i++;
};
} else {
iLeft = 0;
while ((((iLeft < str.length)) && ((whitespaces.indexOf(str.charAt(iLeft)) > -1)))) {
iLeft++;
};
str = str.substr(iLeft);
iRight = (str.length - 1);
while ((((iRight >= 0)) && ((whitespaces.indexOf(str.charAt(iRight)) > -1)))) {
iRight--;
};
str = str.substring(0, (iRight + 1));
};
return (str);
}
public static function generateHash(input:String):int{
var pos:int;
var current:int;
var hash = 1;
var leftMost7:int;
if (((!((input == null))) && (!((input == ""))))){
hash = 0;
pos = (input.length - 1);
while (pos >= 0) {
current = input.charCodeAt(pos);
hash = ((((hash << 6) & 268435455) + current) + (current << 14));
leftMost7 = (hash & 266338304);
if (leftMost7 != 0){
hash = (hash ^ (leftMost7 >> 21));
};
pos--;
};
};
return (hash);
}
public static function generate32bitRandom():int{
return (Math.round((Math.random() * 2147483647)));
}
public static function validateAccount(account:String):Boolean{
var rel:RegExp = /^UA-[0-9]*-[0-9]*$/;
return (rel.test(account));
}
}
}//package com.google.analytics.core
Section 98
//Cookie (com.google.analytics.data.Cookie)
package com.google.analytics.data {
public interface Cookie {
function fromSharedObject(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\data;Cookie.as:Object):void;
function toURLString():String;
function get creation():Date;
function toSharedObject():Object;
function isExpired():Boolean;
function set creation(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\data;Cookie.as:Date):void;
function set expiration(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\data;Cookie.as:Date):void;
function get expiration():Date;
}
}//package com.google.analytics.data
Section 99
//UTMA (com.google.analytics.data.UTMA)
package com.google.analytics.data {
import com.google.analytics.utils.*;
public class UTMA extends UTMCookie {
private var _sessionId:Number;
private var _domainHash:Number;
private var _firstTime:Number;
private var _currentTime:Number;
private var _lastTime:Number;
private var _sessionCount:Number;
public function UTMA(domainHash:Number=NaN, sessionId:Number=NaN, firstTime:Number=NaN, lastTime:Number=NaN, currentTime:Number=NaN, sessionCount:Number=NaN){
super("utma", "__utma", ["domainHash", "sessionId", "firstTime", "lastTime", "currentTime", "sessionCount"], (Timespan.twoyears * 1000));
this.domainHash = domainHash;
this.sessionId = sessionId;
this.firstTime = firstTime;
this.lastTime = lastTime;
this.currentTime = currentTime;
this.sessionCount = sessionCount;
}
public function get lastTime():Number{
return (_lastTime);
}
public function set lastTime(value:Number):void{
_lastTime = value;
update();
}
public function set currentTime(value:Number):void{
_currentTime = value;
update();
}
public function get sessionId():Number{
return (_sessionId);
}
public function get sessionCount():Number{
return (_sessionCount);
}
public function get firstTime():Number{
return (_firstTime);
}
public function get currentTime():Number{
return (_currentTime);
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
public function set sessionId(value:Number):void{
_sessionId = value;
update();
}
public function set sessionCount(value:Number):void{
_sessionCount = value;
update();
}
public function get domainHash():Number{
return (_domainHash);
}
public function set firstTime(value:Number):void{
_firstTime = value;
update();
}
}
}//package com.google.analytics.data
Section 100
//UTMB (com.google.analytics.data.UTMB)
package com.google.analytics.data {
import com.google.analytics.utils.*;
public class UTMB extends UTMCookie {
private var _trackCount:Number;
private var _lastTime:Number;
private var _domainHash:Number;
private var _token:Number;
public static var defaultTimespan:Number = Timespan.thirtyminutes;
public function UTMB(domainHash:Number=NaN, trackCount:Number=NaN, token:Number=NaN, lastTime:Number=NaN){
super("utmb", "__utmb", ["domainHash", "trackCount", "token", "lastTime"], (defaultTimespan * 1000));
this.domainHash = domainHash;
this.trackCount = trackCount;
this.token = token;
this.lastTime = lastTime;
}
public function set token(value:Number):void{
_token = value;
update();
}
public function set trackCount(value:Number):void{
_trackCount = value;
update();
}
public function get lastTime():Number{
return (_lastTime);
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
public function set lastTime(value:Number):void{
_lastTime = value;
update();
}
public function get domainHash():Number{
return (_domainHash);
}
public function get token():Number{
return (_token);
}
public function get trackCount():Number{
return (_trackCount);
}
}
}//package com.google.analytics.data
Section 101
//UTMC (com.google.analytics.data.UTMC)
package com.google.analytics.data {
public class UTMC extends UTMCookie {
private var _domainHash:Number;
public function UTMC(domainHash:Number=NaN){
super("utmc", "__utmc", ["domainHash"]);
this.domainHash = domainHash;
}
public function get domainHash():Number{
return (_domainHash);
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
}
}//package com.google.analytics.data
Section 102
//UTMCookie (com.google.analytics.data.UTMCookie)
package com.google.analytics.data {
import com.google.analytics.core.*;
public class UTMCookie implements Cookie {
protected var inURL:String;
protected var name:String;
private var _creation:Date;
private var _expiration:Date;
public var proxy:Buffer;
protected var fields:Array;
private var _timespan:Number;
public function UTMCookie(name:String, inURL:String, fields:Array, timespan:Number=0){
super();
this.name = name;
this.inURL = inURL;
this.fields = fields;
_timestamp(timespan);
}
public function isEmpty():Boolean{
var field:String;
var empty:int;
var i:int;
while (i < fields.length) {
field = fields[i];
if ((((this[field] is Number)) && (isNaN(this[field])))){
empty++;
} else {
if ((((this[field] is String)) && ((this[field] == "")))){
empty++;
};
};
i++;
};
if (empty == fields.length){
return (true);
};
return (false);
}
public function resetTimestamp(timespan:Number=NaN):void{
if (!isNaN(timespan)){
_timespan = timespan;
};
_creation = null;
_expiration = null;
_timestamp(_timespan);
}
protected function update():void{
resetTimestamp();
if (proxy){
proxy.update(name, toSharedObject());
};
}
public function reset():void{
var field:String;
var i:int;
while (i < fields.length) {
field = fields[i];
if ((this[field] is Number)){
this[field] = NaN;
} else {
if ((this[field] is String)){
this[field] = "";
};
};
i++;
};
resetTimestamp();
update();
}
public function fromSharedObject(data:Object):void{
var field:String;
var len:int = fields.length;
var i:int;
while (i < len) {
field = fields[i];
if (data[field]){
this[field] = data[field];
};
i++;
};
if (data.creation){
this.creation = data.creation;
};
if (data.expiration){
this.expiration = data.expiration;
};
}
private function _timestamp(timespan:Number):void{
creation = new Date();
_timespan = timespan;
if (timespan > 0){
expiration = new Date((creation.valueOf() + timespan));
};
}
public function isExpired():Boolean{
var current:Date = new Date();
var diff:Number = (expiration.valueOf() - current.valueOf());
if (diff <= 0){
return (true);
};
return (false);
}
public function set expiration(value:Date):void{
_expiration = value;
}
public function get creation():Date{
return (_creation);
}
public function valueOf():String{
var field:String;
var value:*;
var testData:Array;
var data:Array = [];
var testOut:String = "";
var i:int;
while (i < fields.length) {
field = fields[i];
value = this[field];
if ((value is String)){
if (value == ""){
value = "-";
data.push(value);
} else {
data.push(value);
};
} else {
if ((value is Number)){
if (value == 0){
data.push(value);
} else {
if (isNaN(value)){
value = "-";
data.push(value);
} else {
data.push(value);
};
};
};
};
i++;
};
if (isEmpty()){
return ("-");
};
return (("" + data.join(".")));
}
public function toURLString():String{
return (((inURL + "=") + valueOf()));
}
public function get expiration():Date{
if (_expiration){
return (_expiration);
};
return (new Date((new Date().valueOf() + 1000)));
}
public function toSharedObject():Object{
var field:String;
var value:*;
var data:Object = {};
var i:int;
for (;i < fields.length;i++) {
field = fields[i];
value = this[field];
if ((value is String)){
data[field] = value;
} else {
if (value == 0){
data[field] = value;
} else {
if (isNaN(value)){
continue;
} else {
data[field] = value;
};
};
};
};
data.creation = creation;
data.expiration = expiration;
return (data);
}
public function toString(showTimestamp:Boolean=false):String{
var field:String;
var value:*;
var data:Array = [];
var len:int = fields.length;
var i:int;
for (;i < len;i++) {
field = fields[i];
value = this[field];
if ((value is String)){
data.push((((field + ": \"") + value) + "\""));
} else {
if (value == 0){
data.push(((field + ": ") + value));
} else {
if (isNaN(value)){
continue;
} else {
data.push(((field + ": ") + value));
};
};
};
};
var str = (((name.toUpperCase() + " {") + data.join(", ")) + "}");
if (showTimestamp){
str = (str + (((" creation:" + creation) + ", expiration:") + expiration));
};
return (str);
}
public function set creation(value:Date):void{
_creation = value;
}
}
}//package com.google.analytics.data
Section 103
//UTMK (com.google.analytics.data.UTMK)
package com.google.analytics.data {
public class UTMK extends UTMCookie {
private var _hash:Number;
public function UTMK(hash:Number=NaN){
super("utmk", "__utmk", ["hash"]);
this.hash = hash;
}
public function set hash(value:Number):void{
_hash = value;
update();
}
public function get hash():Number{
return (_hash);
}
}
}//package com.google.analytics.data
Section 104
//UTMV (com.google.analytics.data.UTMV)
package com.google.analytics.data {
import com.google.analytics.utils.*;
public class UTMV extends UTMCookie {
private var _domainHash:Number;
private var _value:String;
public function UTMV(domainHash:Number=NaN, value:String=""){
super("utmv", "__utmv", ["domainHash", "value"], (Timespan.twoyears * 1000));
this.domainHash = domainHash;
this.value = value;
}
public function get value():String{
return (_value);
}
public function get domainHash():Number{
return (_domainHash);
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
public function set value(value:String):void{
_value = value;
update();
}
}
}//package com.google.analytics.data
Section 105
//UTMX (com.google.analytics.data.UTMX)
package com.google.analytics.data {
public class UTMX extends UTMCookie {
private var _value:String;
public function UTMX(){
super("utmx", "__utmx", ["value"], 0);
_value = "-";
}
public function get value():String{
return (_value);
}
public function set value(value:String):void{
_value = value;
}
}
}//package com.google.analytics.data
Section 106
//UTMZ (com.google.analytics.data.UTMZ)
package com.google.analytics.data {
import com.google.analytics.utils.*;
public class UTMZ extends UTMCookie {
private var _campaignTracking:String;
private var _campaignCreation:Number;
private var _responseCount:Number;
private var _domainHash:Number;
private var _campaignSessions:Number;
public static var defaultTimespan:Number = Timespan.sixmonths;
public function UTMZ(domainHash:Number=NaN, campaignCreation:Number=NaN, campaignSessions:Number=NaN, responseCount:Number=NaN, campaignTracking:String=""){
super("utmz", "__utmz", ["domainHash", "campaignCreation", "campaignSessions", "responseCount", "campaignTracking"], (defaultTimespan * 1000));
this.domainHash = domainHash;
this.campaignCreation = campaignCreation;
this.campaignSessions = campaignSessions;
this.responseCount = responseCount;
this.campaignTracking = campaignTracking;
}
public function set responseCount(value:Number):void{
_responseCount = value;
update();
}
public function set domainHash(value:Number):void{
_domainHash = value;
update();
}
public function set campaignCreation(value:Number):void{
_campaignCreation = value;
update();
}
public function get campaignTracking():String{
return (_campaignTracking);
}
public function get campaignSessions():Number{
return (_campaignSessions);
}
public function get domainHash():Number{
return (_domainHash);
}
public function get responseCount():Number{
return (_responseCount);
}
public function get campaignCreation():Number{
return (_campaignCreation);
}
public function set campaignSessions(value:Number):void{
_campaignSessions = value;
update();
}
public function set campaignTracking(value:String):void{
_campaignTracking = value;
update();
}
}
}//package com.google.analytics.data
Section 107
//X10 (com.google.analytics.data.X10)
package com.google.analytics.data {
public class X10 {
private var _delimEnd:String;// = ")"
private var _minimum:int;
private var _delimSet:String;// = "*"
private var _escapeChar:String;// = "'"
private var _delimBegin:String;// = "("
private var _delimNumValue:String;// = "!"
private var _key:String;// = "k"
private var _set:Array;
private var _hasData:int;
private var _escapeCharMap:Object;
private var _projectData:Object;
private var _value:String;// = "v"
public function X10(){
_set = [_key, _value];
super();
_projectData = {};
_escapeCharMap = {};
_escapeCharMap[_escapeChar] = "'0";
_escapeCharMap[_delimEnd] = "'1";
_escapeCharMap[_delimSet] = "'2";
_escapeCharMap[_delimNumValue] = "'3";
_minimum = 1;
}
private function _setInternal(projectId:Number, type:String, num:Number, value:String):void{
if (!hasProject(projectId)){
_projectData[projectId] = {};
};
if (_projectData[projectId][type] == undefined){
_projectData[projectId][type] = [];
};
_projectData[projectId][type][num] = value;
_hasData = (_hasData + 1);
}
private function _renderProject(project:Object):String{
var i:int;
var data:Array;
var result:String = "";
var needTypeQualifier:Boolean;
var l:int = _set.length;
i = 0;
while (i < l) {
data = project[_set[i]];
if (data){
if (needTypeQualifier){
result = (result + _set[i]);
};
result = (result + _renderDataType(data));
needTypeQualifier = false;
} else {
needTypeQualifier = true;
};
i++;
};
return (result);
}
public function hasProject(projectId:Number):Boolean{
return (_projectData[projectId]);
}
public function clearKey(projectId:Number):void{
_clearInternal(projectId, _key);
}
private function _renderDataType(data:Array):String{
var str:String;
var i:int;
var result:Array = [];
i = 0;
while (i < data.length) {
if (data[i] != undefined){
str = "";
if (((!((i == _minimum))) && ((data[(i - 1)] == undefined)))){
str = (str + i.toString());
str = (str + _delimNumValue);
};
str = (str + _escapeExtensibleValue(data[i]));
result.push(str);
};
i++;
};
return (((_delimBegin + result.join(_delimSet)) + _delimEnd));
}
public function getKey(projectId:Number, num:Number):String{
return ((_getInternal(projectId, _key, num) as String));
}
public function hasData():Boolean{
return ((_hasData > 0));
}
public function renderMergedUrlString(extObject:X10=null):String{
var projectId:String;
if (!extObject){
return (renderUrlString());
};
var result:Array = [extObject.renderUrlString()];
for (projectId in _projectData) {
if (((hasProject(Number(projectId))) && (!(extObject.hasProject(Number(projectId)))))){
result.push((projectId + _renderProject(_projectData[projectId])));
};
};
return (result.join(""));
}
public function setValue(projectId:Number, num:Number, value:Number):Boolean{
if (((((!((Math.round(value) == value))) || (isNaN(value)))) || ((value == Infinity)))){
return (false);
};
_setInternal(projectId, _value, num, value.toString());
return (true);
}
public function renderUrlString():String{
var projectId:String;
var result:Array = [];
for (projectId in _projectData) {
if (hasProject(Number(projectId))){
result.push((projectId + _renderProject(_projectData[projectId])));
};
};
return (result.join(""));
}
private function _getInternal(projectId:Number, type:String, num:Number):Object{
if (((hasProject(projectId)) && (!((_projectData[projectId][type] == undefined))))){
return (_projectData[projectId][type][num]);
};
return (undefined);
}
public function setKey(projectId:Number, num:Number, value:String):Boolean{
_setInternal(projectId, _key, num, value);
return (true);
}
public function clearValue(projectId:Number):void{
_clearInternal(projectId, _value);
}
private function _clearInternal(projectId:Number, type:String):void{
var isEmpty:Boolean;
var i:int;
var l:int;
if (((hasProject(projectId)) && (!((_projectData[projectId][type] == undefined))))){
_projectData[projectId][type] = undefined;
isEmpty = true;
l = _set.length;
i = 0;
while (i < l) {
if (_projectData[projectId][_set[i]] != undefined){
isEmpty = false;
break;
};
i++;
};
if (isEmpty){
_projectData[projectId] = undefined;
_hasData = (_hasData - 1);
};
};
}
public function getValue(projectId:Number, num:Number){
var value:* = _getInternal(projectId, _value, num);
if (value == null){
return (null);
};
return (Number(value));
}
private function _escapeExtensibleValue(value:String):String{
var i:int;
var c:String;
var escaped:String;
var result:String = "";
i = 0;
while (i < value.length) {
c = value.charAt(i);
escaped = _escapeCharMap[c];
if (escaped){
result = (result + escaped);
} else {
result = (result + c);
};
i++;
};
return (result);
}
}
}//package com.google.analytics.data
Section 108
//_Style (com.google.analytics.debug._Style)
package com.google.analytics.debug {
import flash.net.*;
import flash.text.*;
public class _Style {
public var failureColor:uint;
public var borderColor:uint;
public var backgroundColor:uint;
private var _sheet:StyleSheet;
public var roundedCorner:uint;
public var warningColor:uint;
public var infoColor:uint;
public var alertColor:uint;
public var successColor:uint;
private var _loader:URLLoader;
private var _defaultSheet:String;
public function _Style(){
super();
_sheet = new StyleSheet();
_loader = new URLLoader();
_init();
}
private function _parseSheet(data:String):void{
_sheet.parseCSS(data);
}
public function get sheet():StyleSheet{
return (_sheet);
}
private function _init():void{
_defaultSheet = "";
_defaultSheet = (_defaultSheet + "a{text-decoration: underline;}\n");
_defaultSheet = (_defaultSheet + ".uiLabel{color: #000000;font-family: Arial;font-size: 12;margin-left: 2;margin-right: 2;}\n");
_defaultSheet = (_defaultSheet + ".uiWarning{color: #ffffff;font-family: Arial;font-size: 14;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiAlert{color: #ffffff;font-family: Arial;font-size: 14;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiInfo{color: #000000;font-family: Arial;font-size: 14;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiSuccess{color: #ffffff;font-family: Arial;font-size: 12;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiFailure{color: #ffffff;font-family: Arial;font-size: 12;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiAlertAction{color: #ffffff;text-align: center;font-family: Arial;font-size: 12;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + ".uiAlertTitle{color: #ffffff;font-family: Arial;font-size: 16;font-weight: bold;margin-left: 6;margin-right: 6;}\n");
_defaultSheet = (_defaultSheet + "\n");
roundedCorner = 6;
backgroundColor = 0xCCCCCC;
borderColor = 0x555555;
infoColor = 16777113;
alertColor = 0xFFCC00;
warningColor = 0xCC0000;
successColor = 0xFF00;
failureColor = 0xFF0000;
_parseSheet(_defaultSheet);
}
}
}//package com.google.analytics.debug
Section 109
//Alert (com.google.analytics.debug.Alert)
package com.google.analytics.debug {
import flash.events.*;
public class Alert extends Label {
public var autoClose:Boolean;// = true
public var actionOnNextLine:Boolean;// = true
private var _actions:Array;
public function Alert(text:String, actions:Array, tag:String="uiAlert", color:uint=0, alignement:Align=null, stickToEdge:Boolean=false, actionOnNextLine:Boolean=true){
if (color == 0){
color = Style.alertColor;
};
if (alignement == null){
alignement = Align.center;
};
super(text, tag, color, alignement, stickToEdge);
this.selectable = true;
super.mouseChildren = true;
this.buttonMode = true;
this.mouseEnabled = true;
this.useHandCursor = true;
this.actionOnNextLine = actionOnNextLine;
_actions = [];
var i:int;
while (i < actions.length) {
actions[i].container = this;
_actions.push(actions[i]);
i++;
};
}
private function _defineActions():void{
var action:AlertAction;
var str:String = "";
if (actionOnNextLine){
str = (str + "\n");
} else {
str = (str + " |");
};
str = (str + " ");
var actions:Array = [];
var i:int;
while (i < _actions.length) {
action = _actions[i];
actions.push((((("<a href=\"event:" + action.activator) + "\">") + action.name) + "</a>"));
i++;
};
str = (str + actions.join(" | "));
appendText(str, "uiAlertAction");
}
protected function isValidAction(action:String):Boolean{
var i:int;
while (i < _actions.length) {
if (action == _actions[i].activator){
return (true);
};
i++;
};
return (false);
}
override protected function layout():void{
super.layout();
_defineActions();
}
protected function getAction(name:String):AlertAction{
var i:int;
while (i < _actions.length) {
if (name == _actions[i].activator){
return (_actions[i]);
};
i++;
};
return (null);
}
protected function spaces(num:int):String{
var str:String = "";
var spc:String = " ";
var i:int;
while (i < (num + 1)) {
str = (str + spc);
i++;
};
return (str);
}
override public function onLink(event:TextEvent):void{
var action:AlertAction;
if (isValidAction(event.text)){
action = getAction(event.text);
if (action){
action.execute();
};
};
if (autoClose){
close();
};
}
public function close():void{
if (parent != null){
parent.removeChild(this);
};
}
}
}//package com.google.analytics.debug
Section 110
//AlertAction (com.google.analytics.debug.AlertAction)
package com.google.analytics.debug {
public class AlertAction {
public var container:Alert;
private var _callback;
public var activator:String;
public var name:String;
public function AlertAction(name:String, activator:String, callback){
super();
this.name = name;
this.activator = activator;
_callback = callback;
}
public function execute():void{
if (_callback){
if ((_callback is Function)){
(_callback as Function)();
} else {
if ((_callback is String)){
var _local1 = container;
_local1[_callback]();
};
};
};
}
}
}//package com.google.analytics.debug
Section 111
//Align (com.google.analytics.debug.Align)
package com.google.analytics.debug {
public class Align {
private var _value:int;
private var _name:String;
public static const bottomRight:Align = new Align(18, "bottomRight");
;
public static const right:Align = new Align(16, "right");
;
public static const left:Align = new Align(32, "left");
;
public static const topRight:Align = new Align(17, "topRight");
;
public static const bottom:Align = new Align(2, "bottom");
;
public static const bottomLeft:Align = new Align(34, "bottomLeft");
;
public static const topLeft:Align = new Align(33, "topLeft");
;
public static const center:Align = new Align(0x0100, "center");
;
public static const none:Align = new Align(0, "none");
;
public static const top:Align = new Align(1, "top");
;
public function Align(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.debug
Section 112
//Background (com.google.analytics.debug.Background)
package com.google.analytics.debug {
import flash.display.*;
public class Background {
public function Background(){
super();
}
public static function drawRounded(target, g:Graphics, width:uint=0, height:uint=0):void{
var W:uint;
var H:uint;
var R:uint = Style.roundedCorner;
if ((((width > 0)) && ((height > 0)))){
W = width;
H = height;
} else {
W = target.width;
H = target.height;
};
if (((target.stickToEdge) && (!((target.alignement == Align.none))))){
switch (target.alignement){
case Align.top:
g.drawRoundRectComplex(0, 0, W, H, 0, 0, R, R);
break;
case Align.topLeft:
g.drawRoundRectComplex(0, 0, W, H, 0, 0, 0, R);
break;
case Align.topRight:
g.drawRoundRectComplex(0, 0, W, H, 0, 0, R, 0);
break;
case Align.bottom:
g.drawRoundRectComplex(0, 0, W, H, R, R, 0, 0);
break;
case Align.bottomLeft:
g.drawRoundRectComplex(0, 0, W, H, 0, R, 0, 0);
break;
case Align.bottomRight:
g.drawRoundRectComplex(0, 0, W, H, R, 0, 0, 0);
break;
case Align.left:
g.drawRoundRectComplex(0, 0, W, H, 0, R, 0, R);
break;
case Align.right:
g.drawRoundRectComplex(0, 0, W, H, R, 0, R, 0);
break;
case Align.center:
g.drawRoundRect(0, 0, W, H, R, R);
break;
};
} else {
g.drawRoundRect(0, 0, W, H, R, R);
};
}
}
}//package com.google.analytics.debug
Section 113
//Debug (com.google.analytics.debug.Debug)
package com.google.analytics.debug {
import flash.events.*;
import flash.ui.*;
public class Debug extends Label {
private var _lines:Array;
private var _preferredForcedWidth:uint;// = 540
private var _linediff:int;// = 0
public var maxLines:uint;// = 16
public static var count:uint;
public function Debug(color:uint=0, alignement:Align=null, stickToEdge:Boolean=false){
if (alignement == null){
alignement = Align.bottom;
};
super("", "uiLabel", color, alignement, stickToEdge);
this.name = ("Debug" + count++);
_lines = [];
selectable = true;
addEventListener(KeyboardEvent.KEY_DOWN, onKey);
}
public function writeBold(message:String):void{
write(message, true);
}
private function _getLinesToDisplay(direction:int=0):Array{
var lines:Array;
var start:uint;
var end:uint;
if ((_lines.length - 1) > maxLines){
if ((_linediff <= 0)){
_linediff = (_linediff + direction);
} else {
if ((((_linediff > 0)) && ((direction < 0)))){
_linediff = (_linediff + direction);
};
};
start = ((_lines.length - maxLines) + _linediff);
end = (start + maxLines);
lines = _lines.slice(start, end);
} else {
lines = _lines;
};
return (lines);
}
private function onKey(event:KeyboardEvent=null):void{
var lines:Array;
switch (event.keyCode){
case Keyboard.DOWN:
lines = _getLinesToDisplay(1);
break;
case Keyboard.UP:
lines = _getLinesToDisplay(-1);
break;
default:
lines = null;
};
if (lines == null){
return;
};
text = lines.join("\n");
}
override public function get forcedWidth():uint{
if (this.parent){
if (UISprite(this.parent).forcedWidth > _preferredForcedWidth){
return (_preferredForcedWidth);
};
return (UISprite(this.parent).forcedWidth);
} else {
};
return (!NULL!);
}
public function write(message:String, bold:Boolean=false):void{
var inputLines:Array;
if (message.indexOf("") > -1){
inputLines = message.split("\n");
} else {
inputLines = [message];
};
var pre:String = "";
var post:String = "";
if (bold){
pre = "<b>";
post = "</b>";
};
var i:int;
while (i < inputLines.length) {
_lines.push(((pre + inputLines[i]) + post));
i++;
};
var lines:Array = _getLinesToDisplay();
text = lines.join("\n");
}
public function close():void{
dispose();
}
override protected function dispose():void{
removeEventListener(KeyboardEvent.KEY_DOWN, onKey);
super.dispose();
}
}
}//package com.google.analytics.debug
Section 114
//DebugConfiguration (com.google.analytics.debug.DebugConfiguration)
package com.google.analytics.debug {
import com.google.analytics.core.*;
import flash.net.*;
import flash.utils.*;
public class DebugConfiguration {
public var showHideKey:Number;// = 32
private var _mode:VisualDebugMode;
private var _verbose:Boolean;// = false
public var destroyKey:Number;// = 8
public var GIFRequests:Boolean;// = false
public var showInfos:Boolean;// = true
public var infoTimeout:Number;// = 1000
public var minimizedOnStart:Boolean;// = false
private var _active:Boolean;// = false
public var traceOutput:Boolean;// = false
public var layout:ILayout;
public var warningTimeout:Number;// = 1500
public var javascript:Boolean;// = false
public var showWarnings:Boolean;// = true
private var _visualInitialized:Boolean;// = false
public function DebugConfiguration(){
_mode = VisualDebugMode.basic;
super();
}
public function get verbose():Boolean{
return (_verbose);
}
public function set verbose(value:Boolean):void{
_verbose = value;
}
public function set mode(value):void{
if ((value is String)){
switch (value){
case "geek":
value = VisualDebugMode.geek;
break;
case "advanced":
value = VisualDebugMode.advanced;
break;
case "basic":
default:
value = VisualDebugMode.basic;
};
};
_mode = value;
}
public function success(message:String):void{
if (layout){
layout.createSuccessAlert(message);
};
if (traceOutput){
trace((("[+] " + message) + " !!"));
};
}
public function get active():Boolean{
return (_active);
}
private function _initializeVisual():void{
if (layout){
layout.init();
_visualInitialized = true;
};
}
private function _destroyVisual():void{
if (((layout) && (_visualInitialized))){
layout.destroy();
};
}
public function warning(message:String, mode:VisualDebugMode=null):void{
if (_filter(mode)){
return;
};
if (((layout) && (showWarnings))){
layout.createWarning(message);
};
if (traceOutput){
trace((("## " + message) + " ##"));
};
}
private function _filter(mode:VisualDebugMode=null):Boolean{
return (((mode) && ((int(mode) >= int(this.mode)))));
}
public function failure(message:String):void{
if (layout){
layout.createFailureAlert(message);
};
if (traceOutput){
trace((("[-] " + message) + " !!"));
};
}
public function get mode(){
return (_mode);
}
public function set active(value:Boolean):void{
_active = value;
if (_active){
_initializeVisual();
} else {
_destroyVisual();
};
}
protected function trace(message:String):void{
var msgs:Array;
var j:int;
var messages:Array = [];
var pre0:String = "";
var pre1:String = "";
if (this.mode == VisualDebugMode.geek){
pre0 = (getTimer() + " - ");
pre1 = (new Array(pre0.length).join(" ") + " ");
};
if (message.indexOf("\n") > -1){
msgs = message.split("\n");
j = 0;
while (j < msgs.length) {
if (msgs[j] == ""){
} else {
if (j == 0){
messages.push((pre0 + msgs[j]));
} else {
messages.push((pre1 + msgs[j]));
};
};
j++;
};
} else {
messages.push((pre0 + message));
};
var len:int = messages.length;
var i:int;
while (i < len) {
trace(messages[i]);
i++;
};
}
public function alert(message:String):void{
if (layout){
layout.createAlert(message);
};
if (traceOutput){
trace((("!! " + message) + " !!"));
};
}
public function info(message:String, mode:VisualDebugMode=null):void{
if (_filter(mode)){
return;
};
if (((layout) && (showInfos))){
layout.createInfo(message);
};
if (traceOutput){
trace(message);
};
}
public function alertGifRequest(message:String, request:URLRequest, ref:GIFRequest):void{
if (layout){
layout.createGIFRequestAlert(message, request, ref);
};
if (traceOutput){
trace(((">> " + message) + " <<"));
};
}
}
}//package com.google.analytics.debug
Section 115
//FailureAlert (com.google.analytics.debug.FailureAlert)
package com.google.analytics.debug {
public class FailureAlert extends Alert {
public function FailureAlert(debug:DebugConfiguration, text:String, actions:Array){
var alignement:Align = Align.bottomLeft;
var stickToEdge:Boolean;
var actionOnNextLine:Boolean;
if (debug.verbose){
text = ((("<u><span class=\"uiAlertTitle\">Failure</span>" + spaces(18)) + "</u>\n\n") + text);
alignement = Align.center;
stickToEdge = false;
actionOnNextLine = true;
};
super(text, actions, "uiFailure", Style.failureColor, alignement, stickToEdge, actionOnNextLine);
}
}
}//package com.google.analytics.debug
Section 116
//GIFRequestAlert (com.google.analytics.debug.GIFRequestAlert)
package com.google.analytics.debug {
public class GIFRequestAlert extends Alert {
public function GIFRequestAlert(text:String, actions:Array){
super(text, actions);
}
}
}//package com.google.analytics.debug
Section 117
//ILayout (com.google.analytics.debug.ILayout)
package com.google.analytics.debug {
import flash.display.*;
import com.google.analytics.core.*;
import flash.net.*;
public interface ILayout {
function createAlert(:String):void;
function addToStage(:DisplayObject):void;
function createGIFRequestAlert(_arg1:String, _arg2:URLRequest, _arg3:GIFRequest):void;
function createWarning(:String):void;
function createPanel(_arg1:String, _arg2:uint, _arg3:uint):void;
function createInfo(:String):void;
function createFailureAlert(:String):void;
function addToPanel(_arg1:String, _arg2:DisplayObject):void;
function init():void;
function createSuccessAlert(:String):void;
function createVisualDebug():void;
function destroy():void;
function bringToFront(:DisplayObject):void;
function isAvailable():Boolean;
}
}//package com.google.analytics.debug
Section 118
//Info (com.google.analytics.debug.Info)
package com.google.analytics.debug {
import flash.events.*;
import flash.utils.*;
public class Info extends Label {
private var _timer:Timer;
public function Info(text:String="", timeout:uint=3000){
super(text, "uiInfo", Style.infoColor, Align.top, true);
if (timeout > 0){
_timer = new Timer(timeout, 1);
_timer.start();
_timer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete, false, 0, true);
};
}
public function close():void{
if (parent != null){
parent.removeChild(this);
};
}
override public function onLink(event:TextEvent):void{
switch (event.text){
case "hide":
close();
break;
};
}
public function onComplete(event:TimerEvent):void{
close();
}
}
}//package com.google.analytics.debug
Section 119
//Label (com.google.analytics.debug.Label)
package com.google.analytics.debug {
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class Label extends UISprite {
private var _color:uint;
private var _background:Shape;
private var _textField:TextField;
public var stickToEdge:Boolean;
private var _text:String;
protected var selectable:Boolean;
private var _tag:String;
public static var count:uint = 0;
public function Label(text:String="", tag:String="uiLabel", color:uint=0, alignement:Align=null, stickToEdge:Boolean=false){
super();
this.name = ("Label" + count++);
selectable = false;
_background = new Shape();
_textField = new TextField();
_text = text;
_tag = tag;
if (alignement == null){
alignement = Align.none;
};
this.alignement = alignement;
this.stickToEdge = stickToEdge;
if (color == 0){
color = Style.backgroundColor;
};
_color = color;
_textField.addEventListener(TextEvent.LINK, onLink);
}
public function get tag():String{
return (_tag);
}
private function _draw():void{
var g:Graphics = _background.graphics;
g.clear();
g.beginFill(_color);
var W:uint = _textField.width;
var H:uint = _textField.height;
if (forcedWidth > 0){
W = forcedWidth;
};
Background.drawRounded(this, g, W, H);
g.endFill();
}
public function get text():String{
return (_textField.text);
}
public function appendText(value:String, newtag:String=""):void{
if (value == ""){
return;
};
if (newtag == ""){
newtag = tag;
};
_textField.htmlText = (_textField.htmlText + (((("<span class=\"" + newtag) + "\">") + value) + "</span>"));
_text = (_text + value);
_draw();
resize();
}
public function set text(value:String):void{
if (value == ""){
value = _text;
};
_textField.htmlText = (((("<span class=\"" + tag) + "\">") + value) + "</span>");
_text = value;
_draw();
resize();
}
override protected function layout():void{
_textField.type = TextFieldType.DYNAMIC;
_textField.autoSize = TextFieldAutoSize.LEFT;
_textField.background = false;
_textField.selectable = selectable;
_textField.multiline = true;
_textField.styleSheet = Style.sheet;
this.text = _text;
addChild(_background);
addChild(_textField);
}
public function set tag(value:String):void{
_tag = value;
text = "";
}
public function onLink(event:TextEvent):void{
}
override protected function dispose():void{
_textField.removeEventListener(TextEvent.LINK, onLink);
super.dispose();
}
}
}//package com.google.analytics.debug
Section 120
//Layout (com.google.analytics.debug.Layout)
package com.google.analytics.debug {
import flash.display.*;
import flash.events.*;
import com.google.analytics.*;
import com.google.analytics.core.*;
import flash.net.*;
public class Layout implements ILayout {
private var _display:DisplayObject;
private var _infoQueue:Array;
private var _maxCharPerLine:int;// = 85
private var _hasInfo:Boolean;
private var _warningQueue:Array;
private var _hasDebug:Boolean;
private var _hasWarning:Boolean;
private var _mainPanel:Panel;
private var _GRAlertQueue:Array;
private var _debug:DebugConfiguration;
public var visualDebug:Debug;
private var _hasGRAlert:Boolean;
public function Layout(debug:DebugConfiguration, display:DisplayObject){
super();
_display = display;
_debug = debug;
_hasWarning = false;
_hasInfo = false;
_hasDebug = false;
_hasGRAlert = false;
_warningQueue = [];
_infoQueue = [];
_GRAlertQueue = [];
}
private function onKey(event:KeyboardEvent=null):void{
switch (event.keyCode){
case _debug.showHideKey:
_mainPanel.visible = !(_mainPanel.visible);
break;
case _debug.destroyKey:
destroy();
break;
};
}
public function createWarning(message:String):void{
if (((_hasWarning) || (!(isAvailable())))){
_warningQueue.push(message);
return;
};
message = _filterMaxChars(message);
_hasWarning = true;
var w:Warning = new Warning(message, _debug.warningTimeout);
addToPanel("analytics", w);
w.addEventListener(Event.REMOVED_FROM_STAGE, _clearWarning, false, 0, true);
if (_hasDebug){
visualDebug.writeBold(message);
};
}
public function bringToFront(visual:DisplayObject):void{
_display.stage.setChildIndex(visual, (_display.stage.numChildren - 1));
}
public function createFailureAlert(message:String):void{
var actionClose:AlertAction;
if (_debug.verbose){
message = _filterMaxChars(message);
actionClose = new AlertAction("Close", "close", "close");
} else {
actionClose = new AlertAction("X", "close", "close");
};
var fa:Alert = new FailureAlert(_debug, message, [actionClose]);
addToPanel("analytics", fa);
if (_hasDebug){
if (_debug.verbose){
message = message.split("\n").join("");
message = _filterMaxChars(message, 66);
};
visualDebug.writeBold(message);
};
}
public function init():void{
var spaces = 10;
var W:uint = (_display.stage.stageWidth - (spaces * 2));
var H:uint = (_display.stage.stageHeight - (spaces * 2));
var mp:Panel = new Panel("analytics", W, H);
mp.alignement = Align.top;
mp.stickToEdge = false;
mp.title = ("Google Analytics v" + GATracker.version);
_mainPanel = mp;
addToStage(mp);
bringToFront(mp);
if (_debug.minimizedOnStart){
_mainPanel.onToggle();
};
createVisualDebug();
_display.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKey, false, 0, true);
}
public function addToPanel(name:String, visual:DisplayObject):void{
var panel:Panel;
var d:DisplayObject = _display.stage.getChildByName(name);
if (d){
panel = (d as Panel);
panel.addData(visual);
} else {
trace((("panel \"" + name) + "\" not found"));
};
}
private function _clearInfo(event:Event):void{
_hasInfo = false;
if (_infoQueue.length > 0){
createInfo(_infoQueue.shift());
};
}
private function _filterMaxChars(message:String, maxCharPerLine:int=0):String{
var line:String;
var CRLF:String = "\n";
var output:Array = [];
var lines:Array = message.split(CRLF);
if (maxCharPerLine == 0){
maxCharPerLine = _maxCharPerLine;
};
var i:int;
while (i < lines.length) {
line = lines[i];
while (line.length > maxCharPerLine) {
output.push(line.substr(0, maxCharPerLine));
line = line.substring(maxCharPerLine);
};
output.push(line);
i++;
};
return (output.join(CRLF));
}
private function _clearGRAlert(event:Event):void{
_hasGRAlert = false;
if (_GRAlertQueue.length > 0){
createGIFRequestAlert.apply(this, _GRAlertQueue.shift());
};
}
public function createSuccessAlert(message:String):void{
var actionClose:AlertAction;
if (_debug.verbose){
message = _filterMaxChars(message);
actionClose = new AlertAction("Close", "close", "close");
} else {
actionClose = new AlertAction("X", "close", "close");
};
var sa:Alert = new SuccessAlert(_debug, message, [actionClose]);
addToPanel("analytics", sa);
if (_hasDebug){
if (_debug.verbose){
message = message.split("\n").join("");
message = _filterMaxChars(message, 66);
};
visualDebug.writeBold(message);
};
}
public function isAvailable():Boolean{
return (!((_display.stage == null)));
}
public function createAlert(message:String):void{
message = _filterMaxChars(message);
var a:Alert = new Alert(message, [new AlertAction("Close", "close", "close")]);
addToPanel("analytics", a);
if (_hasDebug){
visualDebug.writeBold(message);
};
}
public function createInfo(message:String):void{
if (((_hasInfo) || (!(isAvailable())))){
_infoQueue.push(message);
return;
};
message = _filterMaxChars(message);
_hasInfo = true;
var i:Info = new Info(message, _debug.infoTimeout);
addToPanel("analytics", i);
i.addEventListener(Event.REMOVED_FROM_STAGE, _clearInfo, false, 0, true);
if (_hasDebug){
visualDebug.write(message);
};
}
public function createGIFRequestAlert(message:String, request:URLRequest, ref:GIFRequest):void{
var message = message;
var request = request;
var ref = ref;
if (_hasGRAlert){
_GRAlertQueue.push([message, request, ref]);
return;
};
_hasGRAlert = true;
var f:Function = function ():void{
ref.sendRequest(request);
};
message = _filterMaxChars(message);
var gra:GIFRequestAlert = new GIFRequestAlert(message, [new AlertAction("OK", "ok", f), new AlertAction("Cancel", "cancel", "close")]);
addToPanel("analytics", gra);
gra.addEventListener(Event.REMOVED_FROM_STAGE, _clearGRAlert, false, 0, true);
if (_hasDebug){
if (_debug.verbose){
message = message.split("\n").join("");
message = _filterMaxChars(message, 66);
};
visualDebug.write(message);
};
}
public function createVisualDebug():void{
if (!visualDebug){
visualDebug = new Debug();
visualDebug.alignement = Align.bottom;
visualDebug.stickToEdge = true;
addToPanel("analytics", visualDebug);
_hasDebug = true;
};
}
public function addToStage(visual:DisplayObject):void{
_display.stage.addChild(visual);
}
private function _clearWarning(event:Event):void{
_hasWarning = false;
if (_warningQueue.length > 0){
createWarning(_warningQueue.shift());
};
}
public function createPanel(name:String, width:uint, height:uint):void{
var p:Panel = new Panel(name, width, height);
p.alignement = Align.center;
p.stickToEdge = false;
addToStage(p);
bringToFront(p);
}
public function destroy():void{
_mainPanel.close();
_debug.layout = null;
}
}
}//package com.google.analytics.debug
Section 121
//Margin (com.google.analytics.debug.Margin)
package com.google.analytics.debug {
public class Margin {
public var top:int;
public var left:int;
public var bottom:int;
public var right:int;
public function Margin(top:int=0, bottom:int=0, left:int=0, right:int=0){
super();
this.top = top;
this.bottom = bottom;
this.left = left;
this.right = right;
}
}
}//package com.google.analytics.debug
Section 122
//Panel (com.google.analytics.debug.Panel)
package com.google.analytics.debug {
import flash.display.*;
import flash.events.*;
public class Panel extends UISprite {
private var _savedH:uint;
private var _data:UISprite;
private var _mask:Sprite;
private var _background:Shape;
private var _savedW:uint;
private var _stickToEdge:Boolean;
private var _border:Shape;
private var _borderColor:uint;
protected var baseAlpha:Number;
private var _backgroundColor:uint;
private var _title:Label;
private var _colapsed:Boolean;
private var _name:String;
public function Panel(name:String, width:uint, height:uint, backgroundColor:uint=0, borderColor:uint=0, baseAlpha:Number=0.3, alignement:Align=null, stickToEdge:Boolean=false){
super();
_name = name;
this.name = name;
this.mouseEnabled = false;
_colapsed = false;
forcedWidth = width;
forcedHeight = height;
this.baseAlpha = baseAlpha;
_background = new Shape();
_data = new UISprite();
_data.forcedWidth = width;
_data.forcedHeight = height;
_data.mouseEnabled = false;
_title = new Label(name, "uiLabel", 0xFFFFFF, Align.topLeft, stickToEdge);
_title.buttonMode = true;
_title.margin.top = 0.6;
_title.margin.left = 0.6;
_title.addEventListener(MouseEvent.CLICK, onToggle);
_title.mouseChildren = false;
_border = new Shape();
_mask = new Sprite();
_mask.useHandCursor = false;
_mask.mouseEnabled = false;
_mask.mouseChildren = false;
if (alignement == null){
alignement = Align.none;
};
this.alignement = alignement;
this.stickToEdge = stickToEdge;
if (backgroundColor == 0){
backgroundColor = Style.backgroundColor;
};
_backgroundColor = backgroundColor;
if (borderColor == 0){
borderColor = Style.borderColor;
};
_borderColor = borderColor;
}
public function get stickToEdge():Boolean{
return (_stickToEdge);
}
public function onToggle(event:MouseEvent=null):void{
if (_colapsed){
_data.visible = true;
} else {
_data.visible = false;
};
_colapsed = !(_colapsed);
_update();
resize();
}
public function set stickToEdge(value:Boolean):void{
_stickToEdge = value;
_title.stickToEdge = value;
}
override protected function dispose():void{
_title.removeEventListener(MouseEvent.CLICK, onToggle);
super.dispose();
}
private function _draw():void{
var W:uint;
var H:uint;
if (((_savedW) && (_savedH))){
forcedWidth = _savedW;
forcedHeight = _savedH;
};
if (!_colapsed){
W = forcedWidth;
H = forcedHeight;
} else {
W = _title.width;
H = _title.height;
_savedW = forcedWidth;
_savedH = forcedHeight;
forcedWidth = W;
forcedHeight = H;
};
var g0:Graphics = _background.graphics;
g0.clear();
g0.beginFill(_backgroundColor);
Background.drawRounded(this, g0, W, H);
g0.endFill();
var g01:Graphics = _data.graphics;
g01.clear();
g01.beginFill(_backgroundColor, 0);
Background.drawRounded(this, g01, W, H);
g01.endFill();
var g1:Graphics = _border.graphics;
g1.clear();
g1.lineStyle(0.1, _borderColor);
Background.drawRounded(this, g1, W, H);
g1.endFill();
var g2:Graphics = _mask.graphics;
g2.clear();
g2.beginFill(_backgroundColor);
Background.drawRounded(this, g2, (W + 1), (H + 1));
g2.endFill();
}
public function get title():String{
return (_title.text);
}
private function _update():void{
_draw();
if (baseAlpha < 1){
_background.alpha = baseAlpha;
_border.alpha = baseAlpha;
};
}
public function addData(child:DisplayObject):void{
_data.addChild(child);
}
override protected function layout():void{
_update();
addChild(_background);
addChild(_data);
addChild(_title);
addChild(_border);
addChild(_mask);
mask = _mask;
}
public function set title(value:String):void{
_title.text = value;
}
public function close():void{
dispose();
if (parent != null){
parent.removeChild(this);
};
}
}
}//package com.google.analytics.debug
Section 123
//Style (com.google.analytics.debug.Style)
package com.google.analytics.debug {
public const Style:_Style = new _Style();
}//package com.google.analytics.debug
Section 124
//SuccessAlert (com.google.analytics.debug.SuccessAlert)
package com.google.analytics.debug {
public class SuccessAlert extends Alert {
public function SuccessAlert(debug:DebugConfiguration, text:String, actions:Array){
var alignement:Align = Align.bottomLeft;
var stickToEdge:Boolean;
var actionOnNextLine:Boolean;
if (debug.verbose){
text = ((("<u><span class=\"uiAlertTitle\">Success</span>" + spaces(18)) + "</u>\n\n") + text);
alignement = Align.center;
stickToEdge = false;
actionOnNextLine = true;
};
super(text, actions, "uiSuccess", Style.successColor, alignement, stickToEdge, actionOnNextLine);
}
}
}//package com.google.analytics.debug
Section 125
//UISprite (com.google.analytics.debug.UISprite)
package com.google.analytics.debug {
import flash.display.*;
import flash.events.*;
public class UISprite extends Sprite {
private var _forcedWidth:uint;
public var margin:Margin;
protected var alignTarget:DisplayObject;
protected var listenResize:Boolean;
public var alignement:Align;
private var _forcedHeight:uint;
public function UISprite(alignTarget:DisplayObject=null){
super();
listenResize = false;
alignement = Align.none;
this.alignTarget = alignTarget;
margin = new Margin();
addEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
addEventListener(Event.REMOVED_FROM_STAGE, _onRemovedFromStage);
}
public function get forcedHeight():uint{
if (_forcedHeight){
return (_forcedHeight);
};
return (height);
}
private function _onAddedToStage(event:Event):void{
layout();
resize();
}
protected function dispose():void{
var d:DisplayObject;
var i:int;
while (i < numChildren) {
d = getChildAt(i);
if (d){
removeChild(d);
};
i++;
};
}
public function set forcedHeight(value:uint):void{
_forcedHeight = value;
}
public function set forcedWidth(value:uint):void{
_forcedWidth = value;
}
protected function layout():void{
}
public function get forcedWidth():uint{
if (_forcedWidth){
return (_forcedWidth);
};
return (width);
}
public function alignTo(alignement:Align, target:DisplayObject=null):void{
var H:uint;
var W:uint;
var X:uint;
var Y:uint;
var t:UISprite;
if (target == null){
if ((parent is Stage)){
target = this.stage;
} else {
target = parent;
};
};
if (target == this.stage){
if (this.stage == null){
return;
};
H = this.stage.stageHeight;
W = this.stage.stageWidth;
X = 0;
Y = 0;
} else {
t = (target as UISprite);
if (t.forcedHeight){
H = t.forcedHeight;
} else {
H = t.height;
};
if (t.forcedWidth){
W = t.forcedWidth;
} else {
W = t.width;
};
X = 0;
Y = 0;
};
switch (alignement){
case Align.top:
x = ((W / 2) - (forcedWidth / 2));
y = (Y + margin.top);
break;
case Align.bottom:
x = ((W / 2) - (forcedWidth / 2));
y = (((Y + H) - forcedHeight) - margin.bottom);
break;
case Align.left:
x = (X + margin.left);
y = ((H / 2) - (forcedHeight / 2));
break;
case Align.right:
x = (((X + W) - forcedWidth) - margin.right);
y = ((H / 2) - (forcedHeight / 2));
break;
case Align.center:
x = ((W / 2) - (forcedWidth / 2));
y = ((H / 2) - (forcedHeight / 2));
break;
case Align.topLeft:
x = (X + margin.left);
y = (Y + margin.top);
break;
case Align.topRight:
x = (((X + W) - forcedWidth) - margin.right);
y = (Y + margin.top);
break;
case Align.bottomLeft:
x = (X + margin.left);
y = (((Y + H) - forcedHeight) - margin.bottom);
break;
case Align.bottomRight:
x = (((X + W) - forcedWidth) - margin.right);
y = (((Y + H) - forcedHeight) - margin.bottom);
break;
};
if (((!(listenResize)) && (!((alignement == Align.none))))){
target.addEventListener(Event.RESIZE, onResize, false, 0, true);
listenResize = true;
};
this.alignement = alignement;
this.alignTarget = target;
}
private function _onRemovedFromStage(event:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
removeEventListener(Event.REMOVED_FROM_STAGE, _onRemovedFromStage);
dispose();
}
public function resize():void{
if (alignement != Align.none){
alignTo(alignement, alignTarget);
};
}
protected function onResize(event:Event):void{
resize();
}
}
}//package com.google.analytics.debug
Section 126
//Warning (com.google.analytics.debug.Warning)
package com.google.analytics.debug {
import flash.events.*;
import flash.utils.*;
public class Warning extends Label {
private var _timer:Timer;
public function Warning(text:String="", timeout:uint=3000){
super(text, "uiWarning", Style.warningColor, Align.top, false);
margin.top = 32;
if (timeout > 0){
_timer = new Timer(timeout, 1);
_timer.start();
_timer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete, false, 0, true);
};
}
public function close():void{
if (parent != null){
parent.removeChild(this);
};
}
override public function onLink(event:TextEvent):void{
switch (event.text){
case "hide":
close();
break;
};
}
public function onComplete(event:TimerEvent):void{
close();
}
}
}//package com.google.analytics.debug
Section 127
//VisualDebugMode (com.google.analytics.debug.VisualDebugMode)
package com.google.analytics.debug {
public class VisualDebugMode {
private var _value:int;
private var _name:String;
public static const advanced:VisualDebugMode = new VisualDebugMode(1, "advanced");
;
public static const geek:VisualDebugMode = new VisualDebugMode(2, "geek");
;
public static const basic:VisualDebugMode = new VisualDebugMode(0, "basic");
;
public function VisualDebugMode(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.debug
Section 128
//Item (com.google.analytics.ecommerce.Item)
package com.google.analytics.ecommerce {
import com.google.analytics.utils.*;
public class Item {
private var _price:String;
private var _id:String;
private var _sku:String;
private var _category:String;
private var _quantity:String;
private var _name:String;
public function Item(id:String, sku:String, name:String, category:String, price:String, quantity:String){
super();
this._id = id;
this._sku = sku;
this._name = name;
this._category = category;
this._price = price;
this._quantity = quantity;
}
public function set sku(value:String):void{
_sku = value;
}
public function get price():String{
return (_price);
}
public function get name():String{
return (_name);
}
public function get quantity():String{
return (_quantity);
}
public function set name(value:String):void{
_name = value;
}
public function set price(value:String):void{
_price = value;
}
public function get id():String{
return (_id);
}
public function get sku():String{
return (_sku);
}
public function set quantity(value:String):void{
_quantity = value;
}
public function toGifParams():Variables{
var vars:Variables = new Variables();
vars.URIencode = true;
vars.post = ["utmt", "utmtid", "utmipc", "utmipn", "utmiva", "utmipr", "utmiqt"];
vars.utmt = "item";
vars.utmtid = _id;
vars.utmipc = _sku;
vars.utmipn = _name;
vars.utmiva = _category;
vars.utmipr = _price;
vars.utmiqt = _quantity;
return (vars);
}
public function set id(value:String):void{
_id = value;
}
public function set category(value:String):void{
_category = value;
}
public function get category():String{
return (_category);
}
}
}//package com.google.analytics.ecommerce
Section 129
//Transaction (com.google.analytics.ecommerce.Transaction)
package com.google.analytics.ecommerce {
import com.google.analytics.utils.*;
public class Transaction {
private var _items:Array;
private var _total:String;
private var _vars:Variables;
private var _shipping:String;
private var _city:String;
private var _state:String;
private var _country:String;
private var _tax:String;
private var _affiliation:String;
private var _id:String;
public function Transaction(id:String, affiliation:String, total:String, tax:String, shipping:String, city:String, state:String, country:String){
super();
this._id = id;
this._affiliation = affiliation;
this._total = total;
this._tax = tax;
this._shipping = shipping;
this._city = city;
this._state = state;
this._country = country;
_items = new Array();
}
public function get total():String{
return (_total);
}
public function getItemFromArray(i:Number):Item{
return (_items[i]);
}
public function set total(value:String):void{
_total = value;
}
public function getItem(sku:String):Item{
var i:Number;
i = 0;
while (i < _items.length) {
if (_items[i].sku == sku){
return (_items[i]);
};
i++;
};
return (null);
}
public function getItemsLength():Number{
return (_items.length);
}
public function addItem(sku:String, name:String, category:String, price:String, quantity:String):void{
var newItem:Item;
newItem = getItem(sku);
if (newItem == null){
newItem = new Item(_id, sku, name, category, price, quantity);
_items.push(newItem);
} else {
newItem.name = name;
newItem.category = category;
newItem.price = price;
newItem.quantity = quantity;
};
}
public function set shipping(value:String):void{
_shipping = value;
}
public function get country():String{
return (_country);
}
public function get state():String{
return (_state);
}
public function set tax(value:String):void{
_tax = value;
}
public function set affiliation(value:String):void{
_affiliation = value;
}
public function set state(value:String):void{
_state = value;
}
public function get id():String{
return (_id);
}
public function get tax():String{
return (_tax);
}
public function toGifParams():Variables{
var vars:Variables = new Variables();
vars.URIencode = true;
vars.utmt = "tran";
vars.utmtid = id;
vars.utmtst = affiliation;
vars.utmtto = total;
vars.utmttx = tax;
vars.utmtsp = shipping;
vars.utmtci = city;
vars.utmtrg = state;
vars.utmtco = country;
vars.post = ["utmtid", "utmtst", "utmtto", "utmttx", "utmtsp", "utmtci", "utmtrg", "utmtco"];
return (vars);
}
public function get affiliation():String{
return (_affiliation);
}
public function get city():String{
return (_city);
}
public function get shipping():String{
return (_shipping);
}
public function set id(value:String):void{
_id = value;
}
public function set city(value:String):void{
_city = value;
}
public function set country(value:String):void{
_country = value;
}
}
}//package com.google.analytics.ecommerce
Section 130
//AnalyticsEvent (com.google.analytics.events.AnalyticsEvent)
package com.google.analytics.events {
import flash.events.*;
import com.google.analytics.*;
public class AnalyticsEvent extends Event {
public var tracker:AnalyticsTracker;
public static const READY:String = "ready";
public function AnalyticsEvent(type:String, tracker:AnalyticsTracker, bubbles:Boolean=false, cancelable:Boolean=false){
super(type, bubbles, cancelable);
this.tracker = tracker;
}
override public function clone():Event{
return (new AnalyticsEvent(type, tracker, bubbles, cancelable));
}
}
}//package com.google.analytics.events
Section 131
//AdSenseGlobals (com.google.analytics.external.AdSenseGlobals)
package com.google.analytics.external {
import com.google.analytics.debug.*;
public class AdSenseGlobals extends JavascriptProxy {
private var _gaGlobalVerified:Boolean;// = false
public static var gaGlobal_js:XML = <script>
<![CDATA[
function()
{
try
{
gaGlobal
}
catch(e)
{
gaGlobal = {} ;
}
}
]]>
</script>
;
public function AdSenseGlobals(debug:DebugConfiguration){
super(debug);
}
public function set vid(value:String):void{
if (!isAvailable()){
return;
};
_verify();
setProperty("gaGlobal.vid", value);
}
public function get hid():String{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal.hid"));
}
public function set hid(value:String):void{
if (!isAvailable()){
return;
};
_verify();
setProperty("gaGlobal.hid", value);
}
public function get dh():String{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal.dh"));
}
public function get sid():String{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal.sid"));
}
public function get vid():String{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal.vid"));
}
private function _verify():void{
if (!_gaGlobalVerified){
executeBlock(gaGlobal_js);
_gaGlobalVerified = true;
};
}
public function set sid(value:String):void{
if (!isAvailable()){
return;
};
_verify();
setProperty("gaGlobal.sid", value);
}
public function get gaGlobal():Object{
if (!isAvailable()){
return (null);
};
_verify();
return (getProperty("gaGlobal"));
}
}
}//package com.google.analytics.external
Section 132
//HTMLDOM (com.google.analytics.external.HTMLDOM)
package com.google.analytics.external {
import com.google.analytics.debug.*;
public class HTMLDOM extends JavascriptProxy {
private var _referrer:String;
private var _language:String;
private var _host:String;
private var _pathname:String;
private var _location:String;
private var _search:String;
private var _characterSet:String;
private var _title:String;
private var _protocol:String;
private var _colorDepth:String;
public static var cache_properties_js:XML = <script>
<![CDATA[
function()
{
var obj = {};
obj.host = document.location.host;
obj.language = navigator.language ? navigator.language : navigator.browserLanguage;
obj.characterSet = document.characterSet ? document.characterSet : document.charset;
obj.colorDepth = window.screen.colorDepth;
obj.location = document.location.toString();
obj.pathname = document.location.pathname;
obj.protocol = document.location.protocol;
obj.search = document.location.search;
obj.referrer = document.referrer;
obj.title = document.title;
return obj;
}
]]>
</script>
;
public function HTMLDOM(debug:DebugConfiguration){
super(debug);
}
public function get search():String{
if (_search){
return (_search);
};
if (!isAvailable()){
return (null);
};
_search = getProperty("document.location.search");
return (_search);
}
public function get location():String{
if (_location){
return (_location);
};
if (!isAvailable()){
return (null);
};
_location = getPropertyString("document.location");
return (_location);
}
public function get pathname():String{
if (_pathname){
return (_pathname);
};
if (!isAvailable()){
return (null);
};
_pathname = getProperty("document.location.pathname");
return (_pathname);
}
public function cacheProperties():void{
if (!isAvailable()){
return;
};
var obj:Object = call(cache_properties_js);
if (obj){
_host = obj.host;
_language = obj.language;
_characterSet = obj.characterSet;
_colorDepth = obj.colorDepth;
_location = obj.location;
_pathname = obj.pathname;
_protocol = obj.protocol;
_search = obj.search;
_referrer = obj.referrer;
_title = obj.title;
};
}
public function get language():String{
if (_language){
return (_language);
};
if (!isAvailable()){
return (null);
};
var lang:String = getProperty("navigator.language");
if (lang == null){
lang = getProperty("navigator.browserLanguage");
};
_language = lang;
return (_language);
}
public function get colorDepth():String{
if (_colorDepth){
return (_colorDepth);
};
if (!isAvailable()){
return (null);
};
_colorDepth = getProperty("window.screen.colorDepth");
return (_colorDepth);
}
public function get referrer():String{
if (_referrer){
return (_referrer);
};
if (!isAvailable()){
return (null);
};
_referrer = getProperty("document.referrer");
return (_referrer);
}
public function get protocol():String{
if (_protocol){
return (_protocol);
};
if (!isAvailable()){
return (null);
};
_protocol = getProperty("document.location.protocol");
return (_protocol);
}
public function get host():String{
if (_host){
return (_host);
};
if (!isAvailable()){
return (null);
};
_host = getProperty("document.location.host");
return (_host);
}
public function get characterSet():String{
if (_characterSet){
return (_characterSet);
};
if (!isAvailable()){
return (null);
};
var cs:String = getProperty("document.characterSet");
if (cs == null){
cs = getProperty("document.charset");
};
_characterSet = cs;
return (_characterSet);
}
public function get title():String{
if (_title){
return (_title);
};
if (!isAvailable()){
return (null);
};
_title = getProperty("document.title");
return (_title);
}
}
}//package com.google.analytics.external
Section 133
//JavascriptProxy (com.google.analytics.external.JavascriptProxy)
package com.google.analytics.external {
import com.google.analytics.debug.*;
import flash.external.*;
import flash.system.*;
public class JavascriptProxy {
private var _notAvailableWarning:Boolean;// = true
private var _debug:DebugConfiguration;
public static var setProperty_js:XML = <script>
<![CDATA[
function( path , value )
{
var paths;
var prop;
if( path.indexOf(".") > 0 )
{
paths = path.split(".");
prop = paths.pop() ;
}
else
{
paths = [];
prop = path;
}
var target = window ;
var len = paths.length ;
for( var i = 0 ; i < len ; i++ )
{
target = target[ paths[i] ] ;
}
target[ prop ] = value ;
}
]]>
</script>
;
public static var hasProperty_js:XML = <script>
<![CDATA[
function( path )
{
var paths;
if( path.indexOf(".") > 0 )
{
paths = path.split(".");
}
else
{
paths = [path];
}
var target = window ;
var len = paths.length ;
for( var i = 0 ; i < len ; i++ )
{
target = target[ paths[i] ] ;
}
if( target )
{
return true;
}
else
{
return false;
}
}
]]>
</script>
;
public static var setPropertyRef_js:XML = <script>
<![CDATA[
function( path , target )
{
var paths;
var prop;
if( path.indexOf(".") > 0 )
{
paths = path.split(".");
prop = paths.pop() ;
}
else
{
paths = [];
prop = path;
}
alert( "paths:"+paths.length+", prop:"+prop );
var targets;
var name;
if( target.indexOf(".") > 0 )
{
targets = target.split(".");
name = targets.pop();
}
else
{
targets = [];
name = target;
}
alert( "targets:"+targets.length+", name:"+name );
var root = window;
var len = paths.length;
for( var i = 0 ; i < len ; i++ )
{
root = root[ paths[i] ] ;
}
var ref = window;
var depth = targets.length;
for( var j = 0 ; j < depth ; j++ )
{
ref = ref[ targets[j] ] ;
}
root[ prop ] = ref[name] ;
}
]]>
</script>
;
public function JavascriptProxy(debug:DebugConfiguration){
super();
_debug = debug;
}
public function getProperty(name:String){
return (call((name + ".valueOf")));
}
public function hasProperty(path:String):Boolean{
return (call(hasProperty_js, path));
}
public function setProperty(path:String, value):void{
call(setProperty_js, path, value);
}
public function executeBlock(data:String):void{
var data = data;
if (isAvailable()){
ExternalInterface.call(data);
//unresolved jump
var _slot1 = e;
if (_debug.javascript){
_debug.warning("ExternalInterface is not allowed.\nEnsure that allowScriptAccess is set to \"always\" in the Flash embed HTML.");
};
//unresolved jump
var _slot1 = e;
if (_debug.javascript){
_debug.warning(("ExternalInterface failed to make the call\nreason: " + _slot1.message));
};
};
}
public function getPropertyString(name:String):String{
return (call((name + ".toString")));
}
public function setPropertyByReference(path:String, target:String):void{
call(setPropertyRef_js, path, target);
}
public function call(functionName:String, ... _args){
var output:String;
var functionName = functionName;
var args = _args;
if (isAvailable()){
if (((_debug.javascript) && (_debug.verbose))){
output = "";
output = ("Flash->JS: " + functionName);
output = (output + "( ");
if (args.length > 0){
output = (output + args.join(","));
};
output = (output + " )");
_debug.info(output);
};
args.unshift(functionName);
return (ExternalInterface.call.apply(ExternalInterface, args));
//unresolved jump
var _slot1 = e;
if (_debug.javascript){
_debug.warning("ExternalInterface is not allowed.\nEnsure that allowScriptAccess is set to \"always\" in the Flash embed HTML.");
};
//unresolved jump
var _slot1 = e;
if (_debug.javascript){
_debug.warning(("ExternalInterface failed to make the call\nreason: " + _slot1.message));
};
};
return (null);
}
public function isAvailable():Boolean{
var available:Boolean = ExternalInterface.available;
if (((available) && ((Capabilities.playerType == "External")))){
available = false;
};
if (((((!(available)) && (_debug.javascript))) && (_notAvailableWarning))){
_debug.warning("ExternalInterface is not available.");
_notAvailableWarning = false;
};
return (available);
}
}
}//package com.google.analytics.external
Section 134
//Environment (com.google.analytics.utils.Environment)
package com.google.analytics.utils {
import com.google.analytics.debug.*;
import com.google.analytics.external.*;
import flash.system.*;
public class Environment {
private var _dom:HTMLDOM;
private var _appName:String;
private var _debug:DebugConfiguration;
private var _appVersion:Version;
private var _url:String;
private var _protocol:Protocols;
private var _userAgent:UserAgent;
public function Environment(url:String="", app:String="", version:String="", debug:DebugConfiguration=null, dom:HTMLDOM=null){
var v:Version;
super();
if (app == ""){
if (isAIR()){
app = "AIR";
} else {
app = "Flash";
};
};
if (version == ""){
v = flashVersion;
} else {
v = Version.fromString(version);
};
_url = url;
_appName = app;
_appVersion = v;
_debug = debug;
_dom = dom;
}
public function isAIR():Boolean{
return ((((playerType == "Desktop")) && ((Security.sandboxType.toString() == "application"))));
}
public function get screenWidth():Number{
return (Capabilities.screenResolutionX);
}
public function get playerType():String{
return (Capabilities.playerType);
}
public function get locationSearch():String{
var _search:String = _dom.search;
if (_search){
return (_search);
};
return ("");
}
public function get protocol():Protocols{
if (!_protocol){
_findProtocol();
};
return (_protocol);
}
public function get flashVersion():Version{
var v:Version = Version.fromString(Capabilities.version.split(" ")[1], ",");
return (v);
}
public function get userAgent():UserAgent{
if (!_userAgent){
_userAgent = new UserAgent(this, appName, appVersion.toString(4));
};
return (_userAgent);
}
public function get languageEncoding():String{
var _charset:String;
if (System.useCodePage){
_charset = _dom.characterSet;
if (_charset){
return (_charset);
};
return ("-");
};
return ("UTF-8");
}
public function get appName():String{
return (_appName);
}
public function get screenColorDepth():String{
var color:String;
switch (Capabilities.screenColor){
case "bw":
color = "1";
break;
case "gray":
color = "2";
break;
case "color":
default:
color = "24";
};
var _colorDepth:String = _dom.colorDepth;
if (_colorDepth){
color = _colorDepth;
};
return (color);
}
private function _findProtocol():void{
var URL:String;
var test:String;
var p:Protocols = Protocols.none;
if (_url != ""){
URL = _url.toLowerCase();
test = URL.substr(0, 5);
switch (test){
case "file:":
p = Protocols.file;
break;
case "http:":
p = Protocols.HTTP;
break;
case "https":
if (URL.charAt(5) == ":"){
p = Protocols.HTTPS;
};
break;
default:
_protocol = Protocols.none;
};
};
var _proto:String = _dom.protocol;
var proto:String = (p.toString() + ":").toLowerCase();
if (((((_proto) && (!((_proto == proto))))) && (_debug))){
_debug.warning(((("Protocol mismatch: SWF=" + proto) + ", DOM=") + _proto));
};
_protocol = p;
}
public function get locationSWFPath():String{
return (_url);
}
public function get platform():String{
var p:String = Capabilities.manufacturer;
return (p.split("Adobe ")[1]);
}
public function get operatingSystem():String{
return (Capabilities.os);
}
public function set appName(value:String):void{
_appName = value;
userAgent.applicationProduct = value;
}
function set url(value:String):void{
_url = value;
}
public function get referrer():String{
var _referrer:String = _dom.referrer;
if (_referrer){
return (_referrer);
};
if (protocol == Protocols.file){
return ("localhost");
};
return ("");
}
public function isInHTML():Boolean{
return ((Capabilities.playerType == "PlugIn"));
}
public function get language():String{
var _lang:String = _dom.language;
var lang:String = Capabilities.language;
if (_lang){
if ((((_lang.length > lang.length)) && ((_lang.substr(0, lang.length) == lang)))){
lang = _lang;
};
};
return (lang);
}
public function get domainName():String{
var URL:String;
var str:String;
var end:int;
if ((((protocol == Protocols.HTTP)) || ((protocol == Protocols.HTTPS)))){
URL = _url.toLowerCase();
if (protocol == Protocols.HTTP){
str = URL.split("http://").join("");
} else {
if (protocol == Protocols.HTTPS){
str = URL.split("https://").join("");
};
};
end = str.indexOf("/");
if (end > -1){
str = str.substring(0, end);
};
return (str);
};
if (protocol == Protocols.file){
return ("localhost");
};
return ("");
}
public function set userAgent(custom:UserAgent):void{
_userAgent = custom;
}
public function set appVersion(value:Version):void{
_appVersion = value;
userAgent.applicationVersion = value.toString(4);
}
public function get screenHeight():Number{
return (Capabilities.screenResolutionY);
}
public function get locationPath():String{
var _pathname:String = _dom.pathname;
if (_pathname){
return (_pathname);
};
return ("");
}
public function get documentTitle():String{
var _title:String = _dom.title;
if (_title){
return (_title);
};
return ("");
}
public function get appVersion():Version{
return (_appVersion);
}
}
}//package com.google.analytics.utils
Section 135
//Protocols (com.google.analytics.utils.Protocols)
package com.google.analytics.utils {
public class Protocols {
private var _value:int;
private var _name:String;
public static const none:Protocols = new Protocols(0, "none");
;
public static const HTTPS:Protocols = new Protocols(3, "HTTPS");
;
public static const file:Protocols = new Protocols(1, "file");
;
public static const HTTP:Protocols = new Protocols(2, "HTTP");
;
public function Protocols(value:int=0, name:String=""){
super();
_value = value;
_name = name;
}
public function valueOf():int{
return (_value);
}
public function toString():String{
return (_name);
}
}
}//package com.google.analytics.utils
Section 136
//Timespan (com.google.analytics.utils.Timespan)
package com.google.analytics.utils {
public class Timespan {
public static var sixmonths:Number = 15768000;
public static var twoyears:Number = 63072000;
public static var thirtyminutes:Number = 1800;
public function Timespan(){
super();
}
}
}//package com.google.analytics.utils
Section 137
//URL (com.google.analytics.utils.URL)
package com.google.analytics.utils {
public class URL {
private var _url:String;
public function URL(url:String=""){
super();
_url = url.toLowerCase();
}
public function get domain():String{
var parts:Array;
if (((!((hostName == ""))) && ((hostName.indexOf(".") > -1)))){
parts = hostName.split(".");
switch (parts.length){
case 2:
return (hostName);
case 3:
if (parts[1] == "co"){
return (hostName);
};
parts.shift();
return (parts.join("."));
case 4:
parts.shift();
return (parts.join("."));
};
};
return ("");
}
public function get path():String{
var _path:String = _url;
if (_path.indexOf("://") > -1){
_path = _path.split("://")[1];
};
if (_path.indexOf(hostName) == 0){
_path = _path.substr(hostName.length);
};
if (_path.indexOf("?") > -1){
_path = _path.split("?")[0];
};
if (_path.charAt(0) != "/"){
_path = ("/" + _path);
};
return (_path);
}
public function get protocol():Protocols{
var proto:String = _url.split("://")[0];
switch (proto){
case "file":
return (Protocols.file);
case "http":
return (Protocols.HTTP);
case "https":
return (Protocols.HTTPS);
default:
return (Protocols.none);
};
}
public function get hostName():String{
var hostname:String = _url;
if (hostname.indexOf("://") > -1){
hostname = hostname.split("://")[1];
};
if (hostname.indexOf("/") > -1){
hostname = hostname.split("/")[0];
};
if (hostname.indexOf("?") > -1){
hostname = hostname.split("?")[0];
};
if ((((protocol == Protocols.file)) || ((protocol == Protocols.none)))){
return ("");
};
return (hostname);
}
public function get subDomain():String{
if (((!((domain == ""))) && (!((domain == hostName))))){
return (hostName.split(("." + domain)).join(""));
};
return ("");
}
public function get search():String{
var _search:String = _url;
if (_search.indexOf("://") > -1){
_search = _search.split("://")[1];
};
if (_search.indexOf(hostName) == 0){
_search = _search.substr(hostName.length);
};
if (_search.indexOf("?") > -1){
_search = _search.split("?")[1];
} else {
_search = "";
};
return (_search);
}
}
}//package com.google.analytics.utils
Section 138
//UserAgent (com.google.analytics.utils.UserAgent)
package com.google.analytics.utils {
import com.google.analytics.core.*;
import flash.system.*;
public class UserAgent {
private var _localInfo:Environment;
private var _applicationProduct:String;
private var _version:Version;
public static var minimal:Boolean = false;
public function UserAgent(localInfo:Environment, product:String="", version:String=""){
super();
_localInfo = localInfo;
applicationProduct = product;
_version = Version.fromString(version);
}
public function get tamarinProductToken():String{
if (UserAgent.minimal){
return ("");
};
if (System.vmVersion){
return (("Tamarin/" + Utils.trim(System.vmVersion, true)));
};
return ("");
}
public function get applicationVersion():String{
return (_version.toString(2));
}
public function get vendorProductToken():String{
var vp:String = "";
if (_localInfo.isAIR()){
vp = (vp + "AIR");
} else {
vp = (vp + "FlashPlayer");
};
vp = (vp + "/");
vp = (vp + _version.toString(3));
return (vp);
}
public function toString():String{
var UA:String = "";
UA = (UA + applicationProductToken);
if (applicationComment != ""){
UA = (UA + (" " + applicationComment));
};
if (tamarinProductToken != ""){
UA = (UA + (" " + tamarinProductToken));
};
if (vendorProductToken != ""){
UA = (UA + (" " + vendorProductToken));
};
return (UA);
}
public function get applicationComment():String{
var comment:Array = [];
comment.push(_localInfo.platform);
comment.push(_localInfo.playerType);
if (!UserAgent.minimal){
comment.push(_localInfo.operatingSystem);
comment.push(_localInfo.language);
};
if (Capabilities.isDebugger){
comment.push("DEBUG");
};
if (comment.length > 0){
return ((("(" + comment.join("; ")) + ")"));
};
return ("");
}
public function set applicationVersion(value:String):void{
_version = Version.fromString(value);
}
public function get applicationProductToken():String{
var token:String = applicationProduct;
if (applicationVersion != ""){
token = (token + ("/" + applicationVersion));
};
return (token);
}
public function set applicationProduct(value:String):void{
_applicationProduct = value;
}
public function get applicationProduct():String{
return (_applicationProduct);
}
}
}//package com.google.analytics.utils
Section 139
//Variables (com.google.analytics.utils.Variables)
package com.google.analytics.utils {
import flash.net.*;
public dynamic class Variables {
public var post:Array;
public var URIencode:Boolean;
public var pre:Array;
public var sort:Boolean;// = true
public function Variables(source:String=null, pre:Array=null, post:Array=null){
pre = [];
post = [];
super();
if (source){
decode(source);
};
if (pre){
this.pre = pre;
};
if (post){
this.post = post;
};
}
private function _join(vars:Variables):void{
var prop:String;
if (!vars){
return;
};
for (prop in vars) {
this[prop] = vars[prop];
};
}
public function join(... _args):void{
var l:int = _args.length;
var i:int;
while (i < l) {
if (!(_args[i] is Variables)){
} else {
_join(_args[i]);
};
i++;
};
}
public function toString():String{
var value:String;
var p:String;
var component:String;
var i:int;
var j:int;
var priority:String;
var last:String;
var data:Array = [];
for (p in this) {
value = this[p];
if (URIencode){
value = encodeURI(value);
};
data.push(((p + "=") + value));
};
if (sort){
data.sort();
};
if (pre.length > 0){
pre.reverse();
i = 0;
while (i < pre.length) {
priority = pre[i];
j = 0;
while (j < data.length) {
component = data[j];
if (component.indexOf(priority) == 0){
data.unshift(data.splice(j, 1)[0]);
};
j++;
};
i++;
};
pre.reverse();
};
if (post.length > 0){
i = 0;
while (i < post.length) {
last = post[i];
j = 0;
while (j < data.length) {
component = data[j];
if (component.indexOf(last) == 0){
data.push(data.splice(j, 1)[0]);
};
j++;
};
i++;
};
};
return (data.join("&"));
}
public function decode(source:String):void{
var data:Array;
var prop:String;
var name:String;
var value:String;
var tmp:Array;
if (source == ""){
return;
};
if (source.charAt(0) == "?"){
source = source.substr(1, source.length);
};
if (source.indexOf("&") > -1){
data = source.split("&");
} else {
data = [source];
};
var i:int;
while (i < data.length) {
prop = data[i];
if (prop.indexOf("=") > -1){
tmp = prop.split("=");
name = tmp[0];
value = decodeURI(tmp[1]);
this[name] = value;
};
i++;
};
}
public function toURLVariables():URLVariables{
var p:String;
var urlvars:URLVariables = new URLVariables();
for (p in this) {
urlvars[p] = this[p];
};
return (urlvars);
}
}
}//package com.google.analytics.utils
Section 140
//Version (com.google.analytics.utils.Version)
package com.google.analytics.utils {
public class Version {
private var _revision:uint;
private var _maxBuild:uint;// = 0xFF
private var _maxMinor:uint;// = 15
private var _maxMajor:uint;// = 15
private var _separator:String;// = "."
private var _maxRevision:uint;// = 0xFFFF
private var _build:uint;
private var _major:uint;
private var _minor:uint;
public function Version(major:uint=0, minor:uint=0, build:uint=0, revision:uint=0){
var v:Version;
super();
if ((((((((major > _maxMajor)) && ((minor == 0)))) && ((build == 0)))) && ((revision == 0)))){
v = Version.fromNumber(major);
major = v.major;
minor = v.minor;
build = v.build;
revision = v.revision;
};
this.major = major;
this.minor = minor;
this.build = build;
this.revision = revision;
}
public function toString(fields:int=0):String{
var arr:Array;
if ((((fields <= 0)) || ((fields > 4)))){
fields = getFields();
};
switch (fields){
case 1:
arr = [major];
break;
case 2:
arr = [major, minor];
break;
case 3:
arr = [major, minor, build];
break;
case 4:
default:
arr = [major, minor, build, revision];
};
return (arr.join(_separator));
}
public function set revision(value:uint):void{
_revision = Math.min(value, _maxRevision);
}
public function get revision():uint{
return (_revision);
}
public function set build(value:uint):void{
_build = Math.min(value, _maxBuild);
}
public function set minor(value:uint):void{
_minor = Math.min(value, _maxMinor);
}
public function get build():uint{
return (_build);
}
public function set major(value:uint):void{
_major = Math.min(value, _maxMajor);
}
public function get minor():uint{
return (_minor);
}
private function getFields():int{
var f = 4;
if (revision == 0){
f--;
};
if ((((f == 3)) && ((build == 0)))){
f--;
};
if ((((f == 2)) && ((minor == 0)))){
f--;
};
return (f);
}
public function valueOf():uint{
return (((((major << 28) | (minor << 24)) | (build << 16)) | revision));
}
public function get major():uint{
return (_major);
}
public function equals(o):Boolean{
if (!(o is Version)){
return (false);
};
if ((((((((o.major == major)) && ((o.minor == minor)))) && ((o.build == build)))) && ((o.revision == revision)))){
return (true);
};
return (false);
}
public static function fromString(value:String="", separator:String="."):Version{
var values:Array;
var v:Version = new (Version);
if ((((value == "")) || ((value == null)))){
return (v);
};
if (value.indexOf(separator) > -1){
values = value.split(separator);
v.major = parseInt(values[0]);
v.minor = parseInt(values[1]);
v.build = parseInt(values[2]);
v.revision = parseInt(values[3]);
} else {
v.major = parseInt(value);
};
return (v);
}
public static function fromNumber(value:Number=0):Version{
var v:Version = new (Version);
if (((((((((((isNaN(value)) || ((value == 0)))) || ((value < 0)))) || ((value == Number.MAX_VALUE)))) || ((value == Number.POSITIVE_INFINITY)))) || ((value == Number.NEGATIVE_INFINITY)))){
return (v);
};
v.major = (value >>> 28);
v.minor = ((value & 251658240) >>> 24);
v.build = ((value & 0xFF0000) >>> 16);
v.revision = (value & 0xFFFF);
return (v);
}
}
}//package com.google.analytics.utils
Section 141
//Bridge (com.google.analytics.v4.Bridge)
package com.google.analytics.v4 {
import com.google.analytics.core.*;
import com.google.analytics.debug.*;
import com.google.analytics.external.*;
public class Bridge implements GoogleAnalyticsAPI {
private var _debug:DebugConfiguration;
private var _proxy:JavascriptProxy;
private var _jsContainer:String;// = "_GATracker"
private var _hasGATracker:Boolean;// = false
private var _account:String;
private static var _linkTrackingObject_js:XML = <script>
<![CDATA[
function( container , target )
{
var targets ;
var name ;
if( target.indexOf(".") > 0 )
{
targets = target.split(".");
name = targets.pop();
}
else
{
targets = [];
name = target;
}
var ref = window;
var depth = targets.length;
for( var j = 0 ; j < depth ; j++ )
{
ref = ref[ targets[j] ] ;
}
window[container][target] = ref[name] ;
}
]]>
</script>
;
private static var _createTrackingObject_js:XML = <script>
<![CDATA[
function( acct )
{
_GATracker[acct] = _gat._getTracker(acct);
}
]]>
</script>
;
private static var _injectTrackingObject_js:XML = <script>
<![CDATA[
function()
{
try
{
_GATracker
}
catch(e)
{
_GATracker = {};
}
}
]]>
</script>
;
private static var _checkGAJS_js:XML = <script>
<![CDATA[
function()
{
if( _gat && _gat._getTracker )
{
return true;
}
return false;
}
]]>
</script>
;
private static var _checkValidTrackingObject_js:XML = <script>
<![CDATA[
function(acct)
{
if( _GATracker[acct] && (_GATracker[acct]._getAccount) )
{
return true ;
}
else
{
return false;
}
}
]]>
</script>
;
public function Bridge(account:String, debug:DebugConfiguration, jsproxy:JavascriptProxy){
var msg0:String;
var msg1:String;
var msg2:String;
super();
_account = account;
_debug = debug;
_proxy = jsproxy;
if (!_checkGAJS()){
msg0 = "";
msg0 = (msg0 + "ga.js not found, be sure to check if\n");
msg0 = (msg0 + "<script src=\"http://www.google-analytics.com/ga.js\"></script>\n");
msg0 = (msg0 + "is included in the HTML.");
_debug.warning(msg0);
throw (new Error(msg0));
};
if (!_hasGATracker){
if (((_debug.javascript) && (_debug.verbose))){
msg1 = "";
msg1 = (msg1 + "The Google Analytics tracking code was not found on the container page\n");
msg1 = (msg1 + "we create it");
_debug.info(msg1, VisualDebugMode.advanced);
};
_injectTrackingObject();
};
if (Utils.validateAccount(account)){
_createTrackingObject(account);
} else {
if (_checkTrackingObject(account)){
_linkTrackingObject(account);
} else {
msg2 = "";
msg2 = (msg2 + (("JS Object \"" + account) + "\" doesn't exist in DOM\n"));
msg2 = (msg2 + "Bridge object not created.");
_debug.warning(msg2);
throw (new Error(msg2));
};
};
}
public function link(targetUrl:String, useHash:Boolean=false):void{
_debug.info((((("link( " + targetUrl) + ", ") + useHash) + " )"));
_call("_link", targetUrl, useHash);
}
public function addOrganic(newOrganicEngine:String, newOrganicKeyword:String):void{
_debug.info((("addOrganic( " + [newOrganicEngine, newOrganicKeyword].join(", ")) + " )"));
_call("_addOrganic", newOrganicEngine);
}
public function setAllowLinker(enable:Boolean):void{
_debug.info((("setAllowLinker( " + enable) + " )"));
_call("_setAllowLinker", enable);
}
public function getLinkerUrl(url:String="", useHash:Boolean=false):String{
_debug.info((((("getLinkerUrl(" + url) + ", ") + useHash) + ")"));
return (_call("_getLinkerUrl", url, useHash));
}
private function _linkTrackingObject(path:String):void{
_proxy.call(_linkTrackingObject_js, _jsContainer, path);
}
public function setClientInfo(enable:Boolean):void{
_debug.info((("setClientInfo( " + enable) + " )"));
_call("_setClientInfo", enable);
}
public function trackTrans():void{
_debug.info("trackTrans()");
_call("_trackTrans");
}
public function trackEvent(category:String, action:String, label:String=null, value:Number=NaN):Boolean{
var param = 2;
if (((label) && (!((label == ""))))){
param = 3;
};
if ((((param == 3)) && (!(isNaN(value))))){
param = 4;
};
switch (param){
case 4:
_debug.info((("trackEvent( " + [category, action, label, value].join(", ")) + " )"));
return (_call("_trackEvent", category, action, label, value));
case 3:
_debug.info((("trackEvent( " + [category, action, label].join(", ")) + " )"));
return (_call("_trackEvent", category, action, label));
case 2:
default:
_debug.info((("trackEvent( " + [category, action].join(", ")) + " )"));
return (_call("_trackEvent", category, action));
};
}
public function setCookieTimeout(newDefaultTimeout:int):void{
_debug.info((("setCookieTimeout( " + newDefaultTimeout) + " )"));
_call("_setCookieTimeout", newDefaultTimeout);
}
public function trackPageview(pageURL:String=""):void{
_debug.info((("trackPageview( " + pageURL) + " )"));
_call("_trackPageview", pageURL);
}
private function _checkValidTrackingObject(account:String):Boolean{
return (_proxy.call(_checkValidTrackingObject_js, account));
}
private function _checkGAJS():Boolean{
return (_proxy.call(_checkGAJS_js));
}
public function linkByPost(formObject:Object, useHash:Boolean=false):void{
_debug.warning((((("linkByPost( " + formObject) + ", ") + useHash) + " ) not implemented"));
}
public function getClientInfo():Boolean{
_debug.info("getClientInfo()");
return (_call("_getClientInfo"));
}
private function _call(functionName:String, ... _args){
_args.unshift(((((("window." + _jsContainer) + "[\"") + _account) + "\"].") + functionName));
return (_proxy.call.apply(_proxy, _args));
}
public function hasGAJS():Boolean{
return (_checkGAJS());
}
private function _checkTrackingObject(account:String):Boolean{
var hasObj:Boolean = _proxy.hasProperty(account);
var isTracker:Boolean = _proxy.hasProperty((account + "._getAccount"));
return (((hasObj) && (isTracker)));
}
public function resetSession():void{
_debug.warning("resetSession() not implemented");
}
public function getDetectTitle():Boolean{
_debug.info("getDetectTitle()");
return (_call("_getDetectTitle"));
}
public function setCampNameKey(newCampNameKey:String):void{
_debug.info((("setCampNameKey( " + newCampNameKey) + " )"));
_call("_setCampNameKey", newCampNameKey);
}
public function setDetectFlash(enable:Boolean):void{
_debug.info((("setDetectFlash( " + enable) + " )"));
_call("_setDetectFlash", enable);
}
public function createEventTracker(objName:String):EventTracker{
_debug.info((("createEventTracker( " + objName) + " )"));
return (new EventTracker(objName, this));
}
public function addItem(item:String, sku:String, name:String, category:String, price:Number, quantity:int):void{
_debug.info((("addItem( " + [item, sku, name, category, price, quantity].join(", ")) + " )"));
_call("_addItem", item, sku, name, category, price, quantity);
}
public function clearIgnoredOrganic():void{
_debug.info("clearIgnoredOrganic()");
_call("_clearIgnoreOrganic");
}
public function setVar(newVal:String):void{
_debug.info((("setVar( " + newVal) + " )"));
_call("_setVar", newVal);
}
public function setDomainName(newDomainName:String):void{
_debug.info((("setDomainName( " + newDomainName) + " )"));
_call("_setDomainName", newDomainName);
}
public function hasTrackingAccount(account:String):Boolean{
if (Utils.validateAccount(account)){
return (_checkValidTrackingObject(account));
};
return (_checkTrackingObject(account));
}
public function setCampSourceKey(newCampSrcKey:String):void{
_debug.info((("setCampSourceKey( " + newCampSrcKey) + " )"));
_call("_setCampSourceKey", newCampSrcKey);
}
public function addTrans(orderId:String, affiliation:String, total:Number, tax:Number, shipping:Number, city:String, state:String, country:String):void{
_debug.info((("addTrans( " + [orderId, affiliation, total, tax, shipping, city, state, country].join(", ")) + " )"));
_call("_addTrans", orderId, affiliation, total, tax, shipping, city, state, country);
}
public function setCampContentKey(newCampContentKey:String):void{
_debug.info((("setCampContentKey( " + newCampContentKey) + " )"));
_call("_setCampContentKey", newCampContentKey);
}
public function setLocalServerMode():void{
_debug.info("setLocalServerMode()");
_call("_setLocalServerMode");
}
public function getLocalGifPath():String{
_debug.info("getLocalGifPath()");
return (_call("_getLocalGifPath"));
}
public function clearIgnoredRef():void{
_debug.info("clearIgnoredRef()");
_call("_clearIgnoreRef");
}
public function setAllowAnchor(enable:Boolean):void{
_debug.info((("setAllowAnchor( " + enable) + " )"));
_call("_setAllowAnchor", enable);
}
public function setLocalGifPath(newLocalGifPath:String):void{
_debug.info((("setLocalGifPath( " + newLocalGifPath) + " )"));
_call("_setLocalGifPath", newLocalGifPath);
}
public function getVersion():String{
_debug.info("getVersion()");
return (_call("_getVersion"));
}
private function _injectTrackingObject():void{
_proxy.executeBlock(_injectTrackingObject_js);
_hasGATracker = true;
}
public function setCookiePath(newCookiePath:String):void{
_debug.info((("setCookiePath( " + newCookiePath) + " )"));
_call("_setCookiePath", newCookiePath);
}
public function setSampleRate(newRate:Number):void{
_debug.info((("setSampleRate( " + newRate) + " )"));
_call("_setSampleRate", newRate);
}
public function setAllowHash(enable:Boolean):void{
_debug.info((("setAllowHash( " + enable) + " )"));
_call("_setAllowHash", enable);
}
public function addIgnoredOrganic(newIgnoredOrganicKeyword:String):void{
_debug.info((("addIgnoredOrganic( " + newIgnoredOrganicKeyword) + " )"));
_call("_addIgnoredOrganic", newIgnoredOrganicKeyword);
}
public function setCampNOKey(newCampNOKey:String):void{
_debug.info((("setCampNOKey( " + newCampNOKey) + " )"));
_call("_setCampNOKey", newCampNOKey);
}
public function cookiePathCopy(newPath:String):void{
_debug.info((("cookiePathCopy( " + newPath) + " )"));
_call("_cookiePathCopy", newPath);
}
public function setLocalRemoteServerMode():void{
_debug.info("setLocalRemoteServerMode()");
_call("_setLocalRemoteServerMode");
}
public function getServiceMode():ServerOperationMode{
_debug.info("getServiceMode()");
return (_call("_getServiceMode"));
}
public function setDetectTitle(enable:Boolean):void{
_debug.info((("setDetectTitle( " + enable) + " )"));
_call("_setDetectTitle", enable);
}
private function _createTrackingObject(account:String):void{
_proxy.call(_createTrackingObject_js, account);
}
public function setCampaignTrack(enable:Boolean):void{
_debug.info((("setCampaignTrack( " + enable) + " )"));
_call("_setCampaignTrack", enable);
}
public function clearOrganic():void{
_debug.info("clearOrganic()");
_call("_clearOrganic");
}
public function setCampTermKey(newCampTermKey:String):void{
_debug.info((("setCampTermKey( " + newCampTermKey) + " )"));
_call("_setCampTermKey", newCampTermKey);
}
public function getDetectFlash():Boolean{
_debug.info("getDetectFlash()");
return (_call("_getDetectFlash"));
}
public function setCampMediumKey(newCampMedKey:String):void{
_debug.info((("setCampMediumKey( " + newCampMedKey) + " )"));
_call("_setCampMediumKey", newCampMedKey);
}
public function addIgnoredRef(newIgnoredReferrer:String):void{
_debug.info((("addIgnoredRef( " + newIgnoredReferrer) + " )"));
_call("_addIgnoredRef", newIgnoredReferrer);
}
public function setSessionTimeout(newTimeout:int):void{
_debug.info((("setSessionTimeout( " + newTimeout) + " )"));
_call("_setSessionTimeout", newTimeout);
}
public function setRemoteServerMode():void{
_debug.info("setRemoteServerMode()");
_call("_setRemoteServerMode");
}
public function getAccount():String{
_debug.info("getAccount()");
return (_call("_getAccount"));
}
}
}//package com.google.analytics.v4
Section 142
//Configuration (com.google.analytics.v4.Configuration)
package com.google.analytics.v4 {
import com.google.analytics.core.*;
import com.google.analytics.debug.*;
import com.google.analytics.utils.*;
import com.google.analytics.campaign.*;
public class Configuration {
public var serverMode:ServerOperationMode;
public var detectFlash:Boolean;// = true
public var hasSiteOverlay:Boolean;// = false
public var allowLocalTracking:Boolean;// = true
public var secureRemoteGIFpath:String;// = "https://ssl.google-analytics.com/__utm.gif"
private var _version:String;// = "4.3as"
public var allowDomainHash:Boolean;// = true
public var detectClientInfo:Boolean;// = true
public var idleLoop:Number;// = 30
public var isTrackOutboundSubdomains:Boolean;// = false
public var cookiePath:String;// = "/"
public var transactionFieldDelim:String;// = "|"
private var _organic:Organic;
private var _cookieName:String;// = "analytics"
public var campaignKey:CampaignKey;
public var google:String;// = "google"
public var googleCsePath:String;// = "cse"
public var bucketCapacity:Number;// = 10
private var _sampleRate:Number;// = 1
public var remoteGIFpath:String;// = "http://www.google-analytics.com/__utm.gif"
public var googleSearchParam:String;// = "q"
public var allowLinker:Boolean;// = false
public var maxOutboundLinkExamined:Number;// = 1000
private var _debug:DebugConfiguration;
public var allowAnchor:Boolean;// = false
private var _domain:Domain;
private var _trackingLimitPerSession:int;// = 500
public var tokenCliff:int;// = 10
public var sessionTimeout:Number;
public var idleTimeout:Number;// = 60
public var campaignTracking:Boolean;// = true
public var domainName:String;// = ""
public var detectTitle:Boolean;// = true
public var tokenRate:Number;// = 0.2
public var conversionTimeout:Number;
public var localGIFpath:String;// = "/__utm.gif"
public function Configuration(debug:DebugConfiguration=null){
_organic = new Organic();
conversionTimeout = Timespan.sixmonths;
sessionTimeout = Timespan.thirtyminutes;
campaignKey = new CampaignKey();
serverMode = ServerOperationMode.remote;
super();
_debug = debug;
_domain = new Domain(DomainNameMode.auto, "", _debug);
serverMode = ServerOperationMode.remote;
_initOrganicSources();
}
public function get organic():Organic{
return (_organic);
}
public function get cookieName():String{
return (_cookieName);
}
public function get trackingLimitPerSession():int{
return (_trackingLimitPerSession);
}
private function _initOrganicSources():void{
addOrganicSource(google, googleSearchParam);
addOrganicSource("yahoo", "p");
addOrganicSource("msn", "q");
addOrganicSource("aol", "query");
addOrganicSource("aol", "encquery");
addOrganicSource("lycos", "query");
addOrganicSource("ask", "q");
addOrganicSource("altavista", "q");
addOrganicSource("netscape", "query");
addOrganicSource("cnn", "query");
addOrganicSource("looksmart", "qt");
addOrganicSource("about", "terms");
addOrganicSource("mamma", "query");
addOrganicSource("alltheweb", "q");
addOrganicSource("gigablast", "q");
addOrganicSource("voila", "rdata");
addOrganicSource("virgilio", "qs");
addOrganicSource("live", "q");
addOrganicSource("baidu", "wd");
addOrganicSource("alice", "qs");
addOrganicSource("yandex", "text");
addOrganicSource("najdi", "q");
addOrganicSource("aol", "q");
addOrganicSource("club-internet", "q");
addOrganicSource("mama", "query");
addOrganicSource("seznam", "q");
addOrganicSource("search", "q");
addOrganicSource("wp", "szukaj");
addOrganicSource("onet", "qt");
addOrganicSource("netsprint", "q");
addOrganicSource("google.interia", "q");
addOrganicSource("szukacz", "q");
addOrganicSource("yam", "k");
addOrganicSource("pchome", "q");
addOrganicSource("kvasir", "searchExpr");
addOrganicSource("sesam", "q");
addOrganicSource("ozu", "q");
addOrganicSource("terra", "query");
addOrganicSource("nostrum", "query");
addOrganicSource("mynet", "q");
addOrganicSource("ekolay", "q");
addOrganicSource("search.ilse", "search_for");
}
public function get sampleRate():Number{
return (_sampleRate);
}
public function addOrganicSource(engine:String, keyword:String):void{
var engine = engine;
var keyword = keyword;
_organic.addSource(engine, keyword);
//unresolved jump
var _slot1 = e;
if (((_debug) && (_debug.active))){
_debug.warning(_slot1.message);
};
}
public function get domain():Domain{
return (_domain);
}
public function set sampleRate(value:Number):void{
if (value <= 0){
value = 0.1;
};
if (value > 1){
value = 1;
};
value = Number(value.toFixed(2));
_sampleRate = value;
}
public function get version():String{
return (_version);
}
}
}//package com.google.analytics.v4
Section 143
//GoogleAnalyticsAPI (com.google.analytics.v4.GoogleAnalyticsAPI)
package com.google.analytics.v4 {
import com.google.analytics.core.*;
public interface GoogleAnalyticsAPI {
function setCampSourceKey(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function setDetectTitle(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:Boolean):void;
function setLocalRemoteServerMode():void;
function resetSession():void;
function setLocalServerMode():void;
function setCampContentKey(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function addOrganic(_arg1:String, _arg2:String):void;
function setDetectFlash(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:Boolean):void;
function setAllowLinker(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:Boolean):void;
function trackEvent(_arg1:String, _arg2:String, _arg3:String=null, _arg4:Number=NaN):Boolean;
function setCampTermKey(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function setCampNameKey(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function getLinkerUrl(_arg1:String="", _arg2:Boolean=false):String;
function addItem(_arg1:String, _arg2:String, _arg3:String, _arg4:String, _arg5:Number, _arg6:int):void;
function clearIgnoredRef():void;
function addTrans(_arg1:String, _arg2:String, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:String, _arg7:String, _arg8:String):void;
function getDetectFlash():Boolean;
function setCampaignTrack(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:Boolean):void;
function createEventTracker(void:String):EventTracker;
function setCookieTimeout(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:int):void;
function setAllowAnchor(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:Boolean):void;
function trackTrans():void;
function clearOrganic():void;
function trackPageview(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String=""):void;
function setLocalGifPath(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function getVersion():String;
function getLocalGifPath():String;
function getServiceMode():ServerOperationMode;
function setVar(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function clearIgnoredOrganic():void;
function setCampMediumKey(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function addIgnoredRef(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function setClientInfo(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:Boolean):void;
function setCookiePath(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function setSampleRate(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:Number):void;
function setSessionTimeout(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:int):void;
function setRemoteServerMode():void;
function setDomainName(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function addIgnoredOrganic(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function setAllowHash(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:Boolean):void;
function getAccount():String;
function linkByPost(_arg1:Object, _arg2:Boolean=false):void;
function link(_arg1:String, _arg2:Boolean=false):void;
function setCampNOKey(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function getClientInfo():Boolean;
function cookiePathCopy(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics\v4;GoogleAnalyticsAPI.as:String):void;
function getDetectTitle():Boolean;
}
}//package com.google.analytics.v4
Section 144
//Tracker (com.google.analytics.v4.Tracker)
package com.google.analytics.v4 {
import com.google.analytics.core.*;
import com.google.analytics.debug.*;
import flash.net.*;
import com.google.analytics.data.*;
import com.google.analytics.external.*;
import com.google.analytics.utils.*;
import com.google.analytics.ecommerce.*;
import com.google.analytics.campaign.*;
public class Tracker implements GoogleAnalyticsAPI {
private const EVENT_TRACKER_LABEL_KEY_NUM:int = 3;
private const EVENT_TRACKER_VALUE_VALUE_NUM:int = 1;
private const EVENT_TRACKER_PROJECT_ID:int = 5;
private const EVENT_TRACKER_OBJECT_NAME_KEY_NUM:int = 1;
private const EVENT_TRACKER_TYPE_KEY_NUM:int = 2;
private var _adSense:AdSenseGlobals;
private var _eventTracker:X10;
private var _noSessionInformation:Boolean;// = false
private var _browserInfo:BrowserInfo;
private var _debug:DebugConfiguration;
private var _isNewVisitor:Boolean;// = false
private var _buffer:Buffer;
private var _config:Configuration;
private var _x10Module:X10;
private var _campaign:CampaignManager;
private var _formatedReferrer:String;
private var _timeStamp:Number;
private var _info:Environment;
private var _domainHash:Number;
private var _campaignInfo:CampaignInfo;
private var _gifRequest:GIFRequest;
private var _hasInitData:Boolean;// = false
private var _ecom:Ecommerce;
private var _account:String;
public function Tracker(account:String, config:Configuration, debug:DebugConfiguration, info:Environment, buffer:Buffer, gifRequest:GIFRequest, adSense:AdSenseGlobals, ecom:Ecommerce){
var msg:String;
super();
_account = account;
_config = config;
_debug = debug;
_info = info;
_buffer = buffer;
_gifRequest = gifRequest;
_adSense = adSense;
_ecom = ecom;
if (!Utils.validateAccount(account)){
msg = (("Account \"" + account) + "\" is not valid.");
_debug.warning(msg);
throw (new Error(msg));
};
}
private function _doTracking():Boolean{
if (((((!((_info.protocol == Protocols.file))) && (!((_info.protocol == Protocols.none))))) && (_isNotGoogleSearch()))){
return (true);
};
if (_config.allowLocalTracking){
return (true);
};
return (false);
}
public function addOrganic(newOrganicEngine:String, newOrganicKeyword:String):void{
_debug.info((("addOrganic( " + [newOrganicEngine, newOrganicKeyword].join(", ")) + " )"));
_config.organic.addSource(newOrganicEngine, newOrganicKeyword);
}
public function setAllowLinker(enable:Boolean):void{
_config.allowLinker = enable;
_debug.info((("setAllowLinker( " + _config.allowLinker) + " )"));
}
public function getLinkerUrl(targetUrl:String="", useHash:Boolean=false):String{
_initData();
_debug.info((((("getLinkerUrl( " + targetUrl) + ", ") + useHash.toString()) + " )"));
return (_buffer.getLinkerUrl(targetUrl, useHash));
}
public function trackEvent(category:String, action:String, label:String=null, value:Number=NaN):Boolean{
_initData();
var success:Boolean;
var params = 2;
if (((!((category == ""))) && (!((action == ""))))){
_eventTracker.clearKey(EVENT_TRACKER_PROJECT_ID);
_eventTracker.clearValue(EVENT_TRACKER_PROJECT_ID);
success = _eventTracker.setKey(EVENT_TRACKER_PROJECT_ID, EVENT_TRACKER_OBJECT_NAME_KEY_NUM, category);
success = _eventTracker.setKey(EVENT_TRACKER_PROJECT_ID, EVENT_TRACKER_TYPE_KEY_NUM, action);
if (((label) && (!((label == ""))))){
success = _eventTracker.setKey(EVENT_TRACKER_PROJECT_ID, EVENT_TRACKER_LABEL_KEY_NUM, label);
params = 3;
if (!isNaN(value)){
success = _eventTracker.setValue(EVENT_TRACKER_PROJECT_ID, EVENT_TRACKER_VALUE_VALUE_NUM, value);
params = 4;
};
};
if (success){
_debug.info(((("valid event tracking call\ncategory: " + category) + "\naction: ") + action), VisualDebugMode.geek);
_sendXEvent(_eventTracker);
};
} else {
_debug.warning(((("event tracking call is not valid, failed!\ncategory: " + category) + "\naction: ") + action), VisualDebugMode.geek);
success = false;
};
switch (params){
case 4:
_debug.info((("trackEvent( " + [category, action, label, value].join(", ")) + " )"));
break;
case 3:
_debug.info((("trackEvent( " + [category, action, label].join(", ")) + " )"));
break;
case 2:
default:
_debug.info((("trackEvent( " + [category, action].join(", ")) + " )"));
};
return (success);
}
public function trackPageview(pageURL:String=""):void{
_debug.info((("trackPageview( " + pageURL) + " )"));
if (_doTracking()){
_initData();
_trackMetrics(pageURL);
_noSessionInformation = false;
} else {
_debug.warning((("trackPageview( " + pageURL) + " ) failed"));
};
}
public function setCookieTimeout(newDefaultTimeout:int):void{
_config.conversionTimeout = newDefaultTimeout;
_debug.info((("setCookieTimeout( " + _config.conversionTimeout) + " )"));
}
public function trackTrans():void{
var i:Number;
var j:Number;
var curTrans:Transaction;
_initData();
var searchStrings:Array = new Array();
if (_takeSample()){
i = 0;
while (i < _ecom.getTransLength()) {
curTrans = _ecom.getTransFromArray(i);
searchStrings.push(curTrans.toGifParams());
j = 0;
while (j < curTrans.getItemsLength()) {
searchStrings.push(curTrans.getItemFromArray(j).toGifParams());
j++;
};
i++;
};
i = 0;
while (i < searchStrings.length) {
_gifRequest.send(_account, searchStrings[i]);
i++;
};
};
}
public function setClientInfo(enable:Boolean):void{
_config.detectClientInfo = enable;
_debug.info((("setClientInfo( " + _config.detectClientInfo) + " )"));
}
public function linkByPost(formObject:Object, useHash:Boolean=false):void{
_debug.warning("linkByPost not implemented in AS3 mode");
}
private function _initData():void{
var data0:String;
var data:String;
if (!_hasInitData){
_updateDomainName();
_domainHash = _getDomainHash();
_timeStamp = Math.round((new Date().getTime() / 1000));
if (_debug.verbose){
data0 = "";
data0 = (data0 + "_initData 0");
data0 = (data0 + ("\ndomain name: " + _config.domainName));
data0 = (data0 + ("\ndomain hash: " + _domainHash));
data0 = (data0 + (((("\ntimestamp: " + _timeStamp) + " (") + new Date((_timeStamp * 1000))) + ")"));
_debug.info(data0, VisualDebugMode.geek);
};
};
if (_doTracking()){
_handleCookie();
};
if (!_hasInitData){
if (_doTracking()){
_formatedReferrer = _formatReferrer();
_browserInfo = new BrowserInfo(_config, _info);
_debug.info(("browserInfo: " + _browserInfo.toURLString()), VisualDebugMode.advanced);
if (_config.campaignTracking){
_campaign = new CampaignManager(_config, _debug, _buffer, _domainHash, _formatedReferrer, _timeStamp);
_campaignInfo = _campaign.getCampaignInformation(_info.locationSearch, _noSessionInformation);
_debug.info(("campaignInfo: " + _campaignInfo.toURLString()), VisualDebugMode.advanced);
_debug.info(("Search: " + _info.locationSearch));
_debug.info(("CampaignTrackig: " + _buffer.utmz.campaignTracking));
};
};
_x10Module = new X10();
_eventTracker = new X10();
_hasInitData = true;
};
if (_config.hasSiteOverlay){
_debug.warning("Site Overlay is not supported");
};
if (_debug.verbose){
data = "";
data = (data + "_initData (misc)");
data = (data + ("\nflash version: " + _info.flashVersion.toString(4)));
data = (data + ("\nprotocol: " + _info.protocol));
data = (data + (("\ndefault domain name (auto): \"" + _info.domainName) + "\""));
data = (data + ("\nlanguage: " + _info.language));
data = (data + ("\ndomain hash: " + _getDomainHash()));
data = (data + ("\nuser-agent: " + _info.userAgent));
_debug.info(data, VisualDebugMode.geek);
};
}
public function getDetectTitle():Boolean{
_debug.info("getDetectTitle()");
return (_config.detectTitle);
}
public function resetSession():void{
_debug.info("resetSession()");
_buffer.resetCurrentSession();
}
public function getClientInfo():Boolean{
_debug.info("getClientInfo()");
return (_config.detectClientInfo);
}
private function _sendXEvent(opt_xObj:X10=null):void{
var searchVariables:Variables;
var eventInfo:EventInfo;
var eventvars:Variables;
var generalvars:Variables;
if (_takeSample()){
searchVariables = new Variables();
searchVariables.URIencode = true;
eventInfo = new EventInfo(true, _x10Module, opt_xObj);
eventvars = eventInfo.toVariables();
generalvars = _renderMetricsSearchVariables();
searchVariables.join(eventvars, generalvars);
_gifRequest.send(_account, searchVariables, false, true);
};
}
public function setDetectFlash(enable:Boolean):void{
_config.detectFlash = enable;
_debug.info((("setDetectFlash( " + _config.detectFlash) + " )"));
}
public function setCampNameKey(newCampNameKey:String):void{
_config.campaignKey.UCCN = newCampNameKey;
var msg = (("setCampNameKey( " + _config.campaignKey.UCCN) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCCN]"));
} else {
_debug.info(msg);
};
}
private function _formatReferrer():String{
var domainName:String;
var ref:URL;
var dom:URL;
var referrer:String = _info.referrer;
if ((((referrer == "")) || ((referrer == "localhost")))){
referrer = "-";
} else {
domainName = _info.domainName;
ref = new URL(referrer);
dom = new URL(("http://" + domainName));
if (ref.hostName == domainName){
return ("-");
};
if (dom.domain == ref.domain){
if (dom.subDomain != ref.subDomain){
referrer = "0";
};
};
if ((((referrer.charAt(0) == "[")) && (referrer.charAt((referrer.length - 1))))){
referrer = "-";
};
};
_debug.info(("formated referrer: " + referrer), VisualDebugMode.advanced);
return (referrer);
}
private function _visitCode():Number{
if (_debug.verbose){
_debug.info(("visitCode: " + _buffer.utma.sessionId), VisualDebugMode.geek);
};
return (_buffer.utma.sessionId);
}
public function createEventTracker(objName:String):EventTracker{
_debug.info((("createEventTracker( " + objName) + " )"));
return (new EventTracker(objName, this));
}
public function addItem(id:String, sku:String, name:String, category:String, price:Number, quantity:int):void{
var parentTrans:Transaction;
parentTrans = _ecom.getTransaction(id);
if (parentTrans == null){
parentTrans = _ecom.addTransaction(id, "", "", "", "", "", "", "");
};
parentTrans.addItem(sku, name, category, price.toString(), quantity.toString());
if (_debug.active){
_debug.info((("addItem( " + [id, sku, name, category, price, quantity].join(", ")) + " )"));
};
}
public function clearIgnoredOrganic():void{
_debug.info("clearIgnoredOrganic()");
_config.organic.clearIgnoredKeywords();
}
public function setVar(newVal:String):void{
var variables:Variables;
if (((!((newVal == ""))) && (_isNotGoogleSearch()))){
_initData();
_buffer.utmv.domainHash = _domainHash;
_buffer.utmv.value = encodeURI(newVal);
if (_debug.verbose){
_debug.info(_buffer.utmv.toString(), VisualDebugMode.geek);
};
_debug.info((("setVar( " + newVal) + " )"));
if (_takeSample()){
variables = new Variables();
variables.utmt = "var";
_gifRequest.send(_account, variables);
};
} else {
_debug.warning((("setVar \"" + newVal) + "\" is ignored"));
};
}
public function setDomainName(newDomainName:String):void{
if (newDomainName == "auto"){
_config.domain.mode = DomainNameMode.auto;
} else {
if (newDomainName == "none"){
_config.domain.mode = DomainNameMode.none;
} else {
_config.domain.mode = DomainNameMode.custom;
_config.domain.name = newDomainName;
};
};
_updateDomainName();
_debug.info((("setDomainName( " + _config.domainName) + " )"));
}
private function _updateDomainName():void{
var domainName:String;
if (_config.domain.mode == DomainNameMode.auto){
domainName = _info.domainName;
if (domainName.substring(0, 4) == "www."){
domainName = domainName.substring(4);
};
_config.domain.name = domainName;
};
_config.domainName = _config.domain.name.toLowerCase();
_debug.info(("domain name: " + _config.domainName), VisualDebugMode.advanced);
}
public function addTrans(orderId:String, affiliation:String, total:Number, tax:Number, shipping:Number, city:String, state:String, country:String):void{
_ecom.addTransaction(orderId, affiliation, total.toString(), tax.toString(), shipping.toString(), city, state, country);
if (_debug.active){
_debug.info((("addTrans( " + [orderId, affiliation, total, tax, shipping, city, state, country].join(", ")) + " );"));
};
}
private function _renderMetricsSearchVariables(pageURL:String=""):Variables{
var campvars:Variables;
var variables:Variables = new Variables();
variables.URIencode = true;
var docInfo:DocumentInfo = new DocumentInfo(_config, _info, _formatedReferrer, pageURL, _adSense);
_debug.info(("docInfo: " + docInfo.toURLString()), VisualDebugMode.geek);
if (_config.campaignTracking){
campvars = _campaignInfo.toVariables();
};
var browservars:Variables = _browserInfo.toVariables();
variables.join(docInfo.toVariables(), browservars, campvars);
return (variables);
}
public function setCampContentKey(newCampContentKey:String):void{
_config.campaignKey.UCCT = newCampContentKey;
var msg = (("setCampContentKey( " + _config.campaignKey.UCCT) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCCT]"));
} else {
_debug.info(msg);
};
}
private function _handleCookie():void{
var data0:String;
var data1:String;
var vid:Array;
var data2:String;
if (_config.allowLinker){
};
_buffer.createSO();
if (((_buffer.hasUTMA()) && (!(_buffer.utma.isEmpty())))){
if (((!(_buffer.hasUTMB())) || (!(_buffer.hasUTMC())))){
_buffer.updateUTMA(_timeStamp);
_noSessionInformation = true;
};
if (_debug.verbose){
_debug.info(("from cookie " + _buffer.utma.toString()), VisualDebugMode.geek);
};
} else {
_debug.info("create a new utma", VisualDebugMode.advanced);
_buffer.utma.domainHash = _domainHash;
_buffer.utma.sessionId = _getUniqueSessionId();
_buffer.utma.firstTime = _timeStamp;
_buffer.utma.lastTime = _timeStamp;
_buffer.utma.currentTime = _timeStamp;
_buffer.utma.sessionCount = 1;
if (_debug.verbose){
_debug.info(_buffer.utma.toString(), VisualDebugMode.geek);
};
_noSessionInformation = true;
_isNewVisitor = true;
};
if (((_adSense.gaGlobal) && ((_adSense.dh == String(_domainHash))))){
if (_adSense.sid){
_buffer.utma.currentTime = Number(_adSense.sid);
if (_debug.verbose){
data0 = "";
data0 = (data0 + "AdSense sid found\n");
data0 = (data0 + (((("Override currentTime(" + _buffer.utma.currentTime) + ") from AdSense sid(") + Number(_adSense.sid)) + ")"));
_debug.info(data0, VisualDebugMode.geek);
};
};
if (_isNewVisitor){
if (_adSense.sid){
_buffer.utma.lastTime = Number(_adSense.sid);
if (_debug.verbose){
data1 = "";
data1 = (data1 + "AdSense sid found (new visitor)\n");
data1 = (data1 + (((("Override lastTime(" + _buffer.utma.lastTime) + ") from AdSense sid(") + Number(_adSense.sid)) + ")"));
_debug.info(data1, VisualDebugMode.geek);
};
};
if (_adSense.vid){
vid = _adSense.vid.split(".");
_buffer.utma.sessionId = Number(vid[0]);
_buffer.utma.firstTime = Number(vid[1]);
if (_debug.verbose){
data2 = "";
data2 = (data2 + "AdSense vid found (new visitor)\n");
data2 = (data2 + (((("Override sessionId(" + _buffer.utma.sessionId) + ") from AdSense vid(") + Number(vid[0])) + ")\n"));
data2 = (data2 + (((("Override firstTime(" + _buffer.utma.firstTime) + ") from AdSense vid(") + Number(vid[1])) + ")"));
_debug.info(data2, VisualDebugMode.geek);
};
};
if (_debug.verbose){
_debug.info(("AdSense modified : " + _buffer.utma.toString()), VisualDebugMode.geek);
};
};
};
_buffer.utmb.domainHash = _domainHash;
if (isNaN(_buffer.utmb.trackCount)){
_buffer.utmb.trackCount = 0;
};
if (isNaN(_buffer.utmb.token)){
_buffer.utmb.token = _config.tokenCliff;
};
if (isNaN(_buffer.utmb.lastTime)){
_buffer.utmb.lastTime = _buffer.utma.currentTime;
};
_buffer.utmc.domainHash = _domainHash;
if (_debug.verbose){
_debug.info(_buffer.utmb.toString(), VisualDebugMode.advanced);
_debug.info(_buffer.utmc.toString(), VisualDebugMode.advanced);
};
}
public function setLocalServerMode():void{
_config.serverMode = ServerOperationMode.local;
_debug.info("setLocalServerMode()");
}
public function clearIgnoredRef():void{
_debug.info("clearIgnoredRef()");
_config.organic.clearIgnoredReferrals();
}
public function setCampSourceKey(newCampSrcKey:String):void{
_config.campaignKey.UCSR = newCampSrcKey;
var msg = (("setCampSourceKey( " + _config.campaignKey.UCSR) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCSR]"));
} else {
_debug.info(msg);
};
}
public function getLocalGifPath():String{
_debug.info("getLocalGifPath()");
return (_config.localGIFpath);
}
public function setLocalGifPath(newLocalGifPath:String):void{
_config.localGIFpath = newLocalGifPath;
_debug.info((("setLocalGifPath( " + _config.localGIFpath) + " )"));
}
public function getVersion():String{
_debug.info("getVersion()");
return (_config.version);
}
public function setAllowAnchor(enable:Boolean):void{
_config.allowAnchor = enable;
_debug.info((("setAllowAnchor( " + _config.allowAnchor) + " )"));
}
private function _isNotGoogleSearch():Boolean{
var domainName:String = _config.domainName;
var g0 = (domainName.indexOf("www.google.") < 0);
var g1 = (domainName.indexOf(".google.") < 0);
var g2 = (domainName.indexOf("google.") < 0);
var g4 = (domainName.indexOf("google.org") > -1);
return (((((((((g0) || (g1))) || (g2))) || (!((_config.cookiePath == "/"))))) || (g4)));
}
public function setSampleRate(newRate:Number):void{
if (newRate < 0){
_debug.warning("sample rate can not be negative, ignoring value.");
} else {
_config.sampleRate = newRate;
};
_debug.info((("setSampleRate( " + _config.sampleRate) + " )"));
}
private function _takeSample():Boolean{
if (_debug.verbose){
_debug.info((((("takeSample: (" + (_visitCode() % 10000)) + ") < (") + (_config.sampleRate * 10000)) + ")"), VisualDebugMode.geek);
};
return (((_visitCode() % 10000) < (_config.sampleRate * 10000)));
}
public function setCookiePath(newCookiePath:String):void{
_config.cookiePath = newCookiePath;
_debug.info((("setCookiePath( " + _config.cookiePath) + " )"));
}
public function setAllowHash(enable:Boolean):void{
_config.allowDomainHash = enable;
_debug.info((("setAllowHash( " + _config.allowDomainHash) + " )"));
}
private function _generateUserDataHash():Number{
var hash:String = "";
hash = (hash + _info.appName);
hash = (hash + _info.appVersion);
hash = (hash + _info.language);
hash = (hash + _info.platform);
hash = (hash + _info.userAgent.toString());
hash = (hash + (((_info.screenWidth + "x") + _info.screenHeight) + _info.screenColorDepth));
hash = (hash + _info.referrer);
return (Utils.generateHash(hash));
}
public function setCampNOKey(newCampNOKey:String):void{
_config.campaignKey.UCNO = newCampNOKey;
var msg = (("setCampNOKey( " + _config.campaignKey.UCNO) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCNO]"));
} else {
_debug.info(msg);
};
}
public function addIgnoredOrganic(newIgnoredOrganicKeyword:String):void{
_debug.info((("addIgnoredOrganic( " + newIgnoredOrganicKeyword) + " )"));
_config.organic.addIgnoredKeyword(newIgnoredOrganicKeyword);
}
public function setLocalRemoteServerMode():void{
_config.serverMode = ServerOperationMode.both;
_debug.info("setLocalRemoteServerMode()");
}
public function cookiePathCopy(newPath:String):void{
_debug.warning((("cookiePathCopy( " + newPath) + " ) not implemented"));
}
public function setDetectTitle(enable:Boolean):void{
_config.detectTitle = enable;
_debug.info((("setDetectTitle( " + _config.detectTitle) + " )"));
}
public function setCampTermKey(newCampTermKey:String):void{
_config.campaignKey.UCTR = newCampTermKey;
var msg = (("setCampTermKey( " + _config.campaignKey.UCTR) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCTR]"));
} else {
_debug.info(msg);
};
}
public function getServiceMode():ServerOperationMode{
_debug.info("getServiceMode()");
return (_config.serverMode);
}
private function _trackMetrics(pageURL:String=""):void{
var searchVariables:Variables;
var x10vars:Variables;
var generalvars:Variables;
var eventInfo:EventInfo;
if (_takeSample()){
searchVariables = new Variables();
searchVariables.URIencode = true;
if (((_x10Module) && (_x10Module.hasData()))){
eventInfo = new EventInfo(false, _x10Module);
x10vars = eventInfo.toVariables();
};
generalvars = _renderMetricsSearchVariables(pageURL);
searchVariables.join(x10vars, generalvars);
_gifRequest.send(_account, searchVariables);
};
}
public function setCampaignTrack(enable:Boolean):void{
_config.campaignTracking = enable;
_debug.info((("setCampaignTrack( " + _config.campaignTracking) + " )"));
}
public function addIgnoredRef(newIgnoredReferrer:String):void{
_debug.info((("addIgnoredRef( " + newIgnoredReferrer) + " )"));
_config.organic.addIgnoredReferral(newIgnoredReferrer);
}
public function clearOrganic():void{
_debug.info("clearOrganic()");
_config.organic.clearEngines();
}
public function getDetectFlash():Boolean{
_debug.info("getDetectFlash()");
return (_config.detectFlash);
}
public function setCampMediumKey(newCampMedKey:String):void{
_config.campaignKey.UCMD = newCampMedKey;
var msg = (("setCampMediumKey( " + _config.campaignKey.UCMD) + " )");
if (_debug.mode == VisualDebugMode.geek){
_debug.info((msg + " [UCMD]"));
} else {
_debug.info(msg);
};
}
private function _getUniqueSessionId():Number{
var sessionID:Number = ((Utils.generate32bitRandom() ^ _generateUserDataHash()) * 2147483647);
_debug.info(("Session ID: " + sessionID), VisualDebugMode.geek);
return (sessionID);
}
private function _getDomainHash():Number{
if (((((!(_config.domainName)) || ((_config.domainName == "")))) || ((_config.domain.mode == DomainNameMode.none)))){
_config.domainName = "";
return (1);
};
_updateDomainName();
if (_config.allowDomainHash){
return (Utils.generateHash(_config.domainName));
};
return (1);
}
public function setSessionTimeout(newTimeout:int):void{
_config.sessionTimeout = newTimeout;
_debug.info((("setSessionTimeout( " + _config.sessionTimeout) + " )"));
}
public function getAccount():String{
_debug.info("getAccount()");
return (_account);
}
public function link(targetUrl:String, useHash:Boolean=false):void{
var targetUrl = targetUrl;
var useHash = useHash;
_initData();
var out:String = _buffer.getLinkerUrl(targetUrl, useHash);
var request:URLRequest = new URLRequest(out);
_debug.info((("link( " + [targetUrl, useHash].join(",")) + " )"));
navigateToURL(request, "_top");
//unresolved jump
var _slot1 = e;
_debug.warning(("An error occured in link() msg: " + _slot1.message));
}
public function setRemoteServerMode():void{
_config.serverMode = ServerOperationMode.remote;
_debug.info("setRemoteServerMode()");
}
}
}//package com.google.analytics.v4
Section 145
//AnalyticsTracker (com.google.analytics.AnalyticsTracker)
package com.google.analytics {
import flash.events.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
public interface AnalyticsTracker extends GoogleAnalyticsAPI, IEventDispatcher {
function set account(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics;AnalyticsTracker.as:String):void;
function get config():Configuration;
function get mode():String;
function set config(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics;AnalyticsTracker.as:Configuration):void;
function set mode(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics;AnalyticsTracker.as:String):void;
function set debug(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics;AnalyticsTracker.as:DebugConfiguration):void;
function get visualDebug():Boolean;
function get account():String;
function set visualDebug(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\google\analytics;AnalyticsTracker.as:Boolean):void;
function isReady():Boolean;
function get debug():DebugConfiguration;
}
}//package com.google.analytics
Section 146
//API (com.google.analytics.API)
package com.google.analytics {
import com.google.analytics.utils.*;
public class API {
public static var version:Version = new Version();
public function API(){
super();
}
version.major = 1;
version.minor = 0;
version.build = 1;
version.revision = "$Rev: 319 $ ".split(" ")[1];
}
}//package com.google.analytics
Section 147
//GATracker (com.google.analytics.GATracker)
package com.google.analytics {
import flash.display.*;
import flash.events.*;
import com.google.analytics.core.*;
import com.google.analytics.v4.*;
import com.google.analytics.debug.*;
import com.google.analytics.external.*;
import com.google.analytics.utils.*;
import com.google.analytics.events.*;
public class GATracker implements AnalyticsTracker {
private var _adSense:AdSenseGlobals;
private var _env:Environment;
private var _visualDebug:Boolean;
private var _idleTimer:IdleTimer;
private var _debug:DebugConfiguration;
private var _buffer:Buffer;
private var _config:Configuration;
private var _mode:String;
private var _display:DisplayObject;
private var _jsproxy:JavascriptProxy;
private var _dom:HTMLDOM;
private var _eventDispatcher:EventDispatcher;
private var _ready:Boolean;// = false
private var _gifRequest:GIFRequest;
private var _ecom:Ecommerce;
private var _account:String;
private var _tracker:GoogleAnalyticsAPI;
public static var version:Version = API.version;
public static var autobuild:Boolean = true;
public function GATracker(display:DisplayObject, account:String, mode:String="AS3", visualDebug:Boolean=false, config:Configuration=null, debug:DebugConfiguration=null){
super();
_display = display;
_eventDispatcher = new EventDispatcher(this);
_tracker = new TrackerCache();
this.account = account;
this.mode = mode;
this.visualDebug = visualDebug;
if (!debug){
this.debug = new DebugConfiguration();
};
if (!config){
this.config = new Configuration(debug);
};
if (autobuild){
_factory();
};
}
public function link(targetUrl:String, useHash:Boolean=false):void{
_tracker.link(targetUrl, useHash);
}
public function addOrganic(Layout:String, Layout:String):void{
_tracker.addOrganic(Layout, Layout);
}
public function setAllowLinker(enable:Boolean):void{
_tracker.setAllowLinker(enable);
}
public function trackEvent(TrackerCache:String, TrackerCache:String, TrackerCache:String=null, TrackerCache:Number=NaN):Boolean{
return (_tracker.trackEvent(TrackerCache, TrackerCache, TrackerCache, TrackerCache));
}
public function getLinkerUrl(url:String="", useHash:Boolean=false):String{
return (_tracker.getLinkerUrl(url, useHash));
}
public function setCookieTimeout(newDefaultTimeout:int):void{
_tracker.setCookieTimeout(newDefaultTimeout);
}
public function trackTrans():void{
_tracker.trackTrans();
}
public function getClientInfo():Boolean{
return (_tracker.getClientInfo());
}
public function trackPageview(pageURL:String=""):void{
_tracker.trackPageview(pageURL);
}
public function setClientInfo(Layout:Boolean):void{
_tracker.setClientInfo(Layout);
}
public function get account():String{
return (_account);
}
public function linkByPost(formObject:Object, useHash:Boolean=false):void{
_tracker.linkByPost(formObject, useHash);
}
public function getDetectTitle():Boolean{
return (_tracker.getDetectTitle());
}
public function dispatchEvent(event:Event):Boolean{
return (_eventDispatcher.dispatchEvent(event));
}
public function get config():Configuration{
return (_config);
}
public function set mode(value:String):void{
_mode = value;
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
_eventDispatcher.removeEventListener(type, listener, useCapture);
}
public function setDetectFlash(Layout:Boolean):void{
_tracker.setDetectFlash(Layout);
}
public function resetSession():void{
_tracker.resetSession();
}
public function setCampNameKey(newCampNameKey:String):void{
_tracker.setCampNameKey(newCampNameKey);
}
public function get debug():DebugConfiguration{
return (_debug);
}
public function addItem(item:String, sku:String, name:String, category:String, price:Number, quantity:int):void{
_tracker.addItem(item, sku, name, category, price, quantity);
}
private function _bridgeFactory():GoogleAnalyticsAPI{
debug.info(((("GATracker (Bridge) v" + version) + "\naccount: ") + account));
return (new Bridge(account, _debug, _jsproxy));
}
public function clearIgnoredOrganic():void{
_tracker.clearIgnoredOrganic();
}
public function set account(value:String):void{
_account = value;
}
public function setVar(newVal:String):void{
_tracker.setVar(newVal);
}
public function build():void{
if (!isReady()){
_factory();
};
}
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 setDomainName(newDomainName:String):void{
_tracker.setDomainName(newDomainName);
}
public function createEventTracker(useCapture:String):EventTracker{
return (_tracker.createEventTracker(useCapture));
}
public function setCampSourceKey(newCampSrcKey:String):void{
_tracker.setCampSourceKey(newCampSrcKey);
}
public function set config(value:Configuration):void{
_config = value;
}
public function addTrans(Layout:String, Layout:String, Layout:Number, Layout:Number, Layout:Number, Layout:String, Layout:String, Layout:String):void{
_tracker.addTrans(Layout, Layout, Layout, Layout, Layout, Layout, Layout, Layout);
}
public function setCampContentKey(newCampContentKey:String):void{
_tracker.setCampContentKey(newCampContentKey);
}
public function willTrigger(type:String):Boolean{
return (_eventDispatcher.willTrigger(type));
}
public function setLocalServerMode():void{
_tracker.setLocalServerMode();
}
public function isReady():Boolean{
return (_ready);
}
public function getLocalGifPath():String{
return (_tracker.getLocalGifPath());
}
public function setAllowAnchor(enable:Boolean):void{
_tracker.setAllowAnchor(enable);
}
public function clearIgnoredRef():void{
_tracker.clearIgnoredRef();
}
public function get mode():String{
return (_mode);
}
public function set debug(value:DebugConfiguration):void{
_debug = value;
}
public function setLocalGifPath(Layout:String):void{
_tracker.setLocalGifPath(Layout);
}
public function getVersion():String{
return (_tracker.getVersion());
}
public function setSampleRate(newRate:Number):void{
_tracker.setSampleRate(newRate);
}
public function setCookiePath(newCookiePath:String):void{
_tracker.setCookiePath(newCookiePath);
}
public function setAllowHash(enable:Boolean):void{
_tracker.setAllowHash(enable);
}
public function addIgnoredOrganic(Layout:String):void{
_tracker.addIgnoredOrganic(Layout);
}
public function setLocalRemoteServerMode():void{
_tracker.setLocalRemoteServerMode();
}
public function cookiePathCopy(newPath:String):void{
_tracker.cookiePathCopy(newPath);
}
private function _factory():void{
var activeTracker:GoogleAnalyticsAPI;
_jsproxy = new JavascriptProxy(debug);
if (visualDebug){
debug.layout = new Layout(debug, _display);
debug.active = visualDebug;
};
var cache:TrackerCache = (_tracker as TrackerCache);
switch (mode){
case TrackerMode.BRIDGE:
activeTracker = _bridgeFactory();
break;
case TrackerMode.AS3:
default:
activeTracker = _trackerFactory();
};
if (!cache.isEmpty()){
cache.tracker = activeTracker;
cache.flush();
};
_tracker = activeTracker;
_ready = true;
dispatchEvent(new AnalyticsEvent(AnalyticsEvent.READY, this));
}
public function setCampTermKey(newCampTermKey:String):void{
_tracker.setCampTermKey(newCampTermKey);
}
private function _trackerFactory():GoogleAnalyticsAPI{
debug.info(((("GATracker (AS3) v" + version) + "\naccount: ") + account));
_adSense = new AdSenseGlobals(debug);
_dom = new HTMLDOM(debug);
_dom.cacheProperties();
_env = new Environment("", "", "", debug, _dom);
_buffer = new Buffer(config, debug, false);
_gifRequest = new GIFRequest(config, debug, _buffer, _env);
_idleTimer = new IdleTimer(config, debug, _display, _buffer);
_ecom = new Ecommerce(_debug);
_env.url = _display.stage.loaderInfo.url;
return (new Tracker(account, config, debug, _env, _buffer, _gifRequest, _adSense, _ecom));
}
public function setCampNOKey(newCampNOKey:String):void{
_tracker.setCampNOKey(newCampNOKey);
}
public function setDetectTitle(Layout:Boolean):void{
_tracker.setDetectTitle(Layout);
}
public function clearOrganic():void{
_tracker.clearOrganic();
}
public function setCampaignTrack(enable:Boolean):void{
_tracker.setCampaignTrack(enable);
}
public function addIgnoredRef(Layout:String):void{
_tracker.addIgnoredRef(Layout);
}
public function getServiceMode():ServerOperationMode{
return (_tracker.getServiceMode());
}
public function set visualDebug(value:Boolean):void{
_visualDebug = value;
}
public function setCampMediumKey(newCampMedKey:String):void{
_tracker.setCampMediumKey(newCampMedKey);
}
public function getDetectFlash():Boolean{
return (_tracker.getDetectFlash());
}
public function get visualDebug():Boolean{
return (_visualDebug);
}
public function hasEventListener(type:String):Boolean{
return (_eventDispatcher.hasEventListener(type));
}
public function getAccount():String{
return (_tracker.getAccount());
}
public function setSessionTimeout(newTimeout:int):void{
_tracker.setSessionTimeout(newTimeout);
}
public function setRemoteServerMode():void{
_tracker.setRemoteServerMode();
}
}
var _local1:* = ServerOperationMode;
return (_local1);
}//package com.google.analytics
Section 148
//CustomEvent (com.malee.mcore.events.CustomEvent)
package com.malee.mcore.events {
import flash.events.*;
public class CustomEvent extends Event {
private var _data:Object;
public function CustomEvent(type:String, data:Object=null, bubbles:Boolean=false, cancelable:Boolean=false):void{
super(type, bubbles, cancelable);
_data = data;
}
public function get data():Object{
return (_data);
}
override public function clone():Event{
return (new CustomEvent(type, _data, bubbles, cancelable));
}
public function set data(data:Object):void{
_data = data;
}
}
}//package com.malee.mcore.events
Section 149
//EventTypes (com.malee.mcore.events.EventTypes)
package com.malee.mcore.events {
public final class EventTypes {
public static const OPENED:String = "NavigationEvent.Opened";
public static const NEXT:String = "NavigationEvent.Next";
public static const TIMELINE_EVENT:String = "FrameEvent.TimelineEvent";
public static const TIMELINE_START:String = "FrameEvent.TimelineStart";
public static const UPDATE:String = "ModifyEvent.Update";
public static const OPEN:String = "NavigationEvent.Open";
public static const MOVE:String = "ModifyEvent.Move";
public static const OK:String = "NavigationEvent.Ok";
public static const CLOSE:String = "NavigationEvent.Close";
public static const BACK:String = "NavigationEvent.Back";
public static const FORWARD:String = "NavigationEvent.Forward";
public static const CANCEL:String = "NavigationEvent.Cancel";
public static const SCALE:String = "ModifyEvent.Scale";
public static const CLOSED:String = "NavigationEvent.Closed";
public static const NAVIGATE:String = "NavigationEvent.Navigate";
public static const ROTATE:String = "ModifyEvent.Rotate";
public static const PREVIOUS:String = "NavigationEvent.Previous";
public static const SELECT:String = "NavigationEvent.Select";
public static const TIMELINE_END:String = "FrameEvent.TimelineEnd";
public function EventTypes(){
super();
}
}
}//package com.malee.mcore.events
Section 150
//FileErrorEvent (com.malee.mcore.events.FileErrorEvent)
package com.malee.mcore.events {
import flash.events.*;
public class FileErrorEvent extends ErrorEvent {
public static const FILESIZE_ERROR:String = "FileErrorEvent.FILESIZE_ERROR";
public function FileErrorEvent(type:String, text:String):void{
super(type, false, false, text);
}
override public function clone():Event{
return (new FileErrorEvent(type, text));
}
}
}//package com.malee.mcore.events
Section 151
//AssetLoader (com.malee.mcore.loaders.AssetLoader)
package com.malee.mcore.loaders {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
import flash.errors.*;
public class AssetLoader extends Loader implements ILoader {
private var context:LoaderContext;
private var request:URLRequest;
private var _url:String;
public function AssetLoader(url:String="", applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null){
super();
_url = url;
request = new URLRequest();
context = new LoaderContext();
this.applicationDomain = ((applicationDomain == null)) ? CURRENT_DOMAIN : applicationDomain;
this.securityDomain = securityDomain;
handleInternalEvents();
}
public function getClass(className:String):Class{
var className = className;
return ((contentLoaderInfo.applicationDomain.getDefinition(className) as Class));
//unresolved jump
var _slot1 = error;
trace(_slot1.message);
throw (new IllegalOperationError(((className + " definition not found in ") + url)));
return (null);
}
private function onIOError(event:IOErrorEvent):void{
dispatchEvent(event);
}
public function get percent():Number{
return ((bytesLoaded / bytesTotal));
}
public function set securityDomain(securityDomain:SecurityDomain):void{
context.securityDomain = securityDomain;
}
private function onSecurityError(event:SecurityErrorEvent):void{
dispatchEvent(event);
}
public function get bytesLoaded():uint{
return (contentLoaderInfo.bytesLoaded);
}
public function loadData(url:String):void{
_url = url;
request.url = url;
load(request, context);
}
private function onInit(event:Event):void{
dispatchEvent(event);
}
public function get bytesTotal():uint{
return (contentLoaderInfo.bytesTotal);
}
private function onComplete(event:Event):void{
dispatchEvent(event);
}
public function get securityDomain():SecurityDomain{
return (context.securityDomain);
}
public function set applicationDomain(applicationDomain:ApplicationDomain):void{
context.applicationDomain = applicationDomain;
}
private function onProgress(event:ProgressEvent):void{
dispatchEvent(event);
}
public function get applicationDomain():ApplicationDomain{
return (contentLoaderInfo.applicationDomain);
}
public function get url():String{
return (_url);
}
private function handleInternalEvents():void{
contentLoaderInfo.addEventListener(Event.INIT, onInit);
contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
}
override public function close():void{
super.close();
//unresolved jump
var _slot1 = error;
}
public static function get CURRENT_DOMAIN():ApplicationDomain{
return (ApplicationDomain.currentDomain);
}
public static function get NEW_DOMAIN():ApplicationDomain{
return (new ApplicationDomain());
}
public static function get CURRENT_SECURITY_DOMAIN():SecurityDomain{
return (SecurityDomain.currentDomain);
}
public static function loadQuick(url:String, onComplete:Function=null, onError:Function=null):AssetLoader{
var loader:AssetLoader = new (AssetLoader);
if (onError != null){
loader.addEventListener(IOErrorEvent.IO_ERROR, onError);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
};
if (onComplete != null){
loader.addEventListener(Event.COMPLETE, onComplete);
};
loader.loadData(url);
return (loader);
}
public static function get CHILD_DOMAIN():ApplicationDomain{
return (new ApplicationDomain(CURRENT_DOMAIN));
}
}
}//package com.malee.mcore.loaders
Section 152
//ILoader (com.malee.mcore.loaders.ILoader)
package com.malee.mcore.loaders {
import flash.events.*;
public interface ILoader extends IEventDispatcher {
function close():void;
function loadData(E:\JOBS\Seek\Seek_Xmas_Cannon\src;com\malee\mcore\loaders;ILoader.as:String):void;
function get url():String;
}
}//package com.malee.mcore.loaders
Section 153
//FileFilters (com.malee.mcore.net.FileFilters)
package com.malee.mcore.net {
import flash.net.*;
public class FileFilters {
public static const IMAGE_FILTER:FileFilter = new FileFilter("images", "*.jpg;*.gif;*.png");
public function FileFilters(){
super();
}
}
}//package com.malee.mcore.net
Section 154
//FileUpload (com.malee.mcore.net.FileUpload)
package com.malee.mcore.net {
import flash.events.*;
import flash.net.*;
import com.malee.mcore.events.*;
public class FileUpload extends EventDispatcher {
private var _limit:Number;
private var _data:URLVariables;
private var _request:URLRequest;
private var _file:FileReference;
public function FileUpload(fileSizeLimit:Number=0):void{
super();
_limit = fileSizeLimit;
_request = new URLRequest();
_data = new URLVariables();
_file = new FileReference();
_file.addEventListener(Event.SELECT, onSelect);
_file.addEventListener(ProgressEvent.PROGRESS, onProgress);
_file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, onUploadComplete);
_file.addEventListener(Event.COMPLETE, onComplete);
}
final public function upload(url:String):void{
_request.url = url;
_request.data = _data;
_file.upload(_request);
}
private function onSelect(event:Event):void{
if (_limit > 0){
if (fileSize > _limit){
dispatchEvent(new FileErrorEvent(FileErrorEvent.FILESIZE_ERROR, "Invalid file size"));
return;
};
};
dispatchEvent(event);
}
final public function get fileSize():uint{
return ((_file.size / 1000));
}
final public function get fileName():String{
return (_file.name);
}
final public function browse(typeFilter:Array=null):void{
_file.browse(typeFilter);
}
final public function addVariable(name:String, data):void{
_data[name] = data;
}
private function onProgress(event:ProgressEvent):void{
dispatchEvent(event);
}
final public function clearVariables():void{
_data = new URLVariables();
}
private function onUploadComplete(event:DataEvent):void{
dispatchEvent(event);
}
final public function get file():FileReference{
return (_file);
}
final public function get fileType():String{
return (_file.type);
}
private function onComplete(event:Event):void{
dispatchEvent(event);
}
}
}//package com.malee.mcore.net
Section 155
//AssetLibrary (com.psiom.assets.AssetLibrary)
package com.psiom.assets {
import flash.display.*;
import flash.media.*;
import com.psiom.rendering.renderableTypes.*;
import flash.utils.*;
public class AssetLibrary {
private var _sounds:Array;
private var _currentProfileID:int;// = -1
private var _currentSoundID:int;// = -1
private var _templateSprites:Array;
protected static var _cacheTimeArray:Array;
private static var _instance:AssetLibrary;
protected static var _timeTrace:Boolean = false;
public function AssetLibrary(){
super();
_instance = this;
_templateSprites = new Array();
_sounds = new Array();
}
public function addAnimClip(inClip:MovieClip, animateSubClips:Boolean=false):int{
var bmdArray:Array = generateAnimSet(inClip, animateSubClips);
return (generateSpriteProfile(bmdArray));
}
public function getSoundForID(inID:int):Sound{
return (_sounds[inID]);
}
public function addSound(inSound:Sound):int{
_sounds.push(inSound);
_currentSoundID++;
return (_currentSoundID);
}
private function generateSpriteProfile(inBMDArray:Array):int{
var sm:SpriteModel = new SpriteModel();
sm.BMDArray = inBMDArray;
sm.w = inBMDArray[0].width;
sm.h = inBMDArray[0].height;
_templateSprites.push(sm);
_currentProfileID++;
return (_currentProfileID);
}
public function getSpriteForProfileID(inID:int):SpriteModel{
return (_templateSprites[inID].clone());
}
public function addBitmap(inBMD:BitmapData):int{
return (generateSpriteProfile([inBMD]));
}
public static function generatePositionalData(mainClip:MovieClip, trackedClip:MovieClip):Array{
var targetClip:MovieClip;
var pArray:Array = [];
var i = 1;
while (i <= mainClip.totalFrames) {
mainClip.gotoAndStop(i);
targetClip = (mainClip.getChildByName(trackedClip.name) as MovieClip);
pArray.push({x:targetClip.x, y:targetClip.y, r:targetClip.rotation, scaleX:targetClip.scaleX, scaleY:targetClip.scaleY});
i++;
};
return (pArray);
}
public static function get Instance():AssetLibrary{
return (_instance);
}
private static function generateAnimSet(sourceClip:MovieClip, animateSubClips:Boolean=false):Array{
var w:Number;
var h:Number;
var secondsStart:uint;
var sBMD:BitmapData;
var j:int;
var childClip:MovieClip;
var secondsEnd:uint;
if (_timeTrace){
secondsStart = getTimer();
};
if (sourceClip.sizeRef){
sourceClip.sizeRef.visible = false;
w = sourceClip.sizeRef.width;
h = sourceClip.sizeRef.height;
} else {
w = sourceClip.width;
h = sourceClip.height;
};
var bmdArray:Array = new Array();
var i = 1;
while (i <= sourceClip.totalFrames) {
sourceClip.gotoAndStop(i);
if (animateSubClips){
j = 0;
while (j < sourceClip.numChildren) {
childClip = (sourceClip.getChildAt(j) as MovieClip);
if (childClip){
childClip.gotoAndStop((childClip.currentFrame + 1));
};
j++;
};
};
sBMD = new BitmapData(w, h, true, 0);
sBMD.draw(sourceClip);
bmdArray.push(sBMD);
i++;
};
if (_timeTrace){
if (!_cacheTimeArray){
_cacheTimeArray = new Array();
};
secondsEnd = getTimer();
_cacheTimeArray.push({name:String(sourceClip), time:Number((secondsEnd - secondsStart))});
};
return (bmdArray);
}
}
}//package com.psiom.assets
Section 156
//CoreSystem (com.psiom.foundation.CoreSystem)
package com.psiom.foundation {
import flash.events.*;
import flash.display.*;
import com.psiom.rendering.*;
import com.psiom.ui.uiComponents.*;
public class CoreSystem {
protected var _currentVGroup:int;// = -1
protected var _autoUpdateObjectSpace:Boolean;// = true
protected var _visibilityGroups:Array;
protected var _visibilityGroupObjects:Array;
protected var _currentSpace:ObjectSpace;
protected var _movieClipLayer:MovieClip;
protected var _currentCamera:RenderCam;
public function CoreSystem(){
super();
_visibilityGroups = new Array();
_visibilityGroupObjects = new Array();
_currentSpace = new ObjectSpace(this);
}
public function get Camera():RenderCam{
if (!_currentCamera){
trace("(EngineBase) WARNING: camera requested but not initialized.");
};
return (_currentCamera);
}
public function update():void{
_currentCamera.update();
if (((_currentSpace) && (_autoUpdateObjectSpace))){
_currentSpace.update();
};
}
protected function addVisibilityGroupObject(inObject:RenderableObject):void{
inObject.isMemberOfVisibilityGroup = true;
_visibilityGroupObjects.push(inObject);
if (!_currentSpace.contains(inObject)){
_currentSpace.addObject(inObject);
} else {
_currentSpace.moveObjToEnd(inObject);
};
inObject.a = 0;
inObject.sm.mc.visible = false;
}
public function applyVisibiltySet(inSetID:int):void{
var i:int;
var j:int;
if (inSetID == _currentVGroup){
return;
};
i = 0;
while (i < _visibilityGroupObjects.length) {
_visibilityGroupObjects[i].isInActiveVisibilityGroup = false;
i++;
};
i = 0;
while (i < _visibilityGroups[inSetID].length) {
j = 0;
while (j < _visibilityGroupObjects.length) {
if (_visibilityGroups[inSetID][i] == _visibilityGroupObjects[j]){
_visibilityGroupObjects[j].isInActiveVisibilityGroup = true;
};
j++;
};
i++;
};
_currentVGroup = inSetID;
}
public function getRenderData():Array{
if (!_currentSpace){
trace("(EngineBase) WARNING: objectSpace is NULL.");
};
return (_currentSpace.generateRenderData(_currentCamera));
}
protected function baseNavCallBack(e:Event):void{
var btn:UIButton = (e.target.parentObj as UIButton);
if ((((btn.VSetID >= 0)) && (btn.Enabled))){
applyVisibiltySet(btn.VSetID);
};
}
public function createNavButton(spriteID:int, clip:MovieClip=null, vSetID:int=-1, functionCallback:Function=null):UIButton{
var btn:UIButton = new UIButton(spriteID, clip);
btn.VSetID = vSetID;
btn.addEventListener(MouseEvent.CLICK, baseNavCallBack);
if (functionCallback != null){
btn.addEventListener(MouseEvent.CLICK, functionCallback);
};
if (!_currentSpace.contains(btn)){
_currentSpace.addObject(btn);
};
return (btn);
}
public function keyUp(keyCode:uint):void{
_currentSpace.keyUp(keyCode);
}
public function keyDown(keyCode:uint):void{
_currentSpace.keyDown(keyCode);
}
public function set MovieClipLayer(inMC:MovieClip):void{
_movieClipLayer = inMC;
}
public function keyboardInput(keyCode:int):void{
}
public function clickInput(x:Number, y:Number):void{
}
public function get CurrentSpace():ObjectSpace{
if (!_currentSpace){
trace("(EngineBase) WARNING: objectSpace requested but not initialized.");
};
return (_currentSpace);
}
public function onFirstAdded():void{
}
public function get MovieClipLayer():MovieClip{
if (!_movieClipLayer){
trace("(EngineBase) WARNING: movieClipLayer requested but does not exist.");
};
return (_movieClipLayer);
}
protected function addVisibilityGroup(inSetArray:Array):int{
_visibilityGroups.push(inSetArray);
return ((_visibilityGroups.length - 1));
}
}
}//package com.psiom.foundation
Section 157
//ObjectSpace (com.psiom.foundation.ObjectSpace)
package com.psiom.foundation {
import flash.display.*;
import com.psiom.rendering.*;
import com.psiom.ui.uiComponents.*;
import com.psiom.rendering.renderableTypes.*;
public class ObjectSpace {
public var zSortMode:int;// = 0
private var _inputListeners:Array;
protected var _autoPurge:Boolean;// = false
protected var _objects:Array;
private var _pendingObjects:Array;
private var _parentSystem:CoreSystem;
protected var _globalTranslateX:Number;// = 0
protected var _globalTranslateY:Number;// = 0
public static var ZSMODE_PERFRAME:int = 2;
public static var ZSMODE_AFTERADD:int = 1;
public static var ZSMODE_NONE:int = 0;
public function ObjectSpace(parentSystem:CoreSystem){
super();
_parentSystem = parentSystem;
_objects = new Array();
_pendingObjects = new Array();
_inputListeners = new Array();
_autoPurge = false;
}
public function addObject(obj:RenderableObject):void{
_pendingObjects.push(obj);
}
public function destroy():void{
removeAllObjects();
}
public function update():void{
updateMain();
}
public function updateUIOnly():void{
updateMain(true);
}
public function init():void{
}
public function removeAllObjects():void{
var i:int;
while (i < _objects.length) {
if (_objects[i].sm.mc){
if (_objects[i].sm.mc.parent == _parentSystem.MovieClipLayer){
_parentSystem.MovieClipLayer.removeChild(_objects[i].sm.mc);
};
};
_objects[i].purgeObject();
_objects[i].destroy();
i++;
};
_objects.splice(0, _objects.length);
_pendingObjects.splice(0, _pendingObjects.length);
_inputListeners.splice(0, _inputListeners.length);
}
public function keyUp(keyCode:uint):void{
}
public function keyDown(keyCode:uint):void{
}
public function clickInput(x:Number, y:Number):void{
var i:int;
while (i < _inputListeners.length) {
_inputListeners[i].clickInput(x, y);
i++;
};
}
public function contains(obj:RenderableObject):Boolean{
var i:int;
i = 0;
while (i < _pendingObjects.length) {
if (obj == _pendingObjects[i]){
return (true);
};
i++;
};
i = 0;
while (i < _objects.length) {
if (obj == _objects[i]){
return (true);
};
i++;
};
return (false);
}
public function updateMain(uiOnly:Boolean=false):void{
var i:int;
var j:int;
var obj:RenderableObject;
var mcObj:DisplayObject;
var addChildIsNeeded:Boolean;
i = 0;
while (i < _pendingObjects.length) {
obj = _pendingObjects[i];
_parentSystem.Camera.checkObjectInView(obj);
if (obj.sm.mc){
mcObj = obj.sm.mc;
addChildIsNeeded = (mcObj.parent == null);
if (addChildIsNeeded){
_parentSystem.MovieClipLayer.addChild(obj.sm.mc);
};
};
_objects.push(obj);
i++;
};
if ((((_pendingObjects.length > 0)) && ((zSortMode == ZSMODE_AFTERADD)))){
zSort();
};
_pendingObjects = new Array();
i = 0;
while (i < _objects.length) {
obj = _objects[i];
if (!obj){
trace(("### WARNING: obj is null: obj: " + obj));
};
if (!uiOnly){
obj.update();
} else {
if ((((obj is UIOBject)) || ((obj is UIButton)))){
obj.update();
};
};
if ((((Math.abs(_globalTranslateX) > 0)) || ((Math.abs(_globalTranslateY) > 0)))){
obj.x = (obj.x + _globalTranslateX);
obj.y = (obj.y + _globalTranslateY);
};
if (obj.FlaggedForPurge){
if (obj.sm.mc){
if (_parentSystem.MovieClipLayer.contains(obj.sm.mc)){
_parentSystem.MovieClipLayer.removeChild(obj.sm.mc);
};
};
obj.destroy();
_objects.splice(i, 1);
i--;
};
i++;
};
if (zSortMode == ZSMODE_PERFRAME){
zSort();
};
}
public function moveObjToEnd(inObj:RenderableObject):void{
var i:int;
i = 0;
while (i < _objects.length) {
if (inObj == _objects[i]){
_objects.splice(i, 1);
_objects.push(inObj);
return;
};
i++;
};
i = 0;
while (i < _pendingObjects.length) {
if (inObj == _pendingObjects[i]){
_pendingObjects.splice(i, 1);
_pendingObjects.push(inObj);
return;
};
i++;
};
}
public function get Objects():Array{
return (_objects);
}
public function generateRenderData(cam:RenderCam):Array{
var i:int;
var obj:RenderableObject;
var rd:Array = new Array();
i = 0;
while (i < _objects.length) {
obj = _objects[i];
if ((((obj.sm.mode == SpriteModel.RMODE_BITMAP_CACHED)) || ((obj.sm.mode == SpriteModel.RMODE_BITMAP_LIVEDRAW)))){
if (cam.checkObjectInView(_objects[i])){
rd.push(_objects[i].sm);
};
};
i++;
};
return (rd);
}
public function zSort():void{
_objects.sortOn("depth", Array.NUMERIC);
}
public function registerInputListener(obj:RenderableObject):void{
_inputListeners.push(obj);
}
public function addInputListener(obj:RenderableObject):void{
_inputListeners.push(obj);
}
}
}//package com.psiom.foundation
Section 158
//SpriteModel (com.psiom.rendering.renderableTypes.SpriteModel)
package com.psiom.rendering.renderableTypes {
import flash.display.*;
import com.psiom.util.*;
import flash.geom.*;
public class SpriteModel {
public var y:Number;// = 0
private var _subFrame:Number;// = 0
public var flipX:Boolean;// = false
private var _cliprect:Rectangle;
public var blendMode:String;
public var lockCameraTransform:Boolean;// = false
private var _movieClip:MovieClip;
public var mode:int;// = 0
public var loop:Boolean;// = false
private var _drawRect:Rectangle;
private var _currentFrame:Number;// = 0
private var _bmdArray:Array;
public var rOX:Number;// = 0
public var rOY:Number;// = 0
public var manualMC:Boolean;// = true
public var h:Number;// = 1
public var screenX:Number;// = 0
public var frameRate:Number;// = 0
public var r:Number;// = 0
public var s:Number;// = 1
public var screenY:Number;// = 0
public var w:Number;// = 1
public var x:Number;// = 0
public var z:Number;// = 1
public static var RMODE_MOVIECLIP:int = 2;
public static var RMODE_BITMAP_CACHED:int = 0;
public static var RMODE_BITMAP_LIVEDRAW:int = 1;
public function SpriteModel(){
super();
}
public function get currentFrame():Number{
return (_currentFrame);
}
public function get lastFrame():int{
if (_movieClip){
return ((_movieClip.totalFrames - 1));
};
return ((_bmdArray.length - 1));
}
public function set BMDArray(inArray:Array):void{
_bmdArray = inArray;
w = inArray[0].width;
h = inArray[0].height;
rOX = (-(w) / 2);
rOY = (-(h) / 2);
_drawRect = new Rectangle(0, 0, w, h);
}
public function get totalFrames():int{
if (_movieClip){
return (_movieClip.totalFrames);
};
return (_bmdArray.length);
}
public function get ClipRect():Rectangle{
return (_cliprect);
}
public function set ClipRect(val:Rectangle):void{
_cliprect = val;
}
public function get mc():MovieClip{
return (_movieClip);
}
public function set mc(inMC:MovieClip):void{
_movieClip = inMC;
_movieClip.stop();
}
public function get DrawRect():Rectangle{
return (_drawRect);
}
public function setBMD(inBMD:BitmapData):void{
currentFrame = 0;
_bmdArray = [inBMD];
w = inBMD.width;
h = inBMD.height;
}
public function get BMDArrayMax():int{
return ((_bmdArray.length - 1));
}
public function update(inX:Number, inY:Number, inZ:Number, inWidth:Number, inHeight:Number, inRotation:Number, inScale:Number, inAlpha:Number):void{
x = inX;
y = inY;
z = inZ;
w = inWidth;
h = inHeight;
r = inRotation;
s = inScale;
if (frameRate != 0){
_subFrame = (_subFrame + frameRate);
_currentFrame = Math.floor(_subFrame);
if (currentFrame < 0){
if (loop){
_subFrame = (_bmdArray.length - 1);
currentFrame = (_bmdArray.length - 1);
} else {
_subFrame = 0;
currentFrame = 0;
};
};
if (currentFrame > lastFrame){
if (loop){
_subFrame = 0;
currentFrame = 0;
} else {
_subFrame = lastFrame;
currentFrame = lastFrame;
};
};
};
if (_movieClip){
_movieClip.x = (x - 0);
_movieClip.y = y--;
_movieClip.rotation = MathFunction.radiansToDegrees(r);
_movieClip.scaleX = s;
_movieClip.scaleY = s;
_movieClip.alpha = inAlpha;
if (manualMC){
if (_movieClip.currentFrame != (currentFrame + 1)){
_movieClip.gotoAndStop((currentFrame + 1));
};
};
};
}
public function get BMD():BitmapData{
return (_bmdArray[currentFrame]);
}
public function clone():SpriteModel{
var smClone:SpriteModel = new SpriteModel();
smClone.BMDArray = _bmdArray;
smClone.x = x;
smClone.y = y;
smClone.z = z;
smClone.w = w;
smClone.h = h;
smClone.r = r;
smClone.s = s;
smClone.lockCameraTransform = lockCameraTransform;
smClone.loop = loop;
smClone.currentFrame = currentFrame;
smClone.frameRate = frameRate;
smClone.blendMode = blendMode;
return (smClone);
}
public function set currentFrame(val:Number):void{
_subFrame = val;
_currentFrame = Math.floor(_subFrame);
}
}
}//package com.psiom.rendering.renderableTypes
Section 159
//RenderableObject (com.psiom.rendering.RenderableObject)
package com.psiom.rendering {
import flash.display.*;
import com.psiom.util.*;
import com.psiom.assets.*;
import com.psiom.rendering.renderableTypes.*;
public class RenderableObject {
public var y:Number;// = 0
private var _spriteID:int;// = -1
public var radius:Number;// = 1
public var depthBias:Number;// = 0
private var _flaggedForPurge:Boolean;// = false
protected var _spriteModel:SpriteModel;
public var baseX:Number;// = 0
public var baseY:Number;// = 0
public var baseZ:Number;// = 1
protected var _autoVel:Boolean;// = true
public var isMemberOfVisibilityGroup:Boolean;// = false
public var primaryVis:Boolean;// = true
public var vx:Number;// = 0
public var vy:Number;// = 0
public var vz:Number;// = 0
public var framesSinceCameraView:Number;// = 0
public var a:Number;// = 1
public var h:Number;// = 0
public var inCameraView:Boolean;// = false
public var r:Number;// = 0
public var s:Number;// = 1
public var isInActiveVisibilityGroup:Boolean;// = false
public var z:Number;// = 1
public var w:Number;// = 0
public var x:Number;// = 0
public function RenderableObject(inSpriteID:int, inMovieClip:MovieClip=null){
super();
if (inSpriteID >= 0){
_spriteModel = AssetLibrary.Instance.getSpriteForProfileID(inSpriteID);
w = _spriteModel.w;
h = _spriteModel.h;
_spriteID = inSpriteID;
} else {
if (inMovieClip){
_spriteModel = new SpriteModel();
_spriteModel.mode = SpriteModel.RMODE_MOVIECLIP;
_spriteModel.mc = inMovieClip;
w = inMovieClip.width;
h = inMovieClip.height;
inCameraView = true;
} else {
trace("### ERROR: RenderableObject > con > neither spriteID or MovieClip supplied");
};
};
radius = ((w + h) / 2);
depthBias = (Math.random() * 0.005);
}
public function destroy():void{
}
public function manualSMUpdate():void{
_spriteModel.update(x, y, z, w, h, r, s, a);
}
public function cursorHitTest(cx:Number, cy:Number):Boolean{
if ((((((((cx > x)) && ((cx < (x + (w * s)))))) && ((cy > y)))) && ((cy < (y + (h * s)))))){
return (true);
};
return (false);
}
public function setSpriteByID(inSpriteID:int):void{
_spriteModel = AssetLibrary.Instance.getSpriteForProfileID(inSpriteID);
w = _spriteModel.w;
h = _spriteModel.h;
_spriteID = inSpriteID;
}
public function setBMD(inBMD:BitmapData):void{
w = inBMD.width;
h = inBMD.height;
sm.setBMD(inBMD);
}
public function get FlaggedForPurge():Boolean{
return (_flaggedForPurge);
}
public function get SpriteID():int{
return (_spriteID);
}
public function purgeObject():void{
if (isMemberOfVisibilityGroup){
trace("### WARNING: RenderableObject > purge > purging an object that belongs to a visibility set");
};
_flaggedForPurge = true;
}
public function setAngleFrameByDegrees(inDegrees:Number):void{
if (inDegrees < 0){
inDegrees = (inDegrees + 360);
};
_spriteModel.currentFrame = Math.floor(((inDegrees / 360) * _spriteModel.BMDArrayMax));
}
public function applyParalaxScale():void{
s = (((z * z) + 0.15) + (0.9 * z));
}
public function setSpriteModelAsClone(inSpriteModel:SpriteModel):void{
_spriteModel = inSpriteModel.clone();
w = _spriteModel.w;
h = _spriteModel.h;
}
public function get sm():SpriteModel{
return (_spriteModel);
}
public function get depth():Number{
return ((z + depthBias));
}
public function setParalaxOffset_mode0(inCamera:RenderCam):void{
var pDist:Number = MathFunction.getDistance(baseX, baseY, inCamera.cx, inCamera.cy);
var pRad:Number = MathFunction.getRadians(baseX, baseY, inCamera.cx, inCamera.cy);
var pVec:Object = MathFunction.getVector(pRad, pDist);
x = (baseX + (pVec.x * (1 - (z / 1))));
y = (baseY + (pVec.y * (1 - (z / 1))));
}
public function setParalaxOffset_mode1(inCamera:RenderCam, modifyer:Number=1):void{
var pDist:Number = MathFunction.getDistance(0, 0, inCamera.x, inCamera.y);
var pRad:Number = MathFunction.getRadians(0, 0, inCamera.x, inCamera.y);
var pVec:Object = MathFunction.getVector(pRad, pDist);
x = (baseX + ((pVec.x * modifyer) * (1 - (z / 1))));
y = (baseY + ((pVec.y * modifyer) * (1 - (z / 1))));
}
public function update():void{
if (_autoVel){
x = (x + vx);
y = (y + vy);
z = (z + vz);
};
if (sm.mc){
sm.mc.x = x;
sm.mc.y = y;
};
if (inCameraView){
_spriteModel.update(x, y, z, w, h, r, s, a);
if (sm.mc){
if (primaryVis){
sm.mc.visible = true;
} else {
sm.mc.visible = false;
};
};
} else {
if (sm.mc){
};
};
}
public function setParalaxOffset(inCamera:RenderCam, vpYBias:Number=100, inParalaxScalePivotY:Number=0):void{
var pDist:Number = MathFunction.getDistance(0, 0, inCamera.x, inCamera.y);
var pRad:Number = MathFunction.getRadians(0, 0, inCamera.x, inCamera.y);
var pVec:Object = MathFunction.getVector(pRad, pDist);
var pZ:Number = z;
var camDamp:Number = (1 - pZ);
x = ((baseX * ((pZ * pZ) * pZ)) + (pVec.x * camDamp));
y = ((baseY * ((pZ * pZ) * pZ)) + (pVec.y * camDamp));
x = (x + (baseX * 0.45));
y = (y + ((baseY * 0.1) + (((z * z) * z) * inParalaxScalePivotY)));
if (z < 1){
y = (y + (vpYBias * (1 - z)));
};
}
}
}//package com.psiom.rendering
Section 160
//RenderCam (com.psiom.rendering.RenderCam)
package com.psiom.rendering {
import com.psiom.util.*;
public class RenderCam {
public var currentY:Number;// = 0
private var _ch:Number;
private var _trackDiffY:Number;// = 0
private var _inverseOffetX:Number;// = 0
private var _inverseOffetY:Number;// = 0
private var _trackDiffX:Number;// = 0
private var _movementDirection:Number;// = 0
private var _cw:Number;
private var _constrained:Boolean;// = false
private var _camShakeAmp:Number;// = 0
private var _camShakeSin:Number;// = 0
private var _minX:Number;// = 0
public var baseX:Number;// = 0
public var baseY:Number;// = 0
private var _minY:Number;// = 0
private var _cropPadding:Number;// = 25
private var _movementVel:Number;// = 0
private var _zoomScale:Number;// = 1
private var _useYConstraintMax:Boolean;// = false
private var _trackSubject:Boolean;// = false
private var _cameraSubject:RenderableObject;
private var _maxX:Number;// = 0
private var _maxY:Number;// = 0
private var _camShake:Number;// = 0
public var subjectOffsetX:Number;// = 0
public var subjectOffsetY:Number;// = 0
public var targetX:Number;// = 0
public var targetY:Number;// = 0
private var _zoomScaleTarget:Number;// = 1
private var _yConstraintMax:Number;
public var x:Number;// = 0
public var y:Number;// = 0
private var _shakeTimer:Number;// = 0
public var currentX:Number;// = 0
private static var _instance:RenderCam;
public function RenderCam(w:Number, h:Number){
super();
_instance = this;
_cw = w;
_ch = h;
}
public function shake(inForce:Number):void{
_shakeTimer = 10;
_camShakeAmp = inForce;
}
public function get MovementDirection():Number{
return (_movementDirection);
}
public function setCameraSubject(obj:RenderableObject, snap:Boolean=true):void{
if (obj == _cameraSubject){
return;
};
_cameraSubject = obj;
if (obj){
_trackSubject = true;
} else {
_trackSubject = false;
return;
};
if (snap){
snapToSubject();
};
}
public function snapToLocation(inX:Number, inY:Number):void{
x = inX;
y = inY;
currentX = x;
currentY = y;
targetX = x;
targetY = y;
}
public function get CameraSubject():RenderableObject{
return (_cameraSubject);
}
public function checkObjectInView(obj:RenderableObject):Boolean{
if (!obj.primaryVis){
return (false);
};
obj.inCameraView = true;
return (true);
}
public function snapToSubject():void{
if (_cameraSubject){
x = _cameraSubject.x;
y = _cameraSubject.y;
currentX = x;
currentY = y;
targetX = x;
targetY = y;
} else {
trace("### WARNING: RenderCam > cannot snap to _cameraSubject with null value.");
};
}
public function update():void{
var tx:Number;
var ty:Number;
var offsetDir:Number;
var offsetDist:Number;
var inverseVec:Object;
_shakeTimer--;
_camShakeAmp = (_camShakeAmp * 0.825);
if (_camShakeAmp < 0.01){
_camShakeAmp = 0;
};
_camShakeSin = (_camShakeSin + 0.7);
_camShake = (Math.sin(_camShakeSin) * _camShakeAmp);
if (_trackSubject){
tx = _cameraSubject.x;
ty = _cameraSubject.y;
targetX = (targetX + ((tx - targetX) * 0.33));
targetY = (targetY + ((ty - targetY) * 0.33));
if (_constrained){
if (targetX < _minX){
targetX = _minX;
};
if (targetX > _maxX){
targetX = _maxX;
};
if (targetY < _minY){
targetY = _minY;
};
if (targetY > _maxY){
targetY = _maxY;
};
if (currentX < _minX){
currentX = _minX;
};
if (currentX > _maxX){
currentX = _maxX;
};
if (currentY < _minY){
currentY = _minY;
};
if (currentY > _maxY){
currentY = _maxY;
};
if (targetX < _minX){
targetX = _minX;
};
if (targetX > _maxX){
targetX = _maxX;
};
if (targetY < _minY){
targetY = _minY;
};
if (targetY > _maxY){
targetY = _maxY;
};
};
offsetDir = MathFunction.getRadians(targetX, targetY, currentX, currentY);
offsetDist = MathFunction.getDistance(targetX, targetY, currentX, currentY);
inverseVec = MathFunction.getVector(offsetDir, (-(offsetDist) * 2.8));
_inverseOffetX = (_inverseOffetX + ((inverseVec.x - _inverseOffetX) * 0.12));
_inverseOffetY = (_inverseOffetY + ((inverseVec.y - _inverseOffetY) * 0.12));
} else {
_inverseOffetX = 0;
_inverseOffetY = 0;
};
currentX = (currentX + ((targetX - currentX) * 0.33));
currentY = (currentY + ((targetY - currentY) * 0.33));
_movementDirection = MathFunction.getRadians(x, y, (currentX + _inverseOffetX), ((currentY + _camShake) + _inverseOffetY));
_movementVel = MathFunction.getDistance(x, y, (currentX + _inverseOffetX), ((currentY + _camShake) + _inverseOffetY));
x = Math.floor((currentX + _inverseOffetX));
y = Math.floor(((currentY + _camShake) + _inverseOffetY));
if (_constrained){
if (x < _minX){
x = _minX;
};
if (x > _maxX){
x = _maxX;
};
if (y < _minY){
y = _minY;
};
if (y > _maxY){
y = _maxY;
};
if (currentX < _minX){
currentX = _minX;
};
if (currentX > _maxX){
currentX = _maxX;
};
if (currentY < _minY){
currentY = _minY;
};
if (currentY > _maxY){
currentY = _maxY;
};
if (targetX < _minX){
targetX = _minX;
};
if (targetX > _maxX){
targetX = _maxX;
};
if (targetY < _minY){
targetY = _minY;
};
if (targetY > _maxY){
targetY = _maxY;
};
};
}
public function get ch():Number{
return (_ch);
}
public function get CamVel():Number{
return (_movementVel);
}
public function get cw():Number{
return (_cw);
}
public function get cx():Number{
return ((x + (_cw / 2)));
}
public function get cy():Number{
return ((y + (_ch / 2)));
}
public function setLocationConstraint(minX:Number, minY:Number, maxX:Number, maxY:Number):void{
_constrained = true;
_minX = minX;
_maxX = maxX;
_minY = minY;
_maxY = maxY;
}
public static function get Instance():RenderCam{
return (_instance);
}
}
}//package com.psiom.rendering
Section 161
//RenderManager (com.psiom.rendering.RenderManager)
package com.psiom.rendering {
import flash.display.*;
import com.psiom.rendering.renderableTypes.*;
import flash.geom.*;
public class RenderManager {
private var _canvasBMD:BitmapData;
private var _matrix:Matrix;
private var _clearColor:int;// = 7828901
private var _canvas:Bitmap;
private var _mainRect:Rectangle;
private var _mainPoint:Point;
private static var _instance:RenderManager;
public function RenderManager(){
super();
_instance = this;
}
public function setCanvas(cw:Number, ch:Number):Bitmap{
if (_canvasBMD){
_canvasBMD.dispose();
};
_canvasBMD = new BitmapData(cw, ch, false, 7828901);
if (!_canvas){
_canvas = new Bitmap(_canvasBMD, PixelSnapping.NEVER, true);
} else {
_canvas.bitmapData = _canvasBMD;
};
_mainRect = new Rectangle(0, 0, cw, ch);
_mainPoint = new Point(0, 0);
return (_canvas);
}
public function renderSprites(spriteData:Array, cam:RenderCam):void{
var pt:Point;
var sm:SpriteModel;
var px:Number;
var py:Number;
var clipRect:Rectangle;
var overlap:Number;
var rx:Number;
var lx:Number;
var by:Number;
var ty:Number;
var ox:Number;
var oy:Number;
var scaleDiff:Number;
_canvasBMD.lock();
var camOffsetX:Number = (cam.x - (cam.cw / 2));
var camOffsetY:Number = (cam.y - (cam.ch / 2));
var i:int;
while (i < spriteData.length) {
sm = spriteData[i];
if (sm.lockCameraTransform){
pt = new Point(sm.x, sm.y);
} else {
px = ((sm.x - ((sm.w * sm.s) / 2)) - camOffsetX);
py = ((sm.y - ((sm.h * sm.s) / 2)) - camOffsetY);
pt = new Point(px, py);
sm.screenX = px;
sm.screenY = py;
};
if (sm.BMD){
if ((((((((sm.r == 0)) && ((sm.s == 1)))) && (!(sm.blendMode)))) && (!(sm.flipX)))){
_canvasBMD.copyPixels(sm.BMD, sm.DrawRect, pt, null, null, true);
} else {
if (!_matrix){
_matrix = new Matrix();
};
_matrix.identity();
if (((sm.flipX) && ((sm.s == 1)))){
_matrix.translate((-(sm.w) * sm.s), 0);
_matrix.scale(-(sm.s), sm.s);
};
if (sm.r != 0){
ox = sm.rOX;
oy = sm.rOY;
_matrix.translate(ox, oy);
_matrix.rotate(sm.r);
_matrix.translate(-(ox), -(oy));
};
if (sm.s != 1){
if (sm.flipX){
_matrix.translate((-(sm.w) * 1), 0);
_matrix.scale(-(sm.s), sm.s);
} else {
scaleDiff = (sm.s - 1);
_matrix.scale(sm.s, sm.s);
};
};
_matrix.translate(pt.x, pt.y);
clipRect = new Rectangle(pt.x, pt.y, (sm.s * sm.w), (sm.s * sm.h));
rx = (pt.x + (sm.s * sm.w));
if (rx > _mainRect.right){
overlap = (rx - _mainRect.right);
clipRect.width = (clipRect.width - overlap);
};
lx = pt.x;
if (lx < 0){
overlap = Math.abs((0 - pt.x));
clipRect.left = (clipRect.left + overlap);
};
by = (pt.y + (sm.s * sm.h));
if (by > _mainRect.right){
overlap = (by - _mainRect.bottom);
clipRect.height = (clipRect.height - overlap);
};
ty = pt.y;
if (ty < 0){
overlap = Math.abs((0 - pt.y));
clipRect.top = (clipRect.top + overlap);
};
_canvasBMD.draw(sm.BMD, _matrix, null, sm.blendMode, clipRect, true);
};
} else {
trace(((("### WARNING: RenderManager > renderSprites > supplied BitmapData is null. sm: " + sm) + " @frame: ") + sm.currentFrame));
};
i++;
};
_canvas.bitmapData = _canvasBMD;
_canvas.smoothing = true;
_canvasBMD.unlock();
}
public function set ClearColor(val:int):void{
_clearColor = val;
}
public function clear():void{
_canvasBMD.fillRect(_mainRect, _clearColor);
}
public function get Canvas():Bitmap{
return (_canvas);
}
public static function get Instance():RenderManager{
return (_instance);
}
}
}//package com.psiom.rendering
Section 162
//SoundManager (com.psiom.sound.SoundManager)
package com.psiom.sound {
import flash.events.*;
import flash.media.*;
import com.psiom.assets.*;
public class SoundManager {
private var _frameID:int;// = 0
private var _musicLoop:Sound;
private var _soundListeners:Array;
private var _volume:Number;// = 1
private var _musicChannel:SoundChannel;
private static var _instance:SoundManager;
public function SoundManager(){
super();
_instance = this;
_soundListeners = new Array();
}
public function fullReset():void{
trace("### warning: SoundManager > fullReset > implement this method.");
}
public function playSound(id:int, vol:Number=1, sndCompleteListener:Function=null):SoundChannel{
var channel:SoundChannel;
var sndtrns:SoundTransform = new SoundTransform();
sndtrns.volume = (sndtrns.volume * vol);
var snd:Sound = AssetLibrary.Instance.getSoundForID(id);
channel = snd.play();
if (sndCompleteListener != null){
channel.addEventListener(Event.SOUND_COMPLETE, sndCompleteListener);
_soundListeners.push({sndchan:channel, callback:sndCompleteListener});
};
return (channel);
}
public function setMusicLoop(id:int=0):void{
if (_musicChannel){
_musicChannel.stop();
};
var vMod2:Number = 1;
if (id == 0){
_musicLoop = new snd_menuloop();
vMod2 = 0.5;
} else {
_musicLoop = new snd_gameloop();
vMod2 = 0.48;
};
var sndtrns:SoundTransform = new SoundTransform();
sndtrns.volume = ((1 * _volume) * vMod2);
_musicChannel = _musicLoop.play(0, int.MAX_VALUE, sndtrns);
}
public function iterate():void{
_frameID++;
}
public function removeListeners():void{
var i:int;
while (i < _soundListeners.length) {
_soundListeners[i].sndchan.removeEventListener(Event.SOUND_COMPLETE, _soundListeners[i].callback);
i++;
};
}
public function setVolume(val:Number):void{
SoundMixer.soundTransform = new SoundTransform(val);
trace(("setting volume to: " + val));
}
public function setLoopVolumeByID(val:Number, id:int):void{
}
public static function get Instance():SoundManager{
return (_instance);
}
}
}//package com.psiom.sound
Section 163
//UIButton (com.psiom.ui.uiComponents.UIButton)
package com.psiom.ui.uiComponents {
import flash.events.*;
import flash.display.*;
public class UIButton extends UIOBject {
private var _enabled:Boolean;// = true
private var _swell:Boolean;// = true
private var basePositionInit:Boolean;// = false
private var baseHeight:Number;
private var _toggleState:int;// = -1
private var rollHLStrength:Number;// = 1
private var rollActive:Boolean;// = false
private var _vsetID:int;// = -1
private var _numStates:int;// = 2
private var baseWidth:Number;
public function UIButton(inSpriteID:int=-1, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
if (sm.mc){
baseX = inMovieClip.x;
baseY = inMovieClip.y;
if (((!((inMovieClip.x == 0))) || (!((inMovieClip.y == 0))))){
basePositionInit = true;
};
};
baseWidth = w;
baseHeight = h;
if (sm.mc){
sm.mc.mouseChildren = false;
if (sm.mc.roll){
sm.mc.roll.alpha = 0;
};
sm.mc.addEventListener(MouseEvent.MOUSE_OVER, onRollOn);
sm.mc.addEventListener(MouseEvent.MOUSE_OUT, onRollOut);
sm.mc.buttonMode = true;
};
}
public function enable():void{
if (_clickCallback != null){
if (sm.mc){
sm.mc.addEventListener(MouseEvent.CLICK, _clickCallback);
sm.mc.buttonMode = true;
} else {
_dispatcherUtil.addEventListener(MouseEvent.CLICK, _clickCallback);
};
};
_enabled = true;
}
public function get VSetID():int{
return (_vsetID);
}
public function set VSetID(id:int):void{
_vsetID = id;
}
public function quickHide():void{
primaryVis = false;
a = 0;
}
override public function update():void{
super.update();
if (!basePositionInit){
baseX = x;
baseY = y;
basePositionInit = true;
};
if (sm.mc.alpha < 0.75){
rollActive = false;
};
if (rollActive){
if (sm.mc){
if (sm.mc.roll){
sm.mc.roll.visible = true;
if (sm.mc.roll.alpha > (rollHLStrength - 0.02)){
sm.mc.roll.alpha = rollHLStrength;
};
sm.mc.roll.alpha = (sm.mc.roll.alpha + ((rollHLStrength - sm.mc.roll.alpha) * 0.33));
};
};
} else {
if (sm.mc){
if (sm.mc.roll){
if (sm.mc.roll.alpha < 0.02){
sm.mc.roll.visible = false;
};
sm.mc.roll.alpha = (sm.mc.roll.alpha + ((0 - sm.mc.roll.alpha) * 0.33));
};
};
};
if (_swell){
if (sm.mc){
if (sm.mc.roll){
s = (1 + (sm.mc.roll.alpha * 0.05));
};
};
};
x = (baseX - (((w * s) - baseWidth) / 2));
y = (baseY - (((h * s) - baseHeight) / 2));
}
public function set RollHLStrength(n:Number):void{
rollHLStrength = n;
}
public function toggleState():void{
if (_toggleState == -1){
trace(("### WARNING: toggleState() called on a button not initialized for toggling: " + this));
};
_toggleState++;
if (_toggleState > (_numStates - 1)){
_toggleState = 0;
};
if (sm.mc){
if (sm.mc.base){
sm.mc.base.gotoAndStop((_toggleState + 1));
};
if (sm.mc.roll){
sm.mc.roll.gotoAndStop((_toggleState + 1));
};
};
}
override protected function onBaseClick(e:Event):void{
if (_enabled){
_dispatcherUtil.dispatchEvent(new Event(MouseEvent.CLICK));
};
}
public function get Enabled():Boolean{
return (_enabled);
}
public function disable():void{
trace(("_clickCallback: " + _clickCallback));
if (_clickCallback != null){
if (sm.mc){
sm.mc.removeEventListener(MouseEvent.CLICK, _clickCallback);
sm.mc.buttonMode = false;
} else {
_dispatcherUtil.removeEventListener(MouseEvent.CLICK, _clickCallback);
};
};
_enabled = false;
}
public function makeToggle(defaultState:int=0, numStates:int=2):void{
if (numStates < 2){
trace(((("### WARNING: number of states in toggle button is out of wack. numStates: " + numStates) + " on ") + this));
};
_numStates = numStates;
if (defaultState < 0){
defaultState = 0;
};
if (defaultState > (_numStates - 1)){
defaultState = (_numStates - 1);
};
if (sm.mc){
if (sm.mc.base){
sm.mc.base.gotoAndStop((defaultState + 1));
};
if (sm.mc.roll){
sm.mc.roll.gotoAndStop((defaultState + 1));
};
};
_toggleState = defaultState;
}
private function onRollOut(event:Event):void{
if (_enabled){
rollActive = false;
_dispatcherUtil.dispatchEvent(new Event(MouseEvent.MOUSE_OUT));
};
}
public function get CurrentState():int{
return (_toggleState);
}
private function onRollOn(event:Event):void{
if (_enabled){
rollActive = true;
_dispatcherUtil.dispatchEvent(new Event(MouseEvent.MOUSE_OVER));
};
}
public function setSwell(val:Boolean):void{
_swell = val;
}
}
}//package com.psiom.ui.uiComponents
Section 164
//UIOBject (com.psiom.ui.uiComponents.UIOBject)
package com.psiom.ui.uiComponents {
import flash.events.*;
import flash.display.*;
import com.psiom.util.*;
import com.psiom.rendering.*;
import com.psiom.*;
public class UIOBject extends RenderableObject {
protected var _dispatcherUtil:DispatcherUtil;
private var _fadeUpDelayTicks:Number;// = 0
private var _fadeSpeed:Number;// = 0.33
protected var _clickCallback:Function;
public var clip:MovieClip;
private var _fadeUpDelayBase:Number;// = 0
public function UIOBject(inSpriteID:int=-1, inMovieClip:MovieClip=null){
_dispatcherUtil = new DispatcherUtil();
_dispatcherUtil.parentObj = this;
super(inSpriteID, inMovieClip);
clip = sm.mc;
}
override public function update():void{
super.update();
var i:int;
if (isMemberOfVisibilityGroup){
if (isInActiveVisibilityGroup){
if (sm.mc){
sm.mc.mouseEnabled = true;
sm.mc.mouseChildren = true;
};
if (_fadeUpDelayTicks < _fadeUpDelayBase){
_fadeUpDelayTicks++;
} else {
primaryVis = true;
a = (a + ((1 - a) * _fadeSpeed));
if (a > 0.98){
a = 1;
};
};
} else {
if (sm.mc){
sm.mc.mouseEnabled = false;
sm.mc.mouseChildren = false;
};
_fadeUpDelayTicks = 0;
a = (a + ((0 - a) * _fadeSpeed));
if (a < 0.02){
primaryVis = false;
};
};
};
}
public function centerY(objRef:RenderableObject=null):void{
var ry:Number;
if (objRef){
ry = (objRef.y + ((objRef.h - h) / 2));
} else {
ry = ((Constants.STAGEHEIGHT - h) / 2);
};
y = ry;
}
protected function onBaseClick(e:Event):void{
_dispatcherUtil.dispatchEvent(new Event(MouseEvent.CLICK));
}
public function centerX(objRef:RenderableObject=null):void{
var rx:Number;
if (objRef){
rx = (objRef.x + ((objRef.w - w) / 2));
} else {
rx = ((Constants.STAGEWIDTH - w) / 2);
};
x = rx;
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
_dispatcherUtil.addEventListener(type, listener, useCapture, priority, useWeakReference);
if (type == MouseEvent.CLICK){
_clickCallback = listener;
if (sm.mc){
sm.mc.addEventListener(type, onBaseClick, useCapture, priority, useWeakReference);
};
};
}
public function positionInsetFromObjY(objRef:RenderableObject, insetY:Number):void{
y = (objRef.y + insetY);
}
public function set FadeSpeed(n:Number):void{
_fadeSpeed = n;
}
public function set FadeUpDelay(n:Number):void{
_fadeUpDelayBase = n;
}
}
}//package com.psiom.ui.uiComponents
Section 165
//ArrayTools (com.psiom.util.ArrayTools)
package com.psiom.util {
public class ArrayTools {
public function ArrayTools(){
super();
}
public static function getRandomStringElement(inArray:Array):String{
var len:int = inArray.length;
var rIndex:int = Math.floor((Math.random() * (len - 0.0001)));
return (inArray[rIndex]);
}
public static function getRandomElementFromArray(inArray:Array){
var len:int = inArray.length;
var rIndex:int = Math.floor((Math.random() * (len - 0.0001)));
return (inArray[rIndex]);
}
public static function getRandomIndexFromArray(inArray:Array):int{
var len:int = inArray.length;
var rIndex:int = Math.floor((Math.random() * (len - 0.0001)));
return (rIndex);
}
}
}//package com.psiom.util
Section 166
//DispatcherUtil (com.psiom.util.DispatcherUtil)
package com.psiom.util {
import flash.events.*;
public class DispatcherUtil extends EventDispatcher {
public var parentObj;
public function DispatcherUtil(target:IEventDispatcher=null){
super(target);
}
}
}//package com.psiom.util
Section 167
//FPSCounter (com.psiom.util.FPSCounter)
package com.psiom.util {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
public class FPSCounter extends Sprite {
private var tf:TextField;
private var ticks:uint;// = 0
private var last:uint;
public function FPSCounter(xPos:int=0, yPos:int=0, color:uint=0xFFFFFF, fillBackground:Boolean=false, backgroundColor:uint=0){
last = getTimer();
super();
x = xPos;
y = yPos;
tf = new TextField();
tf.textColor = color;
tf.text = "----- fps";
tf.selectable = false;
tf.background = fillBackground;
tf.backgroundColor = backgroundColor;
tf.autoSize = TextFieldAutoSize.LEFT;
addChild(tf);
width = tf.textWidth;
height = tf.textHeight;
addEventListener(Event.ENTER_FRAME, tick);
}
public function tick(evt:Event):void{
var fps:Number;
ticks++;
var now:uint = getTimer();
var delta:uint = (now - last);
if (delta >= 1000){
fps = ((ticks / delta) * 1000);
tf.text = (fps.toFixed(1) + " fps");
ticks = 0;
last = now;
};
}
}
}//package com.psiom.util
Section 168
//GigyaWrapper (com.psiom.util.GigyaWrapper)
package com.psiom.util {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public class GigyaWrapper {
private var _gigyaLoader:Loader;
private var _uiWidth:Number;
private var _emailSubject:String;
private var _thumbURL:String;
private var _emailBody:String;
private var _widgetWidth:Number;
private var cfg:Object;
private var _gigyaLayer:MovieClip;
private var _partnerID:String;// = "1085901"
private var _swfURL:String;
private var _wfAlreadyLoaded:Boolean;// = false
private var _widgetHeight:Number;
private var _ready:Boolean;// = false
private var _widgetTitle:String;
private var _uiHeight:Number;
private var _cid:String;
private static var _instance:GigyaWrapper;
public function GigyaWrapper(){
super();
_instance = this;
}
private function onGigyaError(e:Event):void{
trace("GIGYA LOAD ERROR");
}
public function loadWildfire(evt:Event, justEmail:Boolean=false):void{
var url:String;
var urlReq:URLRequest;
var evt = evt;
var justEmail = justEmail;
if (!_ready){
trace("### ERROR: GigyaWrapper > loadWildFire > Gigya module was not initialized");
return;
};
_gigyaLayer.visible = true;
var ModuleID = "PostModule1";
cfg = {};
cfg["width"] = String(_uiWidth);
cfg["height"] = String(_uiHeight);
cfg["widgetTitle"] = _widgetTitle;
cfg["useFacebookMystuff"] = "false";
cfg["partner"] = "1085901";
var configString = "";
configString = (configString + "<config baseTheme=\"v2\"><display ");
if (justEmail){
configString = (configString + "showPost=\"false\" ");
configString = (configString + "showEmail=\"true\" ");
configString = (configString + "showBookmark=\"false\" ");
} else {
configString = (configString + "showPost=\"true\" ");
configString = (configString + "showEmail=\"false\" ");
configString = (configString + "showBookmark=\"true\" ");
};
configString = (configString + "showCodeBox=\"false\" ");
configString = (configString + "showCloseButton=\"true\"");
configString = (configString + ">");
configString = (configString + "</display><body>");
configString = (configString + "<background corner-roundness=\"10\"></background>");
configString = (configString + "<controls>");
configString = (configString + "<snbuttons iconsOnly=\"false\"></snbuttons>");
configString = (configString + "</controls></body></config>");
trace(("configString: " + configString));
cfg["UIConfig"] = configString;
cfg["CID"] = _cid;
cfg["emailSubject"] = _emailSubject;
cfg["emailBody"] = _emailBody;
trace(("@@@@@@@@@@@@@@ GigyaWrapper > _swfURL: " + _swfURL));
cfg["defaultContent"] = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" " + "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" ") + "width=\"") + _widgetWidth) + "\" ") + "height=\"") + _widgetHeight) + "\" ") + "id=\"WFHost\">") + "<param name=\"FlashVars\"") + "value=\"Partner=") + _partnerID) + "&theme=New Classic&") + "&widgetW=") + String(_widgetWidth)) + "&widgetH=") + String(_widgetHeight)) + "&widgetX=0") + "&widgetY=0") + "&stickyType=bottom&WFBtnX=313&WFBtnY=450") + "&defaultPreviewURL=") + _thumbURL) + "&useFacebookMystuff=false") + "&URL=") + _swfURL) + "\"/>") + "<param name=\"wmode\" value=\"transparent\"/>") + "<param name=\"allowScriptAccess\" value=\"always\" />") + "<param name=\"movie\" value=\"") + _swfURL) + "\" /> ") + "<embed name=\"WFHost\" id=\"WFHost\" ") + "width=\"") + _widgetWidth) + "\" ") + "height=\"") + _widgetHeight) + "\" ") + "src=\"") + _swfURL) + "\" flashvars=\"Partner=1085901") + "&theme=New Classic") + "&widgetW=") + _widgetWidth) + "&widgetH=") + _widgetHeight) + "&widgetX=0") + "&widgetY=0") + "&stickyType=bottom") + "&WFBtnX=313") + "&WFBtnY=450") + "&defaultPreviewURL=") + _thumbURL) + "&useFacebookMystuff=false") + "&URL=") + _swfURL) + "AllowScriptAccess=\"always\" ") + "quality=\"high\" ") + "wmode=\"transparent\" ") + "type=\"application/x-shockwave-flash\" ") + "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />") + "</object>");
if (!_gigyaLoader){
_gigyaLoader = new Loader();
_gigyaLayer.addChild(_gigyaLoader);
};
cfg["onClose"] = function (eventObj:Object):void{
_gigyaLayer.visible = false;
var _local2 = _gigyaLoader.content;
_local2["INIT"]();
};
if (!_wfAlreadyLoaded){
_wfAlreadyLoaded = true;
url = ("http://cdn.gigya.com/WildFire/swf/wildfireInAS3.swf?ModuleID=" + ModuleID);
urlReq = new URLRequest(url);
_gigyaLayer[ModuleID] = cfg;
_gigyaLoader.load(urlReq);
_gigyaLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onGigyaLoaded);
_gigyaLoader.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, onGigyaError);
} else {
_gigyaLayer["PostModule1"] = cfg;
var _local4 = _gigyaLoader.content;
_local4["INIT"]();
};
}
private function onGigyaLoaded(e:Event):void{
trace("GIGYA LOADED");
}
public function initParams(parentLayer:MovieClip, inX:Number, inY:Number, inUIWidth:Number, inUIHeight:Number, inWidgetWidth:Number, inWidgetHeight:Number, inTitle:String, inSWFURL:String, inThumbURL:String, inEmailSubject:String, inEmailBody:String):void{
_gigyaLayer = new MovieClip();
parentLayer.addChild(_gigyaLayer);
_gigyaLayer.name = "_gigyaLayer";
_gigyaLayer.x = inX;
_gigyaLayer.y = inY;
_uiWidth = inUIWidth;
_uiHeight = inUIHeight;
_widgetWidth = inWidgetWidth;
_widgetHeight = inWidgetHeight;
_widgetTitle = inTitle;
_swfURL = inSWFURL;
_thumbURL = inThumbURL;
_emailSubject = inEmailSubject;
_emailBody = inEmailBody;
_ready = true;
}
public function generateEmbedCode(width:int, height:int, swf:String, version:String, quality:String="high", base:String="."):String{
var txt:String = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
txt = (txt + (("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + version) + "\" "));
txt = (txt + (("width=\"" + width) + "\" "));
txt = (txt + (("height=\"" + height) + "\" >"));
txt = (txt + (("<param name=\"movie\" value=\"" + swf) + "\" />"));
txt = (txt + (("<param name=\"movie\" value=\"" + swf) + "\" />"));
txt = (txt + (("<param name=\"quality\" value=\"" + quality) + "\" />"));
txt = (txt + (((("<embed src=\"" + swf) + "\" quality=\"") + quality) + "\" "));
txt = (txt + "pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" ");
txt = (txt + "type=\"application/x-shockwave-flash\" ");
txt = (txt + (((((("width=\"" + width) + "\" height=\"") + height) + "\" base=\"") + base) + "\" />"));
txt = (txt + "</object>");
return (txt);
}
public static function get Instance():GigyaWrapper{
if (!_instance){
_instance = new (GigyaWrapper);
};
return (_instance);
}
}
}//package com.psiom.util
Section 169
//MathFunction (com.psiom.util.MathFunction)
package com.psiom.util {
public class MathFunction {
public function MathFunction(){
super();
}
public static function degreesToRadians(inDegrees:Number):Number{
return ((inDegrees * (Math.PI / 180)));
}
public static function framesToTimeCode(inFramerate:Number, inFrameCount:Number):String{
var ts:String;
var subSeconds:Number = (inFrameCount % inFramerate);
var subSeconds100:Number = ((subSeconds / inFramerate) * 99);
var seconds:Number = ((inFrameCount - subSeconds) / inFramerate);
var minutes:Number = 0;
while (seconds > 59) {
seconds = (seconds - 60);
minutes++;
};
var minutesString:String = "";
if (minutes < 10){
minutesString = (minutesString + "0");
};
minutesString = (minutesString + String(minutes));
if (minutes > 99){
minutesString = "99";
};
var secondsString:String = "";
if (seconds < 10){
secondsString = (secondsString + "0");
};
secondsString = (secondsString + String(seconds));
var subSecondsString:String = "";
if (subSeconds < 10){
subSecondsString = (subSecondsString + "0");
};
subSecondsString = (subSecondsString + String(subSeconds));
return (((((minutesString + ":") + secondsString) + ":") + subSecondsString));
}
public static function pnr():Number{
return ((Math.random() - 0.5));
}
public static function formatNumberStringWithCommas(inNumber:Number):String{
var k:Number;
var d:Number;
var nString:String = String(inNumber);
var fieldPieces:Array = nString.split("");
fieldPieces.reverse();
var finalString:String = "";
k = 0;
while (k < fieldPieces.length) {
finalString = (fieldPieces[k] + finalString);
d = (k % 3);
if (k < (fieldPieces.length - 1)){
if (d == 2){
finalString = ("," + finalString);
};
};
k++;
};
return (finalString);
}
public static function get pnRand():Number{
return ((Math.random() - 0.5));
}
public static function getVector(inRadians:Number, inVelocity:Number):Object{
var vX:Number = (inVelocity * Math.cos(inRadians));
var vY:Number = (inVelocity * Math.sin(inRadians));
return ({x:vX, y:vY});
}
public static function radiansToDegrees(inRadians:Number):Number{
return ((inRadians * (180 / Math.PI)));
}
public static function getDistance(inSourceX:Number, inSourceY:Number, inTargetX:Number, inTargetY:Number):Number{
return (Math.sqrt(((Math.abs((inSourceX - inTargetX)) * Math.abs((inSourceX - inTargetX))) + (Math.abs((inSourceY - inTargetY)) * Math.abs((inSourceY - inTargetY))))));
}
public static function getRadians(inSourceX:Number, inSourceY:Number, inTargetX:Number, inTargetY:Number):Number{
return (Math.atan2((inTargetY - inSourceY), (inTargetX - inSourceX)));
}
}
}//package com.psiom.util
Section 170
//SharedObjectWrapper (com.psiom.util.SharedObjectWrapper)
package com.psiom.util {
import flash.events.*;
import flash.net.*;
public class SharedObjectWrapper {
private var _avail:Boolean;// = false
private var _so:SharedObject;
private var _soDummy:Object;
public function SharedObjectWrapper(){
super();
_soDummy = {data:new Object()};
}
public function get data():Object{
if (_avail){
return (_so.data);
};
return (_soDummy.data);
}
public function flush():void{
if (_avail){
_so.flush();
//unresolved jump
var _slot1 = error;
_avail = false;
};
}
private function onFlushStatus(event:NetStatusEvent):void{
switch (event.info.code){
case "SharedObject.Flush.Success":
break;
case "SharedObject.Flush.Failed":
_avail = false;
break;
};
_so.removeEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
}
public function init(inName:String, inLocalPath:String):void{
_so = SharedObject.getLocal(inName, inLocalPath);
_so.addEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
_soDummy = {data:new Object()};
_avail = true;
}
}
}//package com.psiom.util
Section 171
//SwearWordTester (com.psiom.util.SwearWordTester)
package com.psiom.util {
public class SwearWordTester {
private static var isBadword:int;
private static var isLegal:Boolean;
private static var testWordLC:String;
private static var si:int;
private static var swearwordList:Array = new Array("co ck", "c unt", "cu nt", "fu ck", "f uck", "fuk", "fuc", "cnt", "knt", "ass", "dic", "fag", "d1k", "4q", "cun", "pis", "nig", "gay", "fu", "as5", "a55", "p1s", "fu2", "BJ", "BJU", "bum", "cok", "cum", "tit", "t1t", "coc", "koc", "f4g", "c0k", "c0c", "twt", "pus", "dyk", "tlt", "sac", "sak", "s4c", "s4k", "arse", "fuck", "shit", "cunt");
private static var swearWord:String;
public function SwearWordTester(){
super();
}
public static function testWordForErrors(testWord:String):Boolean{
if (testWord.length < 1){
trace("word not long enough");
return (false);
};
si = 0;
while (si < swearwordList.length) {
swearWord = swearwordList[si];
testWordLC = testWord.toLowerCase();
isBadword = testWordLC.indexOf(swearWord);
if (isBadword != -1){
return (false);
};
si++;
};
return (true);
}
}
}//package com.psiom.util
Section 172
//AppMain (com.psiom.AppMain)
package com.psiom {
import flash.events.*;
import com.psiom.foundation.*;
import flash.display.*;
import com.psiom.util.*;
import com.psiom.rendering.*;
import com.psiom.sound.*;
import flash.system.*;
import com.soapcreative.net.tracking.*;
public class AppMain extends MovieClip {
protected var _keyBuffer:Number;
protected var _keyBufferMax:Number;// = 21
protected var _coreSystems:Array;
protected var _keyString:String;
protected var _sharedObj:SharedObjectWrapper;
protected var _gigyaLayer:MovieClip;
private var showFPS:Boolean;// = false
private var _mainMouseDown:Boolean;// = false
private var _renderManager:RenderManager;
private var _gaTracker:GameTracking;
public function AppMain(){
super();
_coreSystems = new Array();
addEventListener(Event.ADDED_TO_STAGE, onMainAdded);
}
private function onMainKeyUp(e:KeyboardEvent):void{
var i:int;
while (i < _coreSystems.length) {
_coreSystems[i].keyUp(e.keyCode);
i++;
};
}
protected function onMainKeyDown(e:KeyboardEvent):void{
_keyBuffer = _keyBufferMax;
_keyString = (_keyString + String.fromCharCode(e.keyCode));
var i:int;
while (i < _coreSystems.length) {
_coreSystems[i].keyDown(e.keyCode);
i++;
};
}
public function get MainMouseDown():Boolean{
return (_mainMouseDown);
}
private function onMainMouseDown(e:Event):void{
_mainMouseDown = true;
}
protected function update():void{
var i:int;
_renderManager.clear();
i = 0;
while (i < _coreSystems.length) {
_coreSystems[i].update();
_renderManager.renderSprites(_coreSystems[i].getRenderData(), _coreSystems[i].Camera);
i++;
};
SoundManager.Instance.iterate();
if (_keyBuffer > 0){
_keyBuffer--;
} else {
_keyString = "";
};
}
private function onMainEnterFrame(e:Event):void{
update();
}
private function onMainMouseUp(e:Event):void{
_mainMouseDown = false;
}
private function onMainAdded(e:Event):void{
mainInit();
}
protected function mainInit():void{
var fpsCount:FPSCounter;
GameTracking.trackLoaded();
addEventListener("enterFrame", onMainEnterFrame);
if (!Constants.SHARED_OBJ_CONTAINER){
trace("### WARNING: AppMain > mainInit > SHARED_OBJ_CONTAINER:null");
};
_sharedObj = new SharedObjectWrapper();
_sharedObj.init(Constants.SHARED_OBJ_CONTAINER, "/");
_sharedObj.init("elfChimneySeeker", "/");
Security.allowDomain("cdn.gigya.com");
Security.allowInsecureDomain("cdn.gigya.com");
new SoundManager();
addEventListener(MouseEvent.CLICK, onMainClick);
addEventListener(MouseEvent.MOUSE_DOWN, onMainMouseDown);
addEventListener(MouseEvent.MOUSE_UP, onMainMouseUp);
stage.addEventListener(MouseEvent.MOUSE_UP, onMainMouseUpOutside);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onMainKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onMainKeyUp);
_keyString = "";
_keyBuffer = 0;
_renderManager = new RenderManager();
_renderManager.setCanvas(1050, 675);
addChild(_renderManager.Canvas);
if (showFPS){
addChild(new FPSCounter());
};
}
protected function addCoreSystem(inSystem:CoreSystem):void{
inSystem.MovieClipLayer = new MovieClip();
addChild(inSystem.MovieClipLayer);
_coreSystems.push(inSystem);
inSystem.onFirstAdded();
}
private function onMainClick(e:Event):void{
var i:int;
i = 0;
while (i < _coreSystems.length) {
_coreSystems[i].clickInput(mouseX, mouseY);
i++;
};
}
private function onMainMouseUpOutside(e:Event):void{
_mainMouseDown = false;
}
}
}//package com.psiom
Section 173
//Constants (com.psiom.Constants)
package com.psiom {
public class Constants {
public static var BASE_URL:String;
public static var STAGEHEIGHT:Number = -1;
public static var STAGEWIDTH:Number = -1;
public static var ENGINE_RESTITUTION:Number = 1;
public static var ENGINE_GRAVITY:Number = 1.2;
public static var ENGINE_PHYS_SCALE:Number = 30;
public static var ENGINE_FRICTION:Number = 0.5;
public static var TRACKING_GAME_NAME:String = "chimney";
public static var SHARED_OBJ_CONTAINER:String;
public function Constants(){
super();
}
}
}//package com.psiom
Section 174
//GameTracking (com.soapcreative.net.tracking.GameTracking)
package com.soapcreative.net.tracking {
import flash.utils.*;
import flash.errors.*;
public class GameTracking {
public static const VERSION:String = "1.0.1";
private static var _started:Boolean;
private static var _level:int;
private static var _initialized:Boolean = false;
private static var _failed:Boolean;
private static var _time:int;
private static var _playing:Boolean;
public function GameTracking(){
super();
throw (new ArgumentError("GameTracking should be implemented as a static class"));
}
public static function get started():Boolean{
return (_started);
}
public static function trackLanguage(language:String="en"):void{
GoogleTracking.pageView("locale", language);
}
private static function getLevelString(level:int):String{
return (("level" + ((level < 10)) ? ("0" + level) : level));
}
public static function trackIndex():void{
if (GoogleTracking.api == null){
throw (new IllegalOperationError("GoogleTracking must be initialized before using GameTracking"));
};
GoogleTracking.pageView("index");
GoogleTracking.trackEvent("game", "index");
_level = 0;
_initialized = true;
_started = (_playing = false);
recordTime();
}
private static function trackLevelBegin(level:int, type:String):void{
GoogleTracking.pageView(getLevelString(level), type);
GoogleTracking.trackEvent(getLevelString(level), type);
}
public static function startLevel(level:int, isReplay:Boolean=false):void{
checkCondition(_started, "startGame must be called prior to startLevel");
_level = level;
if (isReplay == true){
if ((((_playing == true)) && ((_failed == true)))){
trackLevelBegin(_level, "replay");
};
} else {
trackLevelBegin(_level, "start");
};
recordTime();
_failed = false;
_playing = true;
}
public static function get level():int{
return (_level);
}
public static function trackScore(score:int):void{
trackMiscellaneous("score", score);
}
public static function trackSubmitScore(score:int):void{
GoogleTracking.trackEvent("game", "score", score);
}
public static function levelFail():void{
checkCondition(_playing, "startLevel must be called prior to levelFail");
_failed = true;
trackLevelEnd(_level, "fail");
}
public static function clearTime():void{
_time = 0;
}
public static function getElapsedSeconds():Number{
var elapsed:Number = (getElapsedTime() / 1000);
return (Number(elapsed.toFixed(2)));
}
public static function levelComplete():void{
checkCondition(_playing, "startLevel must be called prior to levelComplete");
_failed = false;
trackLevelEnd(_level, "complete");
}
public static function getElapsedTime():int{
return ((getTimer() - _time));
}
public static function trackMiscellaneous(name:String, value:Number=NaN):void{
GoogleTracking.trackEvent("misc", name, value);
}
public static function trackAchievement(achievement:String):void{
GoogleTracking.trackEvent("achievement", achievement);
}
public static function trackLink(name:String="clientSite"):void{
GoogleTracking.trackEvent("linkOut", name);
}
private static function trackLevelEnd(level:int, type:String):void{
GoogleTracking.trackEvent(getLevelString(level), type, getElapsedSeconds());
clearTime();
}
public static function get playing():Boolean{
return (_playing);
}
public static function levelQuit():void{
checkCondition(_playing, "startLevel must be called prior to levelQuit");
_playing = false;
trackLevelEnd(_level, "quit");
}
public static function startGame():void{
checkCondition(_initialized, "trackIndex must be called prior to startGame");
if (_started == false){
GoogleTracking.pageView("start");
GoogleTracking.trackEvent("game", "start");
} else {
GoogleTracking.trackEvent("game", "restart");
};
_started = true;
_failed = (_playing = false);
}
public static function trackLoaded():void{
GoogleTracking.trackEvent("game", "load", int(getElapsedSeconds()));
GoogleTracking.pageView("main");
clearTime();
}
private static function checkCondition(comparison:Boolean, error:String):void{
if (comparison == false){
throw (new IllegalOperationError(error));
};
}
public static function trackPage(page:String):void{
GoogleTracking.trackEvent("menu", page);
}
public static function get failed():Boolean{
return (_failed);
}
public static function recordTime():void{
_time = getTimer();
}
}
}//package com.soapcreative.net.tracking
Section 175
//GoogleTracking (com.soapcreative.net.tracking.GoogleTracking)
package com.soapcreative.net.tracking {
import flash.display.*;
import com.google.analytics.*;
import flash.errors.*;
public class GoogleTracking {
public static const AS3_MODE:String = "AS3";
public static const VERSION:String = "1.0.0";
public static const BRIDGE_MODE:String = "Bridge";
public static var track:Boolean;
private static var _project:String;
private static var _api:GATracker;
public function GoogleTracking():void{
super();
throw (new ArgumentError("GoogleTracking should be implemented as a static class"));
}
public static function pageView(... _args):void{
var rest = _args;
var event:String = rest.join("/");
if (track == true){
_api.trackPageview(((_project + "/") + event));
} else {
trace((((("[GoogleTracking] - TRACKING PAGE VIEW (" + _project) + "/") + event) + ")"));
};
//unresolved jump
var _slot1 = error;
throw (new IllegalOperationError("GoogleTracking has not been initialized"));
}
public static function trackEvent(action:String, label:String=null, value:Number=NaN):Boolean{
var action = action;
var label = label;
var value = value;
var success:Boolean;
if (track == true){
success = _api.trackEvent(_project, action, label, value);
} else {
success = true;
trace((((((("[GoogleTracking] - TRACKING EVENT (" + action) + ", ") + label) + ", ") + value) + ")"));
};
//unresolved jump
var _slot1 = error;
throw (new IllegalOperationError("GoogleTracking has not been initialized"));
return (success);
}
public static function initialize(displayObject:DisplayObject, account:String, project:String, track:Boolean=true, debug:Boolean=false, mode:String="AS3"):GATracker{
_api = new GATracker(displayObject, account, mode, debug);
_project = project;
GoogleTracking.track = track;
return (_api);
}
public static function get api():GATracker{
return (_api);
}
}
}//package com.soapcreative.net.tracking
Section 176
//XmasCannon_Assets (com.xmascannon.assets.XmasCannon_Assets)
package com.xmascannon.assets {
import com.psiom.util.*;
import com.psiom.assets.*;
public class XmasCannon_Assets extends AssetLibrary {
public static var SPR_OBS_DEER1:int;
public static var SPR_TICKFLAG:int;
public static var SND_WOOHOO:int;
public static var SPR_SHOULDER:int;
public static var SPR_MGHILL1:int;
public static var SPR_OBS_TREEBIRDS:int;
public static var SND_COLLECT:int;
public static var SPR_FXSTAR:int;
public static var SPR_GAMEPLAYHINT:int;
public static var SPR_HOUSE1:int;
public static var SPR_HOUSE3:int;
public static var SPR_POWERBARGHOST:int;
public static var SPR_HOUSE5:int;
public static var SPR_HOUSE6:int;
public static var SPR_HOUSE7:int;
public static var SPR_HOUSE2:int;
public static var SPR_HOUSE4:int;
public static var SPR_HOUSE8:int;
public static var SPR_SMOKEPUFF:int;
public static var SPR_CANNONBASE:int;
public static var SND_CLANK:int;
public static var SPR_FGHILL1:int;
public static var SPR_FGHILL2:int;
public static var SPR_FGHILL3:int;
public static var SPR_FGHILL4:int;
public static var SPR_AURORA:int;
public static var SPR_CANNONBARREL:int;
public static var SPR_OBS_UMBRELLASM:int;
public static var SND_OUCH1:int;
public static var SND_OUCH2:int;
public static var SND_OUCH3:int;
public static var SND_OUCH4:int;
public static var SND_OUCH5:int;
public static var SND_OUCH6:int;
public static var SND_OUCH7:int;
public static var SND_OUCH8:int;
public static var SND_OUCH9:int;
public static var SND_CHIMNEYCHIME:int;
public static var SND_YAY:int;
public static var SPR_BGMOUTAINS:int;
public static var SND_CASH:int;
public static var SND_YIPEE:int;
public static var SPR_GROUND:int;
public static var SPR_MGTREES:int;
public static var SND_IMIN:int;
public static var SND_LIGHTTHUD:int;
public static var SPR_WRIST:int;
public static var SPR_DEBUGNODE:int;
public static var SPR_OBS_SLEIGH:int;
public static var SND_HOORAY:int;
public static var SPR_CHIMNEYLEGS:int;
public static var SPR_OBS_SPACEBF:int;
public static var SPR_BGTREES:int;
public static var SPR_SHIN:int;
public static var SPR_OBS_NPSIGN:int;
public static var SND_PRESDELIV:int;
public static var SND_CANNON:int;
public static var SND_HEAVYTHUD:int;
public static var SPR_OBS_DEER2:int;
public static var SPR_OBS_DEER3:int;
public static var SPR_OBS_BAUBLE:int;
public static var SPR_TRAILLINE:int;
public static var SND_OOF1:int;
public static var SND_OOF2:int;
public static var SPR_MIDDLETORSO:int;
public static var SPR_CHIMNEYSMOKE:int;
public static var SPR_OBS_TRAMPOLINE:int;
public static var SPR_FALLINGSNOW:int;
public static var SPR_HAT:int;
public static var SND_CLANK2:int;
public static var SPR_CANNONPOWERBAR:int;
public static var SPR_SHOTDISPLAY:int;
public static var SPR_DEFAULTHEAD:int;
public static var SPR_BLUESPARK1:int;
public static var SPR_THIGH:int;
public static var SPR_SKYBG:int;
public static var SND_BOING:int;
public static var SND_OUCH10:int;
public static var SND_OUCH11:int;
public static var SND_OUCH12:int;
public static var SND_OUCH13:int;
public static var SND_OUCH14:int;
public static var SND_OUCH15:int;
public static var SND_OUCH16:int;
public static var SND_OUCH17:int;
public static var SPR_OBS_STAR:int;
public static var SPR_PANCURSOR:int;
public static var SND_BIGTHUD:int;
public static var SPR_BARRELGHOST:int;
public static var SPR_CROSSHAIR:int;
public static var SPR_COLLECTABLE:int;
public function XmasCannon_Assets(){
var i:int;
super();
_timeTrace = false;
SND_HOORAY = addSound(new snd_hooray());
SND_IMIN = addSound(new snd_imin());
SND_OOF1 = addSound(new snd_oof1());
SND_OOF2 = addSound(new snd_oof2());
SND_OUCH1 = addSound(new snd_ouch1());
SND_OUCH2 = addSound(new snd_ouch2());
SND_OUCH3 = addSound(new snd_ouch3());
SND_OUCH4 = addSound(new snd_ouch4());
SND_OUCH5 = addSound(new snd_ouch5());
SND_OUCH6 = addSound(new snd_ouch6());
SND_OUCH7 = addSound(new snd_ouch7());
SND_OUCH8 = addSound(new snd_ouch8());
SND_OUCH9 = addSound(new snd_ouch9());
SND_OUCH10 = addSound(new snd_ouch10());
SND_OUCH11 = addSound(new snd_ouch11_s());
SND_OUCH12 = addSound(new snd_ouch12());
SND_OUCH13 = addSound(new snd_ouch13());
SND_OUCH14 = addSound(new snd_ouch14());
SND_OUCH15 = addSound(new snd_ouch15());
SND_OUCH16 = addSound(new snd_ouch16());
SND_OUCH17 = addSound(new snd_ouch17_s());
SND_PRESDELIV = addSound(new snd_presdeliv());
SND_WOOHOO = addSound(new snd_woohoo());
SND_YAY = addSound(new snd_yay());
SND_YIPEE = addSound(new snd_yipee());
SND_BIGTHUD = addSound(new snd_bigthud());
SND_BOING = addSound(new snd_boing());
SND_CANNON = addSound(new snd_cannonfire());
SND_CASH = addSound(new snd_cashregister());
SND_CLANK = addSound(new snd_clank());
SND_CLANK2 = addSound(new snd_clank2());
SND_COLLECT = addSound(new snd_collect());
SND_HEAVYTHUD = addSound(new snd_heavythud());
SND_LIGHTTHUD = addSound(new snd_lightthud());
SND_CHIMNEYCHIME = addSound(new snd_hitChimney());
SPR_DEBUGNODE = addAnimClip(new gClip_debugNode());
SPR_PANCURSOR = addAnimClip(new gClip_panCursor());
SPR_GAMEPLAYHINT = addAnimClip(new uimain_gameplayHint());
SPR_SKYBG = addAnimClip(new gClip_skyBG());
SPR_GROUND = addAnimClip(new gClip_ground());
SPR_AURORA = addAnimClip(new gClip_aurora());
SPR_BGMOUTAINS = addAnimClip(new gClip_bgMountians());
SPR_BGTREES = addAnimClip(new gClip_bgTrees());
SPR_CHIMNEYSMOKE = addAnimClip(new gClip_chimneySmoke());
SPR_FGHILL1 = addAnimClip(new gClip_fgHill1());
SPR_FGHILL2 = addAnimClip(new gClip_fgHill2());
SPR_FGHILL3 = addAnimClip(new gClip_fgHill3());
SPR_FGHILL4 = addAnimClip(new gClip_fgHill4());
SPR_MGHILL1 = addAnimClip(new gClip_mgHill1());
SPR_MGTREES = addAnimClip(new gClip_fgTree());
SPR_FXSTAR = addAnimClip(new gClip_star());
SPR_FALLINGSNOW = addAnimClip(new gClip_snowFlake());
SPR_BLUESPARK1 = addAnimClip(new gClip_blueSpark1());
SPR_SMOKEPUFF = addAnimClip(new gClip_smokePuff());
SPR_BARRELGHOST = addAnimClip(new gClip_cannonBarrelGhost());
SPR_POWERBARGHOST = addAnimClip(new gClip_cannonPowerBarGhost());
SPR_TRAILLINE = addAnimClip(new gClip_trailLine());
SPR_CROSSHAIR = addAnimClip(new gClip_crossHair());
SPR_CANNONBASE = addAnimClip(new gClip_cannonBase());
SPR_CANNONBARREL = addAnimClip(new gClip_cannonBarrel());
SPR_CANNONPOWERBAR = addAnimClip(new gClip_cannonPowerBar());
SPR_COLLECTABLE = addAnimClip(new gClip_collectable());
SPR_HOUSE1 = addAnimClip(new gClip_house1());
SPR_HOUSE2 = addAnimClip(new gClip_house2());
SPR_HOUSE3 = addAnimClip(new gClip_house3());
SPR_HOUSE4 = addAnimClip(new gClip_house4());
SPR_HOUSE5 = addAnimClip(new gClip_house5());
SPR_HOUSE6 = addAnimClip(new gClip_house6());
SPR_HOUSE7 = addAnimClip(new gClip_house7());
SPR_HOUSE8 = addAnimClip(new gClip_house8());
SPR_TICKFLAG = addAnimClip(new gClip_tickFlag());
SPR_CHIMNEYLEGS = addAnimClip(new gClip_chimneyLegs());
SPR_DEFAULTHEAD = addAnimClip(new gClip_defaultHead());
SPR_MIDDLETORSO = addAnimClip(new gClip_middleTorso());
SPR_SHIN = addAnimClip(new gClip_shin());
SPR_THIGH = addAnimClip(new gClip_thigh());
SPR_SHOULDER = addAnimClip(new gClip_shoulder());
SPR_WRIST = addAnimClip(new gClip_wrist());
SPR_HAT = addAnimClip(new gClip_elfHat());
SPR_OBS_DEER1 = addAnimClip(new gClip_obs_deer1());
SPR_OBS_DEER2 = addAnimClip(new gClip_obs_deer2());
SPR_OBS_DEER3 = addAnimClip(new gClip_obs_deer3());
SPR_OBS_BAUBLE = addAnimClip(new gClip_obs_bauble());
SPR_OBS_NPSIGN = addAnimClip(new gClip_obs_northPoleSign());
SPR_OBS_SLEIGH = addAnimClip(new gClip_obs_sleigh());
SPR_OBS_SPACEBF = addAnimClip(new gClip_obs_spaceBigfoot());
SPR_OBS_STAR = addAnimClip(new gClip_obs_star());
SPR_OBS_TREEBIRDS = addAnimClip(new gClip_obs_treeBirds());
SPR_OBS_UMBRELLASM = addAnimClip(new gClip_obs_umbrellaSnowman());
SPR_OBS_TRAMPOLINE = addAnimClip(new gClip_obs_trampoline());
SPR_SHOTDISPLAY = addAnimClip(new gClip_shotDisplay());
if (_timeTrace){
trace(("number of clips: " + _cacheTimeArray.length));
_cacheTimeArray = _cacheTimeArray.sortOn("time", Array.NUMERIC);
i = 0;
while (i < _cacheTimeArray.length) {
trace(_cacheTimeArray[i].name, _cacheTimeArray[i].time);
i++;
};
};
}
public static function getRandomVictory():int{
var ouchArray:Array = [SND_HOORAY, SND_IMIN, SND_PRESDELIV, SND_WOOHOO, SND_YAY, SND_YIPEE];
return (ArrayTools.getRandomElementFromArray(ouchArray));
}
public static function getRandomOuch():int{
var ouchArray:Array = [SND_OOF1, SND_OOF2, SND_OUCH1, SND_OUCH2, SND_OUCH3, SND_OUCH4, SND_OUCH5, SND_OUCH6, SND_OUCH7, SND_OUCH8, SND_OUCH9, SND_OUCH10, SND_OUCH11, SND_OUCH12, SND_OUCH13, SND_OUCH14, SND_OUCH15, SND_OUCH16, SND_OUCH17];
return (ArrayTools.getRandomElementFromArray(ouchArray));
}
public static function getRandomThud():int{
var ouchArray:Array = [SND_BIGTHUD, SND_HEAVYTHUD, SND_LIGHTTHUD];
return (ArrayTools.getRandomElementFromArray(ouchArray));
}
public static function getRandomSmallOuch():int{
var ouchArray:Array = [SND_OOF1, SND_OOF2, SND_OUCH11, SND_OUCH17];
return (ArrayTools.getRandomElementFromArray(ouchArray));
}
}
}//package com.xmascannon.assets
Section 177
//BoxEngine (com.xmascannon.engine.engineComponents.BoxEngine)
package com.xmascannon.engine.engineComponents {
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Collision.*;
import com.psiom.*;
public class BoxEngine {
private var _groundSlab:b2Body;
private var _rdupperArmL:b2Body;
private var _rdupperArmR:b2Body;
private var _rigidBodies:Array;
private var _rdupperLegL:b2Body;
private var _rdupperLegR:b2Body;
private var _debugView:Boolean;// = true
public var _timeStep:Number;// = 0.03333
public var _boxLayer:Sprite;
private var zero:b2Vec2;
private var _rdtorso1:b2Body;
private var _rdhead:b2Body;
private var _rdtorso2:b2Body;
private var _rdtorso3:b2Body;
public var _iterations:int;// = 10
private var _physScale:Number;// = 56
public var _boxWorld:b2World;
private var _rdlowerArmL:b2Body;
private var _rdlowerArmR:b2Body;
private var _rdlowerLegL:b2Body;
private var _collisionManager:CollisionManager;
private var _rdlowerLegR:b2Body;
private static var _instance:BoxEngine;
public function BoxEngine(){
var dbgDraw:b2DebugDraw;
zero = new b2Vec2(0, 0);
super();
_instance = this;
_rigidBodies = new Array();
_boxLayer = new Sprite();
var worldAABB:b2AABB = new b2AABB();
worldAABB.lowerBound.Set(-20000, -20000);
worldAABB.upperBound.Set(20000, 20000);
var gravity:b2Vec2 = new b2Vec2(0, 20);
var doSleep:Boolean;
_boxWorld = new b2World(worldAABB, gravity, doSleep);
_collisionManager = new CollisionManager();
_boxWorld.SetContactListener(_collisionManager);
if (_debugView){
dbgDraw = new b2DebugDraw();
dbgDraw.m_sprite = _boxLayer;
dbgDraw.m_drawScale = Constants.ENGINE_PHYS_SCALE;
dbgDraw.m_fillAlpha = 0.3;
dbgDraw.m_lineThickness = 1;
dbgDraw.m_drawFlags = (b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit);
_boxWorld.SetDebugDraw(dbgDraw);
};
var wallSd:b2PolygonDef = new b2PolygonDef();
var wallBd:b2BodyDef = new b2BodyDef();
wallSd.SetAsBox(20, 1);
wallSd.friction = 1.1;
wallSd.restitution = 0.8;
wallSd.density = 0;
wallBd.userData = "GROUND";
_groundSlab = _boxWorld.CreateBody(wallBd);
_groundSlab.CreateShape(wallSd);
_groundSlab.SetMassFromShapes();
_groundSlab.m_linearDamping = 5;
_groundSlab.SetXForm(new b2Vec2((20 + (40 * 1)), 15.3), 0);
}
public function setRagdollInitialPoseForCannonAngle(inAngle:Number, startX:Number=140, startY:Number=270):void{
setRagDollPosition(startX, startY);
}
public function setRagDollPosition(startX:Number, startY:Number):void{
_rdhead.SetXForm(new b2Vec2((startX / Constants.ENGINE_PHYS_SCALE), ((startY / Constants.ENGINE_PHYS_SCALE) - 0.62)), 0);
_rdtorso1.SetXForm(new b2Vec2((startX / Constants.ENGINE_PHYS_SCALE), ((startY + 28) / Constants.ENGINE_PHYS_SCALE)), 0);
_rdupperArmL.SetXForm(new b2Vec2(((startX - 30) / Constants.ENGINE_PHYS_SCALE), ((startY + 20) / Constants.ENGINE_PHYS_SCALE)), 0);
_rdupperArmR.SetXForm(new b2Vec2(((startX + 30) / Constants.ENGINE_PHYS_SCALE), ((startY + 20) / Constants.ENGINE_PHYS_SCALE)), 0);
_rdlowerArmL.SetXForm(new b2Vec2(((startX - 65) / Constants.ENGINE_PHYS_SCALE), ((startY + 20) / Constants.ENGINE_PHYS_SCALE)), 0);
_rdlowerArmR.SetXForm(new b2Vec2(((startX + 65) / Constants.ENGINE_PHYS_SCALE), ((startY + 20) / Constants.ENGINE_PHYS_SCALE)), 0);
_rdupperLegL.SetXForm(new b2Vec2(((startX - 8) / Constants.ENGINE_PHYS_SCALE), ((startY + 85) / Constants.ENGINE_PHYS_SCALE)), 0);
_rdupperLegR.SetXForm(new b2Vec2(((startX + 8) / Constants.ENGINE_PHYS_SCALE), ((startY + 85) / Constants.ENGINE_PHYS_SCALE)), 0);
_rdlowerLegL.SetXForm(new b2Vec2(((startX - 8) / Constants.ENGINE_PHYS_SCALE), ((startY + 120) / Constants.ENGINE_PHYS_SCALE)), 0);
_rdlowerLegR.SetXForm(new b2Vec2(((startX + 8) / Constants.ENGINE_PHYS_SCALE), ((startY + 120) / Constants.ENGINE_PHYS_SCALE)), 0);
zeroOutRagdoll();
}
public function resetRagdoll(startX:Number=90, startY:Number=250):void{
setRagDollPosition(startX, startY);
}
public function addBoxObj(inBodyDef:b2BodyDef, inPolyDef:b2PolygonDef):b2Body{
var b2bodyObj:b2Body;
b2bodyObj = _boxWorld.CreateBody(inBodyDef);
b2bodyObj.CreateShape(inPolyDef);
b2bodyObj.SetMassFromShapes();
return (b2bodyObj);
}
public function initRagdoll(startX:Number, startY:Number):void{
var bd:b2BodyDef;
var circ:b2CircleDef = new b2CircleDef();
var box:b2PolygonDef = new b2PolygonDef();
var jd:b2RevoluteJointDef = new b2RevoluteJointDef();
circ.filter = new b2FilterData();
circ.filter.groupIndex = -8;
box.filter = new b2FilterData();
box.filter.groupIndex = -8;
circ.radius = (30.5 / _physScale);
circ.density = 0.62;
circ.friction = Constants.ENGINE_FRICTION;
circ.restitution = Constants.ENGINE_RESTITUTION;
bd = new b2BodyDef();
bd.angularDamping = 1;
bd.linearDamping = 0;
bd.position.Set((startX / _physScale), ((startY / _physScale) - 0.5));
_rdhead = _boxWorld.CreateBody(bd);
_rdhead.CreateShape(circ);
_rdhead.SetMassFromShapes();
box.SetAsBox((15 / _physScale), (32 / _physScale));
box.density = 0.25;
box.friction = Constants.ENGINE_FRICTION;
box.restitution = Constants.ENGINE_RESTITUTION;
bd = new b2BodyDef();
bd.angularDamping = 1;
bd.linearDamping = 0;
bd.position.Set((startX / _physScale), ((startY + 40) / _physScale));
_rdtorso1 = _boxWorld.CreateBody(bd);
_rdtorso1.CreateShape(box);
_rdtorso1.SetMassFromShapes();
box.SetAsBox((18 / _physScale), (6.5 / _physScale));
box.density = 0.25;
box.friction = Constants.ENGINE_FRICTION;
box.restitution = Constants.ENGINE_RESTITUTION;
bd = new b2BodyDef();
bd.angularDamping = 1;
bd.linearDamping = 0;
bd.position.Set(((startX - 30) / _physScale), ((startY + 20) / _physScale));
_rdupperArmL = _boxWorld.CreateBody(bd);
_rdupperArmL.CreateShape(box);
_rdupperArmL.SetMassFromShapes();
bd.position.Set(((startX + 30) / _physScale), ((startY + 20) / _physScale));
_rdupperArmR = _boxWorld.CreateBody(bd);
_rdupperArmR.CreateShape(box);
_rdupperArmR.SetMassFromShapes();
box.SetAsBox((17 / _physScale), (6 / _physScale));
box.density = 0.25;
box.friction = Constants.ENGINE_FRICTION;
box.restitution = Constants.ENGINE_RESTITUTION;
bd = new b2BodyDef();
bd.angularDamping = 1;
bd.linearDamping = 0;
bd.position.Set(((startX - 57) / _physScale), ((startY + 20) / _physScale));
_rdlowerArmL = _boxWorld.CreateBody(bd);
_rdlowerArmL.CreateShape(box);
_rdlowerArmL.SetMassFromShapes();
bd.position.Set(((startX + 57) / _physScale), ((startY + 20) / _physScale));
_rdlowerArmR = _boxWorld.CreateBody(bd);
_rdlowerArmR.CreateShape(box);
_rdlowerArmR.SetMassFromShapes();
box.SetAsBox((7.5 / _physScale), (22 / _physScale));
box.density = 0.25;
box.friction = Constants.ENGINE_FRICTION;
box.restitution = Constants.ENGINE_RESTITUTION;
bd = new b2BodyDef();
bd.angularDamping = 1;
bd.linearDamping = 0;
bd.position.Set(((startX - 8) / _physScale), ((startY + 85) / _physScale));
_rdupperLegL = _boxWorld.CreateBody(bd);
_rdupperLegL.CreateShape(box);
_rdupperLegL.SetMassFromShapes();
bd.position.Set(((startX + 8) / _physScale), ((startY + 85) / _physScale));
_rdupperLegR = _boxWorld.CreateBody(bd);
_rdupperLegR.CreateShape(box);
_rdupperLegR.SetMassFromShapes();
box.SetAsBox((6 / _physScale), (20 / _physScale));
box.density = 0.25;
box.friction = Constants.ENGINE_FRICTION;
box.restitution = Constants.ENGINE_RESTITUTION;
bd = new b2BodyDef();
bd.angularDamping = 1;
bd.linearDamping = 0;
bd.position.Set(((startX - 8) / _physScale), ((startY + 120) / _physScale));
_rdlowerLegL = _boxWorld.CreateBody(bd);
_rdlowerLegL.CreateShape(box);
_rdlowerLegL.SetMassFromShapes();
bd.position.Set(((startX + 8) / _physScale), ((startY + 120) / _physScale));
_rdlowerLegR = _boxWorld.CreateBody(bd);
_rdlowerLegR.CreateShape(box);
_rdlowerLegR.SetMassFromShapes();
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("Head", _rdhead);
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("MiddleTorso", _rdtorso1);
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("LShoulder", _rdupperArmL);
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("RShoulder", _rdupperArmR);
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("LWrist", _rdlowerArmL);
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("RWrist", _rdlowerArmR);
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("LThigh", _rdupperLegL);
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("RThigh", _rdupperLegR);
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("LShin", _rdlowerLegL);
GameLevel.Instance.RagdollObj.attachBodyPartByNameToBoxShape("RShin", _rdlowerLegR);
jd.enableLimit = true;
jd.lowerAngle = (-30 / (180 / Math.PI));
jd.upperAngle = (30 / (180 / Math.PI));
jd.Initialize(_rdtorso1, _rdhead, new b2Vec2((startX / _physScale), ((startY + 15) / _physScale)));
_boxWorld.CreateJoint(jd);
jd.lowerAngle = (-45 / (180 / Math.PI));
jd.upperAngle = (85 / (180 / Math.PI));
jd.enableLimit = true;
jd.Initialize(_rdtorso1, _rdupperArmL, new b2Vec2(((startX - 18) / _physScale), ((startY + 20) / _physScale)));
_boxWorld.CreateJoint(jd);
jd.lowerAngle = (-45 / (180 / Math.PI));
jd.upperAngle = (85 / (180 / Math.PI));
jd.enableLimit = true;
jd.Initialize(_rdtorso1, _rdupperArmR, new b2Vec2(((startX + 18) / _physScale), ((startY + 20) / _physScale)));
_boxWorld.CreateJoint(jd);
jd.lowerAngle = (-10 / (180 / Math.PI));
jd.upperAngle = (90 / (180 / Math.PI));
jd.enableLimit = true;
jd.Initialize(_rdupperArmL, _rdlowerArmL, new b2Vec2(((startX - 45) / _physScale), ((startY + 20) / _physScale)));
_boxWorld.CreateJoint(jd);
jd.lowerAngle = (-10 / (180 / Math.PI));
jd.upperAngle = (90 / (180 / Math.PI));
jd.enableLimit = true;
jd.Initialize(_rdupperArmR, _rdlowerArmR, new b2Vec2(((startX + 45) / _physScale), ((startY + 20) / _physScale)));
_boxWorld.CreateJoint(jd);
jd.enableLimit = true;
jd.lowerAngle = (-65 / (180 / Math.PI));
jd.upperAngle = (65 / (180 / Math.PI));
jd.Initialize(_rdtorso1, _rdupperLegL, new b2Vec2(((startX - 8) / _physScale), ((startY + 72) / _physScale)));
_boxWorld.CreateJoint(jd);
jd.enableLimit = true;
jd.lowerAngle = (-65 / (180 / Math.PI));
jd.upperAngle = (65 / (180 / Math.PI));
jd.Initialize(_rdtorso1, _rdupperLegR, new b2Vec2(((startX + 8) / _physScale), ((startY + 72) / _physScale)));
_boxWorld.CreateJoint(jd);
jd.enableLimit = true;
jd.lowerAngle = (0 / (180 / Math.PI));
jd.upperAngle = (85 / (180 / Math.PI));
jd.Initialize(_rdupperLegL, _rdlowerLegL, new b2Vec2(((startX - 8) / _physScale), ((startY + 105) / _physScale)));
_boxWorld.CreateJoint(jd);
jd.enableLimit = true;
jd.lowerAngle = (0 / (180 / Math.PI));
jd.upperAngle = (85 / (180 / Math.PI));
jd.Initialize(_rdupperLegR, _rdlowerLegR, new b2Vec2(((startX + 8) / _physScale), ((startY + 105) / _physScale)));
_boxWorld.CreateJoint(jd);
resetRagdoll();
}
public function update():void{
_boxWorld.Step(_timeStep, _iterations);
_boxLayer.x = -(EngineMain.Instance.Camera.x);
_boxLayer.y = -(EngineMain.Instance.Camera.y);
if (_rdhead){
_groundSlab.SetXForm(new b2Vec2(_rdhead.GetWorldCenter().x, 14.4), 0);
};
}
public function get DebugSprite():Sprite{
return (_boxLayer);
}
public function addCircleObj(inBodyDef:b2BodyDef, inCircleDef:b2CircleDef):b2Body{
var b2bodyObj:b2Body;
b2bodyObj = _boxWorld.CreateBody(inBodyDef);
b2bodyObj.CreateShape(inCircleDef);
b2bodyObj.SetMassFromShapes();
return (b2bodyObj);
}
public function zeroOutRagdoll():void{
_rdhead.SetLinearVelocity(zero);
_rdtorso1.SetLinearVelocity(zero);
_rdupperArmL.SetLinearVelocity(zero);
_rdupperArmR.SetLinearVelocity(zero);
_rdlowerArmL.SetLinearVelocity(zero);
_rdlowerArmR.SetLinearVelocity(zero);
_rdupperLegL.SetLinearVelocity(zero);
_rdupperLegR.SetLinearVelocity(zero);
_rdlowerLegL.SetLinearVelocity(zero);
_rdlowerLegR.SetLinearVelocity(zero);
_rdhead.SetAngularVelocity(0);
_rdtorso1.SetAngularVelocity(0);
_rdupperArmL.SetAngularVelocity(0);
_rdupperArmR.SetAngularVelocity(0);
_rdlowerArmL.SetAngularVelocity(0);
_rdlowerArmR.SetAngularVelocity(0);
_rdupperLegL.SetAngularVelocity(0);
_rdupperLegR.SetAngularVelocity(0);
_rdlowerLegL.SetAngularVelocity(0);
_rdlowerLegR.SetAngularVelocity(0);
}
public static function get Instance():BoxEngine{
return (_instance);
}
}
}//package com.xmascannon.engine.engineComponents
Section 178
//CollisionManager (com.xmascannon.engine.engineComponents.CollisionManager)
package com.xmascannon.engine.engineComponents {
import flash.events.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.*;
import Box2D.Collision.*;
public class CollisionManager extends b2ContactListener implements IEventDispatcher {
private var m_force:Number;
private var m_dispatcher:EventDispatcher;
public function CollisionManager(){
super();
m_dispatcher = new EventDispatcher(this);
}
public function dispatchEvent(evt:Event):Boolean{
return (m_dispatcher.dispatchEvent(evt));
}
override public function Remove(point:b2ContactPoint):void{
}
public function willTrigger(type:String):Boolean{
return (m_dispatcher.willTrigger(type));
}
override public function Add(point:b2ContactPoint):void{
var trig:Boolean;
var shape1:b2Shape = point.shape1;
var shape2:b2Shape = point.shape2;
GameLevel.Instance.rdImpact(point.velocity.LengthSquared());
if (point.shape1.GetBody().GetUserData()){
if (point.shape1.GetBody().GetUserData() == "CHIMNEY1"){
GameLevel.Instance.registerChimneyCollision(1, point.shape1);
};
if (point.shape1.GetBody().GetUserData() == "CHIMNEY2"){
GameLevel.Instance.registerChimneyCollision(2, point.shape1);
};
if (point.shape1.GetBody().GetUserData() == "CHIMNEY3"){
GameLevel.Instance.registerChimneyCollision(3, point.shape1);
};
if (point.shape1.GetBody().GetUserData() == "CHIMNEY4"){
GameLevel.Instance.registerChimneyCollision(4, point.shape1);
};
if (point.shape1.GetBody().GetUserData() == "CHIMNEY5"){
GameLevel.Instance.registerChimneyCollision(5, point.shape1);
};
if (point.shape1.GetBody().GetUserData() == "CHIMNEY6"){
GameLevel.Instance.registerChimneyCollision(6, point.shape1);
};
if (point.shape1.GetBody().GetUserData() == "CHIMNEY7"){
GameLevel.Instance.registerChimneyCollision(7, point.shape1);
};
if (point.shape1.GetBody().GetUserData() == "CHIMNEY8"){
GameLevel.Instance.registerChimneyCollision(8, point.shape1);
};
if (point.shape1.GetBody().GetUserData() == "BIGFOOTBONUS"){
GameLevel.Instance.triggerBigfootBonus(point.shape1.GetBody());
};
if (point.shape1.GetBody().GetUserData() == "BAUBLE"){
GameLevel.Instance.collidedWithBauble();
};
if (point.shape1.GetBody().GetUserData() == "STAR"){
GameLevel.Instance.collidedWithStar();
};
if (point.shape1.GetBody().GetUserData() == "GROUND"){
GameLevel.Instance.groundCollide();
if (EngineMain.Instance.State == EngineMain.STATE_GAMEPLAY){
trig = false;
if (point.velocity.LengthSquared() > 15){
if ((((point.velocity.LengthSquared() < 25)) && (!(trig)))){
trig = true;
};
if ((((point.velocity.LengthSquared() < 50)) && (!(trig)))){
trig = true;
};
if ((((point.velocity.LengthSquared() < 100)) && (!(trig)))){
trig = true;
};
if ((((point.velocity.LengthSquared() < 200)) && (!(trig)))){
trig = true;
};
if (!trig){
trig = true;
};
};
};
};
if (point.shape1.GetBody().GetUserData() == "TRAMPOLINE"){
GameLevel.Instance.applyTrampRDVel();
};
};
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{
m_dispatcher.removeEventListener(type, listener, useCapture);
}
override public function Persist(point:b2ContactPoint):void{
}
public function hasEventListener(type:String):Boolean{
return (m_dispatcher.hasEventListener(type));
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{
m_dispatcher.addEventListener(type, listener, useCapture, priority);
}
}
}//package com.xmascannon.engine.engineComponents
Section 179
//BaseHouse (com.xmascannon.engine.gameObjects.houses.BaseHouse)
package com.xmascannon.engine.gameObjects.houses {
import flash.display.*;
import com.psiom.rendering.*;
import com.xmascannon.engine.gameObjects.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class BaseHouse extends Box2dRenderableObj {
public var chimnneyCollided:Boolean;// = false
protected var _chimneyX:Number;// = 0
protected var _liveUpdateBody:b2Body;
protected var _polyDef:b2PolygonDef;
public var chimneyNode:RenderableObject;
protected var _chimneyY:Number;// = 0
public function BaseHouse(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
public function get chmny():Number{
return (_chimneyY);
}
override public function updateLivePlacement(v:int, inX:Number, inY:Number):void{
if (_liveUpdateBody){
_polyDef.vertices[v].Set(inX, inY);
_liveUpdateBody.DestroyShape(_liveUpdateBody.GetShapeList());
_liveUpdateBody.CreateShape(_polyDef);
};
}
public function get chmnx():Number{
return (_chimneyX);
}
}
}//package com.xmascannon.engine.gameObjects.houses
Section 180
//House1 (com.xmascannon.engine.gameObjects.houses.House1)
package com.xmascannon.engine.gameObjects.houses {
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class House1 extends BaseHouse {
public function House1(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
y = 25;
_chimneyX = -100;
_chimneyY = -150;
}
override public function initBoxStuffs():void{
var body:b2Body;
var wx:Number;
chimneyNode = GameLevel.Instance.addInvisibleNode((x + _chimneyX), (y + _chimneyY));
var bodyDefP:b2BodyDef = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
var wy:Number = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 3;
_polyDef.vertices[0].Set(11.15, 2.9);
_polyDef.vertices[1].Set(16.5, 13);
_polyDef.vertices[2].Set(7.5, 13);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.65, 2.95);
_polyDef.vertices[1].Set(9.32, 2.5);
_polyDef.vertices[2].Set(10.1, 7);
_polyDef.vertices[3].Set(9, 9.3);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.933, 2.433);
_polyDef.vertices[1].Set(8.866, 2.2);
_polyDef.vertices[2].Set(9.133, 2.633);
_polyDef.vertices[3].Set(7.833, 3.033);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "CHIMNEY1";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
}
}
}//package com.xmascannon.engine.gameObjects.houses
Section 181
//House2 (com.xmascannon.engine.gameObjects.houses.House2)
package com.xmascannon.engine.gameObjects.houses {
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class House2 extends BaseHouse {
public function House2(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
y = -28;
_chimneyX = -75;
_chimneyY = -200;
}
override public function initBoxStuffs():void{
var body:b2Body;
var wx:Number;
chimneyNode = GameLevel.Instance.addInvisibleNode((x + _chimneyX), (y + _chimneyY));
var bodyDefP:b2BodyDef = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
var wy:Number = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.66, 4.3);
_polyDef.vertices[1].Set(15.5, 4.5);
_polyDef.vertices[2].Set(17.36, 7.43);
_polyDef.vertices[3].Set(5.93, 7.26);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(6.8, 7.366);
_polyDef.vertices[1].Set(16.233, 7.433);
_polyDef.vertices[2].Set(16.3, 12.633);
_polyDef.vertices[3].Set(6.633, 12.6);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.3, 1.2);
_polyDef.vertices[1].Set(10.333, 0.9);
_polyDef.vertices[2].Set(10.7, 4.366);
_polyDef.vertices[3].Set(8.533, 4.333);
_polyDef.density = 0;
_polyDef.friction = 0.3;
polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.666, 0.8);
_polyDef.vertices[1].Set(9.766, 0.7);
_polyDef.vertices[2].Set(9.966, 1.066);
_polyDef.vertices[3].Set(8.566, 1.266);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "CHIMNEY2";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
}
}
}//package com.xmascannon.engine.gameObjects.houses
Section 182
//House3 (com.xmascannon.engine.gameObjects.houses.House3)
package com.xmascannon.engine.gameObjects.houses {
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class House3 extends BaseHouse {
public function House3(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
y = 98;
_chimneyX = -93;
_chimneyY = -88;
}
override public function initBoxStuffs():void{
var body:b2Body;
var wx:Number;
chimneyNode = GameLevel.Instance.addInvisibleNode((x + _chimneyX), (y + _chimneyY));
var bodyDefP:b2BodyDef = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
var wy:Number = (y / Constants.ENGINE_PHYS_SCALE);
var left:Number = 6.5;
var right:Number = 20;
var top:Number = 8;
var bottom1:Number = 15;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.1, 6.766);
_polyDef.vertices[1].Set(11.633, 6.433);
_polyDef.vertices[2].Set(13.6, 7.433);
_polyDef.vertices[3].Set(7.566, 8.233);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.5, 8.233);
_polyDef.vertices[1].Set(13.633, 7.533);
_polyDef.vertices[2].Set(14.366, 8.366);
_polyDef.vertices[3].Set(7, 9.466);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.1, 9.5);
_polyDef.vertices[1].Set(16.3, 8.233);
_polyDef.vertices[2].Set(16.4, 10.133);
_polyDef.vertices[3].Set(6.866, 10.533);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.9, 4.9);
_polyDef.vertices[1].Set(9.5, 4.8);
_polyDef.vertices[2].Set(9.733, 6.6);
_polyDef.vertices[3].Set(7.9, 7.833);
_polyDef.density = 0;
_polyDef.friction = 0.3;
polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.166, 4.533);
_polyDef.vertices[1].Set(9, 4.533);
_polyDef.vertices[2].Set(9.233, 4.9);
_polyDef.vertices[3].Set(8.1, 5);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "CHIMNEY3";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
}
}
}//package com.xmascannon.engine.gameObjects.houses
Section 183
//House4 (com.xmascannon.engine.gameObjects.houses.House4)
package com.xmascannon.engine.gameObjects.houses {
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class House4 extends BaseHouse {
public function House4(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
y = -42;
_chimneyX = -125;
_chimneyY = -210;
}
override public function initBoxStuffs():void{
var body:b2Body;
var wx:Number;
chimneyNode = GameLevel.Instance.addInvisibleNode((x + _chimneyX), (y + _chimneyY));
var bodyDefP:b2BodyDef = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
var wy:Number = (y / Constants.ENGINE_PHYS_SCALE);
var left:Number = 6.5;
var right:Number = 20;
var top:Number = 8;
var bottom1:Number = 15;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(6.5, 1.2);
_polyDef.vertices[1].Set(8.666, 0.233);
_polyDef.vertices[2].Set(8.333, 2.366);
_polyDef.vertices[3].Set(8.066, 2.433);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.9, 2.666);
_polyDef.vertices[1].Set(10.833, 0.4);
_polyDef.vertices[2].Set(13.5, 2.1);
_polyDef.vertices[3].Set(8.3, 9.266);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(13.3, 5.433);
_polyDef.vertices[1].Set(16.666, 7.833);
_polyDef.vertices[2].Set(16.666, 14.133);
_polyDef.vertices[3].Set(14, 14.1);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.366, 9.233);
_polyDef.vertices[1].Set(13.066, 2.666);
_polyDef.vertices[2].Set(14, 14.033);
_polyDef.vertices[3].Set(8.766, 14.133);
_polyDef.density = 0;
_polyDef.friction = 0.3;
polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(6.9, 0.566);
_polyDef.vertices[1].Set(7.666, 0.2);
_polyDef.vertices[2].Set(8.3, 0.533);
_polyDef.vertices[3].Set(7.033, 1.266);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "CHIMNEY4";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
}
}
}//package com.xmascannon.engine.gameObjects.houses
Section 184
//House5 (com.xmascannon.engine.gameObjects.houses.House5)
package com.xmascannon.engine.gameObjects.houses {
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class House5 extends BaseHouse {
public function House5(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
y = 52;
_chimneyX = -140;
_chimneyY = -122;
}
override public function initBoxStuffs():void{
var body:b2Body;
var wx:Number;
chimneyNode = GameLevel.Instance.addInvisibleNode((x + _chimneyX), (y + _chimneyY));
var bodyDefP:b2BodyDef = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
var wy:Number = (y / Constants.ENGINE_PHYS_SCALE);
var left:Number = 6.5;
var right:Number = 20;
var top:Number = 8;
var bottom1:Number = 15;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(13.066, 6);
_polyDef.vertices[1].Set(18.133, 7.8);
_polyDef.vertices[2].Set(18.066, 11.7);
_polyDef.vertices[3].Set(13.133, 11.7);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(5.566, 7.4);
_polyDef.vertices[1].Set(13, 5);
_polyDef.vertices[2].Set(13.066, 11.933);
_polyDef.vertices[3].Set(5.533, 11.8);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(4.866, 6.966);
_polyDef.vertices[1].Set(13.5, 3.733);
_polyDef.vertices[2].Set(13.533, 4.766);
_polyDef.vertices[3].Set(4.966, 7.566);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(5.966, 3.766);
_polyDef.vertices[1].Set(7.9, 3.5);
_polyDef.vertices[2].Set(8.5, 5.766);
_polyDef.vertices[3].Set(6.3, 6.366);
_polyDef.density = 0;
_polyDef.friction = 0.3;
polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(6.266, 3.466);
_polyDef.vertices[1].Set(7.2, 3.233);
_polyDef.vertices[2].Set(7.566, 3.666);
_polyDef.vertices[3].Set(6.133, 3.933);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "CHIMNEY5";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
}
}
}//package com.xmascannon.engine.gameObjects.houses
Section 185
//House6 (com.xmascannon.engine.gameObjects.houses.House6)
package com.xmascannon.engine.gameObjects.houses {
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class House6 extends BaseHouse {
public function House6(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
y = -36;
_chimneyX = -75;
_chimneyY = -200;
}
override public function initBoxStuffs():void{
var body:b2Body;
var wx:Number;
chimneyNode = GameLevel.Instance.addInvisibleNode((x + _chimneyX), (y + _chimneyY));
var bodyDefP:b2BodyDef = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
var wy:Number = (y / Constants.ENGINE_PHYS_SCALE);
var left:Number = 6.5;
var right:Number = 20;
var top:Number = 8;
var bottom1:Number = 15;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.266, 0.733);
_polyDef.vertices[1].Set(9.933, 0.566);
_polyDef.vertices[2].Set(10.233, 2.133);
_polyDef.vertices[3].Set(8.466, 3.2);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.166, 4.033);
_polyDef.vertices[1].Set(11.6, 1.366);
_polyDef.vertices[2].Set(15.8, 4.166);
_polyDef.vertices[3].Set(11.233, 8.033);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.066, 4.933);
_polyDef.vertices[1].Set(14.766, 4.966);
_polyDef.vertices[2].Set(13.566, 14.066);
_polyDef.vertices[3].Set(9.166, 14.066);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(14.4, 7.166);
_polyDef.vertices[1].Set(16.066, 6.966);
_polyDef.vertices[2].Set(16, 8.633);
_polyDef.vertices[3].Set(14.233, 8.466);
_polyDef.density = 0;
_polyDef.friction = 0.3;
polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.533, 0.533);
_polyDef.vertices[1].Set(9.533, 0.366);
_polyDef.vertices[2].Set(9.666, 0.766);
_polyDef.vertices[3].Set(8.433, 0.966);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "CHIMNEY6";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
}
}
}//package com.xmascannon.engine.gameObjects.houses
Section 186
//House7 (com.xmascannon.engine.gameObjects.houses.House7)
package com.xmascannon.engine.gameObjects.houses {
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class House7 extends BaseHouse {
public function House7(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
y = 48;
_chimneyX = -100;
_chimneyY = -110;
}
override public function initBoxStuffs():void{
var body:b2Body;
var wx:Number;
chimneyNode = GameLevel.Instance.addInvisibleNode((x + _chimneyX), (y + _chimneyY));
var bodyDefP:b2BodyDef = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
var wy:Number = (y / Constants.ENGINE_PHYS_SCALE);
var left:Number = 6.5;
var right:Number = 20;
var top:Number = 8;
var bottom1:Number = 15;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.433, 3.666);
_polyDef.vertices[1].Set(9.433, 3.166);
_polyDef.vertices[2].Set(9.766, 5.266);
_polyDef.vertices[3].Set(7.666, 5.9);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(6, 6.466);
_polyDef.vertices[1].Set(11.7, 4.8);
_polyDef.vertices[2].Set(11.8, 11.966);
_polyDef.vertices[3].Set(6.533, 11.9);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(11.766, 4.866);
_polyDef.vertices[1].Set(17.166, 6.466);
_polyDef.vertices[2].Set(16.933, 11.833);
_polyDef.vertices[3].Set(11.866, 11.9);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(15.2, 4.7);
_polyDef.vertices[1].Set(16.466, 4.666);
_polyDef.vertices[2].Set(16.766, 5.3);
_polyDef.vertices[3].Set(15.433, 5.366);
_polyDef.density = 0;
_polyDef.friction = 0.3;
polyDef.restitution = 0.8;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(7.866, 3.2);
_polyDef.vertices[1].Set(8.7, 2.966);
_polyDef.vertices[2].Set(9.033, 3.466);
_polyDef.vertices[3].Set(7.966, 3.866);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "CHIMNEY7";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
}
}
}//package com.xmascannon.engine.gameObjects.houses
Section 187
//House8 (com.xmascannon.engine.gameObjects.houses.House8)
package com.xmascannon.engine.gameObjects.houses {
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class House8 extends BaseHouse {
public function House8(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
y = 25;
_chimneyX = 20;
_chimneyY = -165;
}
override public function initBoxStuffs():void{
var body:b2Body;
var wx:Number;
chimneyNode = GameLevel.Instance.addInvisibleNode((x + _chimneyX), (y + _chimneyY));
var bodyDefP:b2BodyDef = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
var wy:Number = (y / Constants.ENGINE_PHYS_SCALE);
var left:Number = 6.5;
var right:Number = 20;
var top:Number = 8;
var bottom1:Number = 15;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(11.433, 2.366);
_polyDef.vertices[1].Set(13.166, 2.2);
_polyDef.vertices[2].Set(13.233, 4);
_polyDef.vertices[3].Set(11.5, 4.066);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.833, 4.133);
_polyDef.vertices[1].Set(16.066, 4.033);
_polyDef.vertices[2].Set(15.866, 11.2);
_polyDef.vertices[3].Set(8.766, 10.566);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.933, 10.666);
_polyDef.vertices[1].Set(15.966, 11.2);
_polyDef.vertices[2].Set(16.666, 12.633);
_polyDef.vertices[3].Set(8.5, 12.5);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(6.7, 8.866);
_polyDef.vertices[1].Set(8.733, 8.1);
_polyDef.vertices[2].Set(8.933, 12.533);
_polyDef.vertices[3].Set(7.1, 12.666);
_polyDef.density = 0;
_polyDef.friction = 0.3;
polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(11.7, 2.033);
_polyDef.vertices[1].Set(12.666, 1.9);
_polyDef.vertices[2].Set(12.966, 2.333);
_polyDef.vertices[3].Set(11.633, 2.5);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "CHIMNEY8";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
}
}
}//package com.xmascannon.engine.gameObjects.houses
Section 188
//BaseObstacle (com.xmascannon.engine.gameObjects.solidObstacles.BaseObstacle)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import com.psiom.rendering.*;
import com.xmascannon.engine.gameObjects.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class BaseObstacle extends Box2dRenderableObj {
public var chimnneyCollided:Boolean;// = false
protected var _chimneyX:Number;// = 0
protected var _liveUpdateBody:b2Body;
protected var _polyDef:b2PolygonDef;
public var chimneyNode:RenderableObject;
protected var _chimneyY:Number;// = 0
public function BaseObstacle(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
public function get chmny():Number{
return (_chimneyY);
}
override public function updateLivePlacement(v:int, inX:Number, inY:Number):void{
if (_liveUpdateBody){
_polyDef.vertices[v].Set(inX, inY);
_liveUpdateBody.DestroyShape(_liveUpdateBody.GetShapeList());
_liveUpdateBody.CreateShape(_polyDef);
};
}
public function get chmnx():Number{
return (_chimneyX);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 189
//Obs_Bauble (com.xmascannon.engine.gameObjects.solidObstacles.Obs_Bauble)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_Bauble extends BaseObstacle {
public function Obs_Bauble(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var circ:b2CircleDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
circ = new b2CircleDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
circ.radius = 1.8;
circ.density = 0;
circ.friction = 0.3;
circ.restitution = 0.6;
bodyDefP.position.Set((wx + 11.55), (wy + 7.7));
bodyDefP.angle = 0;
bodyDefP.userData = "BAUBLE";
body = BoxEngine.Instance.addCircleObj(bodyDefP, circ);
_liveUpdateBody = body;
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 190
//Obs_Deer1 (com.xmascannon.engine.gameObjects.solidObstacles.Obs_Deer1)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_Deer1 extends BaseObstacle {
public function Obs_Deer1(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.866, 5.133);
_polyDef.vertices[1].Set(11, 4.366);
_polyDef.vertices[2].Set(12.3, 7.766);
_polyDef.vertices[3].Set(9.333, 6.6);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(11.8, 6.333);
_polyDef.vertices[1].Set(14.433, 6.233);
_polyDef.vertices[2].Set(13.4, 10.866);
_polyDef.vertices[3].Set(12.633, 10.733);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 191
//Obs_Deer2 (com.xmascannon.engine.gameObjects.solidObstacles.Obs_Deer2)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_Deer2 extends BaseObstacle {
public function Obs_Deer2(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.266, 4.566);
_polyDef.vertices[1].Set(11.5, 4.8);
_polyDef.vertices[2].Set(11.4, 6.4);
_polyDef.vertices[3].Set(9.1, 6.166);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(10.133, 7.3);
_polyDef.vertices[1].Set(11.566, 6.533);
_polyDef.vertices[2].Set(12.6, 10.4);
_polyDef.vertices[3].Set(12.266, 10.4);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(11.566, 6.433);
_polyDef.vertices[1].Set(14.3, 6.8);
_polyDef.vertices[2].Set(13.633, 9.066);
_polyDef.vertices[3].Set(12.666, 10.5);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 192
//Obs_Deer3 (com.xmascannon.engine.gameObjects.solidObstacles.Obs_Deer3)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_Deer3 extends BaseObstacle {
public function Obs_Deer3(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.866, 5.633);
_polyDef.vertices[1].Set(11.666, 6.9);
_polyDef.vertices[2].Set(10.666, 8.3);
_polyDef.vertices[3].Set(8.933, 6.9);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(12.7, 4.933);
_polyDef.vertices[1].Set(14.266, 5.2);
_polyDef.vertices[2].Set(13.666, 10.9);
_polyDef.vertices[3].Set(13.4, 10.933);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 193
//Obs_NPSign (com.xmascannon.engine.gameObjects.solidObstacles.Obs_NPSign)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_NPSign extends BaseObstacle {
public function Obs_NPSign(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.766, 7.766);
_polyDef.vertices[1].Set(13.833, 7.566);
_polyDef.vertices[2].Set(13.933, 9.2);
_polyDef.vertices[3].Set(9.066, 9.266);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(10.633, 4.433);
_polyDef.vertices[1].Set(12.233, 3.833);
_polyDef.vertices[2].Set(12.566, 4.666);
_polyDef.vertices[3].Set(10.766, 4.866);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.9, 3.866);
_polyDef.vertices[1].Set(10.466, 3.633);
_polyDef.vertices[2].Set(11.166, 7.366);
_polyDef.vertices[3].Set(10.8, 7.7);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 194
//Obs_Sleigh (com.xmascannon.engine.gameObjects.solidObstacles.Obs_Sleigh)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_Sleigh extends BaseObstacle {
public function Obs_Sleigh(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(12.066, 4.8);
_polyDef.vertices[1].Set(13.8, 4.933);
_polyDef.vertices[2].Set(14.3, 7.633);
_polyDef.vertices[3].Set(11.933, 7.1);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(12.066, 8.133);
_polyDef.vertices[1].Set(15.5, 6.666);
_polyDef.vertices[2].Set(13.6, 8.333);
_polyDef.vertices[3].Set(12.433, 8.766);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.1, 8.066);
_polyDef.vertices[1].Set(11.333, 7.2);
_polyDef.vertices[2].Set(13.333, 10.066);
_polyDef.vertices[3].Set(8.8, 10.266);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 195
//Obs_SpaceBF (com.xmascannon.engine.gameObjects.solidObstacles.Obs_SpaceBF)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_SpaceBF extends BaseObstacle {
public var triggeredBonii:Boolean;// = false
private var _triggerBody:b2Body;
public function Obs_SpaceBF(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
z = 0.9;
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(10.6, 6.866);
_polyDef.vertices[1].Set(11.666, 7.033);
_polyDef.vertices[2].Set(10.366, 10.466);
_polyDef.vertices[3].Set(9.366, 10.033);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(10.933, 6.933);
_polyDef.vertices[1].Set(12.466, 7.3);
_polyDef.vertices[2].Set(12.566, 10.6);
_polyDef.vertices[3].Set(11.566, 10.833);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(13.433, 4.966);
_polyDef.vertices[1].Set(14.033, 4.966);
_polyDef.vertices[2].Set(14.033, 7.433);
_polyDef.vertices[3].Set(12.833, 7.966);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(10.3, 4.2);
_polyDef.vertices[1].Set(10.9, 4.533);
_polyDef.vertices[2].Set(9.933, 7.4);
_polyDef.vertices[3].Set(9.233, 6.266);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(11.033, 6.633);
_polyDef.vertices[1].Set(12.3, 6.8);
_polyDef.vertices[2].Set(12.366, 7);
_polyDef.vertices[3].Set(10.9, 6.766);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "BIGFOOTBONUS";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_triggerBody = body;
}
public function doesOwnShape(inBodyDef:b2Body):Boolean{
if (_triggerBody == inBodyDef){
return (true);
};
return (false);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 196
//Obs_Star (com.xmascannon.engine.gameObjects.solidObstacles.Obs_Star)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_Star extends BaseObstacle {
public function Obs_Star(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.866, 7.333);
_polyDef.vertices[1].Set(12.166, 7.666);
_polyDef.vertices[2].Set(11.833, 9.466);
_polyDef.vertices[3].Set(9.533, 7.733);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
bodyDefP.userData = "STAR";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.266, 7.333);
_polyDef.vertices[1].Set(13.3, 4.833);
_polyDef.vertices[2].Set(12.133, 7.533);
_polyDef.vertices[3].Set(11.133, 7.8);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "STAR";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(10.433, 4.666);
_polyDef.vertices[1].Set(13.866, 7.466);
_polyDef.vertices[2].Set(11.033, 7.666);
_polyDef.vertices[3].Set(10.766, 6.333);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.userData = "STAR";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 197
//Obs_Trampoline (com.xmascannon.engine.gameObjects.solidObstacles.Obs_Trampoline)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_Trampoline extends BaseObstacle {
public function Obs_Trampoline(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
y = 160;
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.933, 6.933);
_polyDef.vertices[1].Set(13.533, 6.933);
_polyDef.vertices[2].Set(13.7, 7.7);
_polyDef.vertices[3].Set(9.633, 7.8);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.99;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
bodyDefP.userData = "TRAMPOLINE";
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 198
//Obs_TreeBirds (com.xmascannon.engine.gameObjects.solidObstacles.Obs_TreeBirds)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_TreeBirds extends BaseObstacle {
public function Obs_TreeBirds(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(13.233, 5.566);
_polyDef.vertices[1].Set(12.066, 10.833);
_polyDef.vertices[2].Set(10.3, 12.1);
_polyDef.vertices[3].Set(10.233, 9.233);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(14.133, 8.6);
_polyDef.vertices[1].Set(14.966, 8.5);
_polyDef.vertices[2].Set(15.166, 9.1);
_polyDef.vertices[3].Set(14.4, 9.566);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(13.8, 3.033);
_polyDef.vertices[1].Set(14.666, 3.566);
_polyDef.vertices[2].Set(14.3, 4.133);
_polyDef.vertices[3].Set(13.333, 3.4);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(8.166, 4.733);
_polyDef.vertices[1].Set(9.166, 4.566);
_polyDef.vertices[2].Set(9, 5.366);
_polyDef.vertices[3].Set(8.266, 5.433);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 199
//Obs_UmbrellaSM (com.xmascannon.engine.gameObjects.solidObstacles.Obs_UmbrellaSM)
package com.xmascannon.engine.gameObjects.solidObstacles {
import flash.display.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.engineComponents.*;
import com.psiom.*;
public class Obs_UmbrellaSM extends BaseObstacle {
public function Obs_UmbrellaSM(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function initBoxStuffs():void{
var body:b2Body;
var bodyDefP:b2BodyDef;
var wx:Number;
var wy:Number;
bodyDefP = new b2BodyDef();
_polyDef = new b2PolygonDef();
wx = (x / Constants.ENGINE_PHYS_SCALE);
wy = (y / Constants.ENGINE_PHYS_SCALE);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.5, 9.466);
_polyDef.vertices[1].Set(10.4, 8.8);
_polyDef.vertices[2].Set(10.466, 9.066);
_polyDef.vertices[3].Set(9.4, 9.866);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
bodyDefP.angle = 0;
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
_liveUpdateBody = body;
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(9.533, 7.066);
_polyDef.vertices[1].Set(10.033, 6.466);
_polyDef.vertices[2].Set(12.833, 9.166);
_polyDef.vertices[3].Set(11.5, 10.733);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
bodyDefP = new b2BodyDef();
_polyDef.vertexCount = 4;
_polyDef.vertices[0].Set(10.533, 5.5);
_polyDef.vertices[1].Set(11.8, 4.733);
_polyDef.vertices[2].Set(13.266, 5.2);
_polyDef.vertices[3].Set(14, 6.366);
_polyDef.density = 0;
_polyDef.friction = 0.3;
_polyDef.restitution = 0.6;
bodyDefP.position.Set(wx, wy);
body = BoxEngine.Instance.addBoxObj(bodyDefP, _polyDef);
}
}
}//package com.xmascannon.engine.gameObjects.solidObstacles
Section 200
//BGParalaxTree (com.xmascannon.engine.gameObjects.BGParalaxTree)
package com.xmascannon.engine.gameObjects {
import flash.display.*;
import com.psiom.rendering.*;
public class BGParalaxTree extends RenderableObject {
public var rx:Number;
public var ox:Number;// = 0
public function BGParalaxTree(inSpriteID:int, inMovieClip:MovieClip=null){
rx = (Math.random() * 1050);
super(inSpriteID, inMovieClip);
}
override public function update():void{
super.update();
}
public function setFrameByZ(min:Number, max:Number):void{
var p:Number = ((z - min) / (max - min));
sm.currentFrame = ((1 - p) * sm.totalFrames);
}
}
}//package com.xmascannon.engine.gameObjects
Section 201
//BodyPart (com.xmascannon.engine.gameObjects.BodyPart)
package com.xmascannon.engine.gameObjects {
import com.psiom.util.*;
import com.psiom.rendering.*;
import Box2D.Dynamics.*;
import com.psiom.*;
public class BodyPart extends RenderableObject {
private var _lastX:Number;// = 0
private var _lastY:Number;// = 0
private var hingeNodes:Array;
public var localR:Number;// = 0
public var constraintAngleOffsetR:Number;// = 0
private var _directionTravelled:Number;// = 0
public var constraintDistOffset:Number;// = 0
public var pivotY:Number;// = 0
public var parentOffsetX:Number;// = 0
public var pivotX:Number;// = 0
public var partName:String;
public var parentOffsetY:Number;// = 0
private var _boxParent:b2Body;
public var localvx:Number;// = 0
public var localvy:Number;// = 0
public var parentHingeIndex:Number;// = 0
private var _diffX:Number;// = 0
private var _diffY:Number;// = 0
private var _smokeTrail:Number;// = 0
public var parentPart:BodyPart;
public function BodyPart(inSpriteID:int, inPartName:String){
super(inSpriteID, null);
s = 1;
partName = inPartName;
_autoVel = false;
}
public function attachToBox(inBoxShape:b2Body):void{
_boxParent = inBoxShape;
}
public function getDirectionForce():Object{
return (MathFunction.getVector(_directionTravelled, getDistTravelled()));
}
public function getDistTravelled():Number{
return ((Math.abs(_diffX) + Math.abs(_diffY)));
}
override public function update():void{
_smokeTrail = (_smokeTrail - 0.005);
_lastX = x;
_lastY = y;
if ((Math.random() * 0.5) < _smokeTrail){
if ((((Math.random() > 0.95)) && ((getDistTravelled() > 10)))){
};
};
if (Math.random() < _smokeTrail){
if ((((Math.random() > 0.95)) && ((getDistTravelled() > 25)))){
};
};
if (_boxParent){
x = ((_boxParent.GetWorldCenter().x * Constants.ENGINE_PHYS_SCALE) - 350);
y = ((_boxParent.GetWorldCenter().y * Constants.ENGINE_PHYS_SCALE) - 225);
r = (_boxParent.GetAngle() + localR);
};
_diffX = (x - _lastX);
_diffY = (y - _lastY);
vx = _diffX;
vy = _diffY;
super.update();
}
public function getVel():Number{
return (MathFunction.getDistance(x, y, (x + _diffX), (y + _diffY)));
}
public function getDirectionTravelled():Number{
_directionTravelled = MathFunction.getRadians(x, y, (x + _diffX), (y + _diffY));
return (_directionTravelled);
}
public function resetTrail():void{
_smokeTrail = 1.1;
}
public function get BoxParent():b2Body{
return (_boxParent);
}
}
}//package com.xmascannon.engine.gameObjects
Section 202
//Box2dRenderableObj (com.xmascannon.engine.gameObjects.Box2dRenderableObj)
package com.xmascannon.engine.gameObjects {
import flash.display.*;
import com.psiom.rendering.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
public class Box2dRenderableObj extends RenderableObject {
protected var polyDef:b2PolygonDef;
protected var _boxObj:b2Body;
protected var bodyDefP:b2BodyDef;
protected var _box2dBodyList:Array;
public function Box2dRenderableObj(inSpriteID:int, inMovieClip:MovieClip=null){
bodyDefP = new b2BodyDef();
polyDef = new b2PolygonDef();
super(inSpriteID, inMovieClip);
_box2dBodyList = new Array();
}
public function updateLivePlacement(v:int, inX:Number, inY:Number):void{
}
public function initBoxStuffs():void{
}
protected function addBody():void{
}
}
}//package com.xmascannon.engine.gameObjects
Section 203
//CannonBarrel (com.xmascannon.engine.gameObjects.CannonBarrel)
package com.xmascannon.engine.gameObjects {
import flash.display.*;
import com.psiom.rendering.*;
public class CannonBarrel extends RenderableObject {
public var loaded:Boolean;// = false
private var _currentPower:Number;// = 0
public var powerbar:CannonPowerBar;
public function CannonBarrel(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
public function setPower(inPower:Number):void{
_currentPower = inPower;
powerbar.setShotPower(inPower);
}
public function setAim(inAngle:Number):void{
var minAngle:Number = (-(Math.PI) / 2);
var maxAngle:Number = 0;
if (inAngle < minAngle){
inAngle = minAngle;
};
if (inAngle > maxAngle){
inAngle = maxAngle;
};
var p:Number = ((inAngle + (Math.PI / 2)) / (maxAngle + (Math.PI / 2)));
p = (1 - p);
sm.currentFrame = Math.floor((1 + (p * (sm.totalFrames - 1.01))));
}
public function relax():void{
_currentPower = 0;
powerbar.setShotPower(_currentPower);
}
override public function update():void{
super.update();
}
}
}//package com.xmascannon.engine.gameObjects
Section 204
//CannonPowerBar (com.xmascannon.engine.gameObjects.CannonPowerBar)
package com.xmascannon.engine.gameObjects {
import flash.display.*;
import com.psiom.util.*;
import com.psiom.rendering.*;
public class CannonPowerBar extends RenderableObject {
private var _powerOscFreqBase:Number;// = 0.16
private var _power:Number;// = 0
private var _powerOscFreq:Number;// = 0.16
private var _powerSin:Number;
private var _powerAmp:Number;
public function CannonPowerBar(inSpriteID:int, inMovieClip:MovieClip=null){
_powerSin = (Math.random() * 10);
super(inSpriteID, inMovieClip);
}
public function getBarrelExitX():Number{
var vvec:Object = MathFunction.getVector(r, 150);
return (((x + vvec.x) - sm.rOX));
}
public function get MaxFrame():Boolean{
return ((sm.currentFrame == 13));
}
public function getShotVel(inVariance:Number=0):Object{
var variance:Number = ((Math.random() * inVariance) - (inVariance * 0.5));
var shotVel:Object = MathFunction.getVector((r + variance), (_power * 1.5));
return (shotVel);
}
public function setShotPower(inPower:Number):void{
_power = inPower;
sm.currentFrame = (1 + int(Math.floor(((_power / 450) * 12.999))));
_power = (_power * 0.45);
}
public function getShotPower():Number{
return (_power);
}
override public function update():void{
super.update();
}
public function getBarrelExitY():Number{
var vvec:Object = MathFunction.getVector(r, 150);
return (((y + vvec.y) - sm.rOY));
}
}
}//package com.xmascannon.engine.gameObjects
Section 205
//CollectableObj (com.xmascannon.engine.gameObjects.CollectableObj)
package com.xmascannon.engine.gameObjects {
import flash.display.*;
import com.psiom.rendering.*;
import com.xmascannon.engine.objectSpaces.*;
public class CollectableObj extends RenderableObject {
public var grav:Number;// = 0
public var timeout:int;// = -1
public var collected:Boolean;// = false
public var leadBuffer:int;// = 0
public var pointsVal:Number;// = 100
public static var TYPE_CANE:int = 2;
public static var TYPE_BELLS:int = 5;
public static var TYPE_HAM:int = 0;
public static var TYPE_CHICKEN:int = 1;
public static var TYPE_GIFT:int = 3;
public static var TYPE_MISSLE:int = 4;
public function CollectableObj(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function update():void{
var vyAbs:Number;
vy = (vy + grav);
if (timeout > 0){
timeout--;
};
if (timeout == 0){
s = (s * 0.9);
if (s < 0.05){
GameLevel.Instance.removeCollectable(this);
timeout = -1;
};
};
vx = (vx * 0.96);
if (leadBuffer > 0){
leadBuffer--;
};
if (y > 160){
vyAbs = Math.abs((vy * 0.55));
if (vyAbs > 3.5){
vy = -(vyAbs);
} else {
vy = 0;
grav = 0;
s;
};
y = 160;
};
super.update();
}
public function initVariant(type:int):void{
sm.currentFrame = type;
switch (type){
case 0:
pointsVal = 1000;
break;
case 1:
pointsVal = 5000;
break;
case 2:
pointsVal = 1500;
break;
case 3:
pointsVal = 3000;
break;
case 4:
pointsVal = 2500;
break;
case 5:
pointsVal = 2000;
break;
};
}
public static function get randomType():int{
return ((0 + int(Math.floor((Math.random() * 5.999)))));
}
}
}//package com.xmascannon.engine.gameObjects
Section 206
//FallingSnow (com.xmascannon.engine.gameObjects.FallingSnow)
package com.xmascannon.engine.gameObjects {
import flash.display.*;
import com.psiom.rendering.*;
public class FallingSnow extends RenderableObject {
public var grav:Number;// = 0.5
public var turbulenceX:Number;// = 0
public var rx:Number;
public var ry:Number;
public var turbulenceY:Number;// = 0
public function FallingSnow(inSpriteID:int, inMovieClip:MovieClip=null){
var max:Number;
rx = (Math.random() * 1050);
ry = (Math.random() * 675);
super(inSpriteID, inMovieClip);
sm.lockCameraTransform = true;
var min:Number = 0.1;
max = 1.6;
z = (min + (Math.random() * (max - min)));
var p:Number = ((z - min) / (max - min));
sm.currentFrame = ((1 - p) * sm.totalFrames);
grav = (0.5 + (Math.random() * 0.65));
}
override public function update():void{
super.update();
ry = (ry + (grav * z));
if (ry > 675){
ry = 0;
};
}
}
}//package com.xmascannon.engine.gameObjects
Section 207
//Particle (com.xmascannon.engine.gameObjects.Particle)
package com.xmascannon.engine.gameObjects {
import flash.display.*;
import com.psiom.rendering.*;
import com.psiom.*;
public class Particle extends RenderableObject {
public var lifespan:Number;// = 100
public function Particle(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
sm.frameRate = 0.5;
sm.currentFrame = (sm.currentFrame + (Math.random() * 10));
}
override public function update():void{
var vyAbs:Number;
if (sm.currentFrame >= sm.lastFrame){
purgeObject();
};
vy = (vy + (Constants.ENGINE_GRAVITY * 0.35));
if (y > 172){
vyAbs = Math.abs((vy * 0.55));
if (vyAbs > 3.5){
vy = -(vyAbs);
} else {
vy = 0;
};
y = 172;
};
super.update();
}
}
}//package com.xmascannon.engine.gameObjects
Section 208
//Ragdoll (com.xmascannon.engine.gameObjects.Ragdoll)
package com.xmascannon.engine.gameObjects {
import flash.events.*;
import com.xmascannon.*;
import flash.display.*;
import com.xmascannon.engine.objectSpaces.*;
import Box2D.Dynamics.*;
import com.psiom.assets.*;
import com.psiom.rendering.renderableTypes.*;
import com.xmascannon.engine.*;
import com.xmascannon.ui.*;
import flash.geom.*;
import com.xmascannon.assets.*;
public class Ragdoll {
private var _r_wrist:BodyPart;
private var _l_wrist:BodyPart;
private var _upperTorso:BodyPart;
private var _r_shin:BodyPart;
private var _middleTorso:BodyPart;
public var vis:Boolean;// = false
private var _hips:BodyPart;
private var _l_shoulder:BodyPart;
private var _head:BodyPart;
private var _l_thigh:BodyPart;
public var scale:Number;// = 1
private var _l_shin:BodyPart;
private var _r_thigh:BodyPart;
private var _inertiaTimerLevel1:Number;// = 0
private var _bodyParts:Array;
private var _inertiaTimerLevel2:Number;// = 0
private var _outOfBoundsTimer:Number;// = 0
private var _r_shoulder:BodyPart;
public var x:Number;// = 0
public var y:Number;// = 0
public function Ragdoll(inX:Number=0, inY:Number=0){
_bodyParts = new Array();
super();
x = inX;
y = inY;
_bodyParts = new Array();
reset();
}
public function get Head():BodyPart{
return (_head);
}
public function attachBodyPartByNameToBoxShape(inName:String, inBoxShape:b2Body):void{
var i:Number = 0;
while (i < _bodyParts.length) {
if (_bodyParts[i].partName == inName){
_bodyParts[i].attachToBox(inBoxShape);
};
i++;
};
}
public function swapHead():void{
var cbmd:BitmapData = new BitmapData(_head.w, _head.h, true, 0);
var cmatrix:Matrix = new Matrix();
var scaleMod:Number = 0.65;
var headSprite:SpriteModel = AssetLibrary.Instance.getSpriteForProfileID(XmasCannon_Assets.SPR_DEFAULTHEAD);
if (UIMain.Instance.HeadMode == 0){
if (XmasCannon_Main.Instance.SuppliedFace){
cmatrix.scale(scaleMod, scaleMod);
cmatrix.translate(((cbmd.width / 2) - ((XmasCannon_Main.Instance.SuppliedFace.width * scaleMod) / 2)), (((cbmd.height / 2) - ((XmasCannon_Main.Instance.SuppliedFace.height * scaleMod) / 2)) - 3));
cbmd.draw(XmasCannon_Main.Instance.SuppliedFace, cmatrix);
headSprite.setBMD(cbmd);
} else {
headSprite.currentFrame = 0;
};
};
if (UIMain.Instance.HeadMode == 1){
headSprite.currentFrame = 1;
};
if (UIMain.Instance.HeadMode == 2){
headSprite.currentFrame = 2;
};
if (UIMain.Instance.HeadMode == 3){
cmatrix.scale(scaleMod, scaleMod);
cmatrix.translate(((cbmd.width / 2) - ((EngineMain.Instance.BaseUploadedImageBMD.width * scaleMod) / 2)), (((cbmd.height / 2) - ((EngineMain.Instance.BaseUploadedImageBMD.height * scaleMod) / 2)) - 3));
cbmd.draw(EngineMain.Instance.BaseUploadedImageBMD, cmatrix);
headSprite.setBMD(cbmd);
};
_head.setSpriteModelAsClone(headSprite);
}
public function lval(n:Number):Number{
return ((n * scale));
}
protected function getVector(inRadians:Number, inVelocity:Number):Object{
var vX:Number = (inVelocity * Math.cos(inRadians));
var vY:Number = (inVelocity * Math.sin(inRadians));
return ({x:vX, y:vY});
}
public function addPartsToWorld(inArray:Array):void{
var i:Number = 0;
while (i < _bodyParts.length) {
addPartMethod(_bodyParts[i], inArray);
i++;
};
}
protected function getRadians(inSourceX:Number, inSourceY:Number, inTargetX:Number, inTargetY:Number):Number{
return (Math.atan2((inTargetY - inSourceY), (inTargetX - inSourceX)));
}
public function hide():void{
vis = false;
var i:Number = 0;
while (i < _bodyParts.length) {
_bodyParts[i].primaryVis = false;
i++;
};
}
public function get BodyParts():Array{
return (_bodyParts);
}
public function update():void{
var bpAverageX:Number;
var bpX:Number;
var bpvel:Number;
var i:Number;
if (vis){
bpX = 0;
bpvel = 0;
i = 0;
while (i < _bodyParts.length) {
bpvel = (bpvel + _bodyParts[i].getDistTravelled());
bpX = (bpX + _bodyParts[i].x);
i++;
};
bpAverageX = (bpX / _bodyParts.length);
if (bpAverageX < -300){
_outOfBoundsTimer++;
};
if (bpAverageX > 7000){
_outOfBoundsTimer++;
};
if (bpvel < 60){
_inertiaTimerLevel2++;
};
if (bpvel < 20){
_inertiaTimerLevel1++;
};
if ((((((_inertiaTimerLevel1 > 80)) || ((_inertiaTimerLevel2 > 350)))) || ((_outOfBoundsTimer > 30)))){
GameLevel.Instance.prepNewShot();
};
};
}
public function get MiddleTorso():BodyPart{
return (_middleTorso);
}
private function reset():void{
trace("resetting ragdoll");
_middleTorso = new BodyPart(XmasCannon_Assets.SPR_MIDDLETORSO, "MiddleTorso");
_head = new BodyPart(XmasCannon_Assets.SPR_DEFAULTHEAD, "Head");
_l_shoulder = new BodyPart(XmasCannon_Assets.SPR_SHOULDER, "LShoulder");
_l_wrist = new BodyPart(XmasCannon_Assets.SPR_WRIST, "LWrist");
_r_shoulder = new BodyPart(XmasCannon_Assets.SPR_SHOULDER, "RShoulder");
_r_wrist = new BodyPart(XmasCannon_Assets.SPR_WRIST, "RWrist");
_l_thigh = new BodyPart(XmasCannon_Assets.SPR_THIGH, "LThigh");
_l_shin = new BodyPart(XmasCannon_Assets.SPR_SHIN, "LShin");
_r_thigh = new BodyPart(XmasCannon_Assets.SPR_THIGH, "RThigh");
_r_shin = new BodyPart(XmasCannon_Assets.SPR_SHIN, "RShin");
_bodyParts.push(_middleTorso, _l_shoulder, _l_wrist, _r_shoulder, _r_wrist, _l_thigh, _l_shin, _r_thigh, _r_shin, _head);
_l_shoulder.localR = (-(Math.PI) / 2);
_l_wrist.localR = (Math.PI / 2);
_r_shoulder.localR = (Math.PI / 2);
_r_wrist.localR = (Math.PI / -2);
}
public function impact(force:Number):void{
if ((((force > 40)) && ((force < 150)))){
force = 150;
};
}
public function resetInertiaParams():void{
_inertiaTimerLevel1 = 0;
_inertiaTimerLevel2 = 0;
_outOfBoundsTimer = 0;
}
public function addPartMethod(part:BodyPart, array:Array):void{
array.push(part);
}
public function get Hips():BodyPart{
return (_hips);
}
protected function getDistance(inSourceX:Number, inSourceY:Number, inTargetX:Number, inTargetY:Number):Number{
return (Math.sqrt(((Math.abs((inSourceX - inTargetX)) * Math.abs((inSourceX - inTargetX))) + (Math.abs((inSourceY - inTargetY)) * Math.abs((inSourceY - inTargetY))))));
}
public function show():void{
vis = true;
var i:Number = 0;
while (i < _bodyParts.length) {
_bodyParts[i].primaryVis = true;
i++;
};
}
}
}//package com.xmascannon.engine.gameObjects
Section 209
//ShotDisplay (com.xmascannon.engine.gameObjects.ShotDisplay)
package com.xmascannon.engine.gameObjects {
import flash.display.*;
import com.psiom.rendering.*;
public class ShotDisplay extends RenderableObject {
public var lifespan:int;// = 110
public function ShotDisplay(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
s = 0;
}
override public function update():void{
lifespan--;
if (lifespan < 20){
s = (lifespan / 20);
} else {
s = (s + ((1 - s) * 0.25));
};
if (lifespan < 1){
purgeObject();
};
super.update();
}
}
}//package com.xmascannon.engine.gameObjects
Section 210
//TickFlag (com.xmascannon.engine.gameObjects.TickFlag)
package com.xmascannon.engine.gameObjects {
import flash.display.*;
import com.psiom.rendering.*;
public class TickFlag extends RenderableObject {
public function TickFlag(inSpriteID:int, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
s = 0.1;
r = (Math.PI / 2);
}
override public function update():void{
r = (r + ((0 - r) * 0.24));
s = (s + ((1 - s) * 0.5));
if (s > 0.99){
s = 1;
};
if (Math.abs(r) < 0.001){
r = 0;
};
super.update();
}
}
}//package com.xmascannon.engine.gameObjects
Section 211
//GameLevel (com.xmascannon.engine.objectSpaces.GameLevel)
package com.xmascannon.engine.objectSpaces {
import flash.events.*;
import com.psiom.foundation.*;
import com.xmascannon.*;
import com.psiom.util.*;
import com.psiom.rendering.*;
import com.psiom.sound.*;
import com.xmascannon.engine.gameObjects.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import com.xmascannon.engine.*;
import Box2D.Common.Math.*;
import com.xmascannon.engine.engineComponents.*;
import com.soapcreative.net.tracking.*;
import com.xmascannon.engine.gameObjects.houses.*;
import com.xmascannon.assets.*;
import com.xmascannon.engine.gameObjects.solidObstacles.*;
import flash.ui.*;
public class GameLevel extends ObjectSpace {
private var _targetTrackingScale:Number;// = 1
private var _cannonPowerBar:CannonPowerBar;
private var _crossHairs:Array;
private var _snowWindSinA:Number;// = 0.1
private var _trackingMovementInertia:Number;// = 0
private var _cam:RenderCam;
private var _snowWindSinF:Number;// = 0.05
private var _currentZoomScale:Number;// = 1
private var _registeredChimneys:Array;
private var _ragdoll:Ragdoll;
private var _resetNeeded:Boolean;// = false
private var _bigfoots:Array;
private var _house2:BaseHouse;
private var _house3:BaseHouse;
private var _house4:BaseHouse;
private var _house6:BaseHouse;
private var _house7:BaseHouse;
private var _house1:BaseHouse;
private var _trailLines:Array;
private var _clickInit:Boolean;// = false
private var _house5:BaseHouse;
private var _starAvail:Number;// = 0
private var _bigfootBonusStack:int;// = 250
private var _livePlacementObject:Box2dRenderableObj;
private var _numShots:int;
private var _house8:BaseHouse;
private var _triggeredBigfootBonus:Boolean;// = false
private var _trackingScaleInertia:Number;// = 0
private var _spacePressed:Boolean;// = false
private var _collectables:Array;
private var _currentTrailLineY:Number;
private var _bigfootBonus:int;// = 0
private var _currentTrailLineX:Number;
private var _liveUpdateY:Number;// = 0
private var _baubleColTimer:int;// = 0
private var _liveUpdateX:Number;// = 0
private var _boxEngine:BoxEngine;
private var _debugNode:RenderableObject;
private var _randomOuchTimer:int;// = 0
private var _hintTimer:int;// = 175
private var _houses:Array;
private var _mode:int;
private var _snowWind:Number;// = 0
private var _worldHeight:Number;// = 675
private var _zoomOverride:Number;// = 1
private var _cannonPowerBarGhost:RenderableObject;
private var _ground:RenderableObject;
private var _sOffset:Number;// = 0
private var _shotDisplay:ShotDisplay;
private var _baubleAvail:Number;// = 0
private var _gameplayHint:RenderableObject;
private var _rdElfHat:RenderableObject;
private var _snowWindVel:Number;// = 0
private var _zoomScale:Number;// = 1
private var _currentTrackingScale:Number;// = 1
private var _snowWindTarget:Number;// = 0
private var _sessionObjects:Array;
private var _leadIn:int;// = 0
private var _cannonBarrelGhost:RenderableObject;
private var _panCursor:RenderableObject;
private var _cannonBarrel:CannonBarrel;
private var _trailLinesEnabled:Boolean;// = true
private var _fallingSnow:Array;
private var _snowWindSin:Number;// = 0
private var _starDecrease:int;// = 0
private var _paralaxObjects:Array;
private var _diffX:Number;// = 0
private var _diffY:Number;// = 0
private var _starColTimer:int;// = 0
private var _worldWidth:Number;// = 1050
private var _resetShotTimer:int;// = 0
public static var LEVELMODE_INPROGRESS:int = 1;
public static var LEVELMODE_IDLE:int = 0;
public static var LEVELMODE_LEADIN:int = 2;
private static var _instance:GameLevel;
public static var LEVELMODE_HINT:int = 3;
public function GameLevel(parentSystem:CoreSystem){
_mode = LEVELMODE_IDLE;
_instance = this;
zSortMode = ZSMODE_AFTERADD;
_boxEngine = new BoxEngine();
_trailLines = new Array();
_collectables = new Array();
_crossHairs = new Array();
_paralaxObjects = new Array();
_fallingSnow = new Array();
_houses = new Array();
_bigfoots = new Array();
_registeredChimneys = [false, false, false, false, false, false, false, false];
setSnowWind();
super(parentSystem);
}
private function addCollectableArray(inArray:Array, type:int):void{
var i:int;
while (i < inArray.length) {
addCollectable(inArray[i].x, inArray[i].y, type);
i++;
};
}
private function addCollectableGrid(inX:Number, inY:Number, inType:int, rows:Number, cols:Number, spacing:Number):void{
var i:int;
var j:int;
var ox:Number;
var oy:Number;
i = 0;
while (i < rows) {
j = 0;
while (j < cols) {
ox = (((j - cols) * spacing) + ((cols / 2) * spacing));
oy = (((i - rows) * spacing) + ((rows / 2) * spacing));
addCollectable((inX + ox), (inY + oy), inType);
j++;
};
i++;
};
}
private function animateSnow(cam:RenderCam):void{
var i:int;
var sFlake:FallingSnow;
if (_resetNeeded){
_resetShotTimer--;
if (_resetShotTimer < 0){
_resetNeeded = false;
prepNewShot();
};
};
_snowWindSin = (_snowWindSin + _snowWindSinF);
var windSin:Number = ((Math.sin(_snowWindSin) * _snowWindSinA) * 1.1);
if (Math.random() > 0.996){
setSnowWind();
};
var windDiff:Number = Math.abs((_snowWindTarget - _snowWind));
_snowWind = (_snowWind + ((_snowWindTarget - _snowWind) * 0.005));
if ((((_snowWind < _snowWindTarget)) && ((windDiff > 2)))){
_snowWindVel = (_snowWindVel + 0.002);
if (_snowWindVel > 0.2){
_snowWindVel = 0.2;
};
};
if ((((_snowWind > _snowWindTarget)) && ((windDiff > 2)))){
_snowWindVel = (_snowWindVel - 0.001);
if (_snowWindVel < -0.2){
_snowWindVel = -0.2;
};
};
_snowWind = (_snowWind + _snowWindVel);
i = 0;
while (i < _fallingSnow.length) {
sFlake = _fallingSnow[i];
sFlake.turbulenceX = (sFlake.turbulenceX + ((_snowWind + windSin) * sFlake.z));
sFlake.x = (((sFlake.rx + sFlake.turbulenceX) + (-(cam.x) * sFlake.z)) % 1050);
if (sFlake.x < 0){
sFlake.x = (sFlake.x + 1050);
};
sFlake.y = (((sFlake.ry + sFlake.turbulenceY) + (-(cam.y) * sFlake.z)) % 675);
i++;
};
}
public function closeGame():void{
}
public function rdImpact(force:Number):void{
_ragdoll.impact(force);
if ((((((force > 25)) && ((_randomOuchTimer < 0)))) && (_ragdoll.MiddleTorso.primaryVis))){
_randomOuchTimer = 8;
if (Math.random() > 0.2){
SoundManager.Instance.playSound(XmasCannon_Assets.getRandomOuch());
} else {
SoundManager.Instance.playSound(XmasCannon_Assets.getRandomThud());
};
};
}
private function addCollectable(inX:Number, inY:Number, inType:int):CollectableObj{
var collectable:CollectableObj = new CollectableObj(XmasCannon_Assets.SPR_COLLECTABLE);
collectable.x = inX;
collectable.y = inY;
collectable.initVariant(inType);
_collectables.push(collectable);
addObject(collectable);
return (collectable);
}
override public function clickInput(x:Number, y:Number):void{
}
public function resetRagdoll():void{
_boxEngine.resetRagdoll();
_ragdoll.resetInertiaParams();
_ragdoll.hide();
}
public function spawnChimneyJunk(inX:Number, inY:Number):void{
var star:Particle;
var i:int;
i = 0;
while (i < 75) {
star = new Particle(XmasCannon_Assets.SPR_FXSTAR);
star.x = inX;
star.y = inY;
star.vx = (MathFunction.pnRand * 10);
star.vy = ((MathFunction.pnRand * 5) - 5);
addObject(star);
i++;
};
i = 0;
while (i < 75) {
star = new Particle(XmasCannon_Assets.SPR_FXSTAR);
star.x = inX;
star.y = inY;
star.vx = (MathFunction.pnRand * 4);
star.vy = (Math.random() * -28);
star.sm.frameRate = 0.2;
addObject(star);
i++;
};
var chimneyLegs:TickFlag = new TickFlag(XmasCannon_Assets.SPR_CHIMNEYLEGS);
chimneyLegs.x = inX;
chimneyLegs.y = (inY - 30);
chimneyLegs.sm.frameRate = 0.5;
chimneyLegs.sm.loop = true;
addObject(chimneyLegs);
_sessionObjects.push(chimneyLegs);
_cam.setCameraSubject(chimneyLegs, false);
}
public function addInvisibleNode(inX:Number, inY:Number):RenderableObject{
var invisNode:RenderableObject = new RenderableObject(XmasCannon_Assets.SPR_DEBUGNODE);
invisNode.x = inX;
invisNode.y = inY;
invisNode.z = 10;
invisNode.primaryVis = false;
invisNode.update();
return (invisNode);
}
public function registerChimneyCollision(inChimneyNum:int, inShape:b2Shape):void{
var sx:Number;
var sy:Number;
var house:BaseHouse;
if (!_registeredChimneys[(inChimneyNum - 1)]){
trace("CHIMNEY STRUCK");
EngineMain.Instance.lightHouse(inChimneyNum);
switch (inChimneyNum){
case 1:
house = _house1;
EngineMain.Instance.triggerScoreBlipLarge(50000);
break;
case 2:
house = _house2;
EngineMain.Instance.triggerScoreBlipLarge(80000);
break;
case 3:
house = _house3;
EngineMain.Instance.triggerScoreBlipLarge(110000);
break;
case 4:
house = _house4;
EngineMain.Instance.triggerScoreBlipLarge(140000);
break;
case 5:
house = _house5;
EngineMain.Instance.triggerScoreBlipLarge(180000);
break;
case 6:
house = _house6;
EngineMain.Instance.triggerScoreBlipLarge(250000);
break;
case 7:
house = _house7;
EngineMain.Instance.triggerScoreBlipLarge(300000);
break;
case 8:
house = _house8;
EngineMain.Instance.triggerScoreBlipLarge(350000);
break;
};
sx = (house.chmnx + house.x);
sy = (house.chmny + house.y);
_ragdoll.hide();
resetRagdoll();
_resetNeeded = true;
_resetShotTimer = 100;
spawnChimneyJunk(sx, sy);
SoundManager.Instance.playSound(XmasCannon_Assets.getRandomVictory());
SoundManager.Instance.playSound(XmasCannon_Assets.SND_CHIMNEYCHIME);
};
_registeredChimneys[(inChimneyNum - 1)] = true;
}
public function initGame():void{
var bigfoot:Obs_SpaceBF;
if (!_clickInit){
_clickInit = true;
EngineMain.Instance.mouseTrapper_fullBlank.addEventListener(MouseEvent.CLICK, mainClick);
};
if (_hintTimer > 0){
_mode = LEVELMODE_HINT;
} else {
_mode = LEVELMODE_LEADIN;
};
SoundManager.Instance.setMusicLoop(1);
_bigfootBonusStack = 250;
_ragdoll.swapHead();
_baubleAvail = 12;
_starAvail = 12;
_leadIn = 20;
_numShots = 10;
EngineMain.Instance.ShotsRemainingField.text = ("X" + String(_numShots));
prepNewShot();
resetTemporaryObjects();
_registeredChimneys = [false, false, false, false, false, false, false, false];
var i:int;
i = 0;
while (i < _bigfoots.length) {
bigfoot = _bigfoots[i];
bigfoot.triggeredBonii = false;
i++;
};
}
public function triggerBigfootBonus(inBody:b2Body):void{
var bigfoot_trigger:Obs_SpaceBF;
var bigfoot:Obs_SpaceBF;
var i:int;
while (i < _bigfoots.length) {
bigfoot = _bigfoots[i];
if (((bigfoot.doesOwnShape(inBody)) && (!(bigfoot.triggeredBonii)))){
bigfoot.triggeredBonii = true;
bigfoot_trigger = bigfoot;
};
i++;
};
if (bigfoot_trigger){
_triggeredBigfootBonus = true;
_bigfootBonus = _bigfootBonusStack;
_bigfootBonusStack = (_bigfootBonusStack + 250);
SoundManager.Instance.playSound(XmasCannon_Assets.SND_CASH);
};
}
public function applyTrampRDVel():void{
var i:Number = 0;
_ragdoll.impact(300);
SoundManager.Instance.playSound(XmasCannon_Assets.SND_BOING);
i = 0;
while (i < _ragdoll.BodyParts.length) {
if (_ragdoll.BodyParts[i].BoxParent){
_ragdoll.BodyParts[i].BoxParent.ApplyImpulse(new b2Vec2(0.2, -3), _ragdoll.BodyParts[i].BoxParent.GetWorldCenter());
};
i++;
};
}
public function get WorldHeight():Number{
return (_worldHeight);
}
private function mainClick(e:Event):void{
if (_leadIn > 0){
return;
};
if ((((_mode == LEVELMODE_INPROGRESS)) || ((_mode == LEVELMODE_HINT)))){
_hintTimer = 0;
if (!_spacePressed){
fireCannon();
};
};
}
override public function keyUp(keyCode:uint):void{
if (keyCode == Keyboard.SPACE){
_spacePressed = false;
};
if (keyCode == Keyboard.DOWN){
};
}
public function addDebugNode(inX:Number, inY:Number):void{
var debugNode:RenderableObject = new RenderableObject(XmasCannon_Assets.SPR_DEBUGNODE);
debugNode.x = inX;
debugNode.y = inY;
debugNode.z = 10;
addObject(debugNode);
}
public function removeCollectable(inCollectable:CollectableObj):void{
var cObj:CollectableObj;
inCollectable.purgeObject();
var i:int = (_collectables.length - 1);
while (i >= 0) {
cObj = _collectables[i];
if (inCollectable == cObj){
_collectables.splice(i, 1);
return;
};
i--;
};
}
public function initWorld():void{
var i:int;
var j:int;
var bgObj:RenderableObject;
var house:BaseHouse;
var solidObj:BaseObstacle;
var paralaxTree:BGParalaxTree;
var sFlake:FallingSnow;
_panCursor = new RenderableObject(XmasCannon_Assets.SPR_PANCURSOR);
addObject(_panCursor);
_panCursor.primaryVis = false;
_gameplayHint = new RenderableObject(XmasCannon_Assets.SPR_GAMEPLAYHINT);
addObject(_gameplayHint);
_sessionObjects = new Array();
_cam = EngineMain.Instance.Camera;
setSnowWind();
_snowWind = (MathFunction.pnRand * 3);
var skyBG:RenderableObject = new RenderableObject(XmasCannon_Assets.SPR_SKYBG);
skyBG.baseY = -100;
skyBG.z = 0.03;
addObject(skyBG);
_paralaxObjects.push(skyBG);
bgObj = new RenderableObject(XmasCannon_Assets.SPR_AURORA);
bgObj.baseY = -200;
bgObj.z = 0.1;
addObject(bgObj);
_paralaxObjects.push(bgObj);
i = 0;
while (i < 3) {
bgObj = new RenderableObject(XmasCannon_Assets.SPR_BGMOUTAINS);
bgObj.baseX = (0 + (i * 700));
bgObj.baseY = 15;
bgObj.z = 0.13;
addObject(bgObj);
_paralaxObjects.push(bgObj);
i++;
};
i = 0;
while (i < 4) {
bgObj = new RenderableObject(XmasCannon_Assets.SPR_BGTREES);
bgObj.baseX = (0 + (i * 784));
bgObj.baseY = 70;
bgObj.z = 0.17;
addObject(bgObj);
_paralaxObjects.push(bgObj);
i++;
};
var mgHills:Array = [XmasCannon_Assets.SPR_MGHILL1, XmasCannon_Assets.SPR_MGHILL1, XmasCannon_Assets.SPR_MGHILL1, XmasCannon_Assets.SPR_MGHILL1, XmasCannon_Assets.SPR_MGHILL1];
i = 0;
while (i < 5) {
bgObj = new RenderableObject(mgHills[i]);
bgObj.baseX = (0 + (i * 600));
bgObj.baseY = 115;
bgObj.z = 0.24;
addObject(bgObj);
_paralaxObjects.push(bgObj);
i++;
};
var fgHills:Array = [XmasCannon_Assets.SPR_FGHILL1, XmasCannon_Assets.SPR_FGHILL2, XmasCannon_Assets.SPR_FGHILL3, XmasCannon_Assets.SPR_FGHILL4, XmasCannon_Assets.SPR_FGHILL1, XmasCannon_Assets.SPR_FGHILL2];
var fgHouseBaseY:Array = [90, 120, 100, 120, 120, 120];
i = 0;
while (i < 6) {
bgObj = new RenderableObject(fgHills[i]);
bgObj.baseX = (-200 + (i * 720));
bgObj.baseY = (fgHouseBaseY[i] + 20);
bgObj.z = 0.5;
addObject(bgObj);
_paralaxObjects.push(bgObj);
i++;
};
i = 0;
while (i < 40) {
paralaxTree = new BGParalaxTree(XmasCannon_Assets.SPR_MGTREES);
paralaxTree.baseX = (0 + (i * 162));
paralaxTree.z = (0.35 + (Math.random() * 0.58));
paralaxTree.baseY = (95 + ((1 - paralaxTree.z) * -50));
paralaxTree.setFrameByZ(0.35, 1);
addObject(paralaxTree);
_paralaxObjects.push(paralaxTree);
i++;
};
_ground = new RenderableObject(XmasCannon_Assets.SPR_GROUND);
_ground.z = 1;
_ground.depthBias = -0.02;
_ground.y = 300;
addObject(_ground);
var cannonBase:RenderableObject = new RenderableObject(XmasCannon_Assets.SPR_CANNONBASE);
cannonBase.x = -288;
cannonBase.y = 149;
addObject(cannonBase);
_cannonPowerBar = new CannonPowerBar(XmasCannon_Assets.SPR_CANNONPOWERBAR);
addObject(_cannonPowerBar);
_cannonBarrel = new CannonBarrel(XmasCannon_Assets.SPR_CANNONBARREL);
_cannonBarrel.x = -269;
_cannonBarrel.y = 82;
_cannonBarrel.powerbar = _cannonPowerBar;
addObject(_cannonBarrel);
_cannonPowerBar.x = (_cannonBarrel.x - 32);
_cannonPowerBar.y = (_cannonBarrel.y + 30);
_cannonPowerBar.depthBias = 0.1;
_house1 = new House1(XmasCannon_Assets.SPR_HOUSE1);
_house1.x = 650;
_house1.initBoxStuffs();
_house1.depthBias = 0.1;
_houses.push(_house1);
addObject(_house1);
_house2 = new House2(XmasCannon_Assets.SPR_HOUSE2);
_house2.x = 1350;
_house2.initBoxStuffs();
_house2.depthBias = 0.1;
_houses.push(_house2);
addObject(_house2);
_house3 = new House3(XmasCannon_Assets.SPR_HOUSE3);
_house3.x = 2100;
_house3.initBoxStuffs();
_house3.depthBias = 0.1;
_houses.push(_house3);
addObject(_house3);
_house4 = new House4(XmasCannon_Assets.SPR_HOUSE4);
_house4.x = 3250;
_house4.initBoxStuffs();
_house4.depthBias = 0.1;
_houses.push(_house4);
addObject(_house4);
_house5 = new House5(XmasCannon_Assets.SPR_HOUSE5);
_house5.x = 4000;
_house5.initBoxStuffs();
_house5.depthBias = 0.1;
_houses.push(_house5);
addObject(_house5);
_house6 = new House6(XmasCannon_Assets.SPR_HOUSE6);
_house6.x = 4850;
_house6.initBoxStuffs();
_house6.depthBias = 0.1;
_houses.push(_house6);
addObject(_house6);
_house7 = new House7(XmasCannon_Assets.SPR_HOUSE7);
_house7.x = 5300;
_house7.initBoxStuffs();
_house7.depthBias = 0.1;
_houses.push(_house7);
addObject(_house7);
_house8 = new House8(XmasCannon_Assets.SPR_HOUSE8);
_house8.x = 5950;
_house8.initBoxStuffs();
_house8.depthBias = 0.1;
_houses.push(_house8);
addObject(_house8);
solidObj = new Obs_Deer1(XmasCannon_Assets.SPR_OBS_DEER1);
solidObj.x = 3000;
solidObj.y = -2000;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Deer2(XmasCannon_Assets.SPR_OBS_DEER2);
solidObj.x = 3300;
solidObj.y = -2100;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Deer3(XmasCannon_Assets.SPR_OBS_DEER3);
solidObj.x = 3600;
solidObj.y = -1900;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_UmbrellaSM(XmasCannon_Assets.SPR_OBS_UMBRELLASM);
solidObj.x = 6500;
solidObj.y = -1680;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_UmbrellaSM(XmasCannon_Assets.SPR_OBS_UMBRELLASM);
solidObj.x = 3800;
solidObj.y = -1300;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_UmbrellaSM(XmasCannon_Assets.SPR_OBS_UMBRELLASM);
solidObj.x = 5000;
solidObj.y = -1300;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 500;
solidObj.y = -2100;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 1500;
solidObj.y = -1900;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 2500;
solidObj.y = -2000;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 3500;
solidObj.y = -2250;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 4500;
solidObj.y = -2500;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 5500;
solidObj.y = -1900;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6800;
solidObj.y = 90;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6810;
solidObj.y = -42;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6820;
solidObj.y = -150;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6880;
solidObj.y = -375;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6730;
solidObj.y = -500;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6820;
solidObj.y = -600;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -800;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6900;
solidObj.y = -1000;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -1150;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6790;
solidObj.y = -1325;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -1500;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -1600;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -1800;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -2000;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -2200;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -2400;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -1600;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -2600;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -2800;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Bauble(XmasCannon_Assets.SPR_OBS_BAUBLE);
solidObj.x = 6850;
solidObj.y = -3000;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_NPSign(XmasCannon_Assets.SPR_OBS_NPSIGN);
solidObj.x = 4000;
solidObj.y = -3500;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Sleigh(XmasCannon_Assets.SPR_OBS_SLEIGH);
solidObj.x = 6800;
solidObj.y = -330;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Sleigh(XmasCannon_Assets.SPR_OBS_SLEIGH);
solidObj.x = 6000;
solidObj.y = -3000;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Sleigh(XmasCannon_Assets.SPR_OBS_SLEIGH);
solidObj.x = 5000;
solidObj.y = -3200;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Sleigh(XmasCannon_Assets.SPR_OBS_SLEIGH);
solidObj.x = 4300;
solidObj.y = -2900;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_SpaceBF(XmasCannon_Assets.SPR_OBS_SPACEBF);
solidObj.x = -50;
solidObj.y = -2500;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
_bigfoots.push(solidObj);
solidObj = new Obs_SpaceBF(XmasCannon_Assets.SPR_OBS_SPACEBF);
solidObj.x = 5000;
solidObj.y = -1000;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
_bigfoots.push(solidObj);
solidObj = new Obs_SpaceBF(XmasCannon_Assets.SPR_OBS_SPACEBF);
solidObj.x = 1700;
solidObj.y = -3500;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
_bigfoots.push(solidObj);
solidObj = new Obs_SpaceBF(XmasCannon_Assets.SPR_OBS_SPACEBF);
solidObj.x = 4000;
solidObj.y = -2500;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
_bigfoots.push(solidObj);
solidObj = new Obs_SpaceBF(XmasCannon_Assets.SPR_OBS_SPACEBF);
solidObj.x = 4000;
solidObj.y = -900;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
_bigfoots.push(solidObj);
solidObj = new Obs_Star(XmasCannon_Assets.SPR_OBS_STAR);
solidObj.x = 0;
solidObj.y = -3400;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Star(XmasCannon_Assets.SPR_OBS_STAR);
solidObj.x = 800;
solidObj.y = -3100;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Star(XmasCannon_Assets.SPR_OBS_STAR);
solidObj.x = 1600;
solidObj.y = -3300;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Star(XmasCannon_Assets.SPR_OBS_STAR);
solidObj.x = 2400;
solidObj.y = -3000;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Star(XmasCannon_Assets.SPR_OBS_STAR);
solidObj.x = 3200;
solidObj.y = -3500;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Star(XmasCannon_Assets.SPR_OBS_STAR);
solidObj.x = 4000;
solidObj.y = -3100;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Star(XmasCannon_Assets.SPR_OBS_STAR);
solidObj.x = 4800;
solidObj.y = -3300;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Star(XmasCannon_Assets.SPR_OBS_STAR);
solidObj.x = 5600;
solidObj.y = -2800;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Star(XmasCannon_Assets.SPR_OBS_STAR);
solidObj.x = 0x1900;
solidObj.y = -3100;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_TreeBirds(XmasCannon_Assets.SPR_OBS_TREEBIRDS);
solidObj.x = 1750;
solidObj.y = -200;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Trampoline(XmasCannon_Assets.SPR_OBS_TRAMPOLINE);
solidObj.x = 990;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Trampoline(XmasCannon_Assets.SPR_OBS_TRAMPOLINE);
solidObj.x = 1800;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Trampoline(XmasCannon_Assets.SPR_OBS_TRAMPOLINE);
solidObj.x = 2800;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Trampoline(XmasCannon_Assets.SPR_OBS_TRAMPOLINE);
solidObj.x = 4700;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Trampoline(XmasCannon_Assets.SPR_OBS_TRAMPOLINE);
solidObj.x = 5700;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
solidObj = new Obs_Trampoline(XmasCannon_Assets.SPR_OBS_TRAMPOLINE);
solidObj.x = 6500;
solidObj.initBoxStuffs();
solidObj.depthBias = 0.1;
addObject(solidObj);
i = 0;
while (i < 150) {
sFlake = new FallingSnow(XmasCannon_Assets.SPR_FALLINGSNOW);
addObject(sFlake);
_fallingSnow.push(sFlake);
i++;
};
_ragdoll = new Ragdoll(0, 0);
i = 0;
while (i < _ragdoll.BodyParts.length) {
_ragdoll.BodyParts[i].primaryVis = false;
addObject(_ragdoll.BodyParts[i]);
i++;
};
_rdElfHat = new RenderableObject(XmasCannon_Assets.SPR_HAT);
_rdElfHat.depthBias = 0.1;
addObject(_rdElfHat);
_boxEngine.initRagdoll(0, 0);
}
public function get WorldWidth():Number{
return (_worldWidth);
}
public function get TScale():Number{
return (_targetTrackingScale);
}
public function collidedWithStar():void{
var cObj:CollectableObj;
var i:int;
if ((((_starColTimer < 0)) && ((_starAvail > 0)))){
_starAvail = (_starAvail - 3);
SoundManager.Instance.playSound(XmasCannon_Assets.SND_CLANK);
_starColTimer = 10;
i = 0;
while (i < 10) {
cObj = addCollectable(_ragdoll.MiddleTorso.x, _ragdoll.MiddleTorso.y, CollectableObj.TYPE_BELLS);
cObj.vx = (MathFunction.pnr() * 25);
cObj.vy = ((MathFunction.pnr() * 10) - 5);
cObj.leadBuffer = 30;
cObj.timeout = (2000 + Math.floor((Math.random() * 10)));
cObj.grav = 1;
i++;
};
};
}
public function collidedWithBauble():void{
var cObj:CollectableObj;
var i:int;
if ((((_baubleColTimer < 0)) && ((_baubleAvail > 0)))){
_baubleAvail--;
SoundManager.Instance.playSound(XmasCannon_Assets.SND_CLANK2);
_baubleColTimer = 10;
i = 0;
while (i < 10) {
cObj = addCollectable(_ragdoll.MiddleTorso.x, _ragdoll.MiddleTorso.y, CollectableObj.TYPE_MISSLE);
cObj.vx = (MathFunction.pnr() * 25);
cObj.vy = ((MathFunction.pnr() * 10) - 5);
cObj.leadBuffer = 30;
cObj.timeout = (2000 + Math.floor((Math.random() * 10)));
cObj.grav = 1;
i++;
};
};
}
private function setTrailLines(cam:RenderCam):void{
var dist:Number;
var angleR:Number;
var trailLine:RenderableObject;
var frameP:Number;
if (cam.CameraSubject == _ragdoll.MiddleTorso){
dist = MathFunction.getDistance(_currentTrailLineX, _currentTrailLineY, _ragdoll.MiddleTorso.x, _ragdoll.MiddleTorso.y);
if (dist > 100){
angleR = MathFunction.getRadians(_currentTrailLineX, _currentTrailLineY, _ragdoll.MiddleTorso.x, _ragdoll.MiddleTorso.y);
trailLine = new RenderableObject(XmasCannon_Assets.SPR_TRAILLINE);
trailLine.x = _ragdoll.MiddleTorso.x;
trailLine.y = _ragdoll.MiddleTorso.y;
if (angleR < 0){
angleR = (angleR + (Math.PI * 2));
};
frameP = (angleR / (Math.PI * 2));
trailLine.sm.currentFrame = Math.floor((frameP * trailLine.sm.lastFrame));
_trailLines.push(trailLine);
addObject(trailLine);
_currentTrailLineX = _ragdoll.MiddleTorso.x;
_currentTrailLineY = _ragdoll.MiddleTorso.y;
};
};
}
public function spawnCollectableParticles(inX:Number, inY:Number):void{
var star:Particle;
var i:int;
var numStars:int = (15 - _starDecrease);
if (_starDecrease < 12){
_starDecrease = (_starDecrease + 3);
};
i = 0;
while (i < numStars) {
star = new Particle(XmasCannon_Assets.SPR_FXSTAR);
star.x = inX;
star.y = inY;
star.vx = (MathFunction.pnRand * 16);
star.vy = (MathFunction.pnRand * 16);
star.vx = (star.vx + (_ragdoll.MiddleTorso.vx * 0.85));
star.vy = (star.vy + (_ragdoll.MiddleTorso.vy * 0.85));
addObject(star);
i++;
};
}
public function get RagdollObj():Ragdoll{
return (_ragdoll);
}
public function groundCollide():void{
_trailLinesEnabled = false;
}
private function setSnowWind():void{
if (Math.random() > 0.66){
_snowWindTarget = (MathFunction.pnRand * 0.9);
return;
};
if (Math.random() > 0.5){
_snowWindTarget = (0.1 + (Math.random() * 0.65));
} else {
_snowWindTarget = (-0.1 - (Math.random() * 0.65));
};
}
public function get LevelRunning():Boolean{
return ((_mode == LEVELMODE_INPROGRESS));
}
override public function keyDown(keyCode:uint):void{
if (keyCode == Keyboard.SPACE){
_spacePressed = true;
};
}
public function get SOffset():Number{
return (_sOffset);
}
public function get CScale():Number{
return (_currentTrackingScale);
}
override public function update():void{
var collectable:CollectableObj;
var pObj:RenderableObject;
var aimRadians:Number;
var aimDist:Number;
var i:int;
var j:int;
_randomOuchTimer--;
if (_starDecrease > 0){
_starDecrease--;
};
if (_cam.x > 200){
_hintTimer = 0;
};
if (_mode == LEVELMODE_HINT){
_leadIn--;
_hintTimer--;
if (_hintTimer < 0){
_gameplayHint.s = (_gameplayHint.s * 0.9);
if (_gameplayHint.s < 0.05){
_gameplayHint.purgeObject();
_mode = LEVELMODE_INPROGRESS;
};
};
};
if (_mode == LEVELMODE_LEADIN){
_leadIn--;
if (_leadIn < 0){
_mode = LEVELMODE_INPROGRESS;
};
};
_baubleColTimer--;
_starColTimer--;
_baubleAvail = (_baubleAvail + 0.005);
_starAvail = (_starAvail + 0.005);
if (_baubleAvail > 12){
_baubleAvail = 12;
};
if (_starAvail > 12){
_starAvail = 12;
};
_boxEngine.update();
_ragdoll.update();
if (_trailLinesEnabled){
setTrailLines(_cam);
};
animateSnow(_cam);
checkCollatablesCollision();
_ground.x = EngineMain.Instance.Camera.x;
if (_bigfootBonus > 0){
_bigfootBonus--;
if (Math.random() > 0.6){
_ragdoll.resetInertiaParams();
collectable = new CollectableObj(XmasCannon_Assets.SPR_COLLECTABLE);
collectable.x = _ragdoll.MiddleTorso.x;
collectable.y = ((_ragdoll.MiddleTorso.y - 500) - (Math.random() * 100));
collectable.grav = 1.2;
collectable.initVariant((2 + int(Math.floor((Math.random() * 3.999)))));
_collectables.push(collectable);
addObject(collectable);
};
};
var camDir:Number = _cam.MovementDirection;
var camVel:Number = _cam.CamVel;
var paralaxVec:Object = MathFunction.getVector(camDir, -(camVel));
i = 0;
while (i < _paralaxObjects.length) {
pObj = _paralaxObjects[i];
pObj.x = (pObj.baseX + (_cam.x * (1 - pObj.z)));
pObj.y = (pObj.baseY + (_cam.y * (1 - pObj.z)));
i++;
};
var worldCursorX:Number = (XmasCannon_Main.Instance.mouseX - 350);
var worldCursorY:Number = (XmasCannon_Main.Instance.mouseY - 225);
var cannonAimFromBaseX:Number = -294;
var cannonAimFromBaseY:Number = 116;
worldCursorX = (worldCursorX * (1 / 0.67));
worldCursorY = (worldCursorY * (1 / 0.67));
if (((((((_cannonBarrel.loaded) && ((worldCursorX > (cannonAimFromBaseX - 30))))) && ((worldCursorY < (cannonAimFromBaseY + 50))))) && (!(_spacePressed)))){
aimRadians = MathFunction.getRadians(cannonAimFromBaseX, cannonAimFromBaseY, worldCursorX, worldCursorY);
_cannonBarrel.setAim(aimRadians);
aimDist = MathFunction.getDistance(cannonAimFromBaseX, cannonAimFromBaseY, worldCursorX, worldCursorY);
if (aimDist < 5){
aimDist = 5;
};
if (aimDist > 450){
aimDist = 450;
};
_cannonBarrel.setPower(aimDist);
if (aimRadians < (-(Math.PI) / 2)){
aimRadians = (-(Math.PI) / 2);
};
if (aimRadians > 0){
aimRadians = 0;
};
_cannonPowerBar.r = aimRadians;
if (_cannonPowerBarGhost){
_cannonPowerBarGhost.r = _cannonPowerBar.r;
};
};
super.update();
_rdElfHat.x = _ragdoll.Head.x;
_rdElfHat.y = _ragdoll.Head.y;
_rdElfHat.z = _ragdoll.Head.z;
_rdElfHat.depthBias = (_ragdoll.Head.depthBias + 0.005);
_rdElfHat.r = _ragdoll.Head.r;
_rdElfHat.primaryVis = _ragdoll.Head.primaryVis;
_rdElfHat.update();
zSort();
if (((_spacePressed) && (_cannonBarrel.loaded))){
EngineMain.Instance.Camera.setCameraSubject(null);
_cam.targetX = (_cam.targetX + (worldCursorX * 0.25));
_cam.targetY = (_cam.targetY + (worldCursorY * 0.12));
_panCursor.primaryVis = true;
_panCursor.x = (worldCursorX + _cam.x);
_panCursor.y = (worldCursorY + _cam.y);
Mouse.hide();
} else {
if (((_cannonBarrel.loaded) && (!((_cam.CameraSubject == _cannonBarrel))))){
_cam.setCameraSubject(_cannonBarrel, false);
};
_panCursor.primaryVis = false;
Mouse.show();
};
var camVelP:Number = (_cam.CamVel / 40);
if (camVelP > 1){
camVelP = 1;
};
_zoomScale = (1 - (camVelP * (1 - 0.667)));
_zoomOverride = 0.67;
if (EngineMain.Instance.Camera.CameraSubject == _cannonBarrel){
_zoomScale = 1;
};
if (_zoomOverride < _zoomScale){
_zoomScale = _zoomOverride;
};
_targetTrackingScale = (_targetTrackingScale + ((_zoomScale - _targetTrackingScale) * 0.05));
_currentTrackingScale = (_currentTrackingScale + (((_targetTrackingScale * 1) - _currentTrackingScale) * 0.05));
_sOffset = (_zoomScale - RenderManager.Instance.Canvas.scaleX);
if (_sOffset < 0.001){
_sOffset = 0;
};
RenderManager.Instance.Canvas.scaleX = _currentTrackingScale;
RenderManager.Instance.Canvas.scaleY = _currentTrackingScale;
RenderManager.Instance.Canvas.x = 0;
RenderManager.Instance.Canvas.y = 0;
RenderManager.Instance.Canvas.x = (RenderManager.Instance.Canvas.x + ((700 - (1050 * _currentTrackingScale)) / 2));
RenderManager.Instance.Canvas.y = (RenderManager.Instance.Canvas.y + ((450 - (675 * _currentTrackingScale)) / 2));
}
public function get DiffX():Number{
return (_diffX);
}
public function gameover():void{
}
public function fireCannon():void{
var shotVel:Object;
var velMod:Number;
var shotP:Particle;
var smokePuff:Particle;
_trailLinesEnabled = true;
if (!_cannonBarrel.loaded){
return;
};
EngineMain.Instance.ShotsRemainingField.text = ("X" + String(_numShots));
var worldCursorX:Number = (XmasCannon_Main.Instance.mouseX - 350);
var worldCursorY:Number = (XmasCannon_Main.Instance.mouseY - 225);
worldCursorX = (worldCursorX * (1 / 0.67));
worldCursorY = (worldCursorY * (1 / 0.67));
var crossHair:RenderableObject = new RenderableObject(XmasCannon_Assets.SPR_CROSSHAIR);
crossHair.x = worldCursorX;
crossHair.y = worldCursorY;
addObject(crossHair);
_crossHairs.push(crossHair);
SoundManager.Instance.playSound(XmasCannon_Assets.SND_CANNON);
var i:Number = 0;
i = 0;
while (i < _trailLines.length) {
_trailLines[i].purgeObject();
i++;
};
_trailLines = [];
_currentTrailLineX = _ragdoll.MiddleTorso.x;
_currentTrailLineY = _ragdoll.MiddleTorso.y;
if (!_cannonBarrelGhost){
_cannonBarrelGhost = new RenderableObject(XmasCannon_Assets.SPR_BARRELGHOST);
_cannonBarrelGhost.x = _cannonBarrel.x;
_cannonBarrelGhost.y = _cannonBarrel.y;
_cannonBarrelGhost.depthBias = 0.5;
addObject(_cannonBarrelGhost);
};
if (!_cannonPowerBarGhost){
_cannonPowerBarGhost = new RenderableObject(XmasCannon_Assets.SPR_POWERBARGHOST);
_cannonPowerBarGhost.x = _cannonPowerBar.x;
_cannonPowerBarGhost.y = _cannonPowerBar.y;
_cannonPowerBarGhost.depthBias = 0.5;
addObject(_cannonPowerBarGhost);
};
_cannonBarrelGhost.sm.currentFrame = _cannonBarrel.sm.currentFrame;
_cannonPowerBarGhost.sm.currentFrame = _cannonPowerBar.sm.currentFrame;
i = 0;
while (i < _ragdoll.BodyParts.length) {
_ragdoll.BodyParts[i].resetTrail();
i++;
};
var shotPower:Number = _cannonPowerBar.getShotPower();
shotVel = _cannonPowerBar.getShotVel(0);
_boxEngine.resetRagdoll();
i = 0;
while (i < _ragdoll.BodyParts.length) {
if (_ragdoll.BodyParts[i].BoxParent){
_ragdoll.BodyParts[i].BoxParent.ApplyImpulse(new b2Vec2((shotVel.x * 0.035), (shotVel.y * 0.035)), _ragdoll.BodyParts[i].BoxParent.GetWorldCenter());
_ragdoll.BodyParts[i].BoxParent.m_linearDamping = 0;
};
i++;
};
_ragdoll.show();
EngineMain.Instance.Camera.shake((50 + (shotPower * 0.2)));
var barrelExitX:Number = _ragdoll.MiddleTorso.x;
var barrelExitY:Number = _ragdoll.MiddleTorso.y;
i = 0;
while (i < 35) {
shotVel = _cannonPowerBar.getShotVel(0.1);
shotP = new Particle(XmasCannon_Assets.SPR_BLUESPARK1);
shotP.x = ((barrelExitX + (Math.random() * 8)) - 4);
shotP.y = ((barrelExitY + (Math.random() * 8)) - 4);
velMod = (0.22 + (Math.random() * 0.13));
shotP.vx = (shotVel.x * velMod);
velMod = (0.22 + (Math.random() * 0.13));
shotP.vy = (shotVel.y * velMod);
addObject(shotP);
i++;
};
i = 0;
while (i < 16) {
smokePuff = new Particle(XmasCannon_Assets.SPR_SMOKEPUFF);
smokePuff.x = (_ragdoll.MiddleTorso.x + (MathFunction.pnr() * 140));
smokePuff.y = (_ragdoll.MiddleTorso.y + (MathFunction.pnr() * 140));
velMod = (0.2 + (Math.random() * 0.08));
smokePuff.vx = (shotVel.x * velMod);
velMod = (0.2 + (Math.random() * 0.08));
smokePuff.vy = (shotVel.y * velMod);
addObject(smokePuff);
i++;
};
EngineMain.Instance.Camera.setCameraSubject(_ragdoll.MiddleTorso);
_cannonBarrel.loaded = false;
}
public function get DiffY():Number{
return (_diffY);
}
public function prepNewShot():void{
if (_mode == LEVELMODE_IDLE){
return;
};
if (_numShots <= 0){
_numShots = -1;
EngineMain.Instance.Camera.setCameraSubject(null, false);
EngineMain.Instance.gameover();
GameTracking.levelComplete();
_mode = LEVELMODE_IDLE;
return;
};
EngineMain.Instance.Camera.setCameraSubject(_cannonBarrel, false);
_cannonBarrel.loaded = true;
resetRagdoll();
_numShots--;
}
private function checkCollatablesCollision():void{
var i:int;
var j:int;
var cObj:CollectableObj;
var distA:Number;
var rdbpObj:BodyPart;
var distB:Number;
var motionBonus:Number;
if (!_ragdoll.MiddleTorso.primaryVis){
return;
};
i = 0;
while (i < _collectables.length) {
cObj = _collectables[i];
distA = MathFunction.getDistance(_ragdoll.MiddleTorso.x, _ragdoll.MiddleTorso.y, cObj.x, cObj.y);
if (distA < 250){
j = 0;
while (j < _ragdoll.BodyParts.length) {
rdbpObj = _ragdoll.BodyParts[j];
distB = MathFunction.getDistance(rdbpObj.x, rdbpObj.y, cObj.x, cObj.y);
if ((((distB < 30)) && ((cObj.leadBuffer <= 0)))){
cObj.collected = true;
cObj.purgeObject();
spawnCollectableParticles(cObj.x, cObj.y);
_collectables.splice(i, 1);
motionBonus = Math.floor((_ragdoll.MiddleTorso.getVel() * 2.5));
EngineMain.Instance.triggerScoreBlip((cObj.pointsVal + motionBonus));
SoundManager.Instance.playSound(XmasCannon_Assets.SND_COLLECT);
i--;
if (_collectables.length < 1){
return;
};
break;
};
j++;
};
};
i++;
};
}
public function resetTemporaryObjects():void{
var i:int;
i = 0;
while (i < _sessionObjects.length) {
_sessionObjects[i].purgeObject();
i++;
};
_sessionObjects = [];
i = 0;
while (i < _trailLines.length) {
_trailLines[i].purgeObject();
i++;
};
_trailLines = [];
i = 0;
while (i < _collectables.length) {
_collectables[i].purgeObject();
i++;
};
_collectables = [];
i = 0;
while (i < _crossHairs.length) {
_crossHairs[i].purgeObject();
i++;
};
_crossHairs = [];
addCollectableGrid(500, -500, CollectableObj.TYPE_HAM, 3, 3, 100);
addCollectableGrid(2500, -500, CollectableObj.TYPE_HAM, 3, 3, 100);
addCollectableGrid(5000, -500, CollectableObj.TYPE_HAM, 3, 3, 100);
addCollectableArray([{x:742, y:-2086}, {x:868, y:-2086}, {x:999, y:-2087}, {x:1131, y:-2089}, {x:1257, y:-2092}, {x:1377, y:-2089}, {x:1494, y:-2077}, {x:1611, y:-2057}, {x:1726, y:-2028}, {x:1841, y:-1991}, {x:1956, y:-1947}, {x:2073, y:-1895}, {x:2192, y:-1835}, {x:0x0909, y:-1769}, {x:2436, y:-1697}, {x:2561, y:-1621}, {x:2687, y:-1542}, {x:2771, y:-1486}, {x:2855, y:-1429}, {x:2938, y:-1370}, {x:3020, y:-1308}, {x:3103, y:-1244}, {x:3184, y:-1177}, {x:3266, y:-1108}, {x:3347, y:-1036}, {x:3428, y:-962}, {x:3508, y:-885}, {x:3588, y:-805}, {x:3668, y:-723}, {x:3747, y:-638}, {x:3826, y:-550}], CollectableObj.TYPE_HAM);
addCollectableGrid(1000, -500, CollectableObj.TYPE_CHICKEN, 3, 3, 100);
addCollectableGrid(3000, -2500, CollectableObj.TYPE_CHICKEN, 10, 1, 50);
addCollectableArray([{x:225, y:-988}, {x:298, y:-1114}, {x:370, y:-1241}, {x:440, y:-1367}, {x:508, y:-1493}, {x:573, y:-1616}, {x:635, y:-1735}, {x:696, y:-1850}, {x:756, y:-1961}, {x:816, y:-2066}, {x:877, y:-2168}, {x:940, y:-2266}, {x:1004, y:-2362}, {x:1068, y:-2455}, {x:1132, y:-2545}, {x:1197, y:-2632}, {x:1262, y:-2715}, {x:1328, y:-2795}, {x:1395, y:-2873}, {x:1464, y:-2949}, {x:1535, y:-3023}, {x:1605, y:-3097}, {x:1675, y:-3169}, {x:1780, y:-3274}, {x:1881, y:-3375}, {x:1981, y:-3469}, {x:2080, y:-3556}], CollectableObj.TYPE_CHICKEN);
addCollectableGrid(200, -1000, CollectableObj.TYPE_CANE, 2, 2, 60);
addCollectableGrid(600, -2500, CollectableObj.TYPE_CANE, 15, 2, 60);
addCollectableGrid(2500, -2200, CollectableObj.TYPE_CANE, 2, 15, 60);
addCollectableGrid(4050, -3000, CollectableObj.TYPE_CANE, 1, 50, 60);
addCollectableGrid(5000, -3500, CollectableObj.TYPE_GIFT, 2, 20, 60);
addCollectableGrid(6550, -600, CollectableObj.TYPE_GIFT, 15, 4, 120);
addCollectableGrid(4500, -250, CollectableObj.TYPE_GIFT, 4, 4, 160);
addCollectableArray([{x:2402, y:-2354}, {x:2429, y:-2241}, {x:2456, y:-2126}, {x:2328, y:-2170}, {x:2222, y:-2238}, {x:2115, y:-2297}, {x:2007, y:-2347}, {x:1901, y:-2388}, {x:1797, y:-2421}, {x:1697, y:-2449}, {x:1598, y:-2473}, {x:1499, y:-2492}, {x:1368, y:-2507}, {x:1238, y:-2514}, {x:1108, y:-2511}, {x:978, y:-2499}, {x:848, y:-2477}, {x:750, y:-2453}, {x:653, y:-2425}, {x:555, y:-2391}, {x:457, y:-2352}, {x:358, y:-2307}, {x:258, y:-2256}, {x:158, y:-2200}], CollectableObj.TYPE_MISSLE);
addCollectableGrid(945, 0, CollectableObj.TYPE_MISSLE, 1, 10, 40);
addCollectableGrid(2700, 0, CollectableObj.TYPE_MISSLE, 1, 22, 40);
addCollectableGrid(4600, -1900, CollectableObj.TYPE_MISSLE, 5, 5, 120);
addCollectableGrid(160, -3620, CollectableObj.TYPE_BELLS, 3, 3, 75);
addCollectableGrid(1000, -3620, CollectableObj.TYPE_BELLS, 3, 3, 75);
addCollectableGrid(6500, -2500, CollectableObj.TYPE_BELLS, 3, 3, 75);
addCollectableGrid(1500, -1500, CollectableObj.TYPE_BELLS, 3, 3, 75);
addCollectableGrid(3500, -1500, CollectableObj.TYPE_BELLS, 3, 3, 75);
addCollectableGrid(5800, -1500, CollectableObj.TYPE_BELLS, 3, 3, 75);
addCollectableGrid(1690, 40, CollectableObj.TYPE_BELLS, 5, 5, 60);
}
public function setCameraShakeLevel(inVal:Number):void{
}
public static function get Instance():GameLevel{
return (_instance);
}
}
}//package com.xmascannon.engine.objectSpaces
Section 212
//EngineMain (com.xmascannon.engine.EngineMain)
package com.xmascannon.engine {
import flash.events.*;
import com.psiom.foundation.*;
import com.xmascannon.*;
import flash.display.*;
import com.psiom.rendering.*;
import com.psiom.ui.uiComponents.*;
import com.xmascannon.engine.objectSpaces.*;
import flash.text.*;
import com.soapcreative.net.tracking.*;
public class EngineMain extends CoreSystem {
private var _oldState:int;// = 0
private var _baseUploadedImage:Bitmap;
private var _bonusTime:Number;// = 0
private var SCENE_WIDTH:int;// = 1050
private var _levelLeadOut:Number;// = 115
private var _initialized:Boolean;// = false
private var _confirmationBox:UIOBject;
private var _debugView:Boolean;// = false
private var _difficultyMode:int;// = 0
private var _cursorOX:Number;// = 0
private var _cursorOY:Number;// = 0
private var _scoreBlip:UIOBject;
private var _mainMenuButton:UIButton;
private var _gameLevel:GameLevel;
private var _scoreFieldClips:Array;
public var mouseTrapper_fullBlank:MovieClip;
private var _totalScore:Number;// = 0
private var _bonusScore:Number;// = 0
private var SCENE_HEIGHT:int;// = 675
private var _totalPossibleScore:Number;// = 0
private var _gameplayLeadInTimer:Number;// = 87
private var _soundButton:UIButton;
private var _baseUploadedImageBMD:BitmapData;
private var _scoreBlipLarge:UIOBject;
private var _initialSetup:Boolean;// = false
private var _lastTimeDisplay:String;
private var _cursorX:Number;// = 0
private var _cursorY:Number;// = 0
private var _hintTimer:Number;// = 200
private var _lastCursorX:Number;// = 0
private var _lastCursorY:Number;// = 0
private var _state:Number;// = 0
private var _scoreCharCValues:Array;
private var _scoreDisplayClip:UIOBject;
private var _secondaryState:Number;// = 0
private var _scoreStack:Number;// = 0
private var _controlHint:UIOBject;
private var _shotsRemainingDisplay:UIOBject;
private var _scoreCharTValues:Array;
private var _levelTime:int;// = 0
private var _housesDisplay:UIOBject;
public static var STATE_INIT:int = 6;
public static var STATE_GAMEOVER:int = 5;
public static var STATE_LOADING:int = 4;
public static var STATE_LEVELCOMPLETE:int = 3;
public static var STATE_GAMEPLAY:int = 1;
public static var STATE_INACTIVE:int = 0;
private static var _instance:EngineMain;
public static var STATE_PAUSED:int = 2;
public function EngineMain(){
_scoreCharCValues = [0, 0, 0, 0, 0, 0, 0];
_scoreCharTValues = [0, 0, 0, 0, 0, 0, 0];
_scoreFieldClips = [];
super();
_instance = this;
_gameLevel = new GameLevel(this);
setRestState();
_autoUpdateObjectSpace = false;
}
public function closeGame():void{
_state = _slot1.STATE_INACTIVE;
_confirmationBox.primaryVis = false;
_scoreDisplayClip.primaryVis = false;
_shotsRemainingDisplay.primaryVis = false;
_mainMenuButton.primaryVis = false;
_scoreBlip.primaryVis = false;
_scoreBlipLarge.primaryVis = false;
_housesDisplay.primaryVis = false;
_currentSpace.update();
}
public function get ConfirmQuit():UIOBject{
return (_confirmationBox);
}
public function init():void{
_initialized = true;
_currentCamera = new RenderCam(SCENE_WIDTH, SCENE_HEIGHT);
_currentCamera.setLocationConstraint(0, -3500, 0x1900, 0);
mouseTrapper_fullBlank = new gClip_fullBlank();
mouseTrapper_fullBlank.cacheAsBitmap = true;
MovieClipLayer.addChild(mouseTrapper_fullBlank);
_currentSpace = new GameLevel(this);
GameLevel.Instance.initWorld();
_mainMenuButton = createNavButton(-1, new ui_mainMenuButton(), -1, quitGame);
_mainMenuButton.x = 550;
_mainMenuButton.y = 7;
_housesDisplay = new UIOBject(-1, new uiclip_housesDisplay());
_housesDisplay.sm.mc.mouseChildren = false;
_housesDisplay.sm.mc.mouseEnabled = false;
_housesDisplay.x = 208;
_housesDisplay.y = 7;
_currentSpace.addObject(_housesDisplay);
_scoreBlip = new UIOBject(-1, new ui_scoreBlip());
_scoreBlip.x = 354;
_scoreBlip.y = 75;
_scoreBlip.primaryVis = true;
_scoreBlip.a = 0;
_currentSpace.addObject(_scoreBlip);
_scoreBlipLarge = new UIOBject(-1, new ui_scoreBlipLarge());
_scoreBlipLarge.x = 100;
_scoreBlipLarge.y = 150;
_scoreBlipLarge.primaryVis = true;
_scoreBlipLarge.a = 0;
_currentSpace.addObject(_scoreBlipLarge);
_confirmationBox = new UIOBject(-1, new uimain_confirmQuit());
createNavButton(-1, _confirmationBox.sm.mc.btnNo, -1, XmasCannon_Main.Instance.resumeGame);
createNavButton(-1, _confirmationBox.sm.mc.btnYes, -1, XmasCannon_Main.Instance.quitConfirmed);
_confirmationBox.primaryVis = false;
_currentSpace.addObject(_confirmationBox);
_scoreDisplayClip = new UIOBject(-1, new uiclip_scoreField());
_scoreDisplayClip.x = 395;
_scoreDisplayClip.y = 7;
_scoreFieldClips = [_scoreDisplayClip.sm.mc.f0, _scoreDisplayClip.sm.mc.f1, _scoreDisplayClip.sm.mc.f2, _scoreDisplayClip.sm.mc.f3, _scoreDisplayClip.sm.mc.f4, _scoreDisplayClip.sm.mc.f5, _scoreDisplayClip.sm.mc.f6];
_shotsRemainingDisplay = new UIOBject(-1, new gClip_shotsLeftDisplay());
_shotsRemainingDisplay.x = 115;
_shotsRemainingDisplay.y = 7;
_currentSpace.addObject(_shotsRemainingDisplay);
var i:int;
while (i < _scoreCharTValues.length) {
_scoreCharCValues[i] = 0;
_scoreCharTValues[i] = 0;
_scoreFieldClips[i].text = String(_scoreCharCValues[i]);
i++;
};
_currentSpace.addObject(_scoreDisplayClip);
}
override public function clickInput(x:Number, y:Number):void{
if (_state == STATE_GAMEPLAY){
_currentSpace.clickInput(x, y);
};
}
public function generateRandomSeed(inArray:Array):void{
inArray = [Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random()];
}
public function get MainMenuButton():UIButton{
return (_mainMenuButton);
}
public function addBonusScore(val:Number):void{
_bonusScore = (_bonusScore + val);
}
public function triggerScoreBlipLarge(val:Number):void{
val = Math.round(val);
_totalScore = (_totalScore + val);
_scoreBlipLarge.primaryVis = true;
_scoreBlipLarge.sm.mc._points.text = ("+" + String(val));
_scoreBlipLarge.a = 1;
_scoreBlipLarge.s = 1;
var scoreString:String = String(_totalScore);
while (scoreString.length < 7) {
scoreString = ("0" + scoreString);
};
_scoreCharTValues = [scoreString.charAt(0), scoreString.charAt(1), scoreString.charAt(2), scoreString.charAt(3), scoreString.charAt(4), scoreString.charAt(5), scoreString.charAt(6)];
_scoreBlipLarge.sm.mc._base.gotoAndStop(0);
}
public function showQuitConfirmation():void{
_confirmationBox.primaryVis = true;
_oldState = _state;
_state = STATE_PAUSED;
}
private function onHintClick(e:Event):void{
onSpacePressed();
}
public function reset():void{
_secondaryState = 0;
_state = 0;
}
public function resetTotalScore():void{
trace("resetting total score");
_totalScore = 0;
}
public function set BaseUploadedImageBMD(val:BitmapData):void{
_baseUploadedImageBMD = new BitmapData(val.width, val.height, true);
_baseUploadedImageBMD = val;
}
override public function onFirstAdded():void{
}
public function get State():Number{
return (_state);
}
public function get BaseUploadedImage():Bitmap{
return (_baseUploadedImage);
}
public function initNewGame():void{
trace("EngineMain > initNewGame");
GameTracking.startLevel(1);
_scoreDisplayClip.primaryVis = true;
_shotsRemainingDisplay.primaryVis = true;
_mainMenuButton.primaryVis = true;
_scoreBlip.primaryVis = true;
_scoreBlipLarge.primaryVis = true;
_housesDisplay.primaryVis = true;
_gameplayLeadInTimer = 87;
_levelLeadOut = 115;
_totalScore = 0;
_housesDisplay.sm.mc.hd1.visible = false;
_housesDisplay.sm.mc.hd2.visible = false;
_housesDisplay.sm.mc.hd3.visible = false;
_housesDisplay.sm.mc.hd4.visible = false;
_housesDisplay.sm.mc.hd5.visible = false;
_housesDisplay.sm.mc.hd6.visible = false;
_housesDisplay.sm.mc.hd7.visible = false;
_housesDisplay.sm.mc.hd8.visible = false;
GameLevel.Instance.initGame();
_state = STATE_GAMEPLAY;
}
public function get ShotsRemainingField():TextField{
return (_shotsRemainingDisplay.sm.mc.numField);
}
public function lightHouse(inHouse:int):void{
switch (inHouse){
case 1:
_housesDisplay.sm.mc.hd1.visible = true;
break;
case 2:
_housesDisplay.sm.mc.hd2.visible = true;
break;
case 3:
_housesDisplay.sm.mc.hd3.visible = true;
break;
case 4:
_housesDisplay.sm.mc.hd4.visible = true;
break;
case 5:
_housesDisplay.sm.mc.hd5.visible = true;
break;
case 6:
_housesDisplay.sm.mc.hd6.visible = true;
break;
case 7:
_housesDisplay.sm.mc.hd7.visible = true;
break;
case 8:
_housesDisplay.sm.mc.hd8.visible = true;
break;
};
}
public function get BaseUploadedImageBMD():BitmapData{
return (_baseUploadedImageBMD);
}
public function get Initialized():Boolean{
return (_initialized);
}
public function resumeGame():void{
_state = _oldState;
_confirmationBox.primaryVis = false;
}
public function onSpacePressed():void{
if (_controlHint){
_controlHint.a = (_controlHint.a - 0.1);
XmasCannon_Main.Instance.StageRef.stageFocusRect = false;
XmasCannon_Main.Instance.StageRef.focus = XmasCannon_Main.Instance;
};
}
override public function update():void{
var i:int;
super.update();
if (_gameplayLeadInTimer >= 0){
_gameplayLeadInTimer--;
};
if (_controlHint){
if (_controlHint.a < 1){
_controlHint.a = (_controlHint.a * 0.9);
};
if (_controlHint.a < 0.02){
_controlHint.primaryVis = false;
XmasCannon_Main.Instance.controlHintDone();
_controlHint = null;
};
};
if (_state == _slot1.STATE_LEVELCOMPLETE){
_levelLeadOut--;
if (_levelLeadOut < 0){
closeGame();
XmasCannon_Main.Instance.gameComplete();
};
};
if (_state == _slot1.STATE_GAMEOVER){
_levelLeadOut--;
if (_levelLeadOut < 0){
closeGame();
XmasCannon_Main.Instance.gameover();
};
};
if (_state == _slot1.STATE_PAUSED){
_currentSpace.updateUIOnly();
} else {
if (_state != STATE_INACTIVE){
_currentSpace.update();
};
};
if ((((((((((_state == _slot1.STATE_GAMEPLAY)) || ((_state == _slot1.STATE_GAMEOVER)))) || ((_state == _slot1.STATE_LEVELCOMPLETE)))) || ((_state == _slot1.STATE_GAMEOVER)))) || ((_state == _slot1.STATE_INIT)))){
_levelTime++;
};
if (_scoreDisplayClip){
i = 0;
while (i < _scoreCharTValues.length) {
if (_scoreCharCValues[i] < _scoreCharTValues[i]){
var _local2 = _scoreCharCValues;
var _local3 = i;
var _local4 = (_local2[_local3] + 1);
_local2[_local3] = _local4;
};
if (_scoreCharCValues[i] > _scoreCharTValues[i]){
_scoreCharCValues[i] = _scoreCharTValues[i];
};
_scoreFieldClips[i].text = String(_scoreCharCValues[i]);
i++;
};
};
if (_scoreBlip){
if (_scoreBlip.sm.mc._base.currentFrame < (_scoreBlip.sm.mc._base.totalFrames - 1)){
_scoreBlip.sm.mc._base.gotoAndStop((_scoreBlip.sm.mc._base.currentFrame + 1));
};
if (_scoreBlip.sm.mc._base.currentFrame > 20){
_scoreBlip.a = (_scoreBlip.a * 0.94);
_scoreBlip.s = (_scoreBlip.s * 0.94);
};
if (_scoreBlip.a < 0.75){
_scoreStack = 0;
};
if (_scoreBlip.a < 0.1){
_scoreBlip.primaryVis = false;
_scoreBlip.sm.mc._base.gotoAndStop(0);
};
};
if (_scoreBlipLarge){
if (_scoreBlipLarge.sm.mc._base.currentFrame < (_scoreBlipLarge.sm.mc._base.totalFrames - 1)){
_scoreBlipLarge.sm.mc._base.gotoAndStop((_scoreBlipLarge.sm.mc._base.currentFrame + 1));
};
if (_scoreBlipLarge.sm.mc._base.currentFrame > 48){
_scoreBlipLarge.a = (_scoreBlipLarge.a * 0.94);
_scoreBlipLarge.s = (_scoreBlipLarge.s * 0.94);
};
if (_scoreBlipLarge.a < 0.1){
_scoreBlipLarge.primaryVis = false;
_scoreBlipLarge.sm.mc._base.gotoAndStop(0);
};
};
}
public function triggerScoreBlip(val:Number):void{
val = Math.round(val);
_totalScore = (_totalScore + val);
_scoreStack = (_scoreStack + val);
_scoreBlip.primaryVis = true;
_scoreBlip.sm.mc._points.text = ("+" + String(_scoreStack));
_scoreBlip.a = 1;
_scoreBlip.s = 1;
var scoreString:String = String(_totalScore);
while (scoreString.length < 7) {
scoreString = ("0" + scoreString);
};
_scoreCharTValues = [scoreString.charAt(0), scoreString.charAt(1), scoreString.charAt(2), scoreString.charAt(3), scoreString.charAt(4), scoreString.charAt(5), scoreString.charAt(6)];
_scoreBlip.sm.mc._base.gotoAndStop(0);
}
public function gameover():void{
_state = _slot1.STATE_GAMEOVER;
}
public function set BaseUploadedImage(val:Bitmap):void{
_baseUploadedImage = val;
}
public function setRestState():void{
_state = _slot1.STATE_INACTIVE;
}
public function levelComplete():void{
if (_state != _slot1.STATE_LEVELCOMPLETE){
_levelLeadOut = 210;
_state = _slot1.STATE_LEVELCOMPLETE;
};
}
private function quitGame(e:Event):void{
showQuitConfirmation();
}
public function set State(inState:Number):void{
_state = inState;
}
public function get FinalScore():Number{
return (Math.floor(_totalScore));
}
public function addToFinalPossibleScore(inVal:Number):void{
_totalPossibleScore = (_totalPossibleScore + inVal);
}
public function get FinalPossibleScore():Number{
return (_totalPossibleScore);
}
public static function get Instance():EngineMain{
return (_instance);
}
}
}//package com.xmascannon.engine
Section 213
//LeaderBoard (com.xmascannon.ui.LeaderBoard)
package com.xmascannon.ui {
import flash.events.*;
import flash.display.*;
import com.psiom.ui.uiComponents.*;
import flash.net.*;
public class LeaderBoard extends UIOBject {
private var _pageIndex:Number;// = 0
private var _btnLeft:UIButton;
private var _entryList:Array;
private var _rows:Array;
private var _scoreData:XML;
private var _btnRight:UIButton;
public function LeaderBoard(inSpriteID:int=-1, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
_rows = [clip._row01, clip._row02, clip._row03, clip._row04, clip._row05, clip._row06, clip._row07, clip._row08, clip._row09, clip._row10];
var i:int;
while (i < _rows.length) {
_rows[i].visible = false;
_rows[i]._flag.gotoAndStop(1);
i++;
};
_btnLeft = UIMain.Instance.createNavButton(-1, clip._left, -1, onLeft);
_btnRight = UIMain.Instance.createNavButton(-1, clip._right, -1, onRight);
_btnLeft.primaryVis = false;
}
private function onXMLLoad(e:Event):void{
var e = e;
_scoreData = new XML(URLLoader(e.target).data);
//unresolved jump
var _slot1 = e;
onParseError(_slot1);
parseXML();
}
private function onLeft(event:Event):void{
_btnRight.primaryVis = true;
_pageIndex--;
setScoresDisplay();
}
public function loadScores():void{
var u:URLRequest;
var vars:URLVariables;
var nocache:uint;
_pageIndex = 0;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onXMLLoad);
loader.addEventListener(IOErrorEvent.IO_ERROR, onReadError);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onReadError);
u = new URLRequest("http://stats.soap.com.au/highscore/highscoreXML.php");
nocache = uint((Math.random() * uint.MAX_VALUE));
vars = new URLVariables();
vars["gameid"] = 46;
vars["start"] = 0;
vars["count"] = 101;
vars["nocache"] = nocache.toString(36);
u.method = URLRequestMethod.GET;
u.data = vars;
loader.load(u);
}
private function onRight(event:Event):void{
_btnLeft.primaryVis = true;
_pageIndex++;
setScoresDisplay();
}
private function setScoresDisplay():void{
var j:Number;
var k:Number;
var fieldPieces:Array;
var finalScore:String;
var d:Number;
_btnRight.primaryVis = true;
if (_pageIndex >= 9){
_pageIndex = 9;
_btnRight.primaryVis = false;
};
if (_pageIndex <= 0){
_pageIndex = 0;
_btnLeft.primaryVis = false;
};
var i:int;
while (i < 10) {
j = (i + (_pageIndex * 10));
if (_entryList){
if (_entryList[j]){
_rows[i]._nameField.text = _entryList[j].Name.substr(0, 16);
if (_entryList[j].Country == "AU"){
_rows[i]._flag.gotoAndStop(1);
} else {
_rows[i]._flag.gotoAndStop(2);
};
fieldPieces = _entryList[j].Score.split("");
fieldPieces.reverse();
finalScore = "";
k = 0;
while (k < fieldPieces.length) {
finalScore = (fieldPieces[k] + finalScore);
d = (k % 3);
if (k < (fieldPieces.length - 1)){
if (d == 2){
finalScore = ("," + finalScore);
};
};
k++;
};
_rows[i]._scoreField.text = finalScore;
_rows[i]._rankField.text = String((j + 1));
_rows[i].visible = true;
} else {
_rows[i].visible = false;
};
} else {
_rows[i].visible = false;
};
i++;
};
}
private function onParseError(e:TypeError):void{
}
private function onReadError(e:ErrorEvent):void{
trace(((("### LeaderBoard data error: " + e.type) + ": ") + e.text));
}
private function parseXML():void{
var i:int;
var hsr:MovieClip;
var entry:Object;
_entryList = new Array();
var scoreList:XMLList = _scoreData.entry;
for each (entry in scoreList) {
_entryList.push({Name:unescape(entry.@pname.toString()), Score:entry.@score.toString(), Country:entry.@miscellaneous1.toString()});
};
setScoresDisplay();
}
}
}//package com.xmascannon.ui
Section 214
//LevelSelect (com.xmascannon.ui.LevelSelect)
package com.xmascannon.ui {
import flash.events.*;
import com.xmascannon.*;
import flash.display.*;
import com.psiom.util.*;
import com.psiom.ui.uiComponents.*;
public class LevelSelect extends UIOBject {
private var _levelList:Array;
private var _pageIndex:Number;// = 0
private var _levelScores:Array;
private var _currentLevel:int;// = -1
private var _levelTypeDescriptions:Array;
private static var _instance:LevelSelect;
public function LevelSelect(inSpriteID:int=-1, inMovieClip:MovieClip=null){
_levelTypeDescriptions = ["BEGINNER MISSIONS", "INTERMEDIATE MISSIONS", "CHALLENGING MISSIONS", "HARD MISSIONS", "VETERAN MISSIONS"];
super(inSpriteID, inMovieClip);
_instance = this;
_levelScores = new Array();
_levelList = ["sp_pilot_training_i.xml", "sp_pilot_training_ii.xml", "sp_first_run.xml", "sp_rookie_tunnel_i.xml", "sp_stellar_novice.xml", "sp_rookie_tunnel_ii.xml", "sp_meteroidz.xml", "sp_medium_bang.xml", "sp_spacehopper.xml", "sp_clustercuss.xml", "sp_space_frontier.xml", "sp_descent.xml", "sp_clover.xml", "sp_crop_circles.xml", "sp_asteroid_grid.xml", "sp_laser_slalom.xml", "sp_the_shell.xml", "sp_solar_fossil.xml", "sp_dark_orbit.xml", "sp_hexapod.xml", "sp_hostage.xml", "sp_octoroid.xml", "sp_gridlocked.xml", "sp_cosmic_circuit.xml", "sp_badlands.xml", "sp_circular.xml", "sp_junkyard_X4-9.xml", "sp_gamma_complex.xml", "sp_stronghold.xml", "sp_doom_cactus.xml"];
sm.mc._left.addEventListener(MouseEvent.CLICK, onLeft);
sm.mc._right.addEventListener(MouseEvent.CLICK, onRight);
sm.mc._ls01.addEventListener(MouseEvent.CLICK, on01Click);
sm.mc._ls02.addEventListener(MouseEvent.CLICK, on02Click);
sm.mc._ls03.addEventListener(MouseEvent.CLICK, on03Click);
sm.mc._ls04.addEventListener(MouseEvent.CLICK, on04Click);
sm.mc._ls05.addEventListener(MouseEvent.CLICK, on05Click);
sm.mc._ls06.addEventListener(MouseEvent.CLICK, on06Click);
sm.mc._ls01._levelNum.mouseEnabled = false;
sm.mc._ls02._levelNum.mouseEnabled = false;
sm.mc._ls03._levelNum.mouseEnabled = false;
sm.mc._ls04._levelNum.mouseEnabled = false;
sm.mc._ls05._levelNum.mouseEnabled = false;
sm.mc._ls06._levelNum.mouseEnabled = false;
sm.mc._ls01._bg.gotoAndStop(1);
sm.mc._ls02._bg.gotoAndStop(1);
sm.mc._ls03._bg.gotoAndStop(1);
sm.mc._ls04._bg.gotoAndStop(1);
sm.mc._ls05._bg.gotoAndStop(1);
sm.mc._ls06._bg.gotoAndStop(1);
sm.mc._ls01._lock.gotoAndStop(1);
sm.mc._ls02._lock.gotoAndStop(1);
sm.mc._ls03._lock.gotoAndStop(1);
sm.mc._ls04._lock.gotoAndStop(1);
sm.mc._ls05._lock.gotoAndStop(1);
sm.mc._ls06._lock.gotoAndStop(1);
}
public function get LevelNum():int{
return (_currentLevel);
}
public function get BestScores():Array{
return (_levelScores);
}
public function set BestScores(inVal:Array):void{
_levelScores = inVal.slice();
}
private function on05Click(e:Event):void{
var lnum:int = ((_pageIndex * 6) + 4);
if (!sm.mc._ls05._lock.visible){
selectLevel(_levelList[lnum], lnum);
} else {
sm.mc._ls05._lock.gotoAndPlay(2);
};
}
public function get LevelName():String{
return (generateNameString(_levelList[LevelNum]));
}
public function generateNameString(inFilename:String):String{
var n:int;
if (inFilename == "test.xml"){
return ("TEST");
};
var nameString:String = inFilename;
nameString = nameString.substr(0, (nameString.length - 4));
nameString = nameString.substr(3, (nameString.length - 3));
nameString = nameString.toLocaleUpperCase();
var nameSplit:Array = nameString.split("_");
if (nameSplit.length > 1){
nameString = "";
n = 0;
while (n < nameSplit.length) {
if (n > 0){
nameString = (nameString + (" " + nameSplit[n]));
} else {
nameString = (nameString + nameSplit[n]);
};
n++;
};
};
return (nameString);
}
public function checkAndSetLevelBest(inLevelName:String, inLevelScore:int):void{
var comparativeScore:Number = Number(XmasCannon_Main.Instance.SharedObject.data[inLevelName]);
if (!isFinite(comparativeScore)){
comparativeScore = 0;
};
if (Number(inLevelScore) > Number(comparativeScore)){
XmasCannon_Main.Instance.SharedObject.data[inLevelName] = inLevelScore;
XmasCannon_Main.Instance.SharedObject.flush();
readBestScores();
};
}
private function on01Click(e:Event):void{
var lnum:int = ((_pageIndex * 6) + 0);
if (!sm.mc._ls01._lock.visible){
selectLevel(_levelList[lnum], lnum);
} else {
sm.mc._ls01._lock.gotoAndPlay(2);
};
}
public function readBestScores():void{
var lname:String;
var scoreVal:Number;
var levelScores:Array = new Array();
var i:int;
while (i < LevelSelect.Instance.LevelList.length) {
lname = LevelSelect.Instance.LevelList[i];
lname = lname.substr(0, (lname.length - 4));
scoreVal = Number(XmasCannon_Main.Instance.SharedObject.data[lname]);
if (!isFinite(scoreVal)){
scoreVal = 0;
};
levelScores.push(scoreVal);
i++;
};
LevelSelect.Instance.BestScores = levelScores;
}
private function on03Click(e:Event):void{
var lnum:int = ((_pageIndex * 6) + 2);
if (!sm.mc._ls03._lock.visible){
selectLevel(_levelList[lnum], lnum);
} else {
sm.mc._ls03._lock.gotoAndPlay(2);
};
}
public function get LevelList():Array{
return (_levelList);
}
private function on06Click(e:Event):void{
var lnum:int = ((_pageIndex * 6) + 5);
if (!sm.mc._ls06._lock.visible){
selectLevel(_levelList[lnum], lnum);
} else {
sm.mc._ls06._lock.gotoAndPlay(2);
};
}
public function setLevelNum(inVal:int):void{
trace("@@@ WARNING: natural level progression order has been altered");
_currentLevel = inVal;
}
private function on04Click(e:Event):void{
var lnum:int = ((_pageIndex * 6) + 3);
if (!sm.mc._ls04._lock.visible){
selectLevel(_levelList[lnum], lnum);
} else {
sm.mc._ls04._lock.gotoAndPlay(2);
};
}
private function on02Click(e:Event):void{
var lnum:int = ((_pageIndex * 6) + 1);
if (!sm.mc._ls02._lock.visible){
selectLevel(_levelList[lnum], lnum);
} else {
sm.mc._ls02._lock.gotoAndPlay(2);
};
}
private function selectLevel(fileName:String, levelNum:int):void{
_currentLevel = levelNum;
XmasCannon_Main.Instance.launchLevel();
}
public function advanceLevel():void{
_currentLevel++;
if (_currentLevel <= (_levelList.length - 1)){
selectLevel(_levelList[_currentLevel], _currentLevel);
} else {
trace("ALL LEVELS COMPLETE");
XmasCannon_Main.Instance.allLevelsComplete();
};
}
public function setSelectDisplay():void{
var ldis:String;
var lsBtn:MovieClip;
var maxPage:int = Math.floor(((_levelList.length - 1) / 6));
sm.mc._right.visible = true;
if (_pageIndex >= maxPage){
_pageIndex = maxPage;
sm.mc._right.visible = false;
};
if (_pageIndex <= 0){
_pageIndex = 0;
sm.mc._left.visible = false;
};
sm.mc._levelType.text = _levelTypeDescriptions[_pageIndex];
var unlockLevel:int = XmasCannon_Main.Instance.getUnlockLevel();
var lBtns:Array = [sm.mc._ls01, sm.mc._ls02, sm.mc._ls03, sm.mc._ls04, sm.mc._ls05, sm.mc._ls06];
var j:int;
while (j < lBtns.length) {
lsBtn = lBtns[j];
if (_levelList.length > ((_pageIndex * 6) + j)){
lsBtn.visible = true;
ldis = String(((_pageIndex * 6) + (j + 1)));
if (ldis.length < 2){
ldis = ("0" + ldis);
};
lsBtn._levelNum.text = ldis;
lsBtn._levelName.text = generateNameString(_levelList[((_pageIndex * 6) + j)]);
lsBtn._lock.visible = false;
lsBtn._bestScore.text = MathFunction.formatNumberStringWithCommas(_levelScores[((_pageIndex * 6) + j)]);
if (lsBtn._bestScore.text == "0"){
lsBtn._bg.gotoAndStop(2);
} else {
lsBtn._bg.gotoAndStop(1);
};
} else {
lsBtn.visible = false;
};
j++;
};
}
private function onRight(event:Event):void{
sm.mc._left.visible = true;
_pageIndex++;
setSelectDisplay();
}
private function onLeft(event:Event):void{
sm.mc._right.visible = true;
_pageIndex--;
setSelectDisplay();
}
public static function get Instance():LevelSelect{
return (_instance);
}
}
}//package com.xmascannon.ui
Section 215
//ScoreSubmit (com.xmascannon.ui.ScoreSubmit)
package com.xmascannon.ui {
import flash.events.*;
import flash.display.*;
import com.psiom.util.*;
import com.psiom.ui.uiComponents.*;
import com.xmascannon.engine.*;
import flash.net.*;
import com.soapcreative.net.tracking.*;
public class ScoreSubmit extends UIOBject {
private var _submitting:Boolean;// = false
private var _optToggle:UIButton;
private var PAR_SCORE:Number;// = 1000000
public function ScoreSubmit(inSpriteID:int=-1, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
_optToggle = UIMain.Instance.createNavButton(-1, sm.mc._optInBox, -1, toggleOptIn);
_optToggle.makeToggle();
toggleOptIn();
UIMain.Instance.createNavButton(-1, sm.mc._submitScore, -1, onSubmitScorePost);
UIMain.Instance.createNavButton(-1, sm.mc._tsandcs, -1, linkoutTermsAndConditions);
UIMain.Instance.createNavButton(-1, sm.mc._privacyPolicy, -1, linkoutPrivacyPolicy);
sm.mc._firstname.restrict = "0-9A-Za-z_\\-";
sm.mc._surname.restrict = "0-9A-Za-z_\\-";
sm.mc._username.restrict = "0-9A-Za-z_\\-";
sm.mc._emailaddress.restrict = "0-9A-Za-z@._\\-";
}
private function toggleOptIn(event:Event=null):void{
_optToggle.toggleState();
if (_optToggle.CurrentState == 0){
sm.mc._firstname.visible = true;
sm.mc._surname.visible = true;
sm.mc._optNameBases.visible = true;
} else {
sm.mc._firstname.visible = false;
sm.mc._surname.visible = false;
sm.mc._optNameBases.visible = false;
};
}
private function linkoutPrivacyPolicy(event:Event):void{
trace(("UIMain.Instance.RegionMode: " + UIMain.Instance.RegionMode));
if (UIMain.Instance.RegionMode == UIMain.RMODE_AUS){
navigateToURL(new URLRequest("http://seek.com.au/general_id_items/content/privacy.ascx"), "_blank");
} else {
navigateToURL(new URLRequest("http://seek.co.nz/general_id_items/content/privacy.ascx"), "_blank");
};
}
public function resetSubmitForm(event:Event=null):void{
_submitting = false;
sm.mc._progress.visible = false;
}
private function onSubmitScorePost(event:Event):void{
var usernameString:String;
var emailString:String;
var firstNameString:String;
var lastNameString:String;
var pReg:RegExp;
var aReg:RegExp;
var formState:URLVariables;
var req:URLRequest;
var loader:URLLoader;
var validEntryCheck:Boolean;
if (!SwearWordTester.testWordForErrors(sm.mc._username.text)){
validEntryCheck = false;
sm.mc._usernameX.visible = true;
} else {
sm.mc._usernameX.visible = false;
};
var validAddress:Boolean;
var foundAtSymb:Boolean;
var foundDotSymb:Boolean;
var atSymbIndex = -1;
var dotSymbIndex = -1;
var t:int;
while (t < sm.mc._emailaddress.text.length) {
if ((((sm.mc._emailaddress.text.substr(t, 1) == "@")) && ((t > 0)))){
foundAtSymb = true;
atSymbIndex = t;
};
if (sm.mc._emailaddress.text.substr(t, 1) == "."){
foundDotSymb = true;
dotSymbIndex = t;
};
t++;
};
if (((foundAtSymb) && (foundDotSymb))){
if (dotSymbIndex > atSymbIndex){
validAddress = true;
trace("EMAIL ADDRESS IS VALID");
};
};
if ((((sm.mc._emailaddress.text.length < 3)) || (!(validAddress)))){
validEntryCheck = false;
sm.mc._emailaddressX.visible = true;
} else {
sm.mc._emailaddressX.visible = false;
};
if (((validEntryCheck) && (!(_submitting)))){
_submitting = true;
sm.mc._progress.visible = true;
usernameString = sm.mc._username.text;
emailString = sm.mc._emailaddress.text;
firstNameString = sm.mc._firstname.text;
lastNameString = sm.mc._surname.text;
pReg = /%+/g;
aReg = /'+/g;
trace(("usernameString: " + usernameString));
trace(("usernameString: " + usernameString));
formState = new URLVariables();
formState["intGameId"] = 46;
formState["intScore"] = EngineMain.Instance.FinalScore;
formState["strName"] = escape(usernameString);
formState["strEmail"] = emailString;
formState["intOptIn"] = (1 - _optToggle.CurrentState);
if (UIMain.Instance.RegionMode == UIMain.RMODE_AUS){
formState["strMisc1"] = "AU";
};
if (UIMain.Instance.RegionMode == UIMain.RMODE_NZ){
formState["strMisc1"] = "NZ";
};
formState["strMisc2"] = escape(firstNameString);
formState["strMisc3"] = escape(lastNameString);
req = new URLRequest("http://stats.soap.com.au/highscore/engine_mofo.php");
req.method = URLRequestMethod.POST;
req.data = formState;
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onSubmitScoreDone);
loader.addEventListener(IOErrorEvent.IO_ERROR, onSubmitScoreDone);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSubmitScoreDone);
loader.load(req);
GameTracking.trackSubmitScore(EngineMain.Instance.FinalScore);
} else {
sm.mc._progress.visible = false;
};
}
private function linkoutTermsAndConditions(event:Event):void{
trace(("UIMain.Instance.RegionMode: " + UIMain.Instance.RegionMode));
if (UIMain.Instance.RegionMode == UIMain.RMODE_AUS){
navigateToURL(new URLRequest("http://seek.com.au/general_id_items/content/terms.ascx"), "_blank");
} else {
navigateToURL(new URLRequest("http://seek.co.nz/general_id_items/content/terms.ascx"), "_blank");
};
}
private function onSubmitScoreDone(event:Event):void{
resetSubmitForm();
UIMain.Instance.viewLeaderBoard();
}
}
}//package com.xmascannon.ui
Section 216
//SendToFriend (com.xmascannon.ui.SendToFriend)
package com.xmascannon.ui {
import flash.events.*;
import com.xmascannon.*;
import flash.display.*;
import com.psiom.util.*;
import com.psiom.ui.uiComponents.*;
import com.xmascannon.engine.*;
import flash.text.*;
import flash.net.*;
import flash.utils.*;
import com.soapcreative.net.tracking.*;
import com.adobe.images.*;
public class SendToFriend extends UIOBject {
private var _submitting:Boolean;// = false
private var _msgFieldFirstClick:Boolean;// = false
private var _defaultString:String;// = ""
private var _defaultMSG:Boolean;// = true
public function SendToFriend(inSpriteID:int=-1, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
UIMain.Instance.createNavButton(-1, sm.mc.sendEmail, -1, onSendToFriendPost);
sm.mc.firstName.restrict = "0-9A-Za-z_\\-";
sm.mc.emailAddress.restrict = "0-9A-Za-z@._\\-";
sm.mc.friendName.restrict = "0-9A-Za-z_\\-";
sm.mc.friendEmail.restrict = "0-9A-Za-z@._\\-";
sm.mc.messageField.restrict = "0-9A-Za-z_\\-. ,!?()'\"";
sm.mc.firstName.tabIndex = 0;
sm.mc.emailAddress.tabIndex = 1;
sm.mc.friendName.tabIndex = 2;
sm.mc.friendEmail.tabIndex = 3;
sm.mc.messageField.tabIndex = 4;
_defaultString = sm.mc.messageField.text;
resetForm();
}
public function resetForm(event:Event=null):void{
_submitting = false;
sm.mc._progress.visible = false;
sm.mc.firstName.text = "";
sm.mc.emailAddress.text = "";
sm.mc.friendName.text = "";
sm.mc.friendEmail.text = "";
sm.mc.messageField.text = _defaultString;
trace(("resetting -- _defaultString: " + _defaultString));
sm.mc.firstNameX.visible = false;
sm.mc.emailAddressX.visible = false;
sm.mc.friendNameX.visible = false;
sm.mc.friendEmailX.visible = false;
sm.mc.messageFieldX.visible = false;
_defaultMSG = true;
}
private function validateField(field:TextField):Boolean{
if (!SwearWordTester.testWordForErrors(field.text)){
return (false);
};
if (field.text.length == 0){
return (false);
};
return (true);
}
private function onSendToFriendPost(event:Event):void{
var firstNameString:String;
var emailString:String;
var friendNameString:String;
var friendEmailString:String;
var messageString:String;
var pReg:RegExp;
var aReg:RegExp;
var postVars:URLVariables;
var appendData:String;
var header:URLRequestHeader;
var req:URLRequest;
var loader:URLLoader;
var bArray:ByteArray;
var validEntryCheck:Boolean;
if (!validateField(sm.mc.firstName)){
validEntryCheck = false;
sm.mc.firstNameX.visible = true;
} else {
sm.mc.firstNameX.visible = false;
};
if (!validateEmailAddress(sm.mc.emailAddress)){
validEntryCheck = false;
sm.mc.emailAddressX.visible = true;
} else {
sm.mc.emailAddressX.visible = false;
};
if (!validateField(sm.mc.friendName)){
validEntryCheck = false;
sm.mc.friendNameX.visible = true;
} else {
sm.mc.friendNameX.visible = false;
};
if (!validateEmailAddress(sm.mc.friendEmail)){
validEntryCheck = false;
sm.mc.friendEmailX.visible = true;
} else {
sm.mc.friendEmailX.visible = false;
};
if (!validateField(sm.mc.messageField)){
validEntryCheck = false;
sm.mc.messageFieldX.visible = true;
} else {
sm.mc.messageFieldX.visible = false;
};
if (((validEntryCheck) && (!(_submitting)))){
_submitting = true;
sm.mc._progress.visible = true;
firstNameString = sm.mc.firstName.text;
emailString = sm.mc.emailAddress.text;
friendNameString = sm.mc.friendName.text;
friendEmailString = sm.mc.friendEmail.text;
messageString = sm.mc.messageField.text;
pReg = /%+/g;
aReg = /'+/g;
trace(("firstNameString: " + firstNameString));
trace(("firstNameString: " + firstNameString));
postVars = new URLVariables();
if (EngineMain.Instance.BaseUploadedImageBMD){
trace(("fouhnd uploaded BMD - EngineMain.Instance.BaseUploadedImageBMD.width: " + EngineMain.Instance.BaseUploadedImageBMD.width));
bArray = PNGEncoder.encode(EngineMain.Instance.BaseUploadedImageBMD);
trace(("bArray.length: " + bArray.length));
postVars.byteArray = bArray;
} else {
trace("use default");
postVars.byteArray = null;
};
appendData = "";
appendData = (appendData + ("?toemail=" + friendEmailString));
appendData = (appendData + ("&fromemail=" + emailString));
appendData = (appendData + ("&fromname=" + firstNameString));
appendData = (appendData + ("&toname=" + friendNameString));
appendData = (appendData + ("©=" + messageString));
if (_defaultMSG){
appendData = (appendData + "<br><br>Immediate start.");
};
appendData = (appendData + ("&country=" + UIMain.Instance.RegionModeString));
trace(("making request - appendData: " + appendData));
header = new URLRequestHeader("Content-type", "application/octet-stream");
req = new URLRequest(("http://games.seek.com.au/chimneyseeker/php/process.php" + appendData));
req.requestHeaders.push(header);
req.method = URLRequestMethod.POST;
req.data = bArray;
req.contentType = "application/x-www-form-urlencoded";
trace("setting loader");
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, onSendToFriendDone);
loader.addEventListener(IOErrorEvent.IO_ERROR, onSendToFriendError);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSendToFriendError);
trace("calling load");
loader.load(req);
GameTracking.trackPage("STF - Email Sent");
} else {
sm.mc._progress.visible = false;
};
}
private function onSendToFriendError(event:ErrorEvent):void{
trace(("LOAD ERROR -- error: " + event.text));
}
private function onSendToFriendDone(event:Event):void{
trace("LOAD DONE");
resetForm();
UIMain.Instance.restoreMainMenu();
}
private function validateEmailAddress(field:TextField):Boolean{
var foundAtSymb:Boolean;
var foundDotSymb:Boolean;
var atSymbIndex = -1;
var dotSymbIndex = -1;
var t:int;
while (t < field.text.length) {
if ((((field.text.substr(t, 1) == "@")) && ((t > 0)))){
foundAtSymb = true;
atSymbIndex = t;
};
if (field.text.substr(t, 1) == "."){
foundDotSymb = true;
dotSymbIndex = t;
};
t++;
};
if (((foundAtSymb) && (foundDotSymb))){
if (dotSymbIndex <= atSymbIndex){
return (false);
};
} else {
return (false);
};
if (field.text.length < 3){
return (false);
};
return (true);
}
override public function update():void{
if (!_msgFieldFirstClick){
if (XmasCannon_Main.Instance.stage.focus == sm.mc.messageField){
_defaultMSG = false;
sm.mc.messageField.text = "";
_msgFieldFirstClick = true;
};
};
super.update();
}
}
}//package com.xmascannon.ui
Section 217
//UIMain (com.xmascannon.ui.UIMain)
package com.xmascannon.ui {
import flash.events.*;
import com.psiom.foundation.*;
import com.xmascannon.*;
import flash.display.*;
import com.psiom.util.*;
import com.psiom.rendering.*;
import com.psiom.sound.*;
import com.psiom.ui.uiComponents.*;
import com.xmascannon.engine.*;
import seek.face.ui.modifier.*;
import flash.net.*;
import com.psiom.*;
import com.soapcreative.net.tracking.*;
import seek.face.ui.uploader.*;
public class UIMain extends CoreSystem {
private var _headMode:int;// = 0
private var _uiNavBar:UIOBject;
private var _uiJobOp:UIOBject;
private var _uiSelectFace:UIOBject;
private var _uiFlags:UIOBject;
private var _uiSoundBtn:UIButton;
private var _uiGameSummary:UIOBject;
private var _alteredFromSuppliedFace:Boolean;// = false
private var _dossierDelayLength:Number;// = 150
private var _uiSubmitScore:ScoreSubmit;
private var _uiBgGradient:UIOBject;
private var _uiFaceModifyer:FaceModifier;
private var _formCTAAdditional1:UIOBject;
private var _formCTAAdditional2:UIOBject;
private var _uiLeaderboard:LeaderBoard;
private var _regionMode:int;// = 0
private var _dossierDelayTicks:Number;// = 0
private var _introCTA:UIOBject;
private var _uiLevelSelect:LevelSelect;
private var _uiSendToFriend:UIOBject;
private var _uiSeekLogoCorner:UIButton;
private var _customSelectFaceBitmapHeadB:Bitmap;
private var _customIntroBitmapHead:Bitmap;
private var _mainNavStarted:Boolean;// = false
private var _customSelectFaceBitmapHeadR:Bitmap;
private var _uiBase:UIOBject;
private var _introLeadInTicks:Number;// = 0
private var _trackingRegion:String;// = "other"
private var _introLength:Number;// = 75
private var _uiLeadIn:UIOBject;
private var _uiFaceUploader:FaceUploader;
private var _uiIntroScreen:UIOBject;
private var _customHeadCTA1:Bitmap;
private var _customHeadCTA2:Bitmap;
private var _stfCTA:Boolean;// = false
private var _uiHowToPlay1:UIOBject;
private var _uiCredits:UIOBject;
private var _seekTrackingGameName:String;// = "game"
private static var _instance:UIMain;
public static var UI_VSET_LeadIn:int;
public static var UI_VSET_HighScores:int;
public static var UI_VSET_NULL:int = -1;
public static var UI_VSET_SendToFriend:int;
public static var UI_VSET_Game:int;
public static var UI_VSET_Flags:int;
public static var UI_VSET_SelectFace:int;
public static var UI_VSET_Dossier:int;
public static var UI_VSET_GameSummary:int;
public static var UI_VSET_UploadFace:int;
public static var UI_VSET_ModifyFace:int;
public static var UI_VSET_Credits:int;
public static var UI_VSET_MainBlank:int;
public static var UI_VSET_SubmitScore:int;
public static var UI_VSET_HowToPlay1:int;
public static var UI_VSET_HowToPlay2:int;
public static var UI_VSET_HowToPlay3:int;
public static var UI_VSET_LevelSelect:int;
public function UIMain(){
_instance = this;
_seekTrackingGameName = Constants.TRACKING_GAME_NAME;
super();
_currentSpace = new ObjectSpace(this);
_currentCamera = new RenderCam(Constants.STAGEWIDTH, Constants.STAGEHEIGHT);
}
public function enableSTFCTA(e:Event):void{
_stfCTA = true;
}
public function customFaceDone(e:Event=null):void{
if (_stfCTA){
applyVisibiltySet(UIMain.UI_VSET_SendToFriend);
} else {
_headMode = 3;
XmasCannon_Main.Instance.onMainStart();
GameTracking.trackMiscellaneous("use custom face");
};
setCustomFaceInterals();
}
private function setFlagsScreen():void{
var bypassFlags:Boolean;
var paramObj:Object = LoaderInfo(_movieClipLayer.root.loaderInfo).parameters;
if (XmasCannon_Main.Instance.PortalMode){
paramObj = {country:"au"};
};
if (paramObj.country){
if (paramObj.country == "au"){
_trackingRegion = "au";
bypassFlags = true;
setRegionAus(new Event(""));
applyVisibiltySet(UI_VSET_MainBlank);
};
if (paramObj.country == "nz"){
_trackingRegion = "nz";
bypassFlags = true;
setRegionNZ(new Event(""));
applyVisibiltySet(UI_VSET_MainBlank);
};
};
if (!bypassFlags){
applyVisibiltySet(UI_VSET_Flags);
};
}
public function toggleSound(event:Event):void{
_uiSoundBtn.toggleState();
SoundManager.Instance.setVolume(Number((1 - _uiSoundBtn.CurrentState)));
setSoundPref();
}
private function linkoutSeekMoreGames(event:Event):void{
trace("@@@@@@@ IMPLEMENT @@@@@@@ linkout SeekMoreGames");
GameTracking.trackLink("more games");
if (RegionMode == RMODE_AUS){
navigateToURL(new URLRequest((((("http://games.seek.com.au/index.php?cid=sk:" + _trackingRegion) + ":games:") + _seekTrackingGameName) + ":more")), "_blank");
} else {
navigateToURL(new URLRequest((((("http://games.seek.co.nz/index.php?cid=sk:" + _trackingRegion) + ":games:") + _seekTrackingGameName) + ":more")), "_blank");
};
}
private function startNewGameHead1(e:Event=null):void{
_headMode = 0;
XmasCannon_Main.Instance.onMainStart();
GameTracking.trackMiscellaneous("use default face 1");
}
private function startNewGameHead3(e:Event=null):void{
_headMode = 2;
XmasCannon_Main.Instance.onMainStart();
GameTracking.trackMiscellaneous("use default face 3");
}
private function csEmbed(event:Event):void{
GigyaWrapper.Instance.loadWildfire(new Event(""));
GameTracking.trackPage("gigya share");
}
private function startNewGameHead2(e:Event=null):void{
_headMode = 1;
XmasCannon_Main.Instance.onMainStart();
GameTracking.trackMiscellaneous("use default face 2");
}
public function setMainMenu():void{
_introLeadInTicks = (_introLength + 1);
_mainNavStarted = true;
}
public function setRegionNZ(event:Event):void{
GameTracking.trackMiscellaneous("region NZ");
_regionMode = RMODE_NZ;
_uiIntroScreen.sm.mc.gotoAndPlay(1);
SoundManager.Instance.setMusicLoop();
initGigya();
setMainMenu();
}
private function initGigya():void{
var gameURL:String;
if (_regionMode == RMODE_AUS){
gameURL = (("http://games.seek.com.au/chimneyseeker/?cid=sk:au:games:" + _seekTrackingGameName) + ":emailfriend");
} else {
gameURL = (("http://games.seek.co.nz/chimneyseeker/?cid=sk:nz:games:" + _seekTrackingGameName) + ":emailfriend");
};
var emailSubj:String = "Your friend $sender$ thinks you should Play the Elf Chimney Seeker game";
var emailBody = (((("Hi there,\n\n<br>" + "You’ll be excited to know that I’ve just completed an employment trial as an Elf Chimney Seeker. I know what you’re thinking – you want to steal the job from me don’t you? Well, give it a go! I bet you can’t beat my score…\n\n<br>") + "<a href = '") + gameURL) + "'>Play Elf Chimney Seeker</a>");
var gigyaDisplayWidth:Number = 300;
var gigyaDisplayHeight:Number = 300;
GigyaWrapper.Instance.initParams(MovieClipLayer, ((700 / 2) - (gigyaDisplayWidth / 2)), (((450 / 2) - (gigyaDisplayHeight / 2)) - 40), gigyaDisplayWidth, gigyaDisplayHeight, 700, 450, "Elf Chimney Seeker", "http://games.seek.com.au/chimneyseeker/Seek_Xmas_Cannon.swf", (gameURL + "images/thumb.jpg"), emailSubj, emailBody);
}
private function linkoutVisitSeek2(event:Event):void{
GameTracking.trackLink("Seek site");
if (RegionMode == RMODE_AUS){
navigateToURL(new URLRequest((((("http://www.seek.com.au?cid=sk:" + _trackingRegion) + ":games:") + _seekTrackingGameName) + ":link")), "_blank");
} else {
navigateToURL(new URLRequest((((("http://www.seek.co.nz?cid=sk:" + _trackingRegion) + ":games:") + _seekTrackingGameName) + ":link")), "_blank");
};
}
public function restoreMainMenu():void{
applyVisibiltySet(UI_VSET_MainBlank);
}
public function viewLeaderBoard():void{
_uiLeaderboard.loadScores();
applyVisibiltySet(UIMain.UI_VSET_HighScores);
}
public function setSoundPref():void{
XmasCannon_Main.Instance.SharedObject.data.SoundPref = _uiSoundBtn.CurrentState;
XmasCannon_Main.Instance.SharedObject.flush();
}
public function setGameSummary(inScore:Number, inCopyFrame:int):void{
_uiGameSummary.sm.mc._summaryCopy.gotoAndStop(inCopyFrame);
_uiGameSummary.sm.mc._score.text = String(MathFunction.formatNumberStringWithCommas(inScore));
_uiSubmitScore.sm.mc._score.text = String(MathFunction.formatNumberStringWithCommas(inScore));
_uiSubmitScore.sm.mc._username.text = "";
_uiSubmitScore.sm.mc._emailaddress.text = "";
_uiSubmitScore.sm.mc._firstname.text = "";
_uiSubmitScore.sm.mc._surname.text = "";
_uiSubmitScore.sm.mc._usernameX.visible = false;
_uiSubmitScore.sm.mc._emailaddressX.visible = false;
_uiSubmitScore.sm.mc._progress.visible = false;
applyVisibiltySet(UIMain.UI_VSET_GameSummary);
}
public function endDossierCountdown():void{
_dossierDelayTicks = (_dossierDelayLength + 200);
}
private function loadScores(event:Event):void{
GameTracking.trackPage("leaderboard");
_uiLeaderboard.loadScores();
}
private function linkoutVisitSeek(event:Event):void{
GameTracking.trackLink("Seek site");
if (RegionMode == RMODE_AUS){
navigateToURL(new URLRequest((((("http://www.seek.com.au?cid=sk:" + _trackingRegion) + ":games:") + _seekTrackingGameName) + ":link")), "_blank");
} else {
navigateToURL(new URLRequest((((("http://www.seek.co.nz?cid=sk:" + _trackingRegion) + ":games:") + _seekTrackingGameName) + ":link")), "_blank");
};
}
private function trackHowToPlay(event:Event):void{
GameTracking.trackPage("how to play");
}
public function disableSTFCTA(e:Event):void{
_stfCTA = false;
}
public function setSuppliedFace():void{
if (!_alteredFromSuppliedFace){
_alteredFromSuppliedFace = true;
updateInternalFaceBits(XmasCannon_Main.Instance.SuppliedFace);
};
}
public function linkoutSoap(event:Event):void{
GameTracking.trackLink("Soap site");
navigateToURL(new URLRequest("http://www.soapcreative.com"), "_blank");
}
public function get HeadMode():int{
return (_headMode);
}
public function get RegionModeString():String{
if (_regionMode == RMODE_AUS){
return ("au");
};
return ("nz");
}
private function updateInternalFaceBits(inBMD:BitmapData):void{
if (inBMD){
if (_customIntroBitmapHead){
_uiIntroScreen.sm.mc.dummy.head.removeChild(_customIntroBitmapHead);
_uiSelectFace.sm.mc._defaultFaceOne.base.removeChild(_customSelectFaceBitmapHeadB);
_uiSelectFace.sm.mc._defaultFaceOne.roll.removeChild(_customSelectFaceBitmapHeadR);
_customHeadCTA1.visible = false;
_customHeadCTA2.visible = false;
};
_uiSelectFace.sm.mc._defaultFaceOne.base.inner.visible = false;
_uiSelectFace.sm.mc._defaultFaceOne.roll.inner.visible = false;
_customSelectFaceBitmapHeadB = new Bitmap(inBMD);
_customSelectFaceBitmapHeadR = new Bitmap(inBMD);
_customSelectFaceBitmapHeadB = _uiSelectFace.sm.mc._defaultFaceOne.base.addChild(_customSelectFaceBitmapHeadB);
_customSelectFaceBitmapHeadR = _uiSelectFace.sm.mc._defaultFaceOne.roll.addChild(_customSelectFaceBitmapHeadR);
trace(("_formCTAAdditional1.sm.mc: " + _formCTAAdditional1.sm.mc));
trace(("_formCTAAdditional1.sm.mc.cta: " + _formCTAAdditional1.sm.mc.cta));
trace(("_formCTAAdditional1.sm.mc.cta.head: " + _formCTAAdditional1.sm.mc.cta.head));
_formCTAAdditional1.sm.mc.cta.head.defaultHead.visible = false;
_customHeadCTA1 = new Bitmap(inBMD);
_formCTAAdditional1.sm.mc.cta.head.addChildAt(_customHeadCTA1, 0);
_customHeadCTA1.scaleX = 0.6;
_customHeadCTA1.scaleY = 0.6;
_customHeadCTA1.x = -30;
_customHeadCTA1.y = -30;
_formCTAAdditional2.sm.mc.cta.head.defaultHead.visible = false;
_customHeadCTA2 = new Bitmap(inBMD);
_formCTAAdditional2.sm.mc.cta.head.addChildAt(_customHeadCTA2, 0);
_customHeadCTA2.scaleX = 0.6;
_customHeadCTA2.scaleY = 0.6;
_customHeadCTA2.x = -30;
_customHeadCTA2.y = -30;
_uiIntroScreen.sm.mc.dummy.head.defaultHead.visible = false;
_uiIntroScreen.sm.mc.dummy.head.hat.alpha = 1;
_customIntroBitmapHead = new Bitmap(inBMD);
_uiIntroScreen.sm.mc.dummy.head.addChildAt(_customIntroBitmapHead, 0);
_customIntroBitmapHead.scaleX = 0.75;
_customIntroBitmapHead.scaleY = 0.75;
_customIntroBitmapHead.x = -30;
_customIntroBitmapHead.y = -30;
};
}
private function trackCredits(event:Event):void{
GameTracking.trackPage("credits");
}
override public function update():void{
super.update();
if (_introLeadInTicks < (_introLength + 1)){
_introLeadInTicks++;
};
if (_introLeadInTicks < _introLength){
applyVisibiltySet(UIMain.UI_VSET_LeadIn);
};
if (_introLeadInTicks == _introLength){
setFlagsScreen();
};
if (_mainNavStarted){
if (_dossierDelayTicks < (_dossierDelayLength + 186)){
_dossierDelayTicks++;
};
if (_dossierDelayTicks == (_dossierDelayLength + 20)){
trace("SHOW DOSSIER");
if (_currentVGroup == UI_VSET_MainBlank){
applyVisibiltySet(UIMain.UI_VSET_Dossier);
};
};
if (_dossierDelayTicks == (_dossierDelayLength + 185)){
trace("HIDE DOSSIER");
if (_currentVGroup == UI_VSET_Dossier){
applyVisibiltySet(UIMain.UI_VSET_MainBlank);
};
};
};
}
private function trackSTFClick(e:Event):void{
GameTracking.trackPage("STF - Form View");
}
public function get RegionMode():int{
return (_regionMode);
}
public function readSoundPref():int{
if (!XmasCannon_Main.Instance.SharedObject.data.SoundPref){
XmasCannon_Main.Instance.SharedObject.data.SoundPref = _uiSoundBtn.CurrentState;
XmasCannon_Main.Instance.SharedObject.flush();
};
return (XmasCannon_Main.Instance.SharedObject.data.SoundPref);
}
public function setCustomFaceInterals():void{
XmasCannon_Main.Instance.SuppliedFace = EngineMain.Instance.BaseUploadedImageBMD;
updateInternalFaceBits(EngineMain.Instance.BaseUploadedImageBMD);
}
public function initObjects():void{
_uiBgGradient = new UIOBject(-1, new uimain_bggradient());
_uiFlags = new UIOBject(-1, new uimain_flags());
_uiFlags.centerX();
_uiFlags.centerY();
_uiFlags.FadeSpeed = 0.25;
_uiFlags.FadeUpDelay = 20;
_uiLeadIn = new UIOBject(-1, new uimain_leadin());
_uiLeadIn.centerX();
_uiLeadIn.centerY();
_uiLeadIn.FadeSpeed = 0.25;
_uiLeadIn.FadeUpDelay = 15;
_uiIntroScreen = new UIOBject(-1, new uimain_introscreen());
_uiIntroScreen.sm.manualMC = false;
_uiBase = new UIOBject(-1, new uimain_base());
_uiBase.centerX();
_uiBase.centerY();
_uiBase.y = (_uiBase.y - 20);
_uiJobOp = new UIOBject(-1, new uimain_jobOp());
_uiJobOp.centerX(_uiBase);
_uiJobOp.centerY(_uiBase);
_uiJobOp.x = (_uiJobOp.x - 2);
_uiJobOp.y = (_uiJobOp.y - 4);
_uiSoundBtn = createNavButton(-1, new uimain_soundBtn(), UI_VSET_NULL, toggleSound);
_uiSoundBtn.x = 661;
_uiSoundBtn.y = 9;
_uiSoundBtn.makeToggle();
_uiSoundBtn.quickHide();
_uiSoundBtn.FadeUpDelay = 21;
if (XmasCannon_Main.Instance.PortalMode){
_uiNavBar = new UIOBject(-1, new uimain_navBar_portal());
} else {
_uiNavBar = new UIOBject(-1, new uimain_navBar());
};
_uiNavBar.centerX();
_uiNavBar.y = 366;
_uiSeekLogoCorner = createNavButton(-1, new uimain_seeklogocorner(), UI_VSET_NULL, linkoutVisitSeekLogo);
_uiSeekLogoCorner.x = 5;
_uiSeekLogoCorner.y = 5;
_uiSeekLogoCorner.FadeUpDelay = 2;
if (XmasCannon_Main.Instance.PortalMode){
_uiSeekLogoCorner.disable();
};
_uiSeekLogoCorner.quickHide();
_uiSeekLogoCorner.sm.mc.cacheAsBitmap = true;
_uiSubmitScore = new ScoreSubmit(-1, new uimain_submitscore());
_uiSubmitScore.centerX(_uiBase);
_uiSubmitScore.positionInsetFromObjY(_uiBase, 12);
_uiSubmitScore.FadeUpDelay = 2;
_uiSubmitScore.x = (_uiSubmitScore.x - 5);
_uiSubmitScore.y = (_uiSubmitScore.y + 20);
_uiSendToFriend = new SendToFriend(-1, new uimain_sendToFriend());
_uiSendToFriend.centerX(_uiBase);
_uiSendToFriend.positionInsetFromObjY(_uiBase, 12);
_uiSendToFriend.FadeUpDelay = 2;
_uiSendToFriend.x = (_uiSendToFriend.x - 5);
_uiSendToFriend.y = (_uiSendToFriend.y + 20);
_uiLevelSelect = new LevelSelect(-1, new uimain_levelSelect());
_uiLevelSelect.centerX(_uiBase);
_uiLevelSelect.positionInsetFromObjY(_uiBase, 12);
_uiLevelSelect.FadeUpDelay = 6;
_uiLevelSelect.readBestScores();
_uiGameSummary = new UIOBject(-1, new uimain_gamesummary());
_uiGameSummary.centerX(_uiBase);
_uiGameSummary.positionInsetFromObjY(_uiBase, 12);
_uiGameSummary.FadeUpDelay = 6;
_uiGameSummary.x = (_uiGameSummary.x - 5);
_uiGameSummary.y = (_uiGameSummary.y + 20);
_uiHowToPlay1 = new UIOBject(-1, new uimain_howtoplay1());
_uiHowToPlay1.centerX(_uiBase);
_uiHowToPlay1.positionInsetFromObjY(_uiBase, 12);
_uiHowToPlay1.FadeUpDelay = 6;
_uiHowToPlay1.x = (_uiHowToPlay1.x - 5);
_uiHowToPlay1.y = (_uiHowToPlay1.y + 20);
_uiLeaderboard = new LeaderBoard(-1, new uimain_leaderboard());
_uiLeaderboard.centerX(_uiBase);
_uiLeaderboard.positionInsetFromObjY(_uiBase, 12);
_uiLeaderboard.FadeUpDelay = 6;
_uiLeaderboard.x = (_uiLeaderboard.x - 5);
_uiLeaderboard.y = (_uiLeaderboard.y + 20);
_uiCredits = new UIOBject(-1, new uimain_credits());
_uiCredits.centerX(_uiBase);
_uiCredits.positionInsetFromObjY(_uiBase, 12);
_uiCredits.FadeUpDelay = 6;
_uiCredits.x = (_uiCredits.x - 5);
_uiCredits.y = (_uiCredits.y + 20);
_uiSelectFace = new UIOBject(-1, new uimain_selectface());
_uiSelectFace.centerX(_uiBase);
_uiSelectFace.positionInsetFromObjY(_uiBase, 12);
_uiSelectFace.FadeUpDelay = 6;
_uiSelectFace.x = (_uiSelectFace.x - 5);
_uiSelectFace.y = (_uiSelectFace.y + 20);
_uiFaceUploader = new FaceUploader(-1, new uimain_customface1());
_uiFaceUploader.centerX(_uiBase);
_uiFaceUploader.positionInsetFromObjY(_uiBase, 12);
_uiFaceUploader.FadeUpDelay = 6;
_uiFaceUploader.initializeUploader();
_uiFaceUploader.x = (_uiFaceUploader.x - 5);
_uiFaceUploader.y = (_uiFaceUploader.y + 20);
_uiFaceModifyer = new FaceModifier(-1, new uimain_customface2());
_uiFaceModifyer.centerX(_uiBase);
_uiFaceModifyer.positionInsetFromObjY(_uiBase, 12);
_uiFaceModifyer.FadeUpDelay = 6;
_uiFaceModifyer.x = (_uiFaceModifyer.x - 5);
_uiFaceModifyer.y = (_uiFaceModifyer.y + 20);
_introCTA = new UIOBject(-1, new ctaClickClip());
_introCTA.x = 420;
_introCTA.y = 10;
_formCTAAdditional1 = new UIOBject(-1, new gClip_additionalUICTA());
_formCTAAdditional1.x = 500;
_formCTAAdditional1.y = 237;
_formCTAAdditional2 = new UIOBject(-1, new gClip_additionalUICTA2());
_formCTAAdditional2.x = 60;
_formCTAAdditional2.y = 237;
if (XmasCannon_Main.Instance.SharedObject.data.shownControlHint){
};
UI_VSET_LeadIn = addVisibilityGroup([_uiBgGradient, _uiLeadIn]);
UI_VSET_Flags = addVisibilityGroup([_uiBgGradient, _uiFlags, _uiSoundBtn]);
UI_VSET_Dossier = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiJobOp, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn]);
trace(("UI_VSET_Dossier: " + UI_VSET_Dossier));
UI_VSET_HowToPlay1 = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiHowToPlay1]);
UI_VSET_LevelSelect = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiLevelSelect]);
UI_VSET_GameSummary = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiGameSummary, _formCTAAdditional1]);
UI_VSET_SubmitScore = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiSubmitScore]);
UI_VSET_SendToFriend = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiSendToFriend, _formCTAAdditional2]);
UI_VSET_HighScores = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiLeaderboard]);
UI_VSET_Credits = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiCredits]);
UI_VSET_Game = addVisibilityGroup([_uiSeekLogoCorner, _uiSoundBtn]);
UI_VSET_MainBlank = addVisibilityGroup([_uiIntroScreen, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _introCTA]);
UI_VSET_SelectFace = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiSelectFace]);
UI_VSET_UploadFace = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiFaceUploader]);
UI_VSET_ModifyFace = addVisibilityGroup([_uiIntroScreen, _uiBase, _uiNavBar, _uiSeekLogoCorner, _uiSoundBtn, _uiFaceModifyer]);
addVisibilityGroupObject(_uiBgGradient);
addVisibilityGroupObject(_uiFlags);
addVisibilityGroupObject(_uiIntroScreen);
addVisibilityGroupObject(_uiBase);
addVisibilityGroupObject(_uiCredits);
addVisibilityGroupObject(_uiJobOp);
addVisibilityGroupObject(_uiGameSummary);
addVisibilityGroupObject(_uiHowToPlay1);
addVisibilityGroupObject(_uiLeaderboard);
addVisibilityGroupObject(_uiLeadIn);
addVisibilityGroupObject(_uiNavBar);
addVisibilityGroupObject(_uiSeekLogoCorner);
addVisibilityGroupObject(_uiLevelSelect);
addVisibilityGroupObject(_uiSubmitScore);
addVisibilityGroupObject(_uiSoundBtn);
addVisibilityGroupObject(_uiSelectFace);
addVisibilityGroupObject(_uiFaceUploader);
addVisibilityGroupObject(_uiFaceModifyer);
addVisibilityGroupObject(_uiSendToFriend);
addVisibilityGroupObject(_introCTA);
addVisibilityGroupObject(_formCTAAdditional1);
addVisibilityGroupObject(_formCTAAdditional2);
createNavButton(-1, _introCTA.sm.mc.inner, UI_VSET_UploadFace, enableSTFCTA);
createNavButton(-1, _formCTAAdditional1.sm.mc.ctaClick, UI_VSET_UploadFace, enableSTFCTA);
createNavButton(-1, _formCTAAdditional2.sm.mc.ctaClick, UI_VSET_UploadFace, enableSTFCTA);
createNavButton(-1, _uiFlags.sm.mc._ausFlag, UI_VSET_MainBlank, setRegionAus);
createNavButton(-1, _uiFlags.sm.mc._nzFlag, UI_VSET_MainBlank, setRegionNZ);
createNavButton(-1, _uiBase.sm.mc._closeButton, UI_VSET_MainBlank);
createNavButton(-1, _uiNavBar.sm.mc._howToPlay, UI_VSET_HowToPlay1, trackHowToPlay);
createNavButton(-1, _uiNavBar.sm.mc._highScores, UI_VSET_HighScores, loadScores);
createNavButton(-1, _uiNavBar.sm.mc._startGame, UI_VSET_SelectFace, disableSTFCTA);
if (!XmasCannon_Main.Instance.PortalMode){
createNavButton(-1, _uiNavBar.sm.mc._sendToFriend, UI_VSET_SendToFriend, trackSTFClick);
createNavButton(-1, _uiNavBar.sm.mc._embed, UI_VSET_NULL, csEmbed);
};
createNavButton(-1, _uiNavBar.sm.mc._seekMoreGames, UI_VSET_NULL, linkoutSeekMoreGames);
createNavButton(-1, _uiNavBar.sm.mc._credits, UI_VSET_Credits, trackCredits);
createNavButton(-1, _uiGameSummary.sm.mc._submitScore, UI_VSET_SubmitScore);
createNavButton(-1, _uiGameSummary.sm.mc._playAgain, UI_VSET_SelectFace, disableSTFCTA);
createNavButton(-1, _uiSelectFace.sm.mc._uploadFace, UI_VSET_UploadFace);
createNavButton(-1, _uiSelectFace.sm.mc._defaultFaceOne, -1, startNewGameHead1);
createNavButton(-1, _uiSelectFace.sm.mc._defaultFaceTwo, -1, startNewGameHead2);
createNavButton(-1, _uiSelectFace.sm.mc._defaultFaceThree, -1, startNewGameHead3);
var db:UIButton = createNavButton(-1, _uiFaceUploader.sm.mc._buttonDone, UI_VSET_ModifyFace, customFaceNextStep);
_uiFaceUploader.db = db;
db.primaryVis = false;
createNavButton(-1, _uiFaceUploader.sm.mc._buttonBrowse, -1);
createNavButton(-1, _uiFaceModifyer.sm.mc._buttonDone, -1);
if (XmasCannon_Main.Instance.PortalMode){
} else {
createNavButton(-1, _uiCredits.sm.mc._soapButton, UI_VSET_NULL, linkoutSoap);
createNavButton(-1, _uiCredits.sm.mc._seekButton, UI_VSET_NULL, linkoutVisitSeekLogo);
createNavButton(-1, _uiNavBar.sm.mc._visitSeekSite, UI_VSET_NULL, linkoutVisitSeek2);
};
if (readSoundPref() == 1){
toggleSound(new Event(""));
};
applyVisibiltySet(UI_VSET_LeadIn);
if (XmasCannon_Main.Instance.PortalMode){
_uiSeekLogoCorner.disable();
trace("UIMain - PortalMode enabled");
};
}
public function setRegionAus(event:Event):void{
GameTracking.trackMiscellaneous("region AU");
_regionMode = RMODE_AUS;
_uiIntroScreen.sm.mc.gotoAndPlay(1);
SoundManager.Instance.setMusicLoop();
initGigya();
setMainMenu();
}
private function customFaceNextStep(e:Event):void{
_uiFaceModifyer.initializeModifer();
}
public function get STFCTAEnabled():Boolean{
return (_stfCTA);
}
private function linkoutVisitSeekLogo(event:Event):void{
GameTracking.trackLink("Seek site");
if (RegionMode == RMODE_AUS){
navigateToURL(new URLRequest((((("http://www.seek.com.au?cid=sk:" + _trackingRegion) + ":games:") + _seekTrackingGameName) + ":logo")), "_blank");
} else {
navigateToURL(new URLRequest((((("http://www.seek.co.nz?cid=sk:" + _trackingRegion) + ":games:") + _seekTrackingGameName) + ":logo")), "_blank");
};
}
public static function get RMODE_AUS():int{
return (0);
}
public static function get RMODE_NZ():int{
return (1);
}
public static function get Instance():UIMain{
return (_instance);
}
}
}//package com.xmascannon.ui
Section 218
//XmasCannon_Main (com.xmascannon.XmasCannon_Main)
package com.xmascannon {
import flash.events.*;
import flash.display.*;
import com.psiom.util.*;
import com.psiom.sound.*;
import com.xmascannon.engine.objectSpaces.*;
import com.xmascannon.engine.*;
import com.xmascannon.ui.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.utils.*;
import com.psiom.*;
import com.soapcreative.net.tracking.*;
import com.xmascannon.assets.*;
import flash.ui.*;
public class XmasCannon_Main extends AppMain {
private var _uiMain:UIMain;
private var _customFace:BitmapData;
private var _shownControlHint:int;// = 0
private var _upgradeHintTimer:Number;// = 0
private var _hintedOnce:Boolean;// = false
private var _customLoader:Loader;
private var _uiElements:Array;
private var _portalMode:Boolean;// = false
private var _vModeID:String;
private var _cheatActivationDisplay:MovieClip;
private var _autoPlay:Boolean;// = false
private var _gameEngine:EngineMain;
private var _gameTrackingTimer:Timer;
private static var CHEATSENABLED:int = 0;
private static var _instance:XmasCannon_Main;
public function XmasCannon_Main(){
Constants.SHARED_OBJ_CONTAINER = "xmasCannon";
Constants.STAGEWIDTH = 700;
Constants.STAGEHEIGHT = 450;
Constants.BASE_URL = "";
Security.allowDomain("games.seek.com.au");
Security.allowDomain("games.seek.co.nz");
super();
_instance = this;
}
public function onMainStart(e:Event=null):void{
_uiMain.endDossierCountdown();
GameTracking.startGame();
_gameEngine.resetTotalScore();
launchLevel();
}
public function launchLevel():void{
_uiMain.applyVisibiltySet(UIMain.UI_VSET_Game);
startNewGame();
}
private function playAgain(event:Event):void{
onMainStart();
}
private function closeGame():void{
SoundManager.Instance.setMusicLoop(0);
EngineMain.Instance.closeGame();
_gameEngine.setRestState();
var parScore:Number = 1250000;
var copyFrame = 1;
if (_gameEngine.FinalScore <= (parScore * 0.25)){
copyFrame = (10 + Math.floor((Math.random() * 2.99)));
};
if ((((_gameEngine.FinalScore > (parScore * 0.25))) && ((_gameEngine.FinalScore <= (parScore * 0.5))))){
copyFrame = (7 + Math.floor((Math.random() * 2.99)));
};
if ((((_gameEngine.FinalScore > (parScore * 0.5))) && ((_gameEngine.FinalScore <= (parScore * 0.75))))){
copyFrame = (4 + Math.floor((Math.random() * 2.99)));
};
if (_gameEngine.FinalScore > (parScore * 0.75)){
copyFrame = (1 + Math.floor((Math.random() * 2.99)));
};
_uiMain.setGameSummary(_gameEngine.FinalScore, copyFrame);
_gameTrackingTimer.stop();
}
public function get SharedObject():SharedObjectWrapper{
return (_sharedObj);
}
public function controlHintDone():void{
_shownControlHint = 1;
_sharedObj.data.shownControlHint = 1;
_sharedObj.flush();
}
public function set SuppliedFace(inBMD:BitmapData):void{
_customFace = inBMD;
}
public function resumeGame(e:Event):void{
_gameEngine.resumeGame();
}
public function gameover(e:Event=null):void{
closeGame();
}
override protected function onMainKeyDown(e:KeyboardEvent):void{
super.onMainKeyDown(e);
if (_keyString == "ROCKOUT"){
if (GameLevel.Instance){
};
};
}
public function gameComplete():void{
closeGame();
}
public function get PortalMode():Boolean{
return (_portalMode);
}
public function allLevelsComplete():void{
closeGame();
}
private function onGameBySoap(e:Event):void{
_uiMain.linkoutSoap(new Event(""));
}
public function quitConfirmed(e:Event):void{
GameTracking.levelQuit();
_uiMain.applyVisibiltySet(UIMain.UI_VSET_MainBlank);
SoundManager.Instance.setMusicLoop(0);
EngineMain.Instance.closeGame();
_gameEngine.setRestState();
}
public function get ShownControlHint():int{
return (_shownControlHint);
}
public function get SuppliedFace():BitmapData{
return (_customFace);
}
public function get StageRef():Stage{
return (stage);
}
public function setUnlockLevel(level:int):void{
var unlockLevel:Number = Number(_sharedObj.data.LevelUnlocked);
if (!isFinite(unlockLevel)){
unlockLevel = 0;
};
if (Number(level) > Number(unlockLevel)){
_sharedObj.data.LevelUnlocked = level;
_sharedObj.flush();
};
}
private function onSuppliedFaceLoaded(e:Event):void{
trace("DRAWING CUSTOM FACE");
_customFace = new BitmapData(_customLoader.width, _customLoader.height, true, 0);
_customFace.draw(_customLoader);
UIMain.Instance.setSuppliedFace();
}
override protected function update():void{
super.update();
if (_cheatActivationDisplay.alpha < 0.02){
_cheatActivationDisplay.visible = false;
} else {
_cheatActivationDisplay.visible = true;
_cheatActivationDisplay.alpha = (_cheatActivationDisplay.alpha * 0.95);
};
}
override protected function mainInit():void{
var item:ContextMenuItem;
var context:LoaderContext;
scrollRect = new Rectangle(0, 0, 700, 450);
_sharedObj = new SharedObjectWrapper();
new XmasCannon_Assets();
super.mainInit();
_gameEngine = new EngineMain();
addCoreSystem(_gameEngine);
_gameEngine.init();
_uiMain = new UIMain();
addCoreSystem(_uiMain);
_uiMain.initObjects();
var customFacePath:String = root.loaderInfo.parameters.head;
if (customFacePath){
context = new LoaderContext();
context.checkPolicyFile = true;
_customLoader = new Loader();
_customLoader.load(new URLRequest((("http://games.seek.com.au/chimneyseeker/php/images/" + customFacePath) + "-player-head.png")), context);
_customLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSuppliedFaceLoaded);
};
_gameTrackingTimer = new Timer(1000, Number.POSITIVE_INFINITY);
var myContextMenu:ContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
var defaultItems:ContextMenuBuiltInItems = myContextMenu.builtInItems;
defaultItems.print = true;
item = new ContextMenuItem("Game by Soap");
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onGameBySoap, false, 0, true);
myContextMenu.customItems.push(item);
item = new ContextMenuItem("v1.0");
myContextMenu.customItems.push(item);
this.contextMenu = myContextMenu;
_cheatActivationDisplay = new MovieClip();
_uiMain.MovieClipLayer.addChild(_cheatActivationDisplay);
if (_autoPlay){
UIMain.Instance.setRegionAus(new Event(""));
onMainStart();
};
}
public function getUnlockLevel():int{
if (!_sharedObj.data.LevelUnlocked){
_sharedObj.data.LevelUnlocked = 0;
_sharedObj.flush();
};
return (int(_sharedObj.data.LevelUnlocked));
}
public function endGame(e:Event=null):void{
closeGame();
}
private function startNewGame():void{
_gameEngine.initNewGame();
_gameTrackingTimer.reset();
_gameTrackingTimer.start();
}
public static function get Instance():XmasCannon_Main{
return (_instance);
}
}
}//package com.xmascannon
Section 219
//AbstractPreloader (preloader.AbstractPreloader)
package preloader {
import flash.display.*;
import flash.events.*;
import com.soapcreative.net.tracking.*;
import flash.utils.*;
public class AbstractPreloader extends MovieClip {
private var USE_EXTERNAL:Boolean;// = true
private var m_loadTime:int;
protected var VALID_URL:Array;
private var _loadTime:Number;// = 0
private var m_firstEnterFrame:Boolean;
protected var m_adLoaded:Boolean;// = false
private static var _instance:MovieClip;
public function AbstractPreloader(){
super();
_instance = this;
GoogleTracking.initialize(this, "UA-6368558-45", "xmasCannon", true, false);
GameTracking.trackIndex();
addEventListener(Event.ADDED_TO_STAGE, handleOnAddedToStage);
stop();
}
protected function endLoading():void{
}
public function start():void{
m_firstEnterFrame = true;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
protected function updateLoading(a_percent:Number):void{
}
private function handleOnAddedToStage(event:Event):void{
stage.scaleMode = StageScaleMode.EXACT_FIT;
stage.align = StageAlign.TOP_LEFT;
m_loadTime = getTimer();
}
protected function beginLoading():void{
}
protected function get mainClassName():String{
return ("");
}
private function onEnterFrame(event:Event):void{
var percent:Number;
if (m_firstEnterFrame){
m_firstEnterFrame = false;
if (root.loaderInfo.bytesLoaded >= root.loaderInfo.bytesTotal){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
nextFrame();
run();
} else {
beginLoading();
};
return;
};
if (root.loaderInfo.bytesLoaded >= root.loaderInfo.bytesTotal){
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
nextFrame();
run();
endLoading();
} else {
percent = (root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal);
updateLoading(percent);
};
}
private function startMain():void{
var MainClass:Class = (getDefinitionByName(mainClassName) as Class);
if (MainClass == null){
throw (new Error("AbstractPreloader:initialize. There was no class matching that name. Did you remember to override mainClassName?"));
};
var main:DisplayObject = (new (MainClass) as DisplayObject);
if (main == null){
throw (new Error("AbstractPreloader:initialize. Main class needs to inherit from Sprite or MovieClip."));
};
MainClass.loadTime = int(((getTimer() - m_loadTime) / 1000));
addChild(main);
}
protected function run():void{
startMain();
}
public static function get Instance():MovieClip{
return (_instance);
}
}
}//package preloader
Section 220
//AbstractPreloaderView (preloader.AbstractPreloaderView)
package preloader {
public class AbstractPreloaderView extends AbstractPreloader {
private var _loaderGraphic:uimain_loader;
public function AbstractPreloaderView(){
super();
stop();
trace("@@preloader view");
_loaderGraphic = new uimain_loader();
_loaderGraphic.x = 291;
_loaderGraphic.y = 167;
addChild(_loaderGraphic);
super.start();
}
override protected function run():void{
removeChild(_loaderGraphic);
_loaderGraphic = null;
super.run();
}
override protected function get mainClassName():String{
return ("Seek_Xmas_Cannon");
}
override protected function updateLoading(a_percent:Number):void{
var frame:int;
if (_loaderGraphic._pField){
frame = (1 + int((a_percent * (_loaderGraphic.totalFrames - 1))));
_loaderGraphic._pField.text = (String(Math.floor((a_percent * 100))) + "%");
trace(("_loaderGraphic._pField.text: " + _loaderGraphic._pField.text));
};
}
}
}//package preloader
Section 221
//FaceResult (seek.face.data.FaceResult)
package seek.face.data {
import flash.display.*;
import flash.geom.*;
import seek.face.ui.modifier.*;
public class FaceResult {
public var eye1:Point;
public var eye2:Point;
public var mouth:Point;
public var bitmapData:BitmapData;
public function FaceResult(bitmapData:BitmapData, align:FaceAlign){
super();
this.bitmapData = bitmapData;
}
}
}//package seek.face.data
Section 222
//ComponentEvent (seek.face.events.ComponentEvent)
package seek.face.events {
import flash.events.*;
public class ComponentEvent extends Event {
private var _data:Object;
public static const COMPLETE:String = "ComponentEvent.COMPLETE";
public function ComponentEvent(type:String, data:Object=null){
super(type, false, false);
_data = data;
}
public function get data():Object{
return (_data);
}
override public function clone():Event{
return (new ComponentEvent(type, _data));
}
}
}//package seek.face.events
Section 223
//ControlPoint (seek.face.ui.modifier.ControlPoint)
package seek.face.ui.modifier {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.malee.mcore.events.*;
public class ControlPoint extends Sprite {
private var _pressY:Number;
var normal:Point;
var type:String;
private var _pressX:Number;
var connection:ControlPoint;
public static const POSITION:String = "position";
public static const SCALE:String = "scale";
public static const ROTATE:String = "rotate";
public function ControlPoint(){
super();
addEventListener(Event.ADDED_TO_STAGE, onAdded);
addEventListener(Event.REMOVED_FROM_STAGE, onRemoved);
}
private function onAdded(event:Event):void{
addEventListener(MouseEvent.MOUSE_DOWN, onSelect);
}
private function onSelect(event:MouseEvent):void{
_pressX = mouseX;
_pressY = mouseY;
stage.addEventListener(MouseEvent.MOUSE_MOVE, onDrag, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, onStageRelease, false, 0, true);
}
private function onDrag(event:MouseEvent):void{
dispatchEvent(new CustomEvent(EventTypes.UPDATE, this));
event.updateAfterEvent();
}
private function onStageRelease(event:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onDrag);
stage.removeEventListener(MouseEvent.MOUSE_UP, onStageRelease);
}
private function onRemoved(event:Event):void{
removeEventListener(MouseEvent.MOUSE_DOWN, onSelect);
}
public function get pressX():Number{
return (_pressX);
}
public function get pressY():Number{
return (_pressY);
}
}
}//package seek.face.ui.modifier
Section 224
//ControlPoints (seek.face.ui.modifier.ControlPoints)
package seek.face.ui.modifier {
import flash.display.*;
import flash.geom.*;
import com.malee.mcore.events.*;
public class ControlPoints extends Sprite {
private var _currScale:Number;
private var _currAngle:Number;
private var _origScale:Number;
public var _c0:ControlPoint;
public var _c1:ControlPoint;
public var _c2:ControlPoint;
public var _c3:ControlPoint;
private var _origAngle:Number;
private static const SIZE:int = 35;
public function ControlPoints(){
super();
}
public function get currAngle():Number{
return (_currAngle);
}
function updatePoint(cp:ControlPoint):void{
cp.connection.x = -(cp.x);
cp.connection.y = -(cp.y);
_currAngle = getAngle(cp);
_currScale = getScale(cp);
if (cp.type == ControlPoint.ROTATE){
movePoints(_c0, _c3, _c1);
} else {
movePoints(_c1, _c2, _c3);
};
}
public function get origScale():Number{
return (_origScale);
}
public function get origAngle():Number{
return (_origAngle);
}
function getScale(cp:ControlPoint):Number{
var dx:Number = (cp.x * scaleX);
var dy:Number = (cp.y * scaleY);
return (Math.sqrt(((dx * dx) + (dy * dy))));
}
function getAngle(cp:ControlPoint):Number{
var dx:Number = (cp.x * scaleX);
var dy:Number = (cp.y * scaleY);
return (Math.atan2(dy, dx));
}
private function initializePoint(c1:ControlPoint, c2:ControlPoint, type:String, dx:int, dy:int):void{
c1.buttonMode = true;
c1.addEventListener(EventTypes.UPDATE, onPointUpdate, false, 0, true);
c1.connection = c2;
c1.x = (SIZE * dx);
c1.y = (SIZE * dy);
c1.normal = new Point(dx, dy);
c1.type = type;
}
private function onPointUpdate(event:CustomEvent):void{
dispatchEvent(event);
}
private function movePoints(c1:ControlPoint, c2:ControlPoint, adj:ControlPoint):void{
var nx:Number;
var ny:Number;
var px:Number;
var py:Number;
var dist:Number = Math.sqrt(((adj.x * adj.x) + (adj.y * adj.y)));
if (dist > 0){
nx = (adj.x / dist);
ny = (adj.y / dist);
px = -(ny);
py = nx;
c1.x = (-(px) * _currScale);
c1.y = (-(py) * _currScale);
c2.x = (px * _currScale);
c2.y = (py * _currScale);
};
}
public function get currScale():Number{
return (_currScale);
}
function initalize():void{
initializePoint(_c0, _c3, ControlPoint.SCALE, -1, -1);
initializePoint(_c1, _c2, ControlPoint.ROTATE, 1, -1);
initializePoint(_c2, _c1, ControlPoint.ROTATE, -1, 1);
initializePoint(_c3, _c0, ControlPoint.SCALE, 1, 1);
_origScale = (_currScale = getScale(_c0));
_origAngle = (_currAngle = getAngle(_c0));
}
}
}//package seek.face.ui.modifier
Section 225
//FaceAlign (seek.face.ui.modifier.FaceAlign)
package seek.face.ui.modifier {
import flash.display.*;
public class FaceAlign extends Sprite {
public var _eye2:Sprite;
public var _eye1:Sprite;
public var _mouth:Sprite;
public function FaceAlign(){
super();
}
}
}//package seek.face.ui.modifier
Section 226
//FaceImage (seek.face.ui.modifier.FaceImage)
package seek.face.ui.modifier {
import flash.display.*;
public class FaceImage extends Sprite {
public var _image:ControlPoint;
public function FaceImage(){
super();
}
}
}//package seek.face.ui.modifier
Section 227
//FaceImagePoint (seek.face.ui.modifier.FaceImagePoint)
package seek.face.ui.modifier {
public dynamic class FaceImagePoint extends ControlPoint {
}
}//package seek.face.ui.modifier
Section 228
//FaceModifier (seek.face.ui.modifier.FaceModifier)
package seek.face.ui.modifier {
import flash.events.*;
import flash.display.*;
import com.xmascannon.engine.*;
import com.xmascannon.ui.*;
import seek.face.data.*;
import seek.face.ui.*;
import seek.face.events.*;
public class FaceModifier extends FaceComponent {
private static var _instance:FaceModifier;
public function FaceModifier(inSpriteID:int=-1, inMovieClip:MovieClip=null){
_instance = this;
super(inSpriteID, inMovieClip);
}
override public function initialize():void{
sm.mc._buttonDone.addEventListener(MouseEvent.CLICK, onDonePress, false, 0, true);
}
override public function onRemoved():void{
sm.mc._face.removeFace();
}
public function getFaceBitmap():FaceResult{
return (new FaceResult(sm.mc._face.getBitmap(), new FaceAlign()));
}
private function onDonePress(event:MouseEvent):void{
EngineMain.Instance.BaseUploadedImageBMD = sm.mc._face.getBitmap();
_dispatcherUtil.dispatchEvent(new ComponentEvent(ComponentEvent.COMPLETE, {bitmap:sm.mc._face.getBitmap()}));
UIMain.Instance.customFaceDone();
}
override public function destroy():void{
super.destroy();
sm.mc._face.destroy();
}
public function initializeModifer():void{
setFace(EngineMain.Instance.BaseUploadedImageBMD);
initialize();
}
public function setFace(face:BitmapData):void{
sm.mc._face.setFace(face);
}
public static function get Instance():FaceModifier{
return (_instance);
}
}
}//package seek.face.ui.modifier
Section 229
//FaceModify (seek.face.ui.modifier.FaceModify)
package seek.face.ui.modifier {
import flash.display.*;
import flash.geom.*;
import com.malee.mcore.events.*;
public class FaceModify extends Sprite {
public var _points:ControlPoints;
public var _align:FaceAlign;
private var bitmap:Bitmap;
public var _face:FaceImage;
private static const MAX_IMAGE_DRAG:int = 50;
private static const BITMAP_LINE:BitmapData = new BitmapData(4, 1, true, 0);
private static const MAX_POINT_DRAG:int = 100;
public function FaceModify(){
super();
}
function removeFace():void{
if (bitmap != null){
_face._image.removeChild(bitmap);
};
bitmap = null;
}
function getBitmap():BitmapData{
var bounds:Rectangle = _align.getBounds(this);
trace(("FaceModify > getBitmap > " + bounds), bounds.height, bounds.width);
var bmp:BitmapData = new BitmapData(bounds.width, bounds.height, true, 0);
bmp.draw(_face, _face.transform.matrix);
return (bmp);
}
private function update():void{
var angle:Number = (_points.getAngle(_points._c0) - _points.origAngle);
var scale:Number = (_points.getScale(_points._c0) / _points.origScale);
_face._image.rotation = ((angle * 180) / Math.PI);
_face._image.scaleX = (_face._image.scaleY = scale);
_points.x = (_face.x + _face._image.x);
_points.y = (_face.y + _face._image.y);
_points.graphics.clear();
_points.graphics.lineStyle(1, 5683914);
_points.graphics.moveTo(_points._c0.x, _points._c0.y);
_points.graphics.lineTo(_points._c1.x, _points._c1.y);
_points.graphics.lineTo(_points._c3.x, _points._c3.y);
_points.graphics.lineTo(_points._c2.x, _points._c2.y);
_points.graphics.lineTo(_points._c0.x, _points._c0.y);
}
private function movePoint(cp:ControlPoint, ox:Number, oy:Number, px:Number, py:Number, max:int=0):void{
var nx:Number;
var ny:Number;
var size:Number;
var dx:Number = (px - ox);
var dy:Number = (py - oy);
var dist:Number = Math.sqrt(((dx * dx) + (dy * dy)));
if (dist > 0){
nx = (dx / dist);
ny = (dy / dist);
size = Math.min(dist, max);
cp.x = (ox + (nx * size));
cp.y = (oy + (ny * size));
};
}
private function onPointUpdate(event:CustomEvent):void{
var cp:ControlPoint = (event.data as ControlPoint);
var mx:int = (_points.mouseX - cp.pressX);
var my:int = (_points.mouseY - cp.pressY);
movePoint(cp, 0, 0, mx, my, MAX_POINT_DRAG);
_points.updatePoint(cp);
update();
}
private function onImageUpdate(event:CustomEvent):void{
var px:Number = _face._image.pressX;
var py:Number = _face._image.pressY;
var a1:Number = ((_face._image.rotation * Math.PI) / 180);
var a2:Number = Math.atan2(py, px);
var an:Number = (a1 + a2);
var ln:Number = Math.sqrt(((px * px) + (py * py)));
var mx:Number = (Math.cos(an) * ln);
var my:Number = (Math.sin(an) * ln);
var tx:int = (_face.mouseX - (mx * _face._image.scaleX));
var ty:int = (_face.mouseY - (my * _face._image.scaleY));
movePoint(_face._image, 0, 0, tx, ty, MAX_IMAGE_DRAG);
update();
}
function destroy():void{
_points.removeEventListener(EventTypes.UPDATE, onPointUpdate);
_points.removeEventListener(EventTypes.UPDATE, onImageUpdate);
}
function setFace(image:BitmapData):void{
removeFace();
_points.initalize();
_points.addEventListener(EventTypes.UPDATE, onPointUpdate, false, 0, true);
bitmap = new Bitmap(image);
bitmap.x = -(int((bitmap.width * 0.5)));
bitmap.y = -(int((bitmap.height * 0.5)));
_face._image.addChild(bitmap);
_face._image.addEventListener(EventTypes.UPDATE, onImageUpdate, false, 0, true);
_face._image.type = ControlPoint.POSITION;
_face._image.x = 0;
_face._image.y = 0;
update();
}
BITMAP_LINE.fillRect(new Rectangle(0, 0, 2, 1), 4278190080);
}
}//package seek.face.ui.modifier
Section 230
//FacePoint (seek.face.ui.modifier.FacePoint)
package seek.face.ui.modifier {
public dynamic class FacePoint extends ControlPoint {
}
}//package seek.face.ui.modifier
Section 231
//FaceUploader (seek.face.ui.uploader.FaceUploader)
package seek.face.ui.uploader {
import flash.events.*;
import flash.display.*;
import com.psiom.ui.uiComponents.*;
import com.xmascannon.engine.*;
import flash.text.*;
import flash.geom.*;
import com.malee.mcore.loaders.*;
import com.malee.mcore.events.*;
import seek.face.ui.*;
import com.malee.mcore.net.*;
import seek.face.events.*;
public class FaceUploader extends FaceComponent {
private var uploader:FileUpload;
private var downloader:AssetLoader;
private var image:Bitmap;
public var db:UIButton;
private static const PHP_SCRIPT:String = "http://games.seek.com.au/chimneyseeker/php/upload.php";
private static const MAX_IMAGE_HEIGHT:int = 300;
private static const MAX_IMAGE_WIDTH:int = 300;
public function FaceUploader(inSpriteID:int=-1, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
override public function onRemoved():void{
removeImage();
}
private function done():void{
var img:BitmapData = image.bitmapData;
var bw:int = Math.min(img.width, MAX_IMAGE_WIDTH);
var bh:int = Math.min(img.height, MAX_IMAGE_HEIGHT);
var bx:int = ((img.width - bw) * 0.5);
var by:int = ((img.height - bh) * 0.5);
var bmp:BitmapData = new BitmapData(bw, bh, true, 0);
bmp.copyPixels(img, new Rectangle(bx, by, bw, bh), new Point());
trace(("FaceUploader > done > bmp: " + bmp));
_dispatcherUtil.dispatchEvent(new ComponentEvent(ComponentEvent.COMPLETE, {bitmap:bmp}));
}
public function initializeUploader():void{
trace("FACE LOADER INITIALIZE");
uploader = new FileUpload(200);
uploader.addEventListener(Event.SELECT, onFileSelect, false, 0, true);
uploader.addEventListener(FileErrorEvent.FILESIZE_ERROR, onFileError, false, 0, true);
uploader.addEventListener(ProgressEvent.PROGRESS, onDataProgress, false, 0, true);
uploader.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, onFileUploaded, false, 0, true);
uploader.file.addEventListener(IOErrorEvent.IO_ERROR, onFileError, false, 0, true);
uploader.file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onFileError, false, 0, true);
downloader = new AssetLoader();
downloader.addEventListener(Event.COMPLETE, onImageLoaded, false, 0, true);
downloader.addEventListener(IOErrorEvent.IO_ERROR, onFileError, false, 0, true);
downloader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onFileError, false, 0, true);
downloader.addEventListener(ProgressEvent.PROGRESS, onDataProgress, false, 0, true);
sm.mc._buttonDone.addEventListener(MouseEvent.CLICK, onDone, false, 0, true);
sm.mc._buttonBrowse.addEventListener(MouseEvent.CLICK, onBrowse, false, 0, true);
sm.mc._progress.visible = false;
sm.mc._error.visible = false;
}
private function onFileSelect(event:Event):void{
sm.mc._progress.visible = true;
sm.mc._progress.gotoAndStop(1);
sm.mc._error.visible = false;
sm.mc._buttonBrowse.visible = false;
db.primaryVis = false;
uploader.addVariable("a", "saveimage");
uploader.upload(PHP_SCRIPT);
}
private function fetchImage(url:String):void{
downloader.loadData(url);
}
private function onError(text:String):void{
sm.mc._error.visible = true;
sm.mc._error.message.autoSize = TextFieldAutoSize.LEFT;
sm.mc._error.message.text = text;
sm.mc._progress.visible = false;
sm.mc._buttonBrowse.visible = true;
}
private function onFileError(event:ErrorEvent):void{
onError(event.text);
}
private function onDone(event:MouseEvent):void{
trace(("@@@ FaceUploader > ONE DONE: " + image));
if (image != null){
done();
};
EngineMain.Instance.BaseUploadedImageBMD = image.bitmapData;
}
private function onFileUploaded(event:DataEvent):void{
var data:XML;
var event = event;
data = new XML(event.data);
//unresolved jump
var _slot1 = error;
onError(_slot1.message);
if (data != null){
fetchImage(data.path.toString());
};
}
private function removeImage():void{
if (image != null){
sm.mc._face._image.removeChild(image);
};
image = null;
}
private function onBrowse(event:MouseEvent):void{
uploader.browse([FileFilters.IMAGE_FILTER]);
}
private function onImageLoaded(event:Event):void{
var event = event;
sm.mc._progress.visible = false;
removeImage();
EngineMain.Instance.BaseUploadedImage = (downloader.content as Bitmap);
image = (downloader.content as Bitmap);
image.x = -(int((image.width * 0.5)));
image.y = -(int((image.height * 0.5)));
sm.mc._face._image.addChild(image);
db.primaryVis = true;
sm.mc._buttonBrowse.visible = true;
//unresolved jump
var _slot1 = error;
onError(_slot1.message);
}
private function onDataProgress(event:ProgressEvent):void{
var p:Number = (event.bytesLoaded / event.bytesTotal);
sm.mc._progress.gotoAndStop(int((p * sm.mc._progress.totalFrames)));
}
}
}//package seek.face.ui.uploader
Section 232
//FaceComponent (seek.face.ui.FaceComponent)
package seek.face.ui {
import flash.display.*;
import com.psiom.ui.uiComponents.*;
public class FaceComponent extends UIOBject {
public function FaceComponent(inSpriteID:int=-1, inMovieClip:MovieClip=null){
super(inSpriteID, inMovieClip);
}
public function onRemoved():void{
}
public function onAdded():void{
}
public function initialize():void{
}
}
}//package seek.face.ui
Section 233
//barry_108 (xmas_assets_fla.barry_108)
package xmas_assets_fla {
import flash.display.*;
public dynamic class barry_108 extends MovieClip {
public var head:MovieClip;
public function barry_108(){
addFrameScript(17, this.frame18, 53, this.frame54);
}
function frame54(){
gotoAndPlay("loop");
}
function frame18(){
gotoAndPlay("flying");
}
}
}//package xmas_assets_fla
Section 234
//canonFire_123 (xmas_assets_fla.canonFire_123)
package xmas_assets_fla {
import flash.display.*;
public dynamic class canonFire_123 extends MovieClip {
public function canonFire_123(){
addFrameScript(25, this.frame26);
}
function frame26(){
stop();
}
}
}//package xmas_assets_fla
Section 235
//food_126 (xmas_assets_fla.food_126)
package xmas_assets_fla {
import flash.display.*;
public dynamic class food_126 extends MovieClip {
public function food_126(){
addFrameScript(48, this.frame49);
}
function frame49(){
stop();
}
}
}//package xmas_assets_fla
Section 236
//logoAnimation2_117 (xmas_assets_fla.logoAnimation2_117)
package xmas_assets_fla {
import flash.display.*;
public dynamic class logoAnimation2_117 extends MovieClip {
public function logoAnimation2_117(){
addFrameScript(0, this.frame1, 31, this.frame32);
}
function frame32(){
stop();
}
function frame1(){
stop();
}
}
}//package xmas_assets_fla
Section 237
//mc_219 (xmas_assets_fla.mc_219)
package xmas_assets_fla {
import flash.display.*;
public dynamic class mc_219 extends MovieClip {
public function mc_219(){
addFrameScript(33, this.frame34);
}
function frame34(){
stop();
}
}
}//package xmas_assets_fla
Section 238
//snowSpill_120 (xmas_assets_fla.snowSpill_120)
package xmas_assets_fla {
import flash.display.*;
public dynamic class snowSpill_120 extends MovieClip {
public function snowSpill_120(){
addFrameScript(15, this.frame16);
}
function frame16(){
stop();
}
}
}//package xmas_assets_fla
Section 239
//snowSpill2_122 (xmas_assets_fla.snowSpill2_122)
package xmas_assets_fla {
import flash.display.*;
public dynamic class snowSpill2_122 extends MovieClip {
public function snowSpill2_122(){
addFrameScript(21, this.frame22);
}
function frame22(){
stop();
}
}
}//package xmas_assets_fla
Section 240
//uploadProgress_234 (xmas_assets_fla.uploadProgress_234)
package xmas_assets_fla {
import flash.display.*;
public dynamic class uploadProgress_234 extends MovieClip {
public function uploadProgress_234(){
addFrameScript(0, this.frame1);
}
function frame1(){
stop();
}
}
}//package xmas_assets_fla
Section 241
//ausFlag (ausFlag)
package {
import flash.display.*;
public dynamic class ausFlag extends MovieClip {
public var base:MovieClip;
public var roll:MovieClip;
}
}//package
Section 242
//buttonBlueGeneric (buttonBlueGeneric)
package {
import flash.display.*;
public dynamic class buttonBlueGeneric extends MovieClip {
public var roll:MovieClip;
}
}//package
Section 243
//buttonPinkGeneric (buttonPinkGeneric)
package {
import flash.display.*;
public dynamic class buttonPinkGeneric extends MovieClip {
public var roll:MovieClip;
}
}//package
Section 244
//buttonPinkGenericLarge (buttonPinkGenericLarge)
package {
import flash.display.*;
public dynamic class buttonPinkGenericLarge extends MovieClip {
public var roll:MovieClip;
}
}//package
Section 245
//buttonSeek (buttonSeek)
package {
import flash.display.*;
public dynamic class buttonSeek extends MovieClip {
public var roll:MovieClip;
}
}//package
Section 246
//closeButtonMain (closeButtonMain)
package {
import flash.display.*;
public dynamic class closeButtonMain extends MovieClip {
public var base:MovieClip;
public var roll:MovieClip;
}
}//package
Section 247
//ctaClickClip (ctaClickClip)
package {
import flash.display.*;
public dynamic class ctaClickClip extends MovieClip {
public var inner:MovieClip;
}
}//package
Section 248
//gClip_additionalUICTA (gClip_additionalUICTA)
package {
import flash.display.*;
public dynamic class gClip_additionalUICTA extends MovieClip {
public var ctaClick:MovieClip;
public var cta:MovieClip;
}
}//package
Section 249
//gClip_additionalUICTA2 (gClip_additionalUICTA2)
package {
import flash.display.*;
public dynamic class gClip_additionalUICTA2 extends MovieClip {
public var ctaClick:MovieClip;
public var cta:MovieClip;
}
}//package
Section 250
//gClip_aurora (gClip_aurora)
package {
import flash.display.*;
public dynamic class gClip_aurora extends MovieClip {
}
}//package
Section 251
//gClip_bgMountians (gClip_bgMountians)
package {
import flash.display.*;
public dynamic class gClip_bgMountians extends MovieClip {
}
}//package
Section 252
//gClip_bgTrees (gClip_bgTrees)
package {
import flash.display.*;
public dynamic class gClip_bgTrees extends MovieClip {
}
}//package
Section 253
//gClip_blueSpark1 (gClip_blueSpark1)
package {
import flash.display.*;
public dynamic class gClip_blueSpark1 extends MovieClip {
}
}//package
Section 254
//gClip_cannonBarrel (gClip_cannonBarrel)
package {
import flash.display.*;
public dynamic class gClip_cannonBarrel extends MovieClip {
}
}//package
Section 255
//gClip_cannonBarrelGhost (gClip_cannonBarrelGhost)
package {
import flash.display.*;
public dynamic class gClip_cannonBarrelGhost extends MovieClip {
}
}//package
Section 256
//gClip_cannonBase (gClip_cannonBase)
package {
import flash.display.*;
public dynamic class gClip_cannonBase extends MovieClip {
}
}//package
Section 257
//gClip_cannonPowerBar (gClip_cannonPowerBar)
package {
import flash.display.*;
public dynamic class gClip_cannonPowerBar extends MovieClip {
}
}//package
Section 258
//gClip_cannonPowerBarGhost (gClip_cannonPowerBarGhost)
package {
import flash.display.*;
public dynamic class gClip_cannonPowerBarGhost extends MovieClip {
}
}//package
Section 259
//gClip_chimneyLegs (gClip_chimneyLegs)
package {
import flash.display.*;
public dynamic class gClip_chimneyLegs extends MovieClip {
}
}//package
Section 260
//gClip_chimneySmoke (gClip_chimneySmoke)
package {
import flash.display.*;
public dynamic class gClip_chimneySmoke extends MovieClip {
}
}//package
Section 261
//gClip_collectable (gClip_collectable)
package {
import flash.display.*;
public dynamic class gClip_collectable extends MovieClip {
}
}//package
Section 262
//gClip_crossHair (gClip_crossHair)
package {
import flash.display.*;
public dynamic class gClip_crossHair extends MovieClip {
}
}//package
Section 263
//gClip_debugNode (gClip_debugNode)
package {
import flash.display.*;
public dynamic class gClip_debugNode extends MovieClip {
}
}//package
Section 264
//gClip_defaultHead (gClip_defaultHead)
package {
import flash.display.*;
public dynamic class gClip_defaultHead extends MovieClip {
public var base:MovieClip;
}
}//package
Section 265
//gClip_elfHat (gClip_elfHat)
package {
import flash.display.*;
public dynamic class gClip_elfHat extends MovieClip {
}
}//package
Section 266
//gClip_fgHill1 (gClip_fgHill1)
package {
import flash.display.*;
public dynamic class gClip_fgHill1 extends MovieClip {
}
}//package
Section 267
//gClip_fgHill2 (gClip_fgHill2)
package {
import flash.display.*;
public dynamic class gClip_fgHill2 extends MovieClip {
}
}//package
Section 268
//gClip_fgHill3 (gClip_fgHill3)
package {
import flash.display.*;
public dynamic class gClip_fgHill3 extends MovieClip {
}
}//package
Section 269
//gClip_fgHill4 (gClip_fgHill4)
package {
import flash.display.*;
public dynamic class gClip_fgHill4 extends MovieClip {
}
}//package
Section 270
//gClip_fgTree (gClip_fgTree)
package {
import flash.display.*;
public dynamic class gClip_fgTree extends MovieClip {
}
}//package
Section 271
//gClip_fullBlank (gClip_fullBlank)
package {
import flash.display.*;
public dynamic class gClip_fullBlank extends MovieClip {
}
}//package
Section 272
//gClip_ground (gClip_ground)
package {
import flash.display.*;
public dynamic class gClip_ground extends MovieClip {
}
}//package
Section 273
//gClip_house1 (gClip_house1)
package {
import flash.display.*;
public dynamic class gClip_house1 extends MovieClip {
}
}//package
Section 274
//gClip_house2 (gClip_house2)
package {
import flash.display.*;
public dynamic class gClip_house2 extends MovieClip {
}
}//package
Section 275
//gClip_house3 (gClip_house3)
package {
import flash.display.*;
public dynamic class gClip_house3 extends MovieClip {
}
}//package
Section 276
//gClip_house4 (gClip_house4)
package {
import flash.display.*;
public dynamic class gClip_house4 extends MovieClip {
}
}//package
Section 277
//gClip_house5 (gClip_house5)
package {
import flash.display.*;
public dynamic class gClip_house5 extends MovieClip {
}
}//package
Section 278
//gClip_house6 (gClip_house6)
package {
import flash.display.*;
public dynamic class gClip_house6 extends MovieClip {
}
}//package
Section 279
//gClip_house7 (gClip_house7)
package {
import flash.display.*;
public dynamic class gClip_house7 extends MovieClip {
}
}//package
Section 280
//gClip_house8 (gClip_house8)
package {
import flash.display.*;
public dynamic class gClip_house8 extends MovieClip {
}
}//package
Section 281
//gClip_mgHill1 (gClip_mgHill1)
package {
import flash.display.*;
public dynamic class gClip_mgHill1 extends MovieClip {
}
}//package
Section 282
//gClip_middleTorso (gClip_middleTorso)
package {
import flash.display.*;
public dynamic class gClip_middleTorso extends MovieClip {
}
}//package
Section 283
//gClip_obs_bauble (gClip_obs_bauble)
package {
import flash.display.*;
public dynamic class gClip_obs_bauble extends MovieClip {
}
}//package
Section 284
//gClip_obs_deer1 (gClip_obs_deer1)
package {
import flash.display.*;
public dynamic class gClip_obs_deer1 extends MovieClip {
}
}//package
Section 285
//gClip_obs_deer2 (gClip_obs_deer2)
package {
import flash.display.*;
public dynamic class gClip_obs_deer2 extends MovieClip {
}
}//package
Section 286
//gClip_obs_deer3 (gClip_obs_deer3)
package {
import flash.display.*;
public dynamic class gClip_obs_deer3 extends MovieClip {
}
}//package
Section 287
//gClip_obs_northPoleSign (gClip_obs_northPoleSign)
package {
import flash.display.*;
public dynamic class gClip_obs_northPoleSign extends MovieClip {
}
}//package
Section 288
//gClip_obs_sleigh (gClip_obs_sleigh)
package {
import flash.display.*;
public dynamic class gClip_obs_sleigh extends MovieClip {
}
}//package
Section 289
//gClip_obs_spaceBigfoot (gClip_obs_spaceBigfoot)
package {
import flash.display.*;
public dynamic class gClip_obs_spaceBigfoot extends MovieClip {
}
}//package
Section 290
//gClip_obs_star (gClip_obs_star)
package {
import flash.display.*;
public dynamic class gClip_obs_star extends MovieClip {
}
}//package
Section 291
//gClip_obs_trampoline (gClip_obs_trampoline)
package {
import flash.display.*;
public dynamic class gClip_obs_trampoline extends MovieClip {
}
}//package
Section 292
//gClip_obs_treeBirds (gClip_obs_treeBirds)
package {
import flash.display.*;
public dynamic class gClip_obs_treeBirds extends MovieClip {
}
}//package
Section 293
//gClip_obs_umbrellaSnowman (gClip_obs_umbrellaSnowman)
package {
import flash.display.*;
public dynamic class gClip_obs_umbrellaSnowman extends MovieClip {
}
}//package
Section 294
//gClip_panCursor (gClip_panCursor)
package {
import flash.display.*;
public dynamic class gClip_panCursor extends MovieClip {
}
}//package
Section 295
//gClip_shin (gClip_shin)
package {
import flash.display.*;
public dynamic class gClip_shin extends MovieClip {
}
}//package
Section 296
//gClip_shotDisplay (gClip_shotDisplay)
package {
import flash.display.*;
public dynamic class gClip_shotDisplay extends MovieClip {
}
}//package
Section 297
//gClip_shotsLeftDisplay (gClip_shotsLeftDisplay)
package {
import flash.display.*;
import flash.text.*;
public dynamic class gClip_shotsLeftDisplay extends MovieClip {
public var numField:TextField;
}
}//package
Section 298
//gClip_shoulder (gClip_shoulder)
package {
import flash.display.*;
public dynamic class gClip_shoulder extends MovieClip {
}
}//package
Section 299
//gClip_skyBG (gClip_skyBG)
package {
import flash.display.*;
public dynamic class gClip_skyBG extends MovieClip {
}
}//package
Section 300
//gClip_smokePuff (gClip_smokePuff)
package {
import flash.display.*;
public dynamic class gClip_smokePuff extends MovieClip {
}
}//package
Section 301
//gClip_snowFlake (gClip_snowFlake)
package {
import flash.display.*;
public dynamic class gClip_snowFlake extends MovieClip {
}
}//package
Section 302
//gClip_star (gClip_star)
package {
import flash.display.*;
public dynamic class gClip_star extends MovieClip {
}
}//package
Section 303
//gClip_thigh (gClip_thigh)
package {
import flash.display.*;
public dynamic class gClip_thigh extends MovieClip {
}
}//package
Section 304
//gClip_tickFlag (gClip_tickFlag)
package {
import flash.display.*;
public dynamic class gClip_tickFlag extends MovieClip {
}
}//package
Section 305
//gClip_trailLine (gClip_trailLine)
package {
import flash.display.*;
public dynamic class gClip_trailLine extends MovieClip {
}
}//package
Section 306
//gClip_wrist (gClip_wrist)
package {
import flash.display.*;
public dynamic class gClip_wrist extends MovieClip {
}
}//package
Section 307
//htpNextButton (htpNextButton)
package {
import flash.display.*;
public dynamic class htpNextButton extends MovieClip {
public var base:MovieClip;
public var roll:MovieClip;
}
}//package
Section 308
//htpPrevButton (htpPrevButton)
package {
import flash.display.*;
public dynamic class htpPrevButton extends MovieClip {
public var base:MovieClip;
public var roll:MovieClip;
}
}//package
Section 309
//invisBlockButton (invisBlockButton)
package {
import flash.display.*;
public dynamic class invisBlockButton extends MovieClip {
}
}//package
Section 310
//levelSelecButton (levelSelecButton)
package {
import flash.display.*;
import flash.text.*;
public dynamic class levelSelecButton extends MovieClip {
public var _levelNum:TextField;
public var _bg:MovieClip;
public var _lock:MovieClip;
public var _bestScore:TextField;
public var _levelName:TextField;
public var _base:MovieClip;
public var _roll:MovieClip;
}
}//package
Section 311
//mcControlPoints (mcControlPoints)
package {
import seek.face.ui.modifier.*;
public dynamic class mcControlPoints extends ControlPoints {
}
}//package
Section 312
//mcFaceAlign (mcFaceAlign)
package {
import seek.face.ui.modifier.*;
public dynamic class mcFaceAlign extends FaceAlign {
}
}//package
Section 313
//mcFaceImage (mcFaceImage)
package {
import seek.face.ui.modifier.*;
public dynamic class mcFaceImage extends FaceImage {
}
}//package
Section 314
//mcfacemodify (mcfacemodify)
package {
import seek.face.ui.modifier.*;
public dynamic class mcfacemodify extends FaceModify {
}
}//package
Section 315
//nzFlag (nzFlag)
package {
import flash.display.*;
public dynamic class nzFlag extends MovieClip {
public var base:MovieClip;
public var roll:MovieClip;
}
}//package
Section 316
//Seek_Xmas_Cannon (Seek_Xmas_Cannon)
package {
import flash.events.*;
import com.xmascannon.*;
import flash.display.*;
public class Seek_Xmas_Cannon extends Sprite {
private var _main:XmasCannon_Main;
public function Seek_Xmas_Cannon(){
super();
_main = new XmasCannon_Main();
addChild(_main);
addEventListener(Event.ADDED_TO_STAGE, onAdded);
}
private function onAdded(event:Event):void{
}
}
}//package
Section 317
//snd_bigthud (snd_bigthud)
package {
import flash.media.*;
public dynamic class snd_bigthud extends Sound {
}
}//package
Section 318
//snd_boing (snd_boing)
package {
import flash.media.*;
public dynamic class snd_boing extends Sound {
}
}//package
Section 319
//snd_cannonfire (snd_cannonfire)
package {
import flash.media.*;
public dynamic class snd_cannonfire extends Sound {
}
}//package
Section 320
//snd_cashregister (snd_cashregister)
package {
import flash.media.*;
public dynamic class snd_cashregister extends Sound {
}
}//package
Section 321
//snd_clank (snd_clank)
package {
import flash.media.*;
public dynamic class snd_clank extends Sound {
}
}//package
Section 322
//snd_clank2 (snd_clank2)
package {
import flash.media.*;
public dynamic class snd_clank2 extends Sound {
}
}//package
Section 323
//snd_collect (snd_collect)
package {
import flash.media.*;
public dynamic class snd_collect extends Sound {
}
}//package
Section 324
//snd_gameloop (snd_gameloop)
package {
import flash.media.*;
public dynamic class snd_gameloop extends Sound {
}
}//package
Section 325
//snd_heavythud (snd_heavythud)
package {
import flash.media.*;
public dynamic class snd_heavythud extends Sound {
}
}//package
Section 326
//snd_hitChimney (snd_hitChimney)
package {
import flash.media.*;
public dynamic class snd_hitChimney extends Sound {
}
}//package
Section 327
//snd_hooray (snd_hooray)
package {
import flash.media.*;
public dynamic class snd_hooray extends Sound {
}
}//package
Section 328
//snd_imin (snd_imin)
package {
import flash.media.*;
public dynamic class snd_imin extends Sound {
}
}//package
Section 329
//snd_lightthud (snd_lightthud)
package {
import flash.media.*;
public dynamic class snd_lightthud extends Sound {
}
}//package
Section 330
//snd_menuloop (snd_menuloop)
package {
import flash.media.*;
public dynamic class snd_menuloop extends Sound {
}
}//package
Section 331
//snd_oof1 (snd_oof1)
package {
import flash.media.*;
public dynamic class snd_oof1 extends Sound {
}
}//package
Section 332
//snd_oof2 (snd_oof2)
package {
import flash.media.*;
public dynamic class snd_oof2 extends Sound {
}
}//package
Section 333
//snd_ouch1 (snd_ouch1)
package {
import flash.media.*;
public dynamic class snd_ouch1 extends Sound {
}
}//package
Section 334
//snd_ouch10 (snd_ouch10)
package {
import flash.media.*;
public dynamic class snd_ouch10 extends Sound {
}
}//package
Section 335
//snd_ouch11_s (snd_ouch11_s)
package {
import flash.media.*;
public dynamic class snd_ouch11_s extends Sound {
}
}//package
Section 336
//snd_ouch12 (snd_ouch12)
package {
import flash.media.*;
public dynamic class snd_ouch12 extends Sound {
}
}//package
Section 337
//snd_ouch13 (snd_ouch13)
package {
import flash.media.*;
public dynamic class snd_ouch13 extends Sound {
}
}//package
Section 338
//snd_ouch14 (snd_ouch14)
package {
import flash.media.*;
public dynamic class snd_ouch14 extends Sound {
}
}//package
Section 339
//snd_ouch15 (snd_ouch15)
package {
import flash.media.*;
public dynamic class snd_ouch15 extends Sound {
}
}//package
Section 340
//snd_ouch16 (snd_ouch16)
package {
import flash.media.*;
public dynamic class snd_ouch16 extends Sound {
}
}//package
Section 341
//snd_ouch17_s (snd_ouch17_s)
package {
import flash.media.*;
public dynamic class snd_ouch17_s extends Sound {
}
}//package
Section 342
//snd_ouch2 (snd_ouch2)
package {
import flash.media.*;
public dynamic class snd_ouch2 extends Sound {
}
}//package
Section 343
//snd_ouch3 (snd_ouch3)
package {
import flash.media.*;
public dynamic class snd_ouch3 extends Sound {
}
}//package
Section 344
//snd_ouch4 (snd_ouch4)
package {
import flash.media.*;
public dynamic class snd_ouch4 extends Sound {
}
}//package
Section 345
//snd_ouch5 (snd_ouch5)
package {
import flash.media.*;
public dynamic class snd_ouch5 extends Sound {
}
}//package
Section 346
//snd_ouch6 (snd_ouch6)
package {
import flash.media.*;
public dynamic class snd_ouch6 extends Sound {
}
}//package
Section 347
//snd_ouch7 (snd_ouch7)
package {
import flash.media.*;
public dynamic class snd_ouch7 extends Sound {
}
}//package
Section 348
//snd_ouch8 (snd_ouch8)
package {
import flash.media.*;
public dynamic class snd_ouch8 extends Sound {
}
}//package
Section 349
//snd_ouch9 (snd_ouch9)
package {
import flash.media.*;
public dynamic class snd_ouch9 extends Sound {
}
}//package
Section 350
//snd_presdeliv (snd_presdeliv)
package {
import flash.media.*;
public dynamic class snd_presdeliv extends Sound {
}
}//package
Section 351
//snd_woohoo (snd_woohoo)
package {
import flash.media.*;
public dynamic class snd_woohoo extends Sound {
}
}//package
Section 352
//snd_yay (snd_yay)
package {
import flash.media.*;
public dynamic class snd_yay extends Sound {
}
}//package
Section 353
//snd_yipee (snd_yipee)
package {
import flash.media.*;
public dynamic class snd_yipee extends Sound {
}
}//package
Section 354
//soapButton (soapButton)
package {
import flash.display.*;
public dynamic class soapButton extends MovieClip {
public var roll:MovieClip;
}
}//package
Section 355
//tickBox (tickBox)
package {
import flash.display.*;
public dynamic class tickBox extends MovieClip {
public var base:MovieClip;
public var roll:MovieClip;
}
}//package
Section 356
//ui_mainMenuButton (ui_mainMenuButton)
package {
import flash.display.*;
public dynamic class ui_mainMenuButton extends MovieClip {
public var roll:MovieClip;
}
}//package
Section 357
//ui_scoreBlip (ui_scoreBlip)
package {
import flash.display.*;
import flash.text.*;
public dynamic class ui_scoreBlip extends MovieClip {
public var _base:MovieClip;
public var _points:TextField;
}
}//package
Section 358
//ui_scoreBlipLarge (ui_scoreBlipLarge)
package {
import flash.display.*;
import flash.text.*;
public dynamic class ui_scoreBlipLarge extends MovieClip {
public var _base:MovieClip;
public var _points:TextField;
}
}//package
Section 359
//uiclip_housesDisplay (uiclip_housesDisplay)
package {
import flash.display.*;
public dynamic class uiclip_housesDisplay extends MovieClip {
public var hd1:MovieClip;
public var hd2:MovieClip;
public var hd3:MovieClip;
public var hd4:MovieClip;
public var hd5:MovieClip;
public var hd6:MovieClip;
public var hd7:MovieClip;
public var hd8:MovieClip;
}
}//package
Section 360
//uiclip_scoreField (uiclip_scoreField)
package {
import flash.display.*;
import flash.text.*;
public dynamic class uiclip_scoreField extends MovieClip {
public var f0:TextField;
public var f1:TextField;
public var f2:TextField;
public var f3:TextField;
public var f4:TextField;
public var f5:TextField;
public var f6:TextField;
}
}//package
Section 361
//uimain_base (uimain_base)
package {
import flash.display.*;
public dynamic class uimain_base extends MovieClip {
public var _closeButton:closeButtonMain;
}
}//package
Section 362
//uimain_bggradient (uimain_bggradient)
package {
import flash.display.*;
public dynamic class uimain_bggradient extends MovieClip {
}
}//package
Section 363
//uimain_confirmQuit (uimain_confirmQuit)
package {
import flash.display.*;
public dynamic class uimain_confirmQuit extends MovieClip {
public var btnYes:buttonBlueGeneric;
public var btnNo:buttonBlueGeneric;
}
}//package
Section 364
//uimain_credits (uimain_credits)
package {
import flash.display.*;
public dynamic class uimain_credits extends MovieClip {
public var _seekButton:buttonSeek;
public var _soapButton:soapButton;
}
}//package
Section 365
//uimain_customface1 (uimain_customface1)
package {
import flash.display.*;
public dynamic class uimain_customface1 extends MovieClip {
public var _face:MovieClip;
public var _error:MovieClip;
public var _buttonDone:buttonBlueGeneric;
public var _buttonBrowse:buttonBlueGeneric;
public var _progress:MovieClip;
}
}//package
Section 366
//uimain_customface2 (uimain_customface2)
package {
import flash.display.*;
public dynamic class uimain_customface2 extends MovieClip {
public var _buttonDone:buttonBlueGeneric;
public var _face:mcfacemodify;
}
}//package
Section 367
//uimain_flags (uimain_flags)
package {
import flash.display.*;
public dynamic class uimain_flags extends MovieClip {
public var _ausFlag:ausFlag;
public var _nzFlag:nzFlag;
}
}//package
Section 368
//uimain_gameplayHint (uimain_gameplayHint)
package {
import flash.display.*;
public dynamic class uimain_gameplayHint extends MovieClip {
}
}//package
Section 369
//uimain_gamesummary (uimain_gamesummary)
package {
import flash.display.*;
import flash.text.*;
public dynamic class uimain_gamesummary extends MovieClip {
public var _score:TextField;
public var _submitScore:buttonBlueGeneric;
public var _summaryCopy:MovieClip;
public var _playAgain:buttonBlueGeneric;
}
}//package
Section 370
//uimain_howtoplay1 (uimain_howtoplay1)
package {
import flash.display.*;
public dynamic class uimain_howtoplay1 extends MovieClip {
}
}//package
Section 371
//uimain_introscreen (uimain_introscreen)
package {
import flash.display.*;
import flash.geom.*;
public dynamic class uimain_introscreen extends MovieClip {
public var logo:MovieClip;
public var dummy:MovieClip;
public function uimain_introscreen(){
addFrameScript(0, this.frame1, 63, this.frame64, 101, this.frame102, 151, this.frame152);
}
function frame152(){
stop();
}
function frame1(){
scrollRect = new Rectangle(0, 0, 700, 450);
}
function frame64(){
this.logo.gotoAndPlay(1);
}
function frame102(){
this.dummy.gotoAndPlay("waving");
}
}
}//package
Section 372
//uimain_jobOp (uimain_jobOp)
package {
import flash.display.*;
import flash.text.*;
public dynamic class uimain_jobOp extends MovieClip {
public var descriptionField:TextField;
}
}//package
Section 373
//uimain_leaderboard (uimain_leaderboard)
package {
import flash.display.*;
public dynamic class uimain_leaderboard extends MovieClip {
public var _row10:MovieClip;
public var _row01:MovieClip;
public var _row02:MovieClip;
public var _row03:MovieClip;
public var _row04:MovieClip;
public var _row05:MovieClip;
public var _row06:MovieClip;
public var _row07:MovieClip;
public var _row08:MovieClip;
public var _row09:MovieClip;
public var _left:htpPrevButton;
public var _right:htpNextButton;
}
}//package
Section 374
//uimain_leadin (uimain_leadin)
package {
import flash.display.*;
public dynamic class uimain_leadin extends MovieClip {
}
}//package
Section 375
//uimain_levelSelect (uimain_levelSelect)
package {
import flash.display.*;
import flash.text.*;
public dynamic class uimain_levelSelect extends MovieClip {
public var _left:htpPrevButton;
public var _ls01:levelSelecButton;
public var _ls02:levelSelecButton;
public var _ls03:levelSelecButton;
public var _ls04:levelSelecButton;
public var _ls05:levelSelecButton;
public var _ls06:levelSelecButton;
public var _right:htpNextButton;
public var _levelType:TextField;
}
}//package
Section 376
//uimain_loader (uimain_loader)
package {
import flash.display.*;
import flash.text.*;
public dynamic class uimain_loader extends MovieClip {
public var _pField:TextField;
}
}//package
Section 377
//uimain_navBar (uimain_navBar)
package {
import flash.display.*;
public dynamic class uimain_navBar extends MovieClip {
public var _sendToFriend:buttonPinkGeneric;
public var _highScores:buttonPinkGeneric;
public var visitSeek:MovieClip;
public var _visitSeekSite:MovieClip;
public var _howToPlay:buttonPinkGeneric;
public var _startGame:buttonPinkGenericLarge;
public var _embed:buttonPinkGeneric;
public var _credits:MovieClip;
public var _seekMoreGames:buttonBlueGeneric;
}
}//package
Section 378
//uimain_navBar_portal (uimain_navBar_portal)
package {
import flash.display.*;
public dynamic class uimain_navBar_portal extends MovieClip {
public var _howToPlay:buttonPinkGeneric;
public var _highScores:buttonPinkGeneric;
public var _startGame:buttonPinkGenericLarge;
public var _credits:MovieClip;
}
}//package
Section 379
//uimain_seeklogocorner (uimain_seeklogocorner)
package {
import flash.display.*;
public dynamic class uimain_seeklogocorner extends MovieClip {
public var base:MovieClip;
public var roll:MovieClip;
}
}//package
Section 380
//uimain_selectface (uimain_selectface)
package {
import flash.display.*;
public dynamic class uimain_selectface extends MovieClip {
public var _uploadFace:MovieClip;
public var _defaultFaceOne:MovieClip;
public var _defaultFaceTwo:MovieClip;
public var _defaultFaceThree:MovieClip;
}
}//package
Section 381
//uimain_sendToFriend (uimain_sendToFriend)
package {
import flash.display.*;
import flash.text.*;
public dynamic class uimain_sendToFriend extends MovieClip {
public var friendEmailX:MovieClip;
public var messageFieldX:MovieClip;
public var friendName:TextField;
public var _progress:MovieClip;
public var firstName:TextField;
public var firstNameX:MovieClip;
public var friendEmail:TextField;
public var emailAddressX:MovieClip;
public var friendNameX:MovieClip;
public var messageField:TextField;
public var sendEmail:buttonBlueGeneric;
public var emailAddress:TextField;
}
}//package
Section 382
//uimain_soundBtn (uimain_soundBtn)
package {
import flash.display.*;
public dynamic class uimain_soundBtn extends MovieClip {
public var base:MovieClip;
public var roll:MovieClip;
}
}//package
Section 383
//uimain_submitscore (uimain_submitscore)
package {
import flash.display.*;
import flash.text.*;
public dynamic class uimain_submitscore extends MovieClip {
public var _emailaddressX:MovieClip;
public var _usernameX:MovieClip;
public var _progress:MovieClip;
public var _optInBox:tickBox;
public var _score:TextField;
public var _privacyPolicy:invisBlockButton;
public var _surname:TextField;
public var _submitScore:buttonBlueGeneric;
public var _optNameBases:MovieClip;
public var _tsandcs:invisBlockButton;
public var _username:TextField;
public var _emailaddress:TextField;
public var _firstname:TextField;
}
}//package