STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
229494
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2575 · P5149

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/89244518?noj=FRM89244518-14DC" width="1" height="1"></div>

Deflection.swf

This is the info page for
Flash #28807

(Click the ID number above for more basic data on this flash file.)


ActionScript [AS3]
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.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((Math.min(p1X, p2X) - m_radius), (Math.min(p1Y, p2Y) - m_radius)); aabb.upperBound.Set((Math.max(p1X, p2X) + m_radius), (Math.max(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
//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 4
//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 5
//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++; }; } public function GetCoreVertices():Array{ return (m_coreVertices); } public function GetVertices():Array{ return (m_vertices); } 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(Math.min(aabb1.lowerBound.x, aabb2.lowerBound.x), Math.min(aabb1.lowerBound.y, aabb2.lowerBound.y)); aabb.upperBound.Set(Math.max(aabb1.upperBound.x, aabb2.upperBound.x), Math.max(aabb1.upperBound.y, aabb2.upperBound.y)); } 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) { tX = (m_vertices[i].x - p1X); tY = (m_vertices[i].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[(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 Support(xf:b2XForm, dX:Number, dY:Number):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; var bestValue:Number = ((m_coreVertices[0].x * dLocalX) + (m_coreVertices[0].y * dLocalY)); var i = 1; while (i < m_vertexCount) { value = ((m_coreVertices[i].x * dLocalX) + (m_coreVertices[i].y * dLocalY)); if (value > bestValue){ bestIndex = i; bestValue = value; }; i++; }; tMat = xf.R; var tVec:b2Vec2 = 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); } override public function UpdateSweepRadius(center:b2Vec2):void{ var dX:Number; var dY:Number; m_sweepRadius = 0; var i:int; while (i < m_vertexCount) { dX = (m_coreVertices[i].x - center.x); dY = (m_coreVertices[i].y - center.y); dX = Math.sqrt(((dX * dX) + (dY * dY))); m_sweepRadius = Math.max(m_sweepRadius, dX); i++; }; } 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)); } public function GetVertexCount():int{ return (m_vertexCount); } override public function TestPoint(xf:b2XForm, p:b2Vec2):Boolean{ 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) { tX = (pLocalX - m_vertices[i].x); tY = (pLocalY - m_vertices[i].y); dot = ((m_normals[i].x * tX) + (m_normals[i].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[(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[(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)); lowerX = Math.min(lowerX, rX); lowerY = Math.min(lowerY, rY); upperX = Math.max(upperX, rX); upperY = Math.max(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 6
//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_restitution:Number; public var m_sweepRadius:Number; public var m_userData; public var m_density:Number; public var m_proxyId:uint; public var m_friction:Number; public var m_isSensor:Boolean; public var m_groupIndex:int; public var m_categoryBits:uint; public var m_body:b2Body; public var m_maskBits:uint; 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_categoryBits = def.categoryBits; m_maskBits = def.maskBits; m_groupIndex = def.groupIndex; m_isSensor = def.isSensor; } 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 TestSegment(xf:b2XForm, lambda:Array, normal:b2Vec2, segment:b2Segment, maxLambda:Number):Boolean{ return (false); } public function IsSensor():Boolean{ return (m_isSensor); } public function ComputeMass(massData:b2MassData):void{ } 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 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 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 GetUserData(){ return (m_userData); } public function TestPoint(xf:b2XForm, p:b2Vec2):Boolean{ return (false); } public function ResetProxy(broadPhase:b2BroadPhase, transform:b2XForm):void{ if (m_proxyId != b2Pair.b2_nullProxy){ 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 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 7
//b2ShapeDef (Box2D.Collision.Shapes.b2ShapeDef) package Box2D.Collision.Shapes { public class b2ShapeDef { public var friction:Number; public var groupIndex:int; public var categoryBits:int; public var density:Number; public var restitution:Number; public var maskBits:int; public var userData;// = null public var type:int; public var isSensor:Boolean; public function b2ShapeDef(){ super(); type = b2Shape.e_unknownShape; userData = null; friction = 0.2; restitution = 0; density = 0; categoryBits = 1; maskBits = 0xFFFF; groupIndex = 0; isSensor = false; } } }//package Box2D.Collision.Shapes
Section 8
//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 9
//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 10
//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 11
//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 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); var dY:Number = (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[(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{ if ((((proxyId == b2Pair.b2_nullProxy)) || ((m_proxyPool[proxyId].IsValid() == false)))){ return (null); }; return (m_proxyPool[proxyId]); } private function IncrementTimeStamp():void{ var i:uint; if (m_timeStamp == b2Settings.USHRT_MAX){ i = 0; while (i < b2Settings.b2_maxProxies) { m_proxyPool[i].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 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) { if (bounds[j].IsLower()){ IncrementOverlapCount(bounds[j].proxyId); }; j++; }; if (lowerQuery > 0){ i = (lowerQuery - 1); s = bounds[i].stabbingCount; while (s) { if (bounds[i].IsLower()){ proxy = m_proxyPool[bounds[i].proxyId]; if (lowerQuery <= proxy.upperBounds[axis]){ IncrementOverlapCount(bounds[i].proxyId); s--; }; }; i--; }; }; lowerQueryOut[0] = lowerQuery; upperQueryOut[0] = upperQuery; } private function TestOverlapValidate(p1:b2Proxy, p2:b2Proxy):Boolean{ var bounds:Array; var axis:int; while (axis < 2) { bounds = m_bounds[axis]; if (bounds[p1.lowerBounds[axis]].value > bounds[p2.upperBounds[axis]].value){ return (false); }; if (bounds[p1.upperBounds[axis]].value < bounds[p2.lowerBounds[axis]].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 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[(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[(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[(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[(tIndex + j)]; tBound1.value = tBound2.value; tBound1.proxyId = tBound2.proxyId; tBound1.stabbingCount = tBound2.stabbingCount; j++; }; upperIndex++; bounds[lowerIndex].value = lowerValues[axis]; bounds[lowerIndex].proxyId = proxyId; bounds[upperIndex].value = upperValues[axis]; bounds[upperIndex].proxyId = proxyId; bounds[lowerIndex].stabbingCount = ((lowerIndex == 0)) ? 0 : bounds[(lowerIndex - 1)].stabbingCount; bounds[upperIndex].stabbingCount = bounds[(upperIndex - 1)].stabbingCount; index = lowerIndex; while (index < upperIndex) { bounds[index].stabbingCount++; index++; }; index = lowerIndex; while (index < (boundCount + 2)) { proxy2 = m_proxyPool[bounds[index].proxyId]; if (bounds[index].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 bounds:Array; var lowerIndex:uint; var upperIndex:uint; var lowerValue:uint; var upperValue:uint; var tArr:Array; var j:int; var tEnd:int; var tBound1:b2Bound; var tBound2:b2Bound; 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]; lowerValue = bounds[lowerIndex].value; upperValue = bounds[upperIndex].value; tArr = new Array(); tEnd = ((upperIndex - lowerIndex) - 1); j = 0; while (j < tEnd) { tArr[j] = new b2Bound(); tBound1 = tArr[j]; tBound2 = bounds[((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[(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[((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[(tIndex + j)]; tBound1.value = tBound2.value; tBound1.proxyId = tBound2.proxyId; tBound1.stabbingCount = tBound2.stabbingCount; j++; }; tEnd = (boundCount - 2); index = lowerIndex; while (index < tEnd) { proxy2 = m_proxyPool[bounds[index].proxyId]; if (bounds[index].IsLower()){ proxy2.lowerBounds[axis] = index; } else { proxy2.upperBounds[axis] = index; }; index++; }; tEnd = (upperIndex - 1); index2 = lowerIndex; while (index2 < tEnd) { bounds[index2].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 axis:int; while (axis < 2) { bounds = m_bounds[axis]; if (b.lowerValues[axis] > bounds[p.upperBounds[axis]].value){ return (false); }; if (b.upperValues[axis] < bounds[p.lowerBounds[axis]].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 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) { oldValues.lowerValues[axis] = m_bounds[axis][proxy.lowerBounds[axis]].value; oldValues.upperValues[axis] = m_bounds[axis][proxy.upperBounds[axis]].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]; deltaLower = (lowerValue - bounds[lowerIndex].value); deltaUpper = (upperValue - bounds[upperIndex].value); bounds[lowerIndex].value = lowerValue; bounds[upperIndex].value = upperValue; if (deltaLower < 0){ index = lowerIndex; while ((((index > 0)) && ((lowerValue < bounds[(index - 1)].value)))) { bound = bounds[index]; prevBound = bounds[(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); }; var _local23 = prevProxy.upperBounds; var _local24 = axis; var _local25 = (_local23[_local24] + 1); _local23[_local24] = _local25; bound.stabbingCount++; } else { _local23 = prevProxy.lowerBounds; _local24 = axis; _local25 = (_local23[_local24] + 1); _local23[_local24] = _local25; bound.stabbingCount--; }; _local23 = proxy.lowerBounds; _local24 = axis; _local25 = (_local23[_local24] - 1); _local23[_local24] = _local25; bound.Swap(prevBound); index--; }; }; if (deltaUpper > 0){ index = upperIndex; while ((((index < (boundCount - 1))) && ((bounds[(index + 1)].value <= upperValue)))) { bound = bounds[index]; nextBound = bounds[(index + 1)]; nextProxyId = nextBound.proxyId; nextProxy = m_proxyPool[nextProxyId]; nextBound.stabbingCount++; if (nextBound.IsLower() == true){ if (TestOverlap(newValues, nextProxy)){ m_pairManager.AddBufferedPair(proxyId, nextProxyId); }; _local23 = nextProxy.lowerBounds; _local24 = axis; _local25 = (_local23[_local24] - 1); _local23[_local24] = _local25; bound.stabbingCount++; } else { _local23 = nextProxy.upperBounds; _local24 = axis; _local25 = (_local23[_local24] - 1); _local23[_local24] = _local25; bound.stabbingCount--; }; _local23 = proxy.upperBounds; _local24 = axis; _local25 = (_local23[_local24] + 1); _local23[_local24] = _local25; bound.Swap(nextBound); index++; }; }; if (deltaLower > 0){ index = lowerIndex; while ((((index < (boundCount - 1))) && ((bounds[(index + 1)].value <= lowerValue)))) { bound = bounds[index]; nextBound = bounds[(index + 1)]; nextProxyId = nextBound.proxyId; nextProxy = m_proxyPool[nextProxyId]; nextBound.stabbingCount--; if (nextBound.IsUpper()){ if (TestOverlap(oldValues, nextProxy)){ m_pairManager.RemoveBufferedPair(proxyId, nextProxyId); }; _local23 = nextProxy.upperBounds; _local24 = axis; _local25 = (_local23[_local24] - 1); _local23[_local24] = _local25; bound.stabbingCount--; } else { _local23 = nextProxy.lowerBounds; _local24 = axis; _local25 = (_local23[_local24] - 1); _local23[_local24] = _local25; bound.stabbingCount++; }; _local23 = proxy.lowerBounds; _local24 = axis; _local25 = (_local23[_local24] + 1); _local23[_local24] = _local25; bound.Swap(nextBound); index++; }; }; if (deltaUpper < 0){ index = upperIndex; while ((((index > 0)) && ((upperValue < bounds[(index - 1)].value)))) { bound = bounds[index]; prevBound = bounds[(index - 1)]; prevProxyId = prevBound.proxyId; prevProxy = m_proxyPool[prevProxyId]; prevBound.stabbingCount--; if (prevBound.IsLower() == true){ if (TestOverlap(oldValues, prevProxy)){ m_pairManager.RemoveBufferedPair(proxyId, prevProxyId); }; _local23 = prevProxy.lowerBounds; _local24 = axis; _local25 = (_local23[_local24] + 1); _local23[_local24] = _local25; bound.stabbingCount--; } else { _local23 = prevProxy.upperBounds; _local24 = axis; _local25 = (_local23[_local24] + 1); _local23[_local24] = _local25; bound.stabbingCount++; }; _local23 = proxy.upperBounds; _local24 = axis; _local25 = (_local23[_local24] - 1); _local23[_local24] = _local25; bound.Swap(prevBound); index--; }; }; axis++; }; } public static function BinarySearch(bounds:Array, count:int, value:uint):uint{ var mid:int; var low:int; var high:int = (count - 1); while (low <= high) { mid = ((low + high) / 2); if (bounds[mid].value > value){ high = (mid - 1); } else { if (bounds[mid].value < value){ low = (mid + 1); } else { return (uint(mid)); }; }; }; return (uint(low)); } } }//package Box2D.Collision
Section 12
//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 13
//b2Collision (Box2D.Collision.b2Collision) package Box2D.Collision { import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; import Box2D.Common.*; public class b2Collision { public static const b2_nullFeature:uint = 0xFF; public static const b2_oldPoint:uint = 4; public static const b2_newPoint:uint = 2; 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; tMat = xf1.R; tVec = poly1.m_normals[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 < poly2.m_vertexCount) { tVec = poly2.m_vertices[i]; dot = ((tVec.x * normal1X) + (tVec.y * normal1Y)); if (dot < minDot){ minDot = dot; index = i; }; i++; }; tVec = poly1.m_vertices[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 = poly2.m_vertices[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; tMat = xf1.R; tVec = poly1.m_normals[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 < poly2.m_vertexCount) { tVec = poly2.m_normals[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) < poly2.m_vertexCount)) ? (i1 + 1) : 0; tClip = c[0]; tVec = poly2.m_vertices[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.referenceFace = edge1; tClip.id.features.incidentEdge = i1; tClip.id.features.incidentVertex = 0; tClip = c[1]; tVec = poly2.m_vertices[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.referenceFace = 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 poly1:b2PolygonShape; var poly2:b2PolygonShape; var edge1:int; var flip:uint; var np:int; 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 vert1s:Array = poly1.m_vertices; var v11:b2Vec2 = vert1s[edge1].Copy(); var v12:b2Vec2 = (((edge1 + 1) < count1)) ? vert1s[(edge1 + 1)].Copy() : vert1s[0].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) { separation = (b2Math.b2Dot(frontNormal, clipPoints2[i].v) - frontOffset); if (separation <= 0){ cp = manifold.points[pointCount]; cp.separation = separation; cp.localPoint1 = b2Math.b2MulXT(xfA, clipPoints2[i].v); cp.localPoint2 = b2Math.b2MulXT(xfB, clipPoints2[i].v); cp.id.key = clipPoints2[i].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; 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) { dot = ((poly1.m_normals[i].x * dLocal1X) + (poly1.m_normals[i].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 vIn1:b2Vec2; var distance0:Number; var interp:Number; var tVec:b2Vec2; var numOut:int; var vIn0:b2Vec2 = vIn[0].v; vIn1 = vIn[1].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 _local12 = _temp1; vOut[_local12] = vIn[0]; }; if (distance1 <= 0){ var _temp2 = numOut; numOut = (numOut + 1); _local12 = _temp2; vOut[_local12] = vIn[1]; }; if ((distance0 * distance1) < 0){ interp = (distance0 / (distance0 - distance1)); tVec = vOut[numOut].v; tVec.x = (vIn0.x + (interp * (vIn1.x - vIn0.x))); tVec.y = (vIn0.y + (interp * (vIn1.y - vIn0.y))); if (distance0 > 0){ vOut[numOut].id = vIn[0].id; } else { vOut[numOut].id = vIn[1].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 radiusSum:Number = (circle1.m_radius + circle2.m_radius); 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 + (circle1.m_radius * manifold.normal.x)); p1Y = (p1Y + (circle1.m_radius * manifold.normal.y)); p2X = (p2X - (circle2.m_radius * manifold.normal.x)); p2Y = (p2Y - (circle2.m_radius * 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 i:int; while (i < polygon.m_vertexCount) { dX = (cLocalX - polygon.m_vertices[i].x); dY = (cLocalY - polygon.m_vertices[i].y); s = ((polygon.m_normals[i].x * dX) + (polygon.m_normals[i].y * dY)); if (s > radius){ return; }; if (s > separation){ separation = s; normalIndex = i; }; i++; }; if (separation < Number.MIN_VALUE){ manifold.pointCount = 1; tVec = polygon.m_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.referenceFace = b2_nullFeature; 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) < polygon.m_vertexCount)) ? (vertIndex1 + 1) : 0; var eX:Number = (polygon.m_vertices[vertIndex2].x - polygon.m_vertices[vertIndex1].x); var eY:Number = (polygon.m_vertices[vertIndex2].y - polygon.m_vertices[vertIndex1].y); var length:Number = Math.sqrt(((eX * eX) + (eY * eY))); eX = (eX / length); eY = (eY / length); if (length < Number.MIN_VALUE){ dX = (cLocalX - polygon.m_vertices[vertIndex1].x); dY = (cLocalY - polygon.m_vertices[vertIndex1].y); 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)); tPoint = manifold.points[0]; tPoint.id.features.incidentEdge = b2_nullFeature; tPoint.id.features.incidentVertex = vertIndex1; tPoint.id.features.referenceFace = b2_nullFeature; 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 = (dist - radius); return; }; dX = (cLocalX - polygon.m_vertices[vertIndex1].x); dY = (cLocalY - polygon.m_vertices[vertIndex1].y); var u:Number = ((dX * eX) + (dY * eY)); tPoint = manifold.points[0]; tPoint.id.features.incidentEdge = b2_nullFeature; tPoint.id.features.incidentVertex = b2_nullFeature; tPoint.id.features.referenceFace = b2_nullFeature; tPoint.id.features.flip = 0; if (u <= 0){ pX = polygon.m_vertices[vertIndex1].x; pY = polygon.m_vertices[vertIndex1].y; tPoint.id.features.incidentVertex = vertIndex1; } else { if (u >= length){ pX = polygon.m_vertices[vertIndex2].x; pY = polygon.m_vertices[vertIndex2].y; tPoint.id.features.incidentVertex = vertIndex2; } else { pX = ((eX * u) + polygon.m_vertices[vertIndex1].x); pY = ((eY * u) + polygon.m_vertices[vertIndex1].y); tPoint.id.features.incidentEdge = vertIndex1; }; }; 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); } } }//package Box2D.Collision
Section 14
//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._referenceFace = (_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 15
//b2ContactPoint (Box2D.Collision.b2ContactPoint) package Box2D.Collision { import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; public class b2ContactPoint { public var normalForce:Number; public var separation:Number; public var normal:b2Vec2; public var position:b2Vec2; public var tangentForce:Number; public var shape1:b2Shape; public var shape2:b2Shape; public var id:b2ContactID; public function b2ContactPoint(){ position = new b2Vec2(); normal = new b2Vec2(); id = new b2ContactID(); super(); } } }//package Box2D.Collision
Section 16
//b2Distance (Box2D.Collision.b2Distance) package Box2D.Collision { import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; 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 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) { 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 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: p1s[0].SetV(w1); p2s[0].SetV(w2); points[0].Set(wX, wY); x1.SetV(p1s[0]); x2.SetV(p2s[0]); pointCount++; break; case 1: p1s[1].SetV(w1); p2s[1].SetV(w2); points[1].x = wX; points[1].y = wY; pointCount = ProcessTwo(x1, x2, p1s, p2s, points); break; case 2: p1s[2].SetV(w1); p2s[2].SetV(w2); points[2].x = wX; points[2].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) { maxSqr = b2Math.b2Max(maxSqr, ((points[i].x * points[i].x) + (points[i].y * points[i].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 lambda:Number; 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)))){ 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)))){ 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.GetRadius() - 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.GetType(); var type2:int = shape2.GetType(); 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 lambda:Number; 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 17
//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 18
//b2ManifoldPoint (Box2D.Collision.b2ManifoldPoint) package Box2D.Collision { import Box2D.Common.Math.*; public class b2ManifoldPoint { public var normalForce:Number; public var tangentForce:Number; public var id:b2ContactID; public var separation:Number; public var localPoint2:b2Vec2; public var localPoint1:b2Vec2; 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; normalForce = m.normalForce; tangentForce = m.tangentForce; id.key = m.id.key; } public function Reset():void{ localPoint1.SetZero(); localPoint2.SetZero(); separation = 0; normalForce = 0; tangentForce = 0; id.key = 0; } } }//package Box2D.Collision
Section 19
//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 20
//b2Pair (Box2D.Collision.b2Pair) package Box2D.Collision { 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 = 0xFFFF; public static var e_pairBuffered:uint = 1; public static var b2_nullProxy:uint = 0xFFFF; public static var b2_tableCapacity:int = 4096; 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 21
//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 22
//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[(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 index:uint = m_hashTable[hash]; while (((!((index == b2Pair.b2_nullPair))) && ((Equals(m_pairs[index], proxyId1, proxyId2) == false)))) { index = m_pairs[index].next; }; if (index == b2Pair.b2_nullPair){ return (null); }; return (m_pairs[index]); } 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 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) { pair = Find(m_pairBuffer[i].proxyId1, m_pairBuffer[i].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); }; m_pairBuffer[removeCount].proxyId1 = pair.proxyId1; m_pairBuffer[removeCount].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) { RemovePair(m_pairBuffer[i].proxyId1, m_pairBuffer[i].proxyId2); i++; }; m_pairBufferCount = 0; if (b2BroadPhase.s_validate){ ValidateTable(); }; } public function RemoveBufferedPair(proxyId1:int, proxyId2:int):void{ var pair:b2Pair = Find(proxyId1, proxyId2); if (pair == null){ return; }; if (pair.IsBuffered() == false){ pair.SetBuffered(); m_pairBuffer[m_pairBufferCount].proxyId1 = pair.proxyId1; m_pairBuffer[m_pairBufferCount].proxyId2 = pair.proxyId2; m_pairBufferCount++; }; pair.SetRemoved(); if (b2BroadPhase.s_validate){ ValidateBuffer(); }; } private function RemovePair(proxyId1:uint, proxyId2:uint){ var temp:uint; var index:uint; var pair:b2Pair; 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; if (pNode){ pNode.next = m_pairs[node].next; } else { m_hashTable[hash] = m_pairs[node].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 pair:b2Pair = AddPair(proxyId1, proxyId2); if (pair.IsBuffered() == false){ pair.SetBuffered(); m_pairBuffer[m_pairBufferCount].proxyId1 = pair.proxyId1; m_pairBuffer[m_pairBufferCount].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 23
//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 24
//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 25
//b2Segment (Box2D.Collision.b2Segment) package Box2D.Collision { import Box2D.Common.Math.*; 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 26
//b2TimeOfImpact (Box2D.Collision.b2TimeOfImpact) package Box2D.Collision { import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; 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 t:Number; var xf1:b2XForm; var xf2:b2XForm; var nLen:Number; var approachVelocityBound:Number; var dAlpha:Number; var newAlpha:Number; var r1:Number = shape1.GetSweepRadius(); var r2:Number = shape2.GetSweepRadius(); 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 { targetDistance = Math.max((0.05 * b2Settings.b2_toiSlop), (distance - (0.5 * b2Settings.b2_toiSlop))); }; }; 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))) + (Math.abs(omega1) * r1)) + (Math.abs(omega2) * r2)); if (Math.abs(approachVelocityBound) < Number.MIN_VALUE){ 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 27
//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 28
//Features (Box2D.Collision.Features) package Box2D.Collision { public class Features { public var _referenceFace: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 referenceFace():int{ return (_referenceFace); } 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 referenceFace(value:int):void{ _referenceFace = value; _m_id._key = ((_m_id._key & 4294967040) | (_referenceFace & 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 29
//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 30
//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 31
//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 32
//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{ x = Math.abs(x); y = Math.abs(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 33
//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 34
//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 35
//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 36
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact) package Box2D.Dynamics.Contacts { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; 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 var 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; m_manifold.points[0].normalForce = 0; m_manifold.points[0].tangentForce = 0; } override public function Evaluate(listener:b2ContactListener):void{ var cp:b2ContactPoint; var tMat:b2Mat22; var tVec:b2Vec2; 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); if (m_manifold.pointCount > 0){ m_manifoldCount = 1; if (m0.pointCount == 0){ m_manifold.points[0].id.features.flip = (m_manifold.points[0].id.features.flip | b2Collision.b2_newPoint); } else { m_manifold.points[0].id.features.flip = (m_manifold.points[0].id.features.flip & ~(b2Collision.b2_newPoint)); }; } else { m_manifoldCount = 0; if ((((m0.pointCount > 0)) && (listener))){ cp = s_evalCP; cp.shape1 = m_shape1; cp.shape2 = m_shape2; cp.normal.SetV(m0.normal); tMat = b1.m_xf.R; tVec = m0.points[0].localPoint1; cp.position.x = (b1.m_xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y))); cp.position.y = (b1.m_xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y))); cp.separation = m0.points[0].separation; cp.normalForce = m0.points[0].normalForce; cp.tangentForce = m0.points[0].tangentForce; cp.id.key = m0.points[0].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 37
//b2Contact (Box2D.Dynamics.Contacts.b2Contact) package Box2D.Dynamics.Contacts { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; 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{ Evaluate(listener); var body1:b2Body = m_shape1.GetBody(); var body2:b2Body = m_shape2.GetBody(); 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.GetManifoldCount() > 0){ contact.GetShape1().GetBody().WakeUp(); contact.GetShape2().GetBody().WakeUp(); }; var type1:int = contact.GetShape1().GetType(); var type2:int = contact.GetShape2().GetType(); var destroyFcn:* = s_registers[type1][type2].destroyFcn; destroyFcn(contact, allocator); } public static function AddType(createFcn, destroyFcn, 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 createFcn:* = s_registers[type1][type2].createFcn; if (createFcn){ if (s_registers[type1][type2].primary){ return (createFcn(shape1, shape2, allocator)); }; c = createFcn(shape2, shape1, allocator); i = 0; while (i < c.GetManifoldCount()) { m = c.GetManifolds()[i]; m.normal = m.normal.Negative(); i++; }; return (c); //unresolved jump }; return (null); } } }//package Box2D.Dynamics.Contacts
Section 38
//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 39
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint) package Box2D.Dynamics.Contacts { import Box2D.Common.Math.*; public class b2ContactConstraintPoint { public var tangentForce:Number; public var normalForce:Number; public var positionImpulse:Number; public var separation:Number; public var localAnchor1:b2Vec2; public var localAnchor2:b2Vec2; public var tangentMass:Number; public var normalMass:Number; public var velocityBias:Number; public var equalizedMass:Number; public function b2ContactConstraintPoint(){ localAnchor1 = new b2Vec2(); localAnchor2 = new b2Vec2(); super(); } } }//package Box2D.Dynamics.Contacts
Section 40
//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 41
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister) package Box2D.Dynamics.Contacts { public class b2ContactRegister { public var primary:Boolean; public var createFcn; public var destroyFcn; public function b2ContactRegister(){ super(); } } }//package Box2D.Dynamics.Contacts
Section 42
//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 i:int; var tVec:b2Vec2; var tMat:b2Mat22; var contact:b2Contact; 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) { m_constraintCount = (m_constraintCount + contacts[i].GetManifoldCount()); 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.GetManifoldCount(); 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.normalForce = cp.normalForce; ccp.tangentForce = cp.tangentForce; ccp.separation = cp.separation; ccp.positionImpulse = 0; ccp.localAnchor1.SetV(cp.localPoint1); ccp.localAnchor2.SetV(cp.localPoint2); tMat = b1.m_xf.R; r1X = (ccp.localAnchor1.x - b1.GetLocalCenter().x); r1Y = (ccp.localAnchor1.y - b1.GetLocalCenter().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 = (ccp.localAnchor2.x - b2.GetLocalCenter().x); r2Y = (ccp.localAnchor2.y - b2.GetLocalCenter().y); tX = ((tMat.col1.x * r2X) + (tMat.col2.x * r2Y)); r2Y = ((tMat.col1.y * r2X) + (tMat.col2.y * r2Y)); r2X = tX; 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():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 r1X:Number; var r1Y:Number; var r2X:Number; var r2Y: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 (b2World.s_enableWarmStarting){ tCount = c.pointCount; j = 0; while (j < tCount) { ccp = c.points[j]; PX = (m_step.dt * ((ccp.normalForce * normalX) + (ccp.tangentForce * tangentX))); PY = (m_step.dt * ((ccp.normalForce * normalY) + (ccp.tangentForce * tangentY))); tMat = b1.m_xf.R; tVec = b1.GetLocalCenter(); 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.GetLocalCenter(); 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; b1.m_angularVelocity = (b1.m_angularVelocity - (invI1 * ((r1X * PY) - (r1Y * 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 * ((r2X * PY) - (r2Y * 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.normalForce = 0; ccp2.tangentForce = 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.GetLocalCenter(); 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.GetLocalCenter(); 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 lambda:Number; var newImpulse:Number; var PX:Number; var PY:Number; var tMat:b2Mat22; var tVec:b2Vec2; var c:b2ContactConstraint; var b1:b2Body; var b2:b2Body; var b1_angularVelocity:Number; var b1_linearVelocity:b2Vec2; var b2_angularVelocity:Number; var b2_linearVelocity: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 tX:Number; var tCount:int; var vn:Number; var newForce:Number; var vt:Number; var maxFriction:Number; var i:int; while (i < m_constraintCount) { c = m_constraints[i]; b1 = c.body1; b2 = c.body2; b1_angularVelocity = b1.m_angularVelocity; b1_linearVelocity = b1.m_linearVelocity; b2_angularVelocity = b2.m_angularVelocity; b2_linearVelocity = 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); tCount = c.pointCount; j = 0; while (j < tCount) { ccp = c.points[j]; tMat = b1.m_xf.R; tVec = b1.GetLocalCenter(); 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.GetLocalCenter(); 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; dvX = (((b2_linearVelocity.x + (-(b2_angularVelocity) * r2Y)) - b1_linearVelocity.x) - (-(b1_angularVelocity) * r1Y)); dvY = (((b2_linearVelocity.y + (b2_angularVelocity * r2X)) - b1_linearVelocity.y) - (b1_angularVelocity * r1X)); vn = ((dvX * normalX) + (dvY * normalY)); lambda = ((-(m_step.inv_dt) * ccp.normalMass) * (vn - ccp.velocityBias)); newForce = b2Math.b2Max((ccp.normalForce + lambda), 0); lambda = (newForce - ccp.normalForce); PX = ((m_step.dt * lambda) * normalX); PY = ((m_step.dt * lambda) * normalY); b1_linearVelocity.x = (b1_linearVelocity.x - (invMass1 * PX)); b1_linearVelocity.y = (b1_linearVelocity.y - (invMass1 * PY)); b1_angularVelocity = (b1_angularVelocity - (invI1 * ((r1X * PY) - (r1Y * PX)))); b2_linearVelocity.x = (b2_linearVelocity.x + (invMass2 * PX)); b2_linearVelocity.y = (b2_linearVelocity.y + (invMass2 * PY)); b2_angularVelocity = (b2_angularVelocity + (invI2 * ((r2X * PY) - (r2Y * PX)))); ccp.normalForce = newForce; dvX = (((b2_linearVelocity.x + (-(b2_angularVelocity) * r2Y)) - b1_linearVelocity.x) - (-(b1_angularVelocity) * r1Y)); dvY = (((b2_linearVelocity.y + (b2_angularVelocity * r2X)) - b1_linearVelocity.y) - (b1_angularVelocity * r1X)); vt = ((dvX * tangentX) + (dvY * tangentY)); lambda = ((m_step.inv_dt * ccp.tangentMass) * -(vt)); maxFriction = (c.friction * ccp.normalForce); newForce = b2Math.b2Clamp((ccp.tangentForce + lambda), -(maxFriction), maxFriction); lambda = (newForce - ccp.tangentForce); PX = ((m_step.dt * lambda) * tangentX); PY = ((m_step.dt * lambda) * tangentY); b1_linearVelocity.x = (b1_linearVelocity.x - (invMass1 * PX)); b1_linearVelocity.y = (b1_linearVelocity.y - (invMass1 * PY)); b1_angularVelocity = (b1_angularVelocity - (invI1 * ((r1X * PY) - (r1Y * PX)))); b2_linearVelocity.x = (b2_linearVelocity.x + (invMass2 * PX)); b2_linearVelocity.y = (b2_linearVelocity.y + (invMass2 * PY)); b2_angularVelocity = (b2_angularVelocity + (invI2 * ((r2X * PY) - (r2Y * PX)))); ccp.tangentForce = newForce; j++; }; b1.m_angularVelocity = b1_angularVelocity; b2.m_angularVelocity = b2_angularVelocity; i++; }; } public function FinalizeVelocityConstraints():void{ var c:b2ContactConstraint; var m:b2Manifold; var j:int; var i:int; while (i < m_constraintCount) { c = m_constraints[i]; m = c.manifold; j = 0; while (j < c.pointCount) { m.points[j].normalForce = c.points[j].normalForce; m.points[j].tangentForce = c.points[j].tangentForce; j++; }; i++; }; } } }//package Box2D.Dynamics.Contacts
Section 43
//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 44
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact) package Box2D.Dynamics.Contacts { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; 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 var 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; m_manifold.points[0].normalForce = 0; m_manifold.points[0].tangentForce = 0; } override public function Evaluate(listener:b2ContactListener):void{ var cp:b2ContactPoint; var tMat:b2Mat22; var tVec:b2Vec2; var b1:b2Body = m_shape1.GetBody(); var b2:b2Body = m_shape2.GetBody(); m0.Set(m_manifold); b2Collision.b2CollidePolygonAndCircle(m_manifold, (m_shape1 as b2PolygonShape), b1.m_xf, (m_shape2 as b2CircleShape), b2.m_xf); if (m_manifold.pointCount > 0){ m_manifoldCount = 1; if (m0.pointCount == 0){ m_manifold.points[0].id.features.flip = (m_manifold.points[0].id.features.flip | b2Collision.b2_newPoint); } else { m_manifold.points[0].id.features.flip = (m_manifold.points[0].id.features.flip & ~(b2Collision.b2_newPoint)); }; } else { m_manifoldCount = 0; if ((((m0.pointCount > 0)) && (listener))){ cp = s_evalCP; cp.shape1 = m_shape1; cp.shape2 = m_shape2; cp.normal.SetV(m0.normal); tMat = b1.m_xf.R; tVec = m0.points[0].localPoint1; cp.position.x = (b1.m_xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y))); cp.position.y = (b1.m_xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y))); cp.separation = m0.points[0].separation; cp.normalForce = m0.points[0].normalForce; cp.tangentForce = m0.points[0].tangentForce; cp.id = m0.points[0].id; 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 b2PolyAndCircleContact(shape1, shape2)); } } }//package Box2D.Dynamics.Contacts
Section 45
//b2PolygonContact (Box2D.Dynamics.Contacts.b2PolygonContact) package Box2D.Dynamics.Contacts { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; import Box2D.Collision.*; public class b2PolygonContact extends b2Contact { private var m_manifolds:Array; private var m0:b2Manifold; public var m_manifold:b2Manifold; private static var 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 cp:b2ContactPoint; var i:int; var mp:b2ManifoldPoint; var matched:Boolean; var idKey:uint; var j:int; var cp0:b2ManifoldPoint; var id0:b2ContactID; var mp0:b2ManifoldPoint; var tMat:b2Mat22; var tVec:b2Vec2; var b1:b2Body = m_shape1.GetBody(); var b2:b2Body = m_shape2.GetBody(); m0.Set(m_manifold); b2Collision.b2CollidePolygons(m_manifold, (m_shape1 as b2PolygonShape), b1.m_xf, (m_shape2 as b2PolygonShape), b2.m_xf); var match:Array = [false, false]; if (m_manifold.pointCount > 0){ i = 0; while (i < m_manifold.pointCount) { mp = m_manifold.points[i]; mp.normalForce = 0; mp.tangentForce = 0; matched = false; idKey = mp.id.key; j = 0; while (j < m0.pointCount) { if (match[j] == true){ } else { cp0 = m0.points[j]; id0 = cp0.id; id0.features.flip = (id0.features.flip & ~(b2Collision.b2_newPoint)); if (id0.key == idKey){ match[j] = true; mp.normalForce = cp0.normalForce; mp.tangentForce = cp0.tangentForce; matched = true; break; }; }; j++; }; if (matched == false){ mp.id.features.flip = (mp.id.features.flip | b2Collision.b2_newPoint); }; i++; }; m_manifoldCount = 1; } else { m_manifoldCount = 0; }; if (((listener) && ((m0.pointCount > 0)))){ cp = s_evalCP; cp.shape1 = m_shape1; cp.shape2 = m_shape2; cp.normal.SetV(m0.normal); i = 0; while (i < m0.pointCount) { if (match[i]){ } else { mp0 = m0.points[i]; tMat = b1.m_xf.R; tVec = mp0.localPoint1; cp.position.x = (b1.m_xf.position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y))); cp.position.y = (b1.m_xf.position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y))); cp.separation = mp0.separation; cp.normalForce = mp0.normalForce; cp.tangentForce = mp0.tangentForce; 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 46
//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_u:b2Vec2; public var m_length:Number; public var m_force:Number; public var m_mass: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_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 GetReactionTorque():Number{ return (0); } override public function GetReactionForce():b2Vec2{ var F:b2Vec2 = new b2Vec2(); F.SetV(m_u); F.Multiply(m_force); return (F); } override public function SolvePositionConstraints():Boolean{ 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.GetLocalCenter().x); var r1Y:Number = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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 InitVelocityConstraints(step:b2TimeStep):void{ var tMat:b2Mat22; var tX:Number; var b1:b2Body; var b2:b2Body; var r1X:Number; var r1Y:Number; var r2X:Number; var PX:Number; var PY:Number; b1 = m_body1; b2 = m_body2; tMat = b1.m_xf.R; r1X = (m_localAnchor1.x - b1.GetLocalCenter().x); r1Y = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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); m_u.y = ((b2.m_sweep.c.y + r2Y) - b1.m_sweep.c.y); 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)); m_mass = (((b1.m_invMass + ((b1.m_invI * cr1u) * cr1u)) + b2.m_invMass) + ((b2.m_invI * cr2u) * cr2u)); m_mass = (1 / m_mass); if (b2World.s_enableWarmStarting){ PX = ((step.dt * m_force) * m_u.x); PY = ((step.dt * m_force) * 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_force = 0; }; } override public function SolveVelocityConstraints(step:b2TimeStep):void{ var tMat:b2Mat22; var b1:b2Body; b1 = m_body1; var b2:b2Body = m_body2; tMat = b1.m_xf.R; var r1X:Number = (m_localAnchor1.x - b1.GetLocalCenter().x); var r1Y:Number = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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 force:Number = ((-(step.inv_dt) * m_mass) * Cdot); m_force = (m_force + force); var PX:Number = ((step.dt * force) * m_u.x); var PY:Number = ((step.dt * force) * 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 47
//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 localAnchor2:b2Vec2; public function b2DistanceJointDef(){ localAnchor1 = new b2Vec2(); localAnchor2 = new b2Vec2(); super(); type = b2Joint.e_distanceJoint; length = 1; } 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))); } } }//package Box2D.Dynamics.Joints
Section 48
//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); 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 (def.joint1.m_type == 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 (def.joint2.m_type == 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 b1:b2Body; var b2:b2Body; 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; b1 = m_body1; b2 = 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.GetLocalCenter().x); rY = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); rY = (m_localAnchor2.y - b2.GetLocalCenter().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 (b2World.s_enableWarmStarting){ 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.GetLocalCenter().x); var rY:Number = (m_localAnchor1.y - m_body2.GetLocalCenter().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 49
//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 50
//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 51
//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_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_userData; public var m_body1:b2Body; 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 InitPositionConstraints():void{ } 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 GetBody1():b2Body{ return (m_body1); } public function SolveVelocityConstraints(step:b2TimeStep):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 52
//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 53
//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 54
//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_mass:b2Mat22; public var m_beta:Number; public var m_force:b2Vec2; private var K2:b2Mat22; public var m_target:b2Vec2; public var m_gamma:Number; 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_force = 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_force.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 = ((mass * omega) * omega); m_gamma = (1 / (d + (def.timeStep * k))); m_beta = ((def.timeStep * k) / (d + (def.timeStep * 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.GetLocalCenter().x); rY = (m_localAnchor.y - b.GetLocalCenter().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_force.x); var PY:Number = (step.dt * m_force.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_force); } 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.GetLocalCenter().x); var rY:Number = (m_localAnchor.y - b.GetLocalCenter().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_force.x)); tY = ((CdotY + ((m_beta * step.inv_dt) * m_C.y)) + ((m_gamma * step.dt) * m_force.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_force.x; var oldForceY:Number = m_force.y; m_force.x = (m_force.x + forceX); m_force.y = (m_force.y + forceY); var forceMagnitude:Number = m_force.Length(); if (forceMagnitude > m_maxForce){ m_force.Multiply((m_maxForce / forceMagnitude)); }; forceX = (m_force.x - oldForceX); forceY = (m_force.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 55
//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 56
//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.GetLocalCenter().x); var r1Y:Number = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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.GetLocalCenter().x); r1Y = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); r2Y = (m_localAnchor2.y - b2.GetLocalCenter().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.GetLocalCenter().x); var r1Y:Number = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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.GetLocalCenter().x); var r1Y:Number = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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 (b2World.s_enableWarmStarting){ 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 57
//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 58
//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.GetLocalCenter().x); r1Y = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); r2Y = (m_localAnchor2.y - b2.GetLocalCenter().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.GetLocalCenter().x); r1Y = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); r2Y = (m_localAnchor2.y - b2.GetLocalCenter().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.GetLocalCenter().x); var r1Y:Number = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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 (b2World.s_enableWarmStarting){ 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.GetLocalCenter().x); var r1Y:Number = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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 59
//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 60
//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.GetLocalCenter().x); var r1Y:Number = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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.GetLocalCenter().x); var r1Y:Number = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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.GetLocalCenter().x); r1Y = (m_localAnchor1.y - b1.GetLocalCenter().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.GetLocalCenter().x); var r2Y:Number = (m_localAnchor2.y - b2.GetLocalCenter().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 (b2World.s_enableWarmStarting){ 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 61
//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 62
//b2Body (Box2D.Dynamics.b2Body) package Box2D.Dynamics { import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; import Box2D.Dynamics.Joints.*; import Box2D.Dynamics.Contacts.*; public class b2Body { public var m_xf:b2XForm; public var m_next:b2Body; public var m_contactList:b2ContactEdge; public var m_angularVelocity:Number; public var m_shapeList:b2Shape; public var m_force:b2Vec2; public var m_sweep:b2Sweep; public var m_mass:Number; public var m_torque:Number; public var m_userData; public var m_linearVelocity:b2Vec2; public var m_flags:uint; public var m_invI:Number; public var m_world:b2World; public var m_prev:b2Body; public var m_invMass:Number; public var m_type:uint; public var m_linearDamping:Number; public var m_shapeCount:int; public var m_angularDamping:Number; 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, type:uint, 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_type = type; 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_mass = 0; m_invMass = 0; m_I = 0; m_invI = 0; if (m_type == e_dynamicType){ m_mass = bd.massData.mass; }; if (m_mass > 0){ m_invMass = (1 / m_mass); }; if (((((m_flags & b2Body.e_fixedRotationFlag) == 0)) && ((m_type == e_dynamicType)))){ m_I = bd.massData.I; }; if (m_I > 0){ m_invI = (1 / m_I); }; m_userData = bd.userData; m_shapeList = null; m_shapeCount = 0; } 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 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 GetLinearVelocity():b2Vec2{ return (m_linearVelocity); } 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; }; if (m_type == e_staticType){ 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); } else { m_invMass = 0; m_invI = 0; }; 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; }; } 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 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 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 GetContactList():b2ContactEdge{ return (m_contactList); } public function GetAngularVelocity():Number{ return (m_angularVelocity); } public function GetMass():Number{ return (m_mass); } public function GetShapeList():b2Shape{ return (m_shapeList); } public function GetLocalPoint(worldPoint:b2Vec2):b2Vec2{ return (b2Math.b2MulXT(m_xf, worldPoint)); } public function SetAngularVelocity(omega:Number):void{ m_angularVelocity = omega; } public function SetMass(massData:b2MassData):void{ var tMat:b2Mat22; if (m_world.m_lock == true){ return; }; if (m_type == e_staticType){ return; }; m_mass = 0; 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); tMat = 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); var s:b2Shape = m_shapeList; while (s) { s.UpdateSweepRadius(m_sweep.localCenter); 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 GetNext():b2Body{ return (m_next); } 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{ if (m_world.m_lock == true){ return (null); }; var s:b2Shape = 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 found:Boolean; while (node != null) { if (node == s){ node = s.m_next; found = true; break; }; 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 GetLocalVector(worldVector:b2Vec2):b2Vec2{ return (b2Math.b2MulTMV(m_xf.R, worldVector)); } public function GetWorldPoint(localPoint:b2Vec2):b2Vec2{ return (b2Math.b2MulX(m_xf, localPoint)); } public function GetPosition():b2Vec2{ return (m_xf.position); } } }//package Box2D.Dynamics
Section 63
//b2BodyDef (Box2D.Dynamics.b2BodyDef) package Box2D.Dynamics { import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; 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 64
//b2BoundaryListener (Box2D.Dynamics.b2BoundaryListener) package Box2D.Dynamics { public class b2BoundaryListener { public function b2BoundaryListener(){ super(); } public function Violation(body:b2Body):void{ } } }//package Box2D.Dynamics
Section 65
//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{ if ((((shape1.m_groupIndex == shape2.m_groupIndex)) && (!((shape1.m_groupIndex == 0))))){ return ((shape1.m_groupIndex > 0)); }; var collide:Boolean = ((!(((shape1.m_maskBits & shape2.m_categoryBits) == 0))) && (!(((shape1.m_categoryBits & shape2.m_maskBits) == 0)))); return (collide); } } }//package Box2D.Dynamics
Section 66
//b2ContactListener (Box2D.Dynamics.b2ContactListener) package Box2D.Dynamics { import Box2D.Collision.*; 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{ } } }//package Box2D.Dynamics
Section 67
//b2ContactManager (Box2D.Dynamics.b2ContactManager) package Box2D.Dynamics { import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; import Box2D.Dynamics.Contacts.*; import Box2D.Collision.*; public class b2ContactManager extends b2PairCallback { public var m_world:b2World; public var m_destroyImmediate:Boolean; public var m_nullContact:b2NullContact; 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 cp:b2ContactPoint; var b1:b2Body; var manifolds:Array; var i:int; var manifold:b2Manifold; var j:int; var point:b2ManifoldPoint; var tMat:b2Mat22; var tPos:b2Vec2; var tVec:b2Vec2; var shape1:b2Shape = c.GetShape1(); var shape2:b2Shape = c.GetShape2(); var manifoldCount:int = c.GetManifoldCount(); if ((((manifoldCount > 0)) && (m_world.m_contactListener))){ cp = new b2ContactPoint(); cp.shape1 = c.GetShape1(); cp.shape2 = c.GetShape2(); b1 = cp.shape1.GetBody(); manifolds = c.GetManifolds(); i = 0; while (i < manifoldCount) { manifold = manifolds[i]; cp.normal.SetV(manifold.normal); j = 0; while (j < manifold.pointCount) { point = manifold.points[j]; tMat = b1.GetXForm().R; tPos = b1.GetXForm().position; tVec = point.localPoint1; cp.position.x = (tPos.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y))); cp.position.y = (tPos.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y))); cp.separation = point.separation; cp.normalForce = point.normalForce; cp.tangentForce = point.tangentForce; cp.id = point.id; 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.GetBody(); var body2:b2Body = shape2.GetBody(); 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.GetBody(); var body2:b2Body = shape2.GetBody(); 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.GetShape1(); shape2 = c.GetShape2(); body1 = shape1.GetBody(); body2 = shape2.GetBody(); 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 cp:b2ContactPoint; var b1:b2Body; var manifoldCount:int; var manifolds:Array; var i:int; var manifold:b2Manifold; var j:int; var point:b2ManifoldPoint; var tMat:b2Mat22; var tPos:b2Vec2; var tVec:b2Vec2; var c:b2Contact = m_world.m_contactList; while (c) { body1 = c.GetShape1().GetBody(); body2 = c.GetShape2().GetBody(); if (((body1.IsSleeping()) && (body2.IsSleeping()))){ } else { c.Update(m_world.m_contactListener); if ((((c.IsSolid() == false)) && (m_world.m_contactListener))){ cp = new b2ContactPoint(); cp.shape1 = c.GetShape1(); cp.shape2 = c.GetShape2(); cp.normalForce = 0; cp.tangentForce = 0; b1 = cp.shape1.GetBody(); manifoldCount = c.GetManifoldCount(); manifolds = c.GetManifolds(); i = 0; while (i < manifoldCount) { manifold = manifolds[i]; cp.normal.SetV(manifold.normal); j = 0; while (j < manifold.pointCount) { point = manifold.points[j]; tMat = b1.GetXForm().R; tPos = b1.GetXForm().position; tVec = point.localPoint1; cp.position.x = (tPos.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y))); cp.position.y = (tPos.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y))); cp.separation = point.separation; if ((point.id.features.flip & b2Collision.b2_newPoint)){ point.id.features.flip = (point.id.features.flip & ~(b2Collision.b2_newPoint)); cp.id = point.id; m_world.m_contactListener.Add(cp); } else { cp.id = point.id; m_world.m_contactListener.Persist(cp); }; j++; }; i++; }; }; }; c = c.GetNext(); }; } } }//package Box2D.Dynamics
Section 68
//b2DebugDraw (Box2D.Dynamics.b2DebugDraw) package Box2D.Dynamics { import flash.display.*; import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; import Box2D.Dynamics.Contacts.*; import Box2D.Collision.*; import Box2D.Common.*; 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 69
//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 70
//b2Island (Box2D.Dynamics.b2Island) package Box2D.Dynamics { import Box2D.Common.Math.*; import Box2D.Dynamics.Joints.*; import Box2D.Dynamics.Contacts.*; import Box2D.Collision.*; import Box2D.Common.*; 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_reportCP:b2ContactPoint = new b2ContactPoint(); 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 cp:b2ContactPoint; 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]; cp = s_reportCP; cp.shape1 = c.GetShape1(); cp.shape2 = c.GetShape2(); b1 = cp.shape1.GetBody(); manifoldCount = c.GetManifoldCount(); manifolds = c.GetManifolds(); j = 0; while (j < manifoldCount) { manifold = manifolds[j]; cp.normal.SetV(manifold.normal); k = 0; while (k < manifold.pointCount) { point = manifold.points[k]; ccp = cc.points[k]; tMat = b1.GetXForm().R; tVec = point.localPoint1; cp.position.x = (b1.GetXForm().position.x + ((tMat.col1.x * tVec.x) + (tMat.col2.x * tVec.y))); cp.position.y = (b1.GetXForm().position.y + ((tMat.col1.y * tVec.x) + (tMat.col2.y * tVec.y))); cp.separation = point.separation; cp.normalForce = ccp.normalForce; cp.tangentForce = ccp.tangentForce; if ((point.id.features.flip & b2Collision.b2_newPoint)){ point.id.features.flip = (point.id.features.flip & ~(b2Collision.b2_newPoint)); cp.id.key = point.id.key; m_listener.Add(cp); } else { cp.id.key = point.id.key; m_listener.Persist(cp); }; 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 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(); i = 0; while (i < m_jointCount) { m_joints[i].InitVelocityConstraints(step); i++; }; i = 0; while (i < step.maxIterations) { contactSolver.SolveVelocityConstraints(); j = 0; while (j < m_jointCount) { m_joints[j].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) { m_joints[i].InitPositionConstraints(); i++; }; m_positionIterationCount = 0; while (m_positionIterationCount < step.maxIterations) { contactsOkay = contactSolver.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); jointsOkay = true; i = 0; while (i < m_jointCount) { jointOkay = m_joints[i].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 71
//b2TimeStep (Box2D.Dynamics.b2TimeStep) package Box2D.Dynamics { public class b2TimeStep { public var dt:Number; public var maxIterations:int; public var inv_dt:Number; public function b2TimeStep(){ super(); } } }//package Box2D.Dynamics
Section 72
//b2World (Box2D.Dynamics.b2World) package Box2D.Dynamics { import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; import Box2D.Dynamics.Joints.*; import Box2D.Dynamics.Contacts.*; import Box2D.Collision.*; import Box2D.Common.*; public class b2World { public var m_contactList:b2Contact; public var m_blockAllocator; public var m_boundaryListener:b2BoundaryListener; public var m_allowSleep:Boolean; public var m_contactListener:b2ContactListener; 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 s_enablePositionCorrection:int = 1; private static var s_coreColor:b2Color = new b2Color(0.9, 0.6, 0.6); private static var s_xf:b2XForm = new b2XForm(); public static var s_enableWarmStarting:int = 1; public static var s_enableTOI:int = 1; 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_allowSleep = doSleep; m_gravity = gravity; m_lock = false; m_contactManager.m_world = this; m_broadPhase = new b2BroadPhase(worldAABB, m_contactManager); var bd:b2BodyDef = new b2BodyDef(); m_groundBody = CreateStaticBody(bd); } public function DrawJoint(joint:b2Joint):void{ var pulley:b2PulleyJoint; var s1:b2Vec2; var s2:b2Vec2; var b1:b2Body = joint.GetBody1(); var b2:b2Body = joint.GetBody2(); var xf1:b2XForm = b1.GetXForm(); var xf2:b2XForm = b2.GetXForm(); 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.GetType()){ 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 SetDebugDraw(debugDraw:b2DebugDraw):void{ m_debugDraw = debugDraw; } public function SetListener(listener:b2ContactListener):void{ m_contactListener = listener; } 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.GetXForm(); 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.GetNext(); }; b = b.GetNext(); }; }; if ((flags & b2DebugDraw.e_jointBit)){ j = m_jointList; while (j) { DrawJoint(j); j = j.GetNext(); }; }; 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.GetXForm(); s = b.GetShapeList(); while (s) { if (s.GetType() != 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.GetNext(); }; b = b.GetNext(); }; }; if ((flags & b2DebugDraw.e_centerOfMassBit)){ b = m_bodyList; while (b) { xf = s_xf; xf.R = b.GetXForm().R; xf.position = b.GetWorldCenter(); m_debugDraw.DrawXForm(xf); b = b.GetNext(); }; }; } 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 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.GetLocalPosition()); radius = circle.GetRadius(); 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 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.GetManifoldCount() == 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, (s_enablePositionCorrection > 0), m_allowSleep); m_positionIterationCount = Math.max(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.GetNext(); }; m_broadPhase.Commit(); } public function GetGroundBody():b2Body{ return (m_groundBody); } 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] as b2Shape); i++; }; return (count); } 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.GetShape1(); s2 = c.GetShape2(); b1 = s1.GetBody(); b2 = s2.GetBody(); 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 = Math.min((((1 - toi) * t0) + 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.GetShape1(); s2 = minContact.GetShape2(); b1 = s1.GetBody(); b2 = s2.GetBody(); b1.Advance(minTOI); b2.Advance(minTOI); minContact.Update(m_contactListener); minContact.m_flags = (minContact.m_flags & ~(b2Contact.e_toiFlag)); if (minContact.GetManifoldCount() == 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.GetManifoldCount() == 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 CreateDynamicBody(def:b2BodyDef):b2Body{ if (m_lock == true){ return (null); }; var b:b2Body = new b2Body(def, b2Body.e_dynamicType, 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 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.ResetProxy(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.ResetProxy(m_broadPhase, b.m_xf); s = s.m_next; }; }; } public function SetFilter(filter:b2ContactFilter):void{ m_contactFilter = filter; } public function SetBoundaryListener(listener:b2BoundaryListener):void{ m_boundaryListener = listener; } public function SetDestructionListener(listener:b2DestructionListener):void{ m_destructionListener = listener; } public function CreateStaticBody(def:b2BodyDef):b2Body{ if (m_lock == true){ return (null); }; var b:b2Body = new b2Body(def, b2Body.e_staticType, 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 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; }; m_contactManager.Collide(); if (step.dt > 0){ Solve(step); }; if (((s_enableTOI) && ((step.dt > 0)))){ SolveTOI(step); }; DrawDebugData(); m_lock = false; } } }//package Box2D.Dynamics
Section 73
//IAutomationObject (mx.automation.IAutomationObject) package mx.automation { import flash.events.*; public interface IAutomationObject { function createAutomationIDPart(:IAutomationObject):Object; function get automationName():String; function get showInAutomationHierarchy():Boolean; function set automationName(E:\dev\3.0.x\frameworks\projects\framework\src;mx\automation;IAutomationObject.as:String):void; function getAutomationChildAt(delegate:int):IAutomationObject; function get automationDelegate():Object; function get automationTabularData():Object; function resolveAutomationIDPart(Object:Object):Array; function replayAutomatableEvent(void:Event):Boolean; function set automationDelegate(E:\dev\3.0.x\frameworks\projects\framework\src;mx\automation;IAutomationObject.as:Object):void; function get automationValue():Array; function get numAutomationChildren():int; function set showInAutomationHierarchy(E:\dev\3.0.x\frameworks\projects\framework\src;mx\automation;IAutomationObject.as:Boolean):void; } }//package mx.automation
Section 74
//Binding (mx.binding.Binding) package mx.binding { import mx.core.*; public class Binding { mx_internal var destFunc:Function; mx_internal var srcFunc:Function; mx_internal var destString:String; mx_internal var document:Object; private var hasHadValue:Boolean; mx_internal var isExecuting:Boolean; mx_internal var isHandlingEvent:Boolean; public var twoWayCounterpart:Binding; mx_internal var isEnabled:Boolean; public var uiComponentWatcher:int; private var lastValue:Object; private var wrappedFunctionSuccessful:Boolean; mx_internal static const VERSION:String = "3.0.0.0"; public function Binding(document:Object, srcFunc:Function, destFunc:Function, destString:String){ super(); this.document = document; this.srcFunc = srcFunc; this.destFunc = destFunc; this.destString = destString; isEnabled = true; isExecuting = false; isHandlingEvent = false; hasHadValue = false; uiComponentWatcher = -1; BindingManager.addBinding(document, destString, this); } protected function wrapFunctionCall(thisArg:Object, wrappedFunction:Function, object:Object=null, ... _args):Object{ var result:Object; var thisArg = thisArg; var wrappedFunction = wrappedFunction; var object = object; var args = _args; wrappedFunctionSuccessful = false; result = wrappedFunction.apply(thisArg, args); wrappedFunctionSuccessful = true; return (result); //unresolved jump var _slot1 = itemPendingError; _slot1.addResponder(new EvalBindingResponder(this, object)); if (BindingManager.debugDestinationStrings[destString]){ trace(((("Binding: destString = " + destString) + ", error = ") + _slot1)); }; //unresolved jump var _slot1 = rangeError; if (BindingManager.debugDestinationStrings[destString]){ trace(((("Binding: destString = " + destString) + ", error = ") + _slot1)); }; //unresolved jump var _slot1 = error; if (((((((((!((_slot1.errorID == 1006))) && (!((_slot1.errorID == 1009))))) && (!((_slot1.errorID == 1010))))) && (!((_slot1.errorID == 1055))))) && (!((_slot1.errorID == 1069))))){ throw (_slot1); } else { if (BindingManager.debugDestinationStrings[destString]){ trace(((("Binding: destString = " + destString) + ", error = ") + _slot1)); }; }; return (null); } private function nodeSeqEqual(x:XMLList, y:XMLList):Boolean{ var i:uint; var n:uint = x.length(); if (n == y.length()){ i = 0; while ((((i < n)) && ((x[i] === y[i])))) { i++; }; return ((i == n)); //unresolved jump }; return (false); } public function watcherFired(commitEvent:Boolean, cloneIndex:int):void{ var commitEvent = commitEvent; var cloneIndex = cloneIndex; if (isHandlingEvent){ return; }; try { try { isHandlingEvent = true; execute(cloneIndex); } finally { }; } finally { isHandlingEvent = false; }; } public function execute(o:Object=null):void{ var o = o; if (!isEnabled){ return; }; if (((isExecuting) || (((twoWayCounterpart) && (twoWayCounterpart.isExecuting))))){ hasHadValue = true; return; }; try { try { isExecuting = true; wrapFunctionCall(this, innerExecute, o); } finally { }; } finally { isExecuting = false; }; } private function innerExecute():void{ var value:Object = wrapFunctionCall(document, srcFunc); if (BindingManager.debugDestinationStrings[destString]){ trace(((("Binding: destString = " + destString) + ", srcFunc result = ") + value)); }; if (((hasHadValue) || (wrappedFunctionSuccessful))){ if (((!((((((lastValue is XML)) && (lastValue.hasComplexContent()))) && ((lastValue === value))))) && (!((((((((lastValue is XMLList)) && (lastValue.hasComplexContent()))) && ((value is XMLList)))) && (nodeSeqEqual((lastValue as XMLList), (value as XMLList)))))))){ destFunc.call(document, value); lastValue = value; hasHadValue = true; }; }; } } }//package mx.binding
Section 75
//BindingManager (mx.binding.BindingManager) package mx.binding { import mx.core.*; public class BindingManager { mx_internal static const VERSION:String = "3.0.0.0"; static var debugDestinationStrings:Object = {}; public function BindingManager(){ super(); } public static function executeBindings(document:Object, destStr:String, destObj:Object):void{ var binding:String; if (((!(destStr)) || ((destStr == "")))){ return; }; if (((((((document) && ((((document is IBindingClient)) || (document.hasOwnProperty("_bindingsByDestination")))))) && (document._bindingsByDestination))) && (document._bindingsBeginWithWord[getFirstWord(destStr)]))){ for (binding in document._bindingsByDestination) { if (binding.charAt(0) == destStr.charAt(0)){ if ((((((binding.indexOf((destStr + ".")) == 0)) || ((binding.indexOf((destStr + "[")) == 0)))) || ((binding == destStr)))){ document._bindingsByDestination[binding].execute(destObj); }; }; }; }; } public static function addBinding(document:Object, destStr:String, b:Binding):void{ if (!document._bindingsByDestination){ document._bindingsByDestination = {}; document._bindingsBeginWithWord = {}; }; document._bindingsByDestination[destStr] = b; document._bindingsBeginWithWord[getFirstWord(destStr)] = true; } public static function debugBinding(destinationString:String):void{ debugDestinationStrings[destinationString] = true; } private static function getFirstWord(destStr:String):String{ var indexPeriod:int = destStr.indexOf("."); var indexBracket:int = destStr.indexOf("["); if (indexPeriod == indexBracket){ return (destStr); }; var minIndex:int = Math.min(indexPeriod, indexBracket); if (minIndex == -1){ minIndex = Math.max(indexPeriod, indexBracket); }; return (destStr.substr(0, minIndex)); } public static function setEnabled(document:Object, isEnabled:Boolean):void{ var bindings:Array; var i:uint; var binding:Binding; if ((((document is IBindingClient)) && (document._bindings))){ bindings = (document._bindings as Array); i = 0; while (i < bindings.length) { binding = bindings[i]; binding.isEnabled = isEnabled; i++; }; }; } } }//package mx.binding
Section 76
//EvalBindingResponder (mx.binding.EvalBindingResponder) package mx.binding { import mx.core.*; import mx.rpc.*; public class EvalBindingResponder implements IResponder { private var binding:Binding; private var object:Object; mx_internal static const VERSION:String = "3.0.0.0"; public function EvalBindingResponder(binding:Binding, object:Object){ super(); this.binding = binding; this.object = object; } public function fault(data:Object):void{ } public function result(data:Object):void{ binding.execute(object); } } }//package mx.binding
Section 77
//IBindingClient (mx.binding.IBindingClient) package mx.binding { public interface IBindingClient { } }//package mx.binding
Section 78
//ItemPendingError (mx.collections.errors.ItemPendingError) package mx.collections.errors { import mx.core.*; import mx.rpc.*; public class ItemPendingError extends Error { private var _responders:Array; mx_internal static const VERSION:String = "3.0.0.0"; public function ItemPendingError(message:String){ super(message); } public function get responders():Array{ return (_responders); } public function addResponder(responder:IResponder):void{ if (!_responders){ _responders = []; }; _responders.push(responder); } } }//package mx.collections.errors
Section 79
//IFlexContextMenu (mx.controls.IFlexContextMenu) package mx.controls { import flash.display.*; public interface IFlexContextMenu { function setContextMenu(:InteractiveObject):void; function unsetContextMenu(:InteractiveObject):void; } }//package mx.controls
Section 80
//ToolTip (mx.controls.ToolTip) package mx.controls { import mx.core.*; import mx.styles.*; import flash.display.*; import flash.text.*; public class ToolTip extends UIComponent implements IToolTip, IFontContextComponent { private var textChanged:Boolean; private var _text:String; protected var textField:IUITextField; mx_internal var border:IFlexDisplayObject; mx_internal static const VERSION:String = "3.0.0.0"; public static var maxWidth:Number = 300; public function ToolTip(){ super(); mouseEnabled = false; } public function set fontContext(moduleFactory:IFlexModuleFactory):void{ this.moduleFactory = moduleFactory; } override public function styleChanged(styleProp:String):void{ super.styleChanged(styleProp); if ((((((styleProp == "borderStyle")) || ((styleProp == "styleName")))) || ((styleProp == null)))){ invalidateDisplayList(); }; } override protected function commitProperties():void{ var index:int; var textFormat:TextFormat; super.commitProperties(); if (((hasFontContextChanged()) && (!((textField == null))))){ index = getChildIndex(DisplayObject(textField)); removeTextField(); createTextField(index); invalidateSize(); textChanged = true; }; if (textChanged){ textFormat = textField.getTextFormat(); textFormat.leftMargin = 0; textFormat.rightMargin = 0; textField.defaultTextFormat = textFormat; textField.text = _text; textChanged = false; }; } mx_internal function getTextField():IUITextField{ return (textField); } override protected function createChildren():void{ var borderClass:Class; super.createChildren(); if (!border){ borderClass = getStyle("borderSkin"); border = new (borderClass); if ((border is ISimpleStyleClient)){ ISimpleStyleClient(border).styleName = this; }; addChild(DisplayObject(border)); }; createTextField(-1); } override protected function measure():void{ var heightSlop:Number; super.measure(); var bm:EdgeMetrics = borderMetrics; var leftInset:Number = (bm.left + getStyle("paddingLeft")); var topInset:Number = (bm.top + getStyle("paddingTop")); var rightInset:Number = (bm.right + getStyle("paddingRight")); var bottomInset:Number = (bm.bottom + getStyle("paddingBottom")); var widthSlop:Number = (leftInset + rightInset); heightSlop = (topInset + bottomInset); textField.wordWrap = false; if ((textField.textWidth + widthSlop) > ToolTip.maxWidth){ textField.width = (ToolTip.maxWidth - widthSlop); textField.wordWrap = true; }; measuredWidth = (textField.width + widthSlop); measuredHeight = (textField.height + heightSlop); } public function get fontContext():IFlexModuleFactory{ return (moduleFactory); } public function set text(value:String):void{ _text = value; textChanged = true; invalidateProperties(); invalidateSize(); invalidateDisplayList(); } public function get text():String{ return (_text); } mx_internal function removeTextField():void{ if (textField){ removeChild(DisplayObject(textField)); textField = null; }; } mx_internal function createTextField(childIndex:int):void{ if (!textField){ textField = IUITextField(createInFontContext(UITextField)); textField.autoSize = TextFieldAutoSize.LEFT; textField.mouseEnabled = false; textField.multiline = true; textField.selectable = false; textField.wordWrap = false; textField.styleName = this; if (childIndex == -1){ addChild(DisplayObject(textField)); } else { addChildAt(DisplayObject(textField), childIndex); }; }; } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{ super.updateDisplayList(unscaledWidth, unscaledHeight); var bm:EdgeMetrics = borderMetrics; var leftInset:Number = (bm.left + getStyle("paddingLeft")); var topInset:Number = (bm.top + getStyle("paddingTop")); var rightInset:Number = (bm.right + getStyle("paddingRight")); var bottomInset:Number = (bm.bottom + getStyle("paddingBottom")); var widthSlop:Number = (leftInset + rightInset); var heightSlop:Number = (topInset + bottomInset); border.setActualSize(unscaledWidth, unscaledHeight); textField.move(leftInset, topInset); textField.setActualSize((unscaledWidth - widthSlop), (unscaledHeight - heightSlop)); } private function get borderMetrics():EdgeMetrics{ if ((border is IRectangularBorder)){ return (IRectangularBorder(border).borderMetrics); }; return (EdgeMetrics.EMPTY); } } }//package mx.controls
Section 81
//ApplicationGlobals (mx.core.ApplicationGlobals) package mx.core { public class ApplicationGlobals { public static var application:Object; public function ApplicationGlobals(){ super(); } } }//package mx.core
Section 82
//BitmapAsset (mx.core.BitmapAsset) package mx.core { import flash.display.*; public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject { mx_internal static const VERSION:String = "3.0.0.0"; public function BitmapAsset(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){ super(bitmapData, pixelSnapping, smoothing); } public function get measuredWidth():Number{ if (bitmapData){ return (bitmapData.width); }; return (0); } public function get measuredHeight():Number{ if (bitmapData){ return (bitmapData.height); }; return (0); } public function setActualSize(newWidth:Number, newHeight:Number):void{ width = newWidth; height = newHeight; } public function move(x:Number, y:Number):void{ this.x = x; this.y = y; } } }//package mx.core
Section 83
//ComponentDescriptor (mx.core.ComponentDescriptor) package mx.core { public class ComponentDescriptor { public var events:Object; public var type:Class; public var document:Object; private var _properties:Object; public var propertiesFactory:Function; public var id:String; mx_internal static const VERSION:String = "3.0.0.0"; public function ComponentDescriptor(descriptorProperties:Object){ var p:String; super(); for (p in descriptorProperties) { this[p] = descriptorProperties[p]; }; } public function toString():String{ return (("ComponentDescriptor_" + id)); } public function invalidateProperties():void{ _properties = null; } public function get properties():Object{ var cd:Array; var n:int; var i:int; if (_properties){ return (_properties); }; if (propertiesFactory != null){ _properties = propertiesFactory.call(document); }; if (_properties){ cd = _properties.childDescriptors; if (cd){ n = cd.length; i = 0; while (i < n) { cd[i].document = document; i++; }; }; } else { _properties = {}; }; return (_properties); } } }//package mx.core
Section 84
//ContainerGlobals (mx.core.ContainerGlobals) package mx.core { import flash.display.*; import mx.managers.*; public class ContainerGlobals { public static var focusedContainer:InteractiveObject; public function ContainerGlobals(){ super(); } public static function checkFocus(oldObj:InteractiveObject, newObj:InteractiveObject):void{ var fm:IFocusManager; var defButton:IButton; var objParent:InteractiveObject = newObj; var currObj:InteractiveObject = newObj; var lastUIComp:IUIComponent; if (((!((newObj == null))) && ((oldObj == newObj)))){ return; }; while (currObj) { if (currObj.parent){ objParent = currObj.parent; } else { objParent = null; }; if ((currObj is IUIComponent)){ lastUIComp = IUIComponent(currObj); }; currObj = objParent; if (((((currObj) && ((currObj is IContainer)))) && (IContainer(currObj).defaultButton))){ break; }; }; if (((!((ContainerGlobals.focusedContainer == currObj))) || ((((ContainerGlobals.focusedContainer == null)) && ((currObj == null)))))){ if (!currObj){ currObj = InteractiveObject(lastUIComp); }; if (((currObj) && ((currObj is IContainer)))){ fm = IContainer(currObj).focusManager; if (!fm){ return; }; defButton = (IContainer(currObj).defaultButton as IButton); if (defButton){ ContainerGlobals.focusedContainer = InteractiveObject(currObj); fm.defaultButton = (defButton as IButton); } else { ContainerGlobals.focusedContainer = InteractiveObject(currObj); fm.defaultButton = null; }; }; }; } } }//package mx.core
Section 85
//DragSource (mx.core.DragSource) package mx.core { public class DragSource { private var formatHandlers:Object; private var dataHolder:Object; private var _formats:Array; mx_internal static const VERSION:String = "3.0.0.0"; public function DragSource(){ dataHolder = {}; formatHandlers = {}; _formats = []; super(); } public function hasFormat(format:String):Boolean{ var n:int = _formats.length; var i:int; while (i < n) { if (_formats[i] == format){ return (true); }; i++; }; return (false); } public function addData(data:Object, format:String):void{ _formats.push(format); dataHolder[format] = data; } public function dataForFormat(format:String):Object{ var data:Object = dataHolder[format]; if (data){ return (data); }; if (formatHandlers[format]){ return (formatHandlers[format]()); }; return (null); } public function addHandler(handler:Function, format:String):void{ _formats.push(format); formatHandlers[format] = handler; } public function get formats():Array{ return (_formats); } } }//package mx.core
Section 86
//EdgeMetrics (mx.core.EdgeMetrics) package mx.core { public class EdgeMetrics { public var top:Number; public var left:Number; public var bottom:Number; public var right:Number; mx_internal static const VERSION:String = "3.0.0.0"; public static const EMPTY:EdgeMetrics = new EdgeMetrics(0, 0, 0, 0); ; public function EdgeMetrics(left:Number=0, top:Number=0, right:Number=0, bottom:Number=0){ super(); this.left = left; this.top = top; this.right = right; this.bottom = bottom; } public function clone():EdgeMetrics{ return (new EdgeMetrics(left, top, right, bottom)); } } }//package mx.core
Section 87
//EmbeddedFont (mx.core.EmbeddedFont) package mx.core { public class EmbeddedFont { private var _fontName:String; private var _fontStyle:String; mx_internal static const VERSION:String = "3.0.0.0"; public function EmbeddedFont(fontName:String, bold:Boolean, italic:Boolean){ super(); _fontName = fontName; _fontStyle = EmbeddedFontRegistry.getFontStyle(bold, italic); } public function get fontStyle():String{ return (_fontStyle); } public function get fontName():String{ return (_fontName); } } }//package mx.core
Section 88
//EmbeddedFontRegistry (mx.core.EmbeddedFontRegistry) package mx.core { import flash.text.*; import flash.utils.*; public class EmbeddedFontRegistry implements IEmbeddedFontRegistry { mx_internal static const VERSION:String = "3.0.0.0"; private static var fonts:Object = {}; private static var instance:IEmbeddedFontRegistry; public function EmbeddedFontRegistry(){ super(); } public function getAssociatedModuleFactory(font:EmbeddedFont, defaultModuleFactory:IFlexModuleFactory):IFlexModuleFactory{ var found:int; var iter:Object; var fontDictionary:Dictionary = fonts[createFontKey(font)]; if (fontDictionary){ found = fontDictionary[defaultModuleFactory]; if (found){ return (defaultModuleFactory); }; for (iter in fontDictionary) { return ((iter as IFlexModuleFactory)); }; }; return (null); } public function deregisterFont(font:EmbeddedFont, moduleFactory:IFlexModuleFactory):void{ var count:int; var obj:Object; var fontKey:String = createFontKey(font); var fontDictionary:Dictionary = fonts[fontKey]; if (fontDictionary != null){ delete fontDictionary[moduleFactory]; count = 0; for (obj in fontDictionary) { count++; }; if (count == 0){ delete fonts[fontKey]; }; }; } public function getFonts():Array{ var key:String; var fontArray:Array = []; for (key in fonts) { fontArray.push(createEmbeddedFont(key)); }; return (fontArray); } public function registerFont(font:EmbeddedFont, moduleFactory:IFlexModuleFactory):void{ var fontKey:String = createFontKey(font); var fontDictionary:Dictionary = fonts[fontKey]; if (!fontDictionary){ fontDictionary = new Dictionary(true); fonts[fontKey] = fontDictionary; }; fontDictionary[moduleFactory] = 1; } public static function registerFonts(fonts:Object, moduleFactory:IFlexModuleFactory):void{ var f:Object; var fontObj:Object; var fieldIter:String; var bold:Boolean; var italic:Boolean; var fontRegistry:IEmbeddedFontRegistry = IEmbeddedFontRegistry(Singleton.getInstance("mx.core::IEmbeddedFontRegistry")); for (f in fonts) { fontObj = fonts[f]; for (fieldIter in fontObj) { if (fontObj[fieldIter] == false){ } else { if (fieldIter == "regular"){ bold = false; italic = false; } else { if (fieldIter == "boldItalic"){ bold = true; italic = true; } else { if (fieldIter == "bold"){ bold = true; italic = false; } else { if (fieldIter == "italic"){ bold = false; italic = true; }; }; }; }; fontRegistry.registerFont(new EmbeddedFont(String(f), bold, italic), moduleFactory); }; }; }; } public static function getInstance():IEmbeddedFontRegistry{ if (!instance){ instance = new (EmbeddedFontRegistry); }; return (instance); } public static function getFontStyle(bold:Boolean, italic:Boolean):String{ var style:String = FontStyle.REGULAR; if (((bold) && (italic))){ style = FontStyle.BOLD_ITALIC; } else { if (bold){ style = FontStyle.BOLD; } else { if (italic){ style = FontStyle.ITALIC; }; }; }; return (style); } private static function createFontKey(font:EmbeddedFont):String{ return ((font.fontName + font.fontStyle)); } private static function createEmbeddedFont(key:String):EmbeddedFont{ var fontName:String; var fontBold:Boolean; var fontItalic:Boolean; var index:int = endsWith(key, FontStyle.REGULAR); if (index > 0){ fontName = key.substring(0, index); return (new EmbeddedFont(fontName, false, false)); }; index = endsWith(key, FontStyle.BOLD); if (index > 0){ fontName = key.substring(0, index); return (new EmbeddedFont(fontName, true, false)); }; index = endsWith(key, FontStyle.BOLD_ITALIC); if (index > 0){ fontName = key.substring(0, index); return (new EmbeddedFont(fontName, true, true)); }; index = endsWith(key, FontStyle.ITALIC); if (index > 0){ fontName = key.substring(0, index); return (new EmbeddedFont(fontName, false, true)); }; return (new EmbeddedFont("", false, false)); } private static function endsWith(s:String, match:String):int{ var index:int = s.lastIndexOf(match); if ((((index > 0)) && (((index + match.length) == s.length)))){ return (index); }; return (-1); } } }//package mx.core
Section 89
//EventPriority (mx.core.EventPriority) package mx.core { public final class EventPriority { public static const DEFAULT:int = 0; public static const BINDING:int = 100; public static const DEFAULT_HANDLER:int = -50; public static const EFFECT:int = -100; public static const CURSOR_MANAGEMENT:int = 200; mx_internal static const VERSION:String = "3.0.0.0"; public function EventPriority(){ super(); } } }//package mx.core
Section 90
//FlexBitmap (mx.core.FlexBitmap) package mx.core { import flash.display.*; import mx.utils.*; public class FlexBitmap extends Bitmap { mx_internal static const VERSION:String = "3.0.0.0"; public function FlexBitmap(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){ var bitmapData = bitmapData; var pixelSnapping = pixelSnapping; var smoothing = smoothing; super(bitmapData, pixelSnapping, smoothing); name = NameUtil.createUniqueName(this); //unresolved jump var _slot1 = e; } override public function toString():String{ return (NameUtil.displayObjectToString(this)); } } }//package mx.core
Section 91
//FlexLoader (mx.core.FlexLoader) package mx.core { import flash.display.*; import mx.utils.*; public class FlexLoader extends Loader { mx_internal static const VERSION:String = "3.0.0.0"; public function FlexLoader(){ super(); name = NameUtil.createUniqueName(this); //unresolved jump var _slot1 = e; } override public function toString():String{ return (NameUtil.displayObjectToString(this)); } } }//package mx.core
Section 92
//FlexShape (mx.core.FlexShape) package mx.core { import flash.display.*; import mx.utils.*; public class FlexShape extends Shape { mx_internal static const VERSION:String = "3.0.0.0"; public function FlexShape(){ super(); name = NameUtil.createUniqueName(this); //unresolved jump var _slot1 = e; } override public function toString():String{ return (NameUtil.displayObjectToString(this)); } } }//package mx.core
Section 93
//FlexSprite (mx.core.FlexSprite) package mx.core { import flash.display.*; import mx.utils.*; public class FlexSprite extends Sprite { mx_internal static const VERSION:String = "3.0.0.0"; public function FlexSprite(){ super(); name = NameUtil.createUniqueName(this); //unresolved jump var _slot1 = e; } override public function toString():String{ return (NameUtil.displayObjectToString(this)); } } }//package mx.core
Section 94
//FlexTextField (mx.core.FlexTextField) package mx.core { import flash.text.*; import mx.utils.*; public class FlexTextField extends TextField { mx_internal static const VERSION:String = "3.0.0.0"; public function FlexTextField(){ super(); name = NameUtil.createUniqueName(this); //unresolved jump var _slot1 = e; } override public function toString():String{ return (NameUtil.displayObjectToString(this)); } } }//package mx.core
Section 95
//FlexVersion (mx.core.FlexVersion) package mx.core { import mx.resources.*; public class FlexVersion { public static const VERSION_2_0_1:uint = 33554433; public static const CURRENT_VERSION:uint = 50331648; public static const VERSION_3_0:uint = 50331648; public static const VERSION_2_0:uint = 33554432; public static const VERSION_ALREADY_READ:String = "versionAlreadyRead"; public static const VERSION_ALREADY_SET:String = "versionAlreadySet"; mx_internal static const VERSION:String = "3.0.0.0"; private static var compatibilityVersionChanged:Boolean = false; private static var _compatibilityErrorFunction:Function; private static var _compatibilityVersion:uint = 50331648; private static var compatibilityVersionRead:Boolean = false; public function FlexVersion(){ super(); } mx_internal static function changeCompatibilityVersionString(value:String):void{ var pieces:Array = value.split("."); var major:uint = parseInt(pieces[0]); var minor:uint = parseInt(pieces[1]); var update:uint = parseInt(pieces[2]); _compatibilityVersion = (((major << 24) + (minor << 16)) + update); } public static function set compatibilityVersion(value:uint):void{ var s:String; if (value == _compatibilityVersion){ return; }; if (compatibilityVersionChanged){ if (compatibilityErrorFunction == null){ s = ResourceManager.getInstance().getString("core", VERSION_ALREADY_SET); throw (new Error(s)); }; compatibilityErrorFunction(value, VERSION_ALREADY_SET); }; if (compatibilityVersionRead){ if (compatibilityErrorFunction == null){ s = ResourceManager.getInstance().getString("core", VERSION_ALREADY_READ); throw (new Error(s)); }; compatibilityErrorFunction(value, VERSION_ALREADY_READ); }; _compatibilityVersion = value; compatibilityVersionChanged = true; } public static function get compatibilityVersion():uint{ compatibilityVersionRead = true; return (_compatibilityVersion); } public static function set compatibilityErrorFunction(value:Function):void{ _compatibilityErrorFunction = value; } public static function set compatibilityVersionString(value:String):void{ var pieces:Array = value.split("."); var major:uint = parseInt(pieces[0]); var minor:uint = parseInt(pieces[1]); var update:uint = parseInt(pieces[2]); compatibilityVersion = (((major << 24) + (minor << 16)) + update); } public static function get compatibilityErrorFunction():Function{ return (_compatibilityErrorFunction); } public static function get compatibilityVersionString():String{ var major:uint = ((compatibilityVersion >> 24) & 0xFF); var minor:uint = ((compatibilityVersion >> 16) & 0xFF); var update:uint = (compatibilityVersion & 0xFFFF); return (((((major.toString() + ".") + minor.toString()) + ".") + update.toString())); } } }//package mx.core
Section 96
//IBorder (mx.core.IBorder) package mx.core { public interface IBorder { function get borderMetrics():EdgeMetrics; } }//package mx.core
Section 97
//IButton (mx.core.IButton) package mx.core { public interface IButton extends IUIComponent { function get emphasized():Boolean; function set emphasized(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IButton.as:Boolean):void; function callLater(_arg1:Function, _arg2:Array=null):void; } }//package mx.core
Section 98
//IChildList (mx.core.IChildList) package mx.core { import flash.display.*; import flash.geom.*; public interface IChildList { function get numChildren():int; function removeChild(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:DisplayObject):DisplayObject; function getChildByName(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:String):DisplayObject; function removeChildAt(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:int):DisplayObject; function getChildIndex(:DisplayObject):int; function addChildAt(_arg1:DisplayObject, _arg2:int):DisplayObject; function getObjectsUnderPoint(child:Point):Array; function setChildIndex(_arg1:DisplayObject, _arg2:int):void; function getChildAt(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:int):DisplayObject; function addChild(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IChildList.as:DisplayObject):DisplayObject; function contains(flash.display:DisplayObject):Boolean; } }//package mx.core
Section 99
//IConstraintClient (mx.core.IConstraintClient) package mx.core { public interface IConstraintClient { function setConstraintValue(_arg1:String, _arg2):void; function getConstraintValue(*:String); } }//package mx.core
Section 100
//IContainer (mx.core.IContainer) package mx.core { import flash.display.*; import flash.geom.*; import flash.text.*; import mx.managers.*; import flash.media.*; public interface IContainer extends IUIComponent { function set hitArea(mx.core:IContainer/mx.core:IContainer:graphics/get:Sprite):void; function swapChildrenAt(_arg1:int, _arg2:int):void; function getChildByName(Graphics:String):DisplayObject; function get doubleClickEnabled():Boolean; function get graphics():Graphics; function get useHandCursor():Boolean; function addChildAt(_arg1:DisplayObject, _arg2:int):DisplayObject; function set mouseChildren(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void; function set creatingContentPane(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void; function get textSnapshot():TextSnapshot; function getChildIndex(value:DisplayObject):int; function set doubleClickEnabled(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void; function getObjectsUnderPoint(lockCenter:Point):Array; function get creatingContentPane():Boolean; function setChildIndex(_arg1:DisplayObject, _arg2:int):void; function get soundTransform():SoundTransform; function set useHandCursor(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void; function get numChildren():int; function contains(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ISpriteInterface.as:DisplayObject):Boolean; function get verticalScrollPosition():Number; function set defaultButton(mx.core:IContainer/mx.core:IContainer:graphics/get:IFlexDisplayObject):void; function swapChildren(_arg1:DisplayObject, _arg2:DisplayObject):void; function set horizontalScrollPosition(mx.core:IContainer/mx.core:IContainer:graphics/get:Number):void; function get focusManager():IFocusManager; function startDrag(_arg1:Boolean=false, _arg2:Rectangle=null):void; function set mouseEnabled(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void; function getChildAt(Graphics:int):DisplayObject; function set soundTransform(mx.core:IContainer/mx.core:IContainer:graphics/get:SoundTransform):void; function get tabChildren():Boolean; function get tabIndex():int; function set focusRect(mx.core:IContainer/mx.core:IContainer:graphics/get:Object):void; function get hitArea():Sprite; function get mouseChildren():Boolean; function removeChildAt(Graphics:int):DisplayObject; function get defaultButton():IFlexDisplayObject; function stopDrag():void; function set tabEnabled(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void; function get horizontalScrollPosition():Number; function get focusRect():Object; function get viewMetrics():EdgeMetrics; function set verticalScrollPosition(mx.core:IContainer/mx.core:IContainer:graphics/get:Number):void; function get dropTarget():DisplayObject; function get mouseEnabled():Boolean; function set tabChildren(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void; function set buttonMode(mx.core:IContainer/mx.core:IContainer:graphics/get:Boolean):void; function get tabEnabled():Boolean; function get buttonMode():Boolean; function removeChild(Graphics:DisplayObject):DisplayObject; function set tabIndex(mx.core:IContainer/mx.core:IContainer:graphics/get:int):void; function addChild(Graphics:DisplayObject):DisplayObject; function areInaccessibleObjectsUnderPoint(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ISpriteInterface.as:Point):Boolean; } }//package mx.core
Section 101
//IDeferredInstantiationUIComponent (mx.core.IDeferredInstantiationUIComponent) package mx.core { public interface IDeferredInstantiationUIComponent extends IUIComponent { function set cacheHeuristic(:Boolean):void; function createReferenceOnParentDocument(:IFlexDisplayObject):void; function get cachePolicy():String; function set id(:String):void; function registerEffects(:Array):void; function executeBindings(:Boolean=false):void; function get id():String; function deleteReferenceOnParentDocument(:IFlexDisplayObject):void; function set descriptor(:UIComponentDescriptor):void; function get descriptor():UIComponentDescriptor; } }//package mx.core
Section 102
//IEmbeddedFontRegistry (mx.core.IEmbeddedFontRegistry) package mx.core { public interface IEmbeddedFontRegistry { function getAssociatedModuleFactory(_arg1:EmbeddedFont, _arg2:IFlexModuleFactory):IFlexModuleFactory; function registerFont(_arg1:EmbeddedFont, _arg2:IFlexModuleFactory):void; function deregisterFont(_arg1:EmbeddedFont, _arg2:IFlexModuleFactory):void; function getFonts():Array; } }//package mx.core
Section 103
//IFlexAsset (mx.core.IFlexAsset) package mx.core { public interface IFlexAsset { } }//package mx.core
Section 104
//IFlexDisplayObject (mx.core.IFlexDisplayObject) package mx.core { import flash.events.*; import flash.display.*; import flash.geom.*; import flash.accessibility.*; public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher { function get visible():Boolean; function get rotation():Number; function localToGlobal(void:Point):Point; function get name():String; function set width(flash.display:Number):void; function get measuredHeight():Number; function get blendMode():String; function get scale9Grid():Rectangle; function set name(flash.display:String):void; function set scaleX(flash.display:Number):void; function set scaleY(flash.display:Number):void; function get measuredWidth():Number; function get accessibilityProperties():AccessibilityProperties; function set scrollRect(flash.display:Rectangle):void; function get cacheAsBitmap():Boolean; function globalToLocal(void:Point):Point; function get height():Number; function set blendMode(flash.display:String):void; function get parent():DisplayObjectContainer; function getBounds(String:DisplayObject):Rectangle; function get opaqueBackground():Object; function set scale9Grid(flash.display:Rectangle):void; function setActualSize(_arg1:Number, _arg2:Number):void; function set alpha(flash.display:Number):void; function set accessibilityProperties(flash.display:AccessibilityProperties):void; function get width():Number; function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean; function set cacheAsBitmap(flash.display:Boolean):void; function get scaleX():Number; function get scaleY():Number; function get scrollRect():Rectangle; function get mouseX():Number; function get mouseY():Number; function set height(flash.display:Number):void; function set mask(flash.display:DisplayObject):void; function getRect(String:DisplayObject):Rectangle; function get alpha():Number; function set transform(flash.display:Transform):void; function move(_arg1:Number, _arg2:Number):void; function get loaderInfo():LoaderInfo; function get root():DisplayObject; function hitTestObject(mx.core:IFlexDisplayObject/mx.core:IFlexDisplayObject:stage/get:DisplayObject):Boolean; function set opaqueBackground(flash.display:Object):void; function set visible(flash.display:Boolean):void; function get mask():DisplayObject; function set x(flash.display:Number):void; function set y(flash.display:Number):void; function get transform():Transform; function set filters(flash.display:Array):void; function get x():Number; function get y():Number; function get filters():Array; function set rotation(flash.display:Number):void; function get stage():Stage; } }//package mx.core
Section 105
//IFlexModule (mx.core.IFlexModule) package mx.core { public interface IFlexModule { function set moduleFactory(:IFlexModuleFactory):void; function get moduleFactory():IFlexModuleFactory; } }//package mx.core
Section 106
//IFlexModuleFactory (mx.core.IFlexModuleFactory) package mx.core { public interface IFlexModuleFactory { function create(... _args):Object; function info():Object; } }//package mx.core
Section 107
//IFontContextComponent (mx.core.IFontContextComponent) package mx.core { public interface IFontContextComponent { function get fontContext():IFlexModuleFactory; function set fontContext(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IFontContextComponent.as:IFlexModuleFactory):void; } }//package mx.core
Section 108
//IIMESupport (mx.core.IIMESupport) package mx.core { public interface IIMESupport { function set imeMode(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IIMESupport.as:String):void; function get imeMode():String; } }//package mx.core
Section 109
//IInvalidating (mx.core.IInvalidating) package mx.core { public interface IInvalidating { function validateNow():void; function invalidateSize():void; function invalidateDisplayList():void; function invalidateProperties():void; } }//package mx.core
Section 110
//IProgrammaticSkin (mx.core.IProgrammaticSkin) package mx.core { public interface IProgrammaticSkin { function validateNow():void; function validateDisplayList():void; } }//package mx.core
Section 111
//IPropertyChangeNotifier (mx.core.IPropertyChangeNotifier) package mx.core { import flash.events.*; public interface IPropertyChangeNotifier extends IEventDispatcher, IUID { } }//package mx.core
Section 112
//IRawChildrenContainer (mx.core.IRawChildrenContainer) package mx.core { public interface IRawChildrenContainer { function get rawChildren():IChildList; } }//package mx.core
Section 113
//IRectangularBorder (mx.core.IRectangularBorder) package mx.core { import flash.geom.*; public interface IRectangularBorder extends IBorder { function get backgroundImageBounds():Rectangle; function get hasBackgroundImage():Boolean; function set backgroundImageBounds(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRectangularBorder.as:Rectangle):void; function layoutBackgroundImage():void; } }//package mx.core
Section 114
//IRepeater (mx.core.IRepeater) package mx.core { public interface IRepeater { function get container():IContainer; function set startingIndex(mx.core:IRepeater/mx.core:IRepeater:container/get:int):void; function get startingIndex():int; function set recycleChildren(mx.core:IRepeater/mx.core:IRepeater:container/get:Boolean):void; function get currentItem():Object; function get count():int; function get recycleChildren():Boolean; function executeChildBindings():void; function set dataProvider(mx.core:IRepeater/mx.core:IRepeater:container/get:Object):void; function initializeRepeater(_arg1:IContainer, _arg2:Boolean):void; function get currentIndex():int; function get dataProvider():Object; function set count(mx.core:IRepeater/mx.core:IRepeater:container/get:int):void; } }//package mx.core
Section 115
//IRepeaterClient (mx.core.IRepeaterClient) package mx.core { public interface IRepeaterClient { function get instanceIndices():Array; function set instanceIndices(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void; function get isDocument():Boolean; function set repeaters(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void; function initializeRepeaterArrays(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:IRepeaterClient):void; function get repeaters():Array; function set repeaterIndices(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void; function get repeaterIndices():Array; } }//package mx.core
Section 116
//IStateClient (mx.core.IStateClient) package mx.core { public interface IStateClient { function get currentState():String; function set currentState(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IStateClient.as:String):void; } }//package mx.core
Section 117
//ITextFieldFactory (mx.core.ITextFieldFactory) package mx.core { import flash.text.*; public interface ITextFieldFactory { function createTextField(:IFlexModuleFactory):TextField; } }//package mx.core
Section 118
//IToolTip (mx.core.IToolTip) package mx.core { import flash.geom.*; public interface IToolTip extends IUIComponent { function set text(mx.core:IToolTip/mx.core:IToolTip:screen/get:String):void; function get screen():Rectangle; function get text():String; } }//package mx.core
Section 119
//IUIComponent (mx.core.IUIComponent) package mx.core { import flash.display.*; import mx.managers.*; public interface IUIComponent extends IFlexDisplayObject { function set focusPane(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Sprite):void; function get enabled():Boolean; function set enabled(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Boolean):void; function set isPopUp(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Boolean):void; function get explicitMinHeight():Number; function get percentWidth():Number; function get isPopUp():Boolean; function get owner():DisplayObjectContainer; function get percentHeight():Number; function get baselinePosition():Number; function owns(Number:DisplayObject):Boolean; function initialize():void; function get maxWidth():Number; function get minWidth():Number; function getExplicitOrMeasuredWidth():Number; function get explicitMaxWidth():Number; function get explicitMaxHeight():Number; function set percentHeight(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void; function get minHeight():Number; function set percentWidth(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void; function get document():Object; function get focusPane():Sprite; function getExplicitOrMeasuredHeight():Number; function set tweeningProperties(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Array):void; function set explicitWidth(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void; function set measuredMinHeight(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void; function get explicitMinWidth():Number; function get tweeningProperties():Array; function get maxHeight():Number; function set owner(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:DisplayObjectContainer):void; function set includeInLayout(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Boolean):void; function setVisible(_arg1:Boolean, _arg2:Boolean=false):void; function parentChanged(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:DisplayObjectContainer):void; function get explicitWidth():Number; function get measuredMinHeight():Number; function set measuredMinWidth(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void; function set explicitHeight(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Number):void; function get includeInLayout():Boolean; function get measuredMinWidth():Number; function get explicitHeight():Number; function set systemManager(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:ISystemManager):void; function set document(mx.core:IUIComponent/mx.core:IUIComponent:baselinePosition/get:Object):void; function get systemManager():ISystemManager; } }//package mx.core
Section 120
//IUID (mx.core.IUID) package mx.core { public interface IUID { function get uid():String; function set uid(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;IUID.as:String):void; } }//package mx.core
Section 121
//IUITextField (mx.core.IUITextField) package mx.core { import mx.styles.*; import flash.display.*; import flash.geom.*; import flash.text.*; import mx.managers.*; public interface IUITextField extends IIMESupport, IFlexModule, IInvalidating, ISimpleStyleClient, IToolTipManagerClient, IUIComponent { function replaceText(_arg1:int, _arg2:int, _arg3:String):void; function get doubleClickEnabled():Boolean; function get nestLevel():int; function get caretIndex():int; function set doubleClickEnabled(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function get maxScrollH():int; function set nestLevel(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:int):void; function get numLines():int; function get scrollH():int; function setColor(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:uint):void; function get maxScrollV():int; function getImageReference(mx.core:IUITextField/mx.core:IUITextField:antiAliasType/set:String):DisplayObject; function get scrollV():int; function get border():Boolean; function get text():String; function get styleSheet():StyleSheet; function getCharBoundaries(String:int):Rectangle; function get background():Boolean; function set scrollH(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:int):void; function getFirstCharInParagraph(value:int):int; function get type():String; function replaceSelectedText(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:String):void; function set borderColor(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:uint):void; function get alwaysShowSelection():Boolean; function get sharpness():Number; function get tabIndex():int; function get textColor():uint; function set defaultTextFormat(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:TextFormat):void; function get condenseWhite():Boolean; function get displayAsPassword():Boolean; function get autoSize():String; function setSelection(_arg1:int, _arg2:int):void; function set scrollV(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:int):void; function set useRichTextClipboard(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function get selectionBeginIndex():int; function get selectable():Boolean; function set border(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function set multiline(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function set background(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function set embedFonts(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function set text(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:String):void; function get selectionEndIndex():int; function set mouseWheelEnabled(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function appendText(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:String):void; function get antiAliasType():String; function set styleSheet(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:StyleSheet):void; function set nonInheritingStyles(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Object):void; function set textColor(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:uint):void; function get wordWrap():Boolean; function getLineIndexAtPoint(_arg1:Number, _arg2:Number):int; function get htmlText():String; function set tabIndex(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:int):void; function get thickness():Number; function getLineIndexOfChar(value:int):int; function get bottomScrollV():int; function set restrict(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:String):void; function set alwaysShowSelection(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function getTextFormat(_arg1:int=-1, _arg2:int=-1):TextFormat; function set sharpness(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Number):void; function set type(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:String):void; function setTextFormat(_arg1:TextFormat, _arg2:int=-1, _arg3:int=-1):void; function set gridFitType(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:String):void; function getUITextFormat():UITextFormat; function set inheritingStyles(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Object):void; function setFocus():void; function get borderColor():uint; function set condenseWhite(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function get textWidth():Number; function getLineOffset(value:int):int; function set displayAsPassword(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function set autoSize(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:String):void; function get defaultTextFormat():TextFormat; function get useRichTextClipboard():Boolean; function get nonZeroTextHeight():Number; function set backgroundColor(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:uint):void; function get embedFonts():Boolean; function set selectable(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function get multiline():Boolean; function set maxChars(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:int):void; function get textHeight():Number; function get nonInheritingStyles():Object; function getLineText(mx.core:IUITextField/mx.core:IUITextField:alwaysShowSelection/get:int):String; function set focusRect(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Object):void; function get mouseWheelEnabled():Boolean; function get restrict():String; function getParagraphLength(value:int):int; function set mouseEnabled(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function get gridFitType():String; function get inheritingStyles():Object; function set ignorePadding(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function set antiAliasType(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:String):void; function get backgroundColor():uint; function getCharIndexAtPoint(_arg1:Number, _arg2:Number):int; function set tabEnabled(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function get maxChars():int; function get focusRect():Object; function get ignorePadding():Boolean; function get mouseEnabled():Boolean; function get length():int; function set wordWrap(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Boolean):void; function get tabEnabled():Boolean; function set thickness(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:Number):void; function getLineLength(value:int):int; function truncateToFit(:String=null):Boolean; function set htmlText(E:\dev\3.0.x\frameworks\projects\framework\src;mx\core;ITextFieldInterface.as:String):void; function getLineMetrics(antiAliasType:int):TextLineMetrics; function getStyle(*:String); } }//package mx.core
Section 122
//mx_internal (mx.core.mx_internal) package mx.core { public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal"; }//package mx.core
Section 123
//ResourceModuleRSLItem (mx.core.ResourceModuleRSLItem) package mx.core { import flash.events.*; import mx.events.*; import mx.resources.*; public class ResourceModuleRSLItem extends RSLItem { mx_internal static const VERSION:String = "3.0.0.0"; public function ResourceModuleRSLItem(url:String){ super(url); } private function resourceErrorHandler(event:ResourceEvent):void{ var errorEvent:IOErrorEvent = new IOErrorEvent(IOErrorEvent.IO_ERROR); errorEvent.text = event.errorText; super.itemErrorHandler(errorEvent); } override public function load(progressHandler:Function, completeHandler:Function, ioErrorHandler:Function, securityErrorHandler:Function, rslErrorHandler:Function):void{ chainedProgressHandler = progressHandler; chainedCompleteHandler = completeHandler; chainedIOErrorHandler = ioErrorHandler; chainedSecurityErrorHandler = securityErrorHandler; chainedRSLErrorHandler = rslErrorHandler; var resourceManager:IResourceManager = ResourceManager.getInstance(); var eventDispatcher:IEventDispatcher = resourceManager.loadResourceModule(url); eventDispatcher.addEventListener(ResourceEvent.PROGRESS, itemProgressHandler); eventDispatcher.addEventListener(ResourceEvent.COMPLETE, itemCompleteHandler); eventDispatcher.addEventListener(ResourceEvent.ERROR, resourceErrorHandler); } } }//package mx.core
Section 124
//RSLItem (mx.core.RSLItem) package mx.core { import flash.events.*; import flash.system.*; import flash.display.*; import mx.events.*; import flash.net.*; public class RSLItem { protected var chainedSecurityErrorHandler:Function; public var total:uint;// = 0 public var loaded:uint;// = 0 private var completed:Boolean;// = false protected var chainedRSLErrorHandler:Function; protected var chainedIOErrorHandler:Function; protected var chainedCompleteHandler:Function; private var errorText:String; protected var chainedProgressHandler:Function; public var urlRequest:URLRequest; protected var url:String; mx_internal static const VERSION:String = "3.0.0.0"; public function RSLItem(url:String){ super(); this.url = url; } public function itemProgressHandler(event:ProgressEvent):void{ loaded = event.bytesLoaded; total = event.bytesTotal; if (chainedProgressHandler != null){ chainedProgressHandler(event); }; } public function itemErrorHandler(event:ErrorEvent):void{ errorText = decodeURI(event.text); completed = true; loaded = 0; total = 0; trace(errorText); if ((((event.type == IOErrorEvent.IO_ERROR)) && (!((chainedIOErrorHandler == null))))){ chainedIOErrorHandler(event); } else { if ((((event.type == SecurityErrorEvent.SECURITY_ERROR)) && (!((chainedSecurityErrorHandler == null))))){ chainedSecurityErrorHandler(event); } else { if ((((event.type == RSLEvent.RSL_ERROR)) && (!((chainedRSLErrorHandler == null))))){ chainedRSLErrorHandler(event); }; }; }; } public function load(progressHandler:Function, completeHandler:Function, ioErrorHandler:Function, securityErrorHandler:Function, rslErrorHandler:Function):void{ chainedProgressHandler = progressHandler; chainedCompleteHandler = completeHandler; chainedIOErrorHandler = ioErrorHandler; chainedSecurityErrorHandler = securityErrorHandler; chainedRSLErrorHandler = rslErrorHandler; var loader:Loader = new Loader(); var loaderContext:LoaderContext = new LoaderContext(); urlRequest = new URLRequest(url); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, itemProgressHandler); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, itemCompleteHandler); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, itemErrorHandler); loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, itemErrorHandler); loaderContext.applicationDomain = ApplicationDomain.currentDomain; loader.load(urlRequest, loaderContext); } public function itemCompleteHandler(event:Event):void{ completed = true; if (chainedCompleteHandler != null){ chainedCompleteHandler(event); }; } } }//package mx.core
Section 125
//RSLListLoader (mx.core.RSLListLoader) package mx.core { import flash.events.*; public class RSLListLoader { private var chainedSecurityErrorHandler:Function; private var chainedIOErrorHandler:Function; private var rslList:Array; private var chainedRSLErrorHandler:Function; private var chainedCompleteHandler:Function; private var currentIndex:int;// = 0 private var chainedProgressHandler:Function; mx_internal static const VERSION:String = "3.0.0.0"; public function RSLListLoader(rslList:Array){ rslList = []; super(); this.rslList = rslList; } private function loadNext():void{ if (!isDone()){ currentIndex++; if (currentIndex < rslList.length){ rslList[currentIndex].load(chainedProgressHandler, listCompleteHandler, listIOErrorHandler, listSecurityErrorHandler, chainedRSLErrorHandler); }; }; } public function getIndex():int{ return (currentIndex); } public function load(progressHandler:Function, completeHandler:Function, ioErrorHandler:Function, securityErrorHandler:Function, rslErrorHandler:Function):void{ chainedProgressHandler = progressHandler; chainedCompleteHandler = completeHandler; chainedIOErrorHandler = ioErrorHandler; chainedSecurityErrorHandler = securityErrorHandler; chainedRSLErrorHandler = rslErrorHandler; currentIndex = -1; loadNext(); } private function listCompleteHandler(event:Event):void{ if (chainedCompleteHandler != null){ chainedCompleteHandler(event); }; loadNext(); } public function isDone():Boolean{ return ((currentIndex >= rslList.length)); } private function listSecurityErrorHandler(event:Event):void{ if (chainedSecurityErrorHandler != null){ chainedSecurityErrorHandler(event); }; } public function getItemCount():int{ return (rslList.length); } public function getItem(index:int):RSLItem{ if ((((index < 0)) || ((index >= rslList.length)))){ return (null); }; return (rslList[index]); } private function listIOErrorHandler(event:Event):void{ if (chainedIOErrorHandler != null){ chainedIOErrorHandler(event); }; } } }//package mx.core
Section 126
//Singleton (mx.core.Singleton) package mx.core { public class Singleton { mx_internal static const VERSION:String = "3.0.0.0"; private static var classMap:Object = {}; public function Singleton(){ super(); } public static function registerClass(interfaceName:String, clazz:Class):void{ var c:Class = classMap[interfaceName]; if (!c){ classMap[interfaceName] = clazz; }; } public static function getClass(interfaceName:String):Class{ return (classMap[interfaceName]); } public static function getInstance(interfaceName:String):Object{ var c:Class = classMap[interfaceName]; if (!c){ throw (new Error((("No class registered for interface '" + interfaceName) + "'."))); }; return (c["getInstance"]()); } } }//package mx.core
Section 127
//SoundAsset (mx.core.SoundAsset) package mx.core { import flash.media.*; public class SoundAsset extends Sound implements IFlexAsset { mx_internal static const VERSION:String = "3.0.0.0"; public function SoundAsset(){ super(); } } }//package mx.core
Section 128
//TextFieldFactory (mx.core.TextFieldFactory) package mx.core { import flash.text.*; import flash.utils.*; public class TextFieldFactory implements ITextFieldFactory { private var textFields:Dictionary; mx_internal static const VERSION:String = "3.0.0.0"; private static var instance:ITextFieldFactory; public function TextFieldFactory(){ textFields = new Dictionary(true); super(); } public function createTextField(moduleFactory:IFlexModuleFactory):TextField{ var iter:Object; var textField:TextField; var textFieldDictionary:Dictionary = textFields[moduleFactory]; if (textFieldDictionary){ for (iter in textFieldDictionary) { textField = TextField(iter); break; }; }; if (!textField){ if (moduleFactory){ textField = TextField(moduleFactory.create("flash.text.TextField")); } else { textField = new TextField(); }; if (!textFieldDictionary){ textFieldDictionary = new Dictionary(true); }; textFieldDictionary[textField] = 1; textFields[moduleFactory] = textFieldDictionary; }; return (textField); } public static function getInstance():ITextFieldFactory{ if (!instance){ instance = new (TextFieldFactory); }; return (instance); } } }//package mx.core
Section 129
//UIComponent (mx.core.UIComponent) package mx.core { import flash.events.*; import mx.styles.*; import flash.system.*; import flash.display.*; import flash.geom.*; import flash.text.*; import mx.modules.*; import mx.events.*; import mx.resources.*; import mx.managers.*; import mx.automation.*; import mx.controls.*; import mx.states.*; import mx.effects.*; import mx.graphics.*; import mx.binding.*; import flash.utils.*; import mx.utils.*; import mx.validators.*; public class UIComponent extends FlexSprite implements IAutomationObject, IChildList, IDeferredInstantiationUIComponent, IFlexDisplayObject, IFlexModule, IInvalidating, ILayoutManagerClient, IPropertyChangeNotifier, IRepeaterClient, ISimpleStyleClient, IStyleClient, IToolTipManagerClient, IUIComponent, IValidatorListener, IStateClient, IConstraintClient { private var cachedEmbeddedFont:EmbeddedFont;// = null private var errorStringChanged:Boolean;// = false mx_internal var overlay:UIComponent; mx_internal var automaticRadioButtonGroups:Object; private var _currentState:String; private var _isPopUp:Boolean; private var _repeaters:Array; private var _systemManager:ISystemManager; private var _measuredWidth:Number;// = 0 private var methodQueue:Array; mx_internal var _width:Number; private var _tweeningProperties:Array; private var _validationSubField:String; private var _endingEffectInstances:Array; mx_internal var saveBorderColor:Boolean;// = true mx_internal var overlayColor:uint; mx_internal var overlayReferenceCount:int;// = 0 private var hasFontContextBeenSaved:Boolean;// = false private var _repeaterIndices:Array; private var oldExplicitWidth:Number; mx_internal var _descriptor:UIComponentDescriptor; private var _initialized:Boolean;// = false private var _focusEnabled:Boolean;// = true private var cacheAsBitmapCount:int;// = 0 private var requestedCurrentState:String; private var listeningForRender:Boolean;// = false mx_internal var invalidateDisplayListFlag:Boolean;// = false private var oldScaleX:Number;// = 1 private var oldScaleY:Number;// = 1 mx_internal var _explicitMaxHeight:Number; mx_internal var invalidatePropertiesFlag:Boolean;// = false private var hasFocusRect:Boolean;// = false mx_internal var invalidateSizeFlag:Boolean;// = false private var _scaleX:Number;// = 1 private var _scaleY:Number;// = 1 private var _styleDeclaration:CSSStyleDeclaration; private var _resourceManager:IResourceManager; mx_internal var _affectedProperties:Object; mx_internal var _documentDescriptor:UIComponentDescriptor; private var _processedDescriptors:Boolean;// = false mx_internal var origBorderColor:Number; private var _focusManager:IFocusManager; private var _cachePolicy:String;// = "auto" private var _measuredHeight:Number;// = 0 private var _id:String; private var _owner:DisplayObjectContainer; public var transitions:Array; mx_internal var _parent:DisplayObjectContainer; private var _measuredMinWidth:Number;// = 0 private var oldMinWidth:Number; private var _explicitWidth:Number; private var _enabled:Boolean;// = false public var states:Array; private var _mouseFocusEnabled:Boolean;// = true private var oldHeight:Number;// = 0 private var _currentStateChanged:Boolean; private var cachedTextFormat:UITextFormat; mx_internal var _height:Number; private var _automationDelegate:IAutomationObject; private var _percentWidth:Number; private var _automationName:String;// = null private var _isEffectStarted:Boolean;// = false private var _styleName:Object; private var lastUnscaledWidth:Number; mx_internal var _document:Object; mx_internal var _errorString:String;// = "" private var oldExplicitHeight:Number; private var _nestLevel:int;// = 0 private var _systemManagerDirty:Boolean;// = false private var _explicitHeight:Number; mx_internal var _toolTip:String; private var _filters:Array; private var _focusPane:Sprite; private var playStateTransition:Boolean;// = true private var _nonInheritingStyles:Object; private var _showInAutomationHierarchy:Boolean;// = true private var _moduleFactory:IFlexModuleFactory; private var preventDrawFocus:Boolean;// = false private var oldX:Number;// = 0 private var oldY:Number;// = 0 private var _instanceIndices:Array; private var _visible:Boolean;// = true private var _inheritingStyles:Object; private var _includeInLayout:Boolean;// = true mx_internal var _effectsStarted:Array; mx_internal var _explicitMinWidth:Number; private var lastUnscaledHeight:Number; mx_internal var _explicitMaxWidth:Number; private var _measuredMinHeight:Number;// = 0 private var _uid:String; private var _currentTransitionEffect:IEffect; private var _updateCompletePendingFlag:Boolean;// = false private var oldMinHeight:Number; private var _flexContextMenu:IFlexContextMenu; mx_internal var _explicitMinHeight:Number; private var _percentHeight:Number; private var oldEmbeddedFontContext:IFlexModuleFactory;// = null private var oldWidth:Number;// = 0 public static const DEFAULT_MEASURED_WIDTH:Number = 160; public static const DEFAULT_MAX_WIDTH:Number = 10000; public static const DEFAULT_MEASURED_MIN_HEIGHT:Number = 22; public static const DEFAULT_MAX_HEIGHT:Number = 10000; public static const DEFAULT_MEASURED_HEIGHT:Number = 22; mx_internal static const VERSION:String = "3.0.0.0"; public static const DEFAULT_MEASURED_MIN_WIDTH:Number = 40; mx_internal static var dispatchEventHook:Function; private static var fakeMouseY:QName = new QName(mx_internal, "_mouseY"); mx_internal static var createAccessibilityImplementation:Function; mx_internal static var STYLE_UNINITIALIZED:Object = {}; private static var fakeMouseX:QName = new QName(mx_internal, "_mouseX"); private static var _embeddedFontRegistry:IEmbeddedFontRegistry; public function UIComponent(){ methodQueue = []; _resourceManager = ResourceManager.getInstance(); _inheritingStyles = UIComponent.STYLE_UNINITIALIZED; _nonInheritingStyles = UIComponent.STYLE_UNINITIALIZED; states = []; transitions = []; _effectsStarted = []; _affectedProperties = {}; _endingEffectInstances = []; super(); focusRect = false; tabEnabled = (this is IFocusManagerComponent); tabChildren = false; enabled = true; $visible = false; addEventListener(Event.ADDED, addedHandler); addEventListener(Event.REMOVED, removedHandler); if ((this is IFocusManagerComponent)){ addEventListener(FocusEvent.FOCUS_IN, focusInHandler); addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler); addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler); addEventListener(KeyboardEvent.KEY_UP, keyUpHandler); }; resourcesChanged(); resourceManager.addEventListener(Event.CHANGE, resourceManager_changeHandler, false, 0, true); _width = super.width; _height = super.height; } override public function get filters():Array{ return ((_filters) ? _filters : super.filters); } public function get toolTip():String{ return (_toolTip); } private function transition_effectEndHandler(event:EffectEvent):void{ _currentTransitionEffect = null; } public function get nestLevel():int{ return (_nestLevel); } protected function adjustFocusRect(obj:DisplayObject=null):void{ var rectCol:Number; var thickness:Number; var pt:Point; var rotRad:Number; if (!obj){ obj = this; }; if (((isNaN(obj.width)) || (isNaN(obj.height)))){ return; }; var fm:IFocusManager = focusManager; if (!fm){ return; }; var focusObj:IFlexDisplayObject = IFlexDisplayObject(getFocusObject()); if (focusObj){ if (((errorString) && (!((errorString == ""))))){ rectCol = getStyle("errorColor"); } else { rectCol = getStyle("themeColor"); }; thickness = getStyle("focusThickness"); if ((focusObj is IStyleClient)){ IStyleClient(focusObj).setStyle("focusColor", rectCol); }; focusObj.setActualSize((obj.width + (2 * thickness)), (obj.height + (2 * thickness))); if (rotation){ rotRad = ((rotation * Math.PI) / 180); pt = new Point((obj.x - (thickness * (Math.cos(rotRad) - Math.sin(rotRad)))), (obj.y - (thickness * (Math.cos(rotRad) + Math.sin(rotRad))))); DisplayObject(focusObj).rotation = rotation; } else { pt = new Point((obj.x - thickness), (obj.y - thickness)); }; if (obj.parent == this){ pt.x = (pt.x + x); pt.y = (pt.y + y); }; pt = parent.localToGlobal(pt); pt = parent.globalToLocal(pt); focusObj.move(pt.x, pt.y); if ((focusObj is IInvalidating)){ IInvalidating(focusObj).validateNow(); } else { if ((focusObj is IProgrammaticSkin)){ IProgrammaticSkin(focusObj).validateNow(); }; }; }; } mx_internal function setUnscaledWidth(value:Number):void{ var scaledValue:Number = (value * Math.abs(oldScaleX)); if (_explicitWidth == scaledValue){ return; }; if (!isNaN(scaledValue)){ _percentWidth = NaN; }; _explicitWidth = scaledValue; invalidateSize(); var p:IInvalidating = (parent as IInvalidating); if (((p) && (includeInLayout))){ p.invalidateSize(); p.invalidateDisplayList(); }; } public function set nestLevel(value:int):void{ var childList:IChildList; var n:int; var i:int; var ui:ILayoutManagerClient; var textField:IUITextField; if ((((value > 1)) && (!((_nestLevel == value))))){ _nestLevel = value; updateCallbacks(); childList = ((this is IRawChildrenContainer)) ? IRawChildrenContainer(this).rawChildren : IChildList(this); n = childList.numChildren; i = 0; while (i < n) { ui = (childList.getChildAt(i) as ILayoutManagerClient); if (ui){ ui.nestLevel = (value + 1); } else { textField = (childList.getChildAt(i) as IUITextField); if (textField){ textField.nestLevel = (value + 1); }; }; i++; }; }; } public function getExplicitOrMeasuredHeight():Number{ return ((isNaN(explicitHeight)) ? measuredHeight : explicitHeight); } private function callLaterDispatcher(event:Event):void{ var callLaterErrorEvent:DynamicEvent; var event = event; UIComponentGlobals.callLaterDispatcherCount++; if (!UIComponentGlobals.catchCallLaterExceptions){ callLaterDispatcher2(event); } else { callLaterDispatcher2(event); //unresolved jump var _slot1 = e; callLaterErrorEvent = new DynamicEvent("callLaterError"); callLaterErrorEvent.error = _slot1; systemManager.dispatchEvent(callLaterErrorEvent); }; UIComponentGlobals.callLaterDispatcherCount--; } public function getStyle(styleProp:String){ return ((StyleManager.inheritingStyles[styleProp]) ? _inheritingStyles[styleProp] : _nonInheritingStyles[styleProp]); } final mx_internal function get $width():Number{ return (super.width); } public function get className():String{ var name:String = getQualifiedClassName(this); var index:int = name.indexOf("::"); if (index != -1){ name = name.substr((index + 2)); }; return (name); } public function verticalGradientMatrix(x:Number, y:Number, width:Number, height:Number):Matrix{ UIComponentGlobals.tempMatrix.createGradientBox(width, height, (Math.PI / 2), x, y); return (UIComponentGlobals.tempMatrix); } public function setCurrentState(stateName:String, playTransition:Boolean=true):void{ if (((!((stateName == currentState))) && (!(((isBaseState(stateName)) && (isBaseState(currentState))))))){ requestedCurrentState = stateName; playStateTransition = playTransition; if (initialized){ commitCurrentState(); } else { _currentStateChanged = true; addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler); }; }; } private function getBaseStates(state:State):Array{ var baseStates:Array = []; while (((state) && (state.basedOn))) { baseStates.push(state.basedOn); state = getState(state.basedOn); }; return (baseStates); } public function set minHeight(value:Number):void{ if (explicitMinHeight == value){ return; }; explicitMinHeight = value; } protected function isOurFocus(target:DisplayObject):Boolean{ return ((target == this)); } public function get errorString():String{ return (_errorString); } mx_internal function setUnscaledHeight(value:Number):void{ var scaledValue:Number = (value * Math.abs(oldScaleY)); if (_explicitHeight == scaledValue){ return; }; if (!isNaN(scaledValue)){ _percentHeight = NaN; }; _explicitHeight = scaledValue; invalidateSize(); var p:IInvalidating = (parent as IInvalidating); if (((p) && (includeInLayout))){ p.invalidateSize(); p.invalidateDisplayList(); }; } public function get automationName():String{ if (_automationName){ return (_automationName); }; if (automationDelegate){ return (automationDelegate.automationName); }; return (""); } final mx_internal function set $width(value:Number):void{ super.width = value; } public function invalidateDisplayList():void{ if (!invalidateDisplayListFlag){ invalidateDisplayListFlag = true; if (((parent) && (UIComponentGlobals.layoutManager))){ UIComponentGlobals.layoutManager.invalidateDisplayList(this); }; }; } mx_internal function initThemeColor():Boolean{ var tc:Object; var rc:Number; var sc:Number; var classSelector:Object; var typeSelectors:Array; var i:int; var typeSelector:CSSStyleDeclaration; var styleName:Object = _styleName; if (_styleDeclaration){ tc = _styleDeclaration.getStyle("themeColor"); rc = _styleDeclaration.getStyle("rollOverColor"); sc = _styleDeclaration.getStyle("selectionColor"); }; if ((((((tc === null)) || (!(StyleManager.isValidStyleValue(tc))))) && (((styleName) && (!((styleName is ISimpleStyleClient))))))){ classSelector = ((styleName is String)) ? StyleManager.getStyleDeclaration(("." + styleName)) : styleName; if (classSelector){ tc = classSelector.getStyle("themeColor"); rc = classSelector.getStyle("rollOverColor"); sc = classSelector.getStyle("selectionColor"); }; }; if ((((tc === null)) || (!(StyleManager.isValidStyleValue(tc))))){ typeSelectors = getClassStyleDeclarations(); i = 0; while (i < typeSelectors.length) { typeSelector = typeSelectors[i]; if (typeSelector){ tc = typeSelector.getStyle("themeColor"); rc = typeSelector.getStyle("rollOverColor"); sc = typeSelector.getStyle("selectionColor"); }; if (((!((tc === null))) && (StyleManager.isValidStyleValue(tc)))){ break; }; i++; }; }; if (((((((!((tc === null))) && (StyleManager.isValidStyleValue(tc)))) && (isNaN(rc)))) && (isNaN(sc)))){ setThemeColor(tc); return (true); }; return (((((((!((tc === null))) && (StyleManager.isValidStyleValue(tc)))) && (!(isNaN(rc))))) && (!(isNaN(sc))))); } override public function get scaleX():Number{ return (_scaleX); } public function get uid():String{ if (!_uid){ _uid = toString(); }; return (_uid); } override public function get mouseX():Number{ if (((((!(root)) || ((root is Stage)))) || ((root[fakeMouseX] === undefined)))){ return (super.mouseX); }; return (globalToLocal(new Point(root[fakeMouseX], 0)).x); } override public function stopDrag():void{ super.stopDrag(); invalidateProperties(); dispatchEvent(new Event("xChanged")); dispatchEvent(new Event("yChanged")); } public function get focusPane():Sprite{ return (_focusPane); } public function set tweeningProperties(value:Array):void{ _tweeningProperties = value; } public function horizontalGradientMatrix(x:Number, y:Number, width:Number, height:Number):Matrix{ UIComponentGlobals.tempMatrix.createGradientBox(width, height, 0, x, y); return (UIComponentGlobals.tempMatrix); } public function get isDocument():Boolean{ return ((document == this)); } public function set validationSubField(value:String):void{ _validationSubField = value; } override public function get scaleY():Number{ return (_scaleY); } protected function keyDownHandler(event:KeyboardEvent):void{ } protected function createInFontContext(classObj:Class):Object{ hasFontContextBeenSaved = true; var fontName:String = StringUtil.trimArrayElements(getStyle("fontFamily"), ","); var fontWeight:String = getStyle("fontWeight"); var fontStyle:String = getStyle("fontStyle"); var bold = (fontWeight == "bold"); var italic = (fontStyle == "italic"); oldEmbeddedFontContext = getFontContext(fontName, bold, italic); var obj:Object = createInModuleContext((oldEmbeddedFontContext) ? oldEmbeddedFontContext : moduleFactory, getQualifiedClassName(classObj)); if (obj == null){ obj = new (classObj); }; return (obj); } public function get screen():Rectangle{ var sm:ISystemManager = systemManager; return ((sm) ? sm.screen : null); } protected function focusInHandler(event:FocusEvent):void{ var fm:IFocusManager; if (isOurFocus(DisplayObject(event.target))){ fm = focusManager; if (((fm) && (fm.showFocusIndicator))){ drawFocus(true); }; ContainerGlobals.checkFocus(event.relatedObject, this); }; } public function hasFontContextChanged():Boolean{ if (!hasFontContextBeenSaved){ return (false); }; var fontName:String = StringUtil.trimArrayElements(getStyle("fontFamily"), ","); var fontWeight:String = getStyle("fontWeight"); var fontStyle:String = getStyle("fontStyle"); var bold = (fontWeight == "bold"); var italic = (fontStyle == "italic"); var embeddedFont:EmbeddedFont = getEmbeddedFont(fontName, bold, italic); var fontContext:IFlexModuleFactory = embeddedFontRegistry.getAssociatedModuleFactory(embeddedFont, moduleFactory); return (!((fontContext == oldEmbeddedFontContext))); } public function get explicitHeight():Number{ return (_explicitHeight); } override public function get x():Number{ return (super.x); } override public function get y():Number{ return (super.y); } override public function get visible():Boolean{ return (_visible); } mx_internal function addOverlay(color:uint, targetArea:RoundedRectangle=null):void{ if (!overlay){ overlayColor = color; overlay = new UIComponent(); overlay.name = "overlay"; overlay.$visible = true; fillOverlay(overlay, color, targetArea); attachOverlay(); if (!targetArea){ addEventListener(ResizeEvent.RESIZE, overlay_resizeHandler); }; overlay.x = 0; overlay.y = 0; invalidateDisplayList(); overlayReferenceCount = 1; } else { overlayReferenceCount++; }; dispatchEvent(new ChildExistenceChangedEvent(ChildExistenceChangedEvent.OVERLAY_CREATED, true, false, overlay)); } public function get percentWidth():Number{ return (_percentWidth); } public function set explicitMinHeight(value:Number):void{ if (_explicitMinHeight == value){ return; }; _explicitMinHeight = value; invalidateSize(); var p:IInvalidating = (parent as IInvalidating); if (p){ p.invalidateSize(); p.invalidateDisplayList(); }; dispatchEvent(new Event("explicitMinHeightChanged")); } public function set automationName(value:String):void{ _automationName = value; } public function get mouseFocusEnabled():Boolean{ return (_mouseFocusEnabled); } mx_internal function getEmbeddedFont(fontName:String, bold:Boolean, italic:Boolean):EmbeddedFont{ if (cachedEmbeddedFont){ if ((((cachedEmbeddedFont.fontName == fontName)) && ((cachedEmbeddedFont.fontStyle == EmbeddedFontRegistry.getFontStyle(bold, italic))))){ return (cachedEmbeddedFont); }; }; cachedEmbeddedFont = new EmbeddedFont(fontName, bold, italic); return (cachedEmbeddedFont); } public function stylesInitialized():void{ } public function set errorString(value:String):void{ var oldValue:String = _errorString; _errorString = value; ToolTipManager.registerErrorString(this, oldValue, value); errorStringChanged = true; invalidateProperties(); dispatchEvent(new Event("errorStringChanged")); } public function getExplicitOrMeasuredWidth():Number{ return ((isNaN(explicitWidth)) ? measuredWidth : explicitWidth); } final mx_internal function set $height(value:Number):void{ super.height = value; } protected function keyUpHandler(event:KeyboardEvent):void{ } final mx_internal function $removeChild(child:DisplayObject):DisplayObject{ return (super.removeChild(child)); } override public function set scaleX(value:Number):void{ if (_scaleX == value){ return; }; _scaleX = value; invalidateProperties(); invalidateSize(); dispatchEvent(new Event("scaleXChanged")); } override public function set scaleY(value:Number):void{ if (_scaleY == value){ return; }; _scaleY = value; invalidateProperties(); invalidateSize(); dispatchEvent(new Event("scaleYChanged")); } public function set uid(uid:String):void{ this._uid = uid; } public function createAutomationIDPart(child:IAutomationObject):Object{ if (automationDelegate){ return (automationDelegate.createAutomationIDPart(child)); }; return (null); } public function getAutomationChildAt(index:int):IAutomationObject{ if (automationDelegate){ return (automationDelegate.getAutomationChildAt(index)); }; return (null); } mx_internal function get isEffectStarted():Boolean{ return (_isEffectStarted); } override public function get parent():DisplayObjectContainer{ return ((_parent) ? _parent : super.parent); } override public function get mouseY():Number{ if (((((!(root)) || ((root is Stage)))) || ((root[fakeMouseY] === undefined)))){ return (super.mouseY); }; return (globalToLocal(new Point(0, root[fakeMouseY])).y); } public function setActualSize(w:Number, h:Number):void{ var changed:Boolean; if (_width != w){ _width = w; dispatchEvent(new Event("widthChanged")); changed = true; }; if (_height != h){ _height = h; dispatchEvent(new Event("heightChanged")); changed = true; }; if (changed){ invalidateDisplayList(); dispatchResizeEvent(); }; } private function focusObj_resizeHandler(event:ResizeEvent):void{ adjustFocusRect(); } mx_internal function adjustSizesForScaleChanges():void{ var scalingFactor:Number; var xScale:Number = scaleX; var yScale:Number = scaleY; if (xScale != oldScaleX){ scalingFactor = Math.abs((xScale / oldScaleX)); if (explicitMinWidth){ explicitMinWidth = (explicitMinWidth * scalingFactor); }; if (!isNaN(explicitWidth)){ explicitWidth = (explicitWidth * scalingFactor); }; if (explicitMaxWidth){ explicitMaxWidth = (explicitMaxWidth * scalingFactor); }; oldScaleX = xScale; }; if (yScale != oldScaleY){ scalingFactor = Math.abs((yScale / oldScaleY)); if (explicitMinHeight){ explicitMinHeight = (explicitMinHeight * scalingFactor); }; if (explicitHeight){ explicitHeight = (explicitHeight * scalingFactor); }; if (explicitMaxHeight){ explicitMaxHeight = (explicitMaxHeight * scalingFactor); }; oldScaleY = yScale; }; } public function set focusPane(value:Sprite):void{ if (value){ addChild(value); value.x = 0; value.y = 0; value.scrollRect = null; _focusPane = value; } else { removeChild(_focusPane); _focusPane = null; }; } public function determineTextFormatFromStyles():UITextFormat{ var font:String; var textFormat:UITextFormat = cachedTextFormat; if (!textFormat){ font = StringUtil.trimArrayElements(_inheritingStyles.fontFamily, ","); textFormat = new UITextFormat(getNonNullSystemManager(), font); textFormat.moduleFactory = moduleFactory; textFormat.align = _inheritingStyles.textAlign; textFormat.bold = (_inheritingStyles.fontWeight == "bold"); textFormat.color = (enabled) ? _inheritingStyles.color : _inheritingStyles.disabledColor; textFormat.font = font; textFormat.indent = _inheritingStyles.textIndent; textFormat.italic = (_inheritingStyles.fontStyle == "italic"); textFormat.kerning = _inheritingStyles.kerning; textFormat.leading = _nonInheritingStyles.leading; textFormat.leftMargin = _nonInheritingStyles.paddingLeft; textFormat.letterSpacing = _inheritingStyles.letterSpacing; textFormat.rightMargin = _nonInheritingStyles.paddingRight; textFormat.size = _inheritingStyles.fontSize; textFormat.underline = (_nonInheritingStyles.textDecoration == "underline"); textFormat.antiAliasType = _inheritingStyles.fontAntiAliasType; textFormat.gridFitType = _inheritingStyles.fontGridFitType; textFormat.sharpness = _inheritingStyles.fontSharpness; textFormat.thickness = _inheritingStyles.fontThickness; cachedTextFormat = textFormat; }; return (textFormat); } public function validationResultHandler(event:ValidationResultEvent):void{ var msg:String; var result:ValidationResult; var i:int; if (event.type == ValidationResultEvent.VALID){ if (errorString != ""){ errorString = ""; dispatchEvent(new FlexEvent(FlexEvent.VALID)); }; } else { if (((((!((validationSubField == null))) && (!((validationSubField == ""))))) && (event.results))){ i = 0; while (i < event.results.length) { result = event.results[i]; if (result.subField == validationSubField){ if (result.isError){ msg = result.errorMessage; } else { if (errorString != ""){ errorString = ""; dispatchEvent(new FlexEvent(FlexEvent.VALID)); }; }; break; }; i++; }; } else { if (((event.results) && ((event.results.length > 0)))){ msg = event.results[0].errorMessage; }; }; if (((msg) && (!((errorString == msg))))){ errorString = msg; dispatchEvent(new FlexEvent(FlexEvent.INVALID)); }; }; } public function invalidateProperties():void{ if (!invalidatePropertiesFlag){ invalidatePropertiesFlag = true; if (((parent) && (UIComponentGlobals.layoutManager))){ UIComponentGlobals.layoutManager.invalidateProperties(this); }; }; } public function get inheritingStyles():Object{ return (_inheritingStyles); } private function focusObj_scrollHandler(event:Event):void{ adjustFocusRect(); } final mx_internal function get $x():Number{ return (super.x); } final mx_internal function get $y():Number{ return (super.y); } public function setConstraintValue(constraintName:String, value):void{ setStyle(constraintName, value); } protected function resourcesChanged():void{ } public function registerEffects(effects:Array):void{ var event:String; var n:int = effects.length; var i:int; while (i < n) { event = EffectManager.getEventForEffectTrigger(effects[i]); if (((!((event == null))) && (!((event == ""))))){ addEventListener(event, EffectManager.eventHandler, false, EventPriority.EFFECT); }; i++; }; } public function get explicitMinWidth():Number{ return (_explicitMinWidth); } private function filterChangeHandler(event:Event):void{ super.filters = _filters; } override public function set visible(value:Boolean):void{ setVisible(value); } public function set explicitHeight(value:Number):void{ if (_explicitHeight == value){ return; }; if (!isNaN(value)){ _percentHeight = NaN; }; _explicitHeight = value; invalidateSize(); var p:IInvalidating = (parent as IInvalidating); if (((p) && (includeInLayout))){ p.invalidateSize(); p.invalidateDisplayList(); }; dispatchEvent(new Event("explicitHeightChanged")); } override public function set x(value:Number):void{ if (super.x == value){ return; }; super.x = value; invalidateProperties(); dispatchEvent(new Event("xChanged")); } public function set showInAutomationHierarchy(value:Boolean):void{ _showInAutomationHierarchy = value; } override public function set y(value:Number):void{ if (super.y == value){ return; }; super.y = value; invalidateProperties(); dispatchEvent(new Event("yChanged")); } private function resourceManager_changeHandler(event:Event):void{ resourcesChanged(); } public function set systemManager(value:ISystemManager):void{ _systemManager = value; _systemManagerDirty = false; } mx_internal function getFocusObject():DisplayObject{ var fm:IFocusManager = focusManager; if (((!(fm)) || (!(fm.focusPane)))){ return (null); }; return (((fm.focusPane.numChildren == 0)) ? null : fm.focusPane.getChildAt(0)); } public function set percentWidth(value:Number):void{ if (_percentWidth == value){ return; }; if (!isNaN(value)){ _explicitWidth = NaN; }; _percentWidth = value; var p:IInvalidating = (parent as IInvalidating); if (p){ p.invalidateSize(); p.invalidateDisplayList(); }; } public function get moduleFactory():IFlexModuleFactory{ return (_moduleFactory); } override public function addChild(child:DisplayObject):DisplayObject{ var formerParent:DisplayObjectContainer = child.parent; if (((formerParent) && (!((formerParent is Loader))))){ formerParent.removeChild(child); }; var index:int = (((overlayReferenceCount) && (!((child == overlay))))) ? Math.max(0, (super.numChildren - 1)) : super.numChildren; addingChild(child); $addChildAt(child, index); childAdded(child); return (child); } public function get document():Object{ return (_document); } public function set mouseFocusEnabled(value:Boolean):void{ _mouseFocusEnabled = value; } final mx_internal function $addChild(child:DisplayObject):DisplayObject{ return (super.addChild(child)); } mx_internal function setThemeColor(value:Object):void{ var newValue:Number; if ((newValue is String)){ newValue = parseInt(String(value)); } else { newValue = Number(value); }; if (isNaN(newValue)){ newValue = StyleManager.getColorName(value); }; var newValueS:Number = ColorUtil.adjustBrightness2(newValue, 50); var newValueR:Number = ColorUtil.adjustBrightness2(newValue, 70); setStyle("selectionColor", newValueS); setStyle("rollOverColor", newValueR); } public function get explicitMaxWidth():Number{ return (_explicitMaxWidth); } public function get id():String{ return (_id); } override public function get height():Number{ return (_height); } public function set minWidth(value:Number):void{ if (explicitMinWidth == value){ return; }; explicitMinWidth = value; } public function set currentState(value:String):void{ setCurrentState(value, true); } public function getRepeaterItem(whichRepeater:int=-1):Object{ var repeaterArray:Array = repeaters; if (whichRepeater == -1){ whichRepeater = (repeaterArray.length - 1); }; return (repeaterArray[whichRepeater].getItemAt(repeaterIndices[whichRepeater])); } public function executeBindings(recurse:Boolean=false):void{ var bindingsHost:Object = (((descriptor) && (descriptor.document))) ? descriptor.document : parentDocument; BindingManager.executeBindings(bindingsHost, id, this); } public function replayAutomatableEvent(event:Event):Boolean{ if (automationDelegate){ return (automationDelegate.replayAutomatableEvent(event)); }; return (false); } mx_internal function getFontContext(fontName:String, bold:Boolean, italic:Boolean):IFlexModuleFactory{ return (embeddedFontRegistry.getAssociatedModuleFactory(getEmbeddedFont(fontName, bold, italic), moduleFactory)); } public function get instanceIndex():int{ return ((_instanceIndices) ? _instanceIndices[(_instanceIndices.length - 1)] : -1); } public function set measuredWidth(value:Number):void{ _measuredWidth = value; } public function effectFinished(effectInst:IEffectInstance):void{ _endingEffectInstances.push(effectInst); invalidateProperties(); UIComponentGlobals.layoutManager.addEventListener(FlexEvent.UPDATE_COMPLETE, updateCompleteHandler, false, 0, true); } mx_internal function set isEffectStarted(value:Boolean):void{ _isEffectStarted = value; } mx_internal function fillOverlay(overlay:UIComponent, color:uint, targetArea:RoundedRectangle=null):void{ if (!targetArea){ targetArea = new RoundedRectangle(0, 0, unscaledWidth, unscaledHeight, 0); }; var g:Graphics = overlay.graphics; g.clear(); g.beginFill(color); g.drawRoundRect(targetArea.x, targetArea.y, targetArea.width, targetArea.height, (targetArea.cornerRadius * 2), (targetArea.cornerRadius * 2)); g.endFill(); } public function get instanceIndices():Array{ return ((_instanceIndices) ? _instanceIndices.slice(0) : null); } mx_internal function childAdded(child:DisplayObject):void{ if ((child is UIComponent)){ if (!UIComponent(child).initialized){ UIComponent(child).initialize(); }; } else { if ((child is IUIComponent)){ IUIComponent(child).initialize(); }; }; } public function globalToContent(point:Point):Point{ return (globalToLocal(point)); } mx_internal function removingChild(child:DisplayObject):void{ } mx_internal function getEffectsForProperty(propertyName:String):Array{ return (((_affectedProperties[propertyName])!=undefined) ? _affectedProperties[propertyName] : []); } override public function removeChildAt(index:int):DisplayObject{ var child:DisplayObject = getChildAt(index); removingChild(child); $removeChild(child); childRemoved(child); return (child); } protected function measure():void{ measuredMinWidth = 0; measuredMinHeight = 0; measuredWidth = 0; measuredHeight = 0; } public function set owner(value:DisplayObjectContainer):void{ _owner = value; } mx_internal function getNonNullSystemManager():ISystemManager{ var sm:ISystemManager = systemManager; if (!sm){ sm = ISystemManager(SystemManager.getSWFRoot(this)); }; if (!sm){ return (SystemManagerGlobals.topLevelSystemManagers[0]); }; return (sm); } protected function get unscaledWidth():Number{ return ((width / Math.abs(scaleX))); } public function set processedDescriptors(value:Boolean):void{ _processedDescriptors = value; if (value){ dispatchEvent(new FlexEvent(FlexEvent.INITIALIZE)); }; } private function processEffectFinished(effectInsts:Array):void{ var j:int; var effectInst:IEffectInstance; var removedInst:IEffectInstance; var aProps:Array; var k:int; var propName:String; var l:int; var i:int = (_effectsStarted.length - 1); while (i >= 0) { j = 0; while (j < effectInsts.length) { effectInst = effectInsts[j]; if (effectInst == _effectsStarted[i]){ removedInst = _effectsStarted[i]; _effectsStarted.splice(i, 1); aProps = removedInst.effect.getAffectedProperties(); k = 0; while (k < aProps.length) { propName = aProps[k]; if (_affectedProperties[propName] != undefined){ l = 0; while (l < _affectedProperties[propName].length) { if (_affectedProperties[propName][l] == effectInst){ _affectedProperties[propName].splice(l, 1); break; }; l++; }; if (_affectedProperties[propName].length == 0){ delete _affectedProperties[propName]; }; }; k++; }; break; }; j++; }; i--; }; isEffectStarted = ((_effectsStarted.length > 0)) ? true : false; if (((effectInst) && (effectInst.hideFocusRing))){ preventDrawFocus = false; }; } private function commitCurrentState():void{ var event:StateChangeEvent; var transition:IEffect = (playStateTransition) ? getTransition(_currentState, requestedCurrentState) : null; var commonBaseState:String = findCommonBaseState(_currentState, requestedCurrentState); var oldState:String = (_currentState) ? _currentState : ""; var destination:State = getState(requestedCurrentState); if (_currentTransitionEffect){ _currentTransitionEffect.end(); }; initializeState(requestedCurrentState); if (transition){ transition.captureStartValues(); }; event = new StateChangeEvent(StateChangeEvent.CURRENT_STATE_CHANGING); event.oldState = oldState; event.newState = (requestedCurrentState) ? requestedCurrentState : ""; dispatchEvent(event); if (isBaseState(_currentState)){ dispatchEvent(new FlexEvent(FlexEvent.EXIT_STATE)); }; removeState(_currentState, commonBaseState); _currentState = requestedCurrentState; if (isBaseState(currentState)){ dispatchEvent(new FlexEvent(FlexEvent.ENTER_STATE)); } else { applyState(_currentState, commonBaseState); }; event = new StateChangeEvent(StateChangeEvent.CURRENT_STATE_CHANGE); event.oldState = oldState; event.newState = (_currentState) ? _currentState : ""; dispatchEvent(event); if (transition){ UIComponentGlobals.layoutManager.validateNow(); _currentTransitionEffect = transition; transition.addEventListener(EffectEvent.EFFECT_END, transition_effectEndHandler); transition.play(); }; } public function get includeInLayout():Boolean{ return (_includeInLayout); } private function dispatchResizeEvent():void{ var resizeEvent:ResizeEvent = new ResizeEvent(ResizeEvent.RESIZE); resizeEvent.oldWidth = oldWidth; resizeEvent.oldHeight = oldHeight; dispatchEvent(resizeEvent); oldWidth = width; oldHeight = height; } public function set maxWidth(value:Number):void{ if (explicitMaxWidth == value){ return; }; explicitMaxWidth = value; } public function validateDisplayList():void{ var sm:ISystemManager; var unscaledWidth:Number; var unscaledHeight:Number; if (invalidateDisplayListFlag){ sm = (parent as ISystemManager); if (sm){ if ((((sm == systemManager.topLevelSystemManager)) && (!((sm.document == this))))){ setActualSize(getExplicitOrMeasuredWidth(), getExplicitOrMeasuredHeight()); }; }; unscaledWidth = ((scaleX == 0)) ? 0 : (width / scaleX); unscaledHeight = ((scaleY == 0)) ? 0 : (height / scaleY); if (Math.abs((unscaledWidth - lastUnscaledWidth)) < 1E-5){ unscaledWidth = lastUnscaledWidth; }; if (Math.abs((unscaledHeight - lastUnscaledHeight)) < 1E-5){ unscaledHeight = lastUnscaledHeight; }; updateDisplayList(unscaledWidth, unscaledHeight); lastUnscaledWidth = unscaledWidth; lastUnscaledHeight = unscaledHeight; invalidateDisplayListFlag = false; }; } public function contentToGlobal(point:Point):Point{ return (localToGlobal(point)); } public function resolveAutomationIDPart(criteria:Object):Array{ if (automationDelegate){ return (automationDelegate.resolveAutomationIDPart(criteria)); }; return ([]); } public function set inheritingStyles(value:Object):void{ _inheritingStyles = value; } public function setFocus():void{ var sm:ISystemManager = systemManager; if (((sm) && (sm.stage))){ if (UIComponentGlobals.callLaterDispatcherCount == 0){ sm.stage.focus = this; UIComponentGlobals.nextFocusObject = null; } else { UIComponentGlobals.nextFocusObject = this; sm.stage.addEventListener(Event.ENTER_FRAME, setFocusLater); }; } else { UIComponentGlobals.nextFocusObject = this; callLater(setFocusLater); }; } private function getTransition(oldState:String, newState:String):IEffect{ var t:Transition; var result:IEffect; var priority:int; if (!transitions){ return (null); }; if (!oldState){ oldState = ""; }; if (!newState){ newState = ""; }; var i:int; while (i < transitions.length) { t = transitions[i]; if ((((((t.fromState == "*")) && ((t.toState == "*")))) && ((priority < 1)))){ result = t.effect; priority = 1; } else { if ((((((t.fromState == oldState)) && ((t.toState == "*")))) && ((priority < 2)))){ result = t.effect; priority = 2; } else { if ((((((t.fromState == "*")) && ((t.toState == newState)))) && ((priority < 3)))){ result = t.effect; priority = 3; } else { if ((((((t.fromState == oldState)) && ((t.toState == newState)))) && ((priority < 4)))){ result = t.effect; priority = 4; break; }; }; }; }; i++; }; return (result); } public function set initialized(value:Boolean):void{ _initialized = value; if (value){ setVisible(_visible, true); dispatchEvent(new FlexEvent(FlexEvent.CREATION_COMPLETE)); }; } final mx_internal function set $y(value:Number):void{ super.y = value; } public function owns(child:DisplayObject):Boolean{ var childList:IChildList = ((this is IRawChildrenContainer)) ? IRawChildrenContainer(this).rawChildren : IChildList(this); if (childList.contains(child)){ return (true); }; while (((child) && (!((child == this))))) { if ((child is IUIComponent)){ child = IUIComponent(child).owner; } else { child = child.parent; }; }; return ((child == this)); } public function setVisible(value:Boolean, noEvent:Boolean=false):void{ _visible = value; if (!initialized){ return; }; if ($visible == value){ return; }; $visible = value; if (!noEvent){ dispatchEvent(new FlexEvent((value) ? FlexEvent.SHOW : FlexEvent.HIDE)); }; } final mx_internal function $addChildAt(child:DisplayObject, index:int):DisplayObject{ return (super.addChildAt(child, index)); } public function deleteReferenceOnParentDocument(parentDocument:IFlexDisplayObject):void{ var indices:Array; var r:Object; var stack:Array; var n:int; var i:int; var j:int; var s:Object; var event:PropertyChangeEvent; if (((id) && (!((id == ""))))){ indices = _instanceIndices; if (!indices){ parentDocument[id] = null; } else { r = parentDocument[id]; if (!r){ return; }; stack = []; stack.push(r); n = indices.length; i = 0; while (i < (n - 1)) { s = r[indices[i]]; if (!s){ return; }; r = s; stack.push(r); i++; }; r.splice(indices[(n - 1)], 1); j = (stack.length - 1); while (j > 0) { if (stack[j].length == 0){ stack[(j - 1)].splice(indices[j], 1); }; j--; }; if ((((stack.length > 0)) && ((stack[0].length == 0)))){ parentDocument[id] = null; } else { event = PropertyChangeEvent.createUpdateEvent(parentDocument, id, parentDocument[id], parentDocument[id]); parentDocument.dispatchEvent(event); }; }; }; } public function get nonInheritingStyles():Object{ return (_nonInheritingStyles); } public function effectStarted(effectInst:IEffectInstance):void{ var propName:String; _effectsStarted.push(effectInst); var aProps:Array = effectInst.effect.getAffectedProperties(); var j:int; while (j < aProps.length) { propName = aProps[j]; if (_affectedProperties[propName] == undefined){ _affectedProperties[propName] = []; }; _affectedProperties[propName].push(effectInst); j++; }; isEffectStarted = true; if (effectInst.hideFocusRing){ preventDrawFocus = true; drawFocus(false); }; } final mx_internal function set $x(value:Number):void{ super.x = value; } private function applyState(stateName:String, lastState:String):void{ var overrides:Array; var i:int; var state:State = getState(stateName); if (stateName == lastState){ return; }; if (state){ if (state.basedOn != lastState){ applyState(state.basedOn, lastState); }; overrides = state.overrides; i = 0; while (i < overrides.length) { overrides[i].apply(this); i++; }; state.dispatchEnterState(); }; } protected function commitProperties():void{ var scalingFactorX:Number; var scalingFactorY:Number; if (_scaleX != oldScaleX){ scalingFactorX = Math.abs((_scaleX / oldScaleX)); if (!isNaN(explicitMinWidth)){ explicitMinWidth = (explicitMinWidth * scalingFactorX); }; if (!isNaN(explicitWidth)){ explicitWidth = (explicitWidth * scalingFactorX); }; if (!isNaN(explicitMaxWidth)){ explicitMaxWidth = (explicitMaxWidth * scalingFactorX); }; _width = (_width * scalingFactorX); super.scaleX = (oldScaleX = _scaleX); }; if (_scaleY != oldScaleY){ scalingFactorY = Math.abs((_scaleY / oldScaleY)); if (!isNaN(explicitMinHeight)){ explicitMinHeight = (explicitMinHeight * scalingFactorY); }; if (!isNaN(explicitHeight)){ explicitHeight = (explicitHeight * scalingFactorY); }; if (!isNaN(explicitMaxHeight)){ explicitMaxHeight = (explicitMaxHeight * scalingFactorY); }; _height = (_height * scalingFactorY); super.scaleY = (oldScaleY = _scaleY); }; if (((!((x == oldX))) || (!((y == oldY))))){ dispatchMoveEvent(); }; if (((!((width == oldWidth))) || (!((height == oldHeight))))){ dispatchResizeEvent(); }; if (errorStringChanged){ errorStringChanged = false; setBorderColorForErrorString(); }; } public function get percentHeight():Number{ return (_percentHeight); } override public function get width():Number{ return (_width); } final mx_internal function get $parent():DisplayObjectContainer{ return (super.parent); } public function set explicitMinWidth(value:Number):void{ if (_explicitMinWidth == value){ return; }; _explicitMinWidth = value; invalidateSize(); var p:IInvalidating = (parent as IInvalidating); if (p){ p.invalidateSize(); p.invalidateDisplayList(); }; dispatchEvent(new Event("explicitMinWidthChanged")); } public function get isPopUp():Boolean{ return (_isPopUp); } private function measureSizes():Boolean{ var scalingFactor:Number; var newValue:Number; var xScale:Number; var yScale:Number; var changed:Boolean; if (!invalidateSizeFlag){ return (changed); }; if (((isNaN(explicitWidth)) || (isNaN(explicitHeight)))){ xScale = Math.abs(scaleX); yScale = Math.abs(scaleY); if (xScale != 1){ _measuredMinWidth = (_measuredMinWidth / xScale); _measuredWidth = (_measuredWidth / xScale); }; if (yScale != 1){ _measuredMinHeight = (_measuredMinHeight / yScale); _measuredHeight = (_measuredHeight / yScale); }; measure(); invalidateSizeFlag = false; if (((!(isNaN(explicitMinWidth))) && ((measuredWidth < explicitMinWidth)))){ measuredWidth = explicitMinWidth; }; if (((!(isNaN(explicitMaxWidth))) && ((measuredWidth > explicitMaxWidth)))){ measuredWidth = explicitMaxWidth; }; if (((!(isNaN(explicitMinHeight))) && ((measuredHeight < explicitMinHeight)))){ measuredHeight = explicitMinHeight; }; if (((!(isNaN(explicitMaxHeight))) && ((measuredHeight > explicitMaxHeight)))){ measuredHeight = explicitMaxHeight; }; if (xScale != 1){ _measuredMinWidth = (_measuredMinWidth * xScale); _measuredWidth = (_measuredWidth * xScale); }; if (yScale != 1){ _measuredMinHeight = (_measuredMinHeight * yScale); _measuredHeight = (_measuredHeight * yScale); }; } else { invalidateSizeFlag = false; _measuredMinWidth = 0; _measuredMinHeight = 0; }; adjustSizesForScaleChanges(); if (isNaN(oldMinWidth)){ oldMinWidth = (isNaN(explicitMinWidth)) ? measuredMinWidth : explicitMinWidth; oldMinHeight = (isNaN(explicitMinHeight)) ? measuredMinHeight : explicitMinHeight; oldExplicitWidth = (isNaN(explicitWidth)) ? measuredWidth : explicitWidth; oldExplicitHeight = (isNaN(explicitHeight)) ? measuredHeight : explicitHeight; changed = true; } else { newValue = (isNaN(explicitMinWidth)) ? measuredMinWidth : explicitMinWidth; if (newValue != oldMinWidth){ oldMinWidth = newValue; changed = true; }; newValue = (isNaN(explicitMinHeight)) ? measuredMinHeight : explicitMinHeight; if (newValue != oldMinHeight){ oldMinHeight = newValue; changed = true; }; newValue = (isNaN(explicitWidth)) ? measuredWidth : explicitWidth; if (newValue != oldExplicitWidth){ oldExplicitWidth = newValue; changed = true; }; newValue = (isNaN(explicitHeight)) ? measuredHeight : explicitHeight; if (newValue != oldExplicitHeight){ oldExplicitHeight = newValue; changed = true; }; }; return (changed); } public function get automationTabularData():Object{ if (automationDelegate){ return (automationDelegate.automationTabularData); }; return (null); } public function validateNow():void{ UIComponentGlobals.layoutManager.validateClient(this); } public function finishPrint(obj:Object, target:IFlexDisplayObject):void{ } public function get repeaters():Array{ return ((_repeaters) ? _repeaters.slice(0) : []); } private function dispatchMoveEvent():void{ var moveEvent:MoveEvent = new MoveEvent(MoveEvent.MOVE); moveEvent.oldX = oldX; moveEvent.oldY = oldY; dispatchEvent(moveEvent); oldX = x; oldY = y; } public function drawFocus(isFocused:Boolean):void{ var focusOwner:DisplayObjectContainer; var focusClass:Class; if (!parent){ return; }; var focusObj:DisplayObject = getFocusObject(); var focusPane:Sprite = (focusManager) ? focusManager.focusPane : null; if (((isFocused) && (!(preventDrawFocus)))){ focusOwner = focusPane.parent; if (focusOwner != parent){ if (focusOwner){ if ((focusOwner is ISystemManager)){ ISystemManager(focusOwner).focusPane = null; } else { IUIComponent(focusOwner).focusPane = null; }; }; if ((parent is ISystemManager)){ ISystemManager(parent).focusPane = focusPane; } else { IUIComponent(parent).focusPane = focusPane; }; }; focusClass = getStyle("focusSkin"); if (((focusObj) && (!((focusObj is focusClass))))){ focusPane.removeChild(focusObj); focusObj = null; }; if (!focusObj){ focusObj = new (focusClass); focusObj.name = "focus"; focusPane.addChild(focusObj); }; if ((focusObj is ILayoutManagerClient)){ ILayoutManagerClient(focusObj).nestLevel = nestLevel; }; if ((focusObj is ISimpleStyleClient)){ ISimpleStyleClient(focusObj).styleName = this; }; addEventListener(MoveEvent.MOVE, focusObj_moveHandler, true); addEventListener(MoveEvent.MOVE, focusObj_moveHandler); addEventListener(ResizeEvent.RESIZE, focusObj_resizeHandler, true); addEventListener(ResizeEvent.RESIZE, focusObj_resizeHandler); addEventListener(Event.REMOVED, focusObj_removedHandler, true); focusObj.visible = true; hasFocusRect = true; adjustFocusRect(); } else { if (hasFocusRect){ hasFocusRect = false; if (focusObj){ focusObj.visible = false; }; removeEventListener(MoveEvent.MOVE, focusObj_moveHandler); removeEventListener(MoveEvent.MOVE, focusObj_moveHandler, true); removeEventListener(ResizeEvent.RESIZE, focusObj_resizeHandler, true); removeEventListener(ResizeEvent.RESIZE, focusObj_resizeHandler); removeEventListener(Event.REMOVED, focusObj_removedHandler, true); }; }; } public function get flexContextMenu():IFlexContextMenu{ return (_flexContextMenu); } private function get indexedID():String{ var s:String = id; var indices:Array = instanceIndices; if (indices){ s = (s + (("[" + indices.join("][")) + "]")); }; return (s); } public function get measuredMinHeight():Number{ return (_measuredMinHeight); } mx_internal function addingChild(child:DisplayObject):void{ if ((((child is IUIComponent)) && (!(IUIComponent(child).document)))){ IUIComponent(child).document = (document) ? document : ApplicationGlobals.application; }; if ((((child is UIComponent)) && ((UIComponent(child).moduleFactory == null)))){ if (moduleFactory != null){ UIComponent(child).moduleFactory = moduleFactory; } else { if ((((document is IFlexModule)) && (!((document.moduleFactory == null))))){ UIComponent(child).moduleFactory = document.moduleFactory; } else { if ((((parent is UIComponent)) && (!((UIComponent(parent).moduleFactory == null))))){ UIComponent(child).moduleFactory = UIComponent(parent).moduleFactory; }; }; }; }; if ((((((child is IFontContextComponent)) && ((!(child) is UIComponent)))) && ((IFontContextComponent(child).fontContext == null)))){ IFontContextComponent(child).fontContext = moduleFactory; }; if ((child is IUIComponent)){ IUIComponent(child).parentChanged(this); }; if ((child is ILayoutManagerClient)){ ILayoutManagerClient(child).nestLevel = (nestLevel + 1); } else { if ((child is IUITextField)){ IUITextField(child).nestLevel = (nestLevel + 1); }; }; if ((child is InteractiveObject)){ if (doubleClickEnabled){ InteractiveObject(child).doubleClickEnabled = true; }; }; if ((child is IStyleClient)){ IStyleClient(child).regenerateStyleCache(true); } else { if ((((child is IUITextField)) && (IUITextField(child).inheritingStyles))){ StyleProtoChain.initTextField(IUITextField(child)); }; }; if ((child is ISimpleStyleClient)){ ISimpleStyleClient(child).styleChanged(null); }; if ((child is IStyleClient)){ IStyleClient(child).notifyStyleChangeInChildren(null, true); }; if ((child is UIComponent)){ UIComponent(child).initThemeColor(); }; if ((child is UIComponent)){ UIComponent(child).stylesInitialized(); }; } public function set repeaterIndices(value:Array):void{ _repeaterIndices = value; } protected function initializationComplete():void{ processedDescriptors = true; } public function set moduleFactory(factory:IFlexModuleFactory):void{ var child:UIComponent; var n:int = numChildren; var i:int; while (i < n) { child = (getChildAt(i) as UIComponent); if (!child){ } else { if ((((child.moduleFactory == null)) || ((child.moduleFactory == _moduleFactory)))){ child.moduleFactory = factory; }; }; i++; }; _moduleFactory = factory; } private function focusObj_removedHandler(event:Event):void{ if (event.target != this){ return; }; var focusObject:DisplayObject = getFocusObject(); if (focusObject){ focusObject.visible = false; }; } mx_internal function updateCallbacks():void{ if (invalidateDisplayListFlag){ UIComponentGlobals.layoutManager.invalidateDisplayList(this); }; if (invalidateSizeFlag){ UIComponentGlobals.layoutManager.invalidateSize(this); }; if (invalidatePropertiesFlag){ UIComponentGlobals.layoutManager.invalidateProperties(this); }; if (systemManager){ if ((((methodQueue.length > 0)) && (!(listeningForRender)))){ _systemManager.stage.addEventListener(Event.RENDER, callLaterDispatcher); _systemManager.stage.addEventListener(Event.ENTER_FRAME, callLaterDispatcher); listeningForRender = true; }; _systemManager.stage.invalidate(); }; } public function set styleDeclaration(value:CSSStyleDeclaration):void{ _styleDeclaration = value; } override public function set doubleClickEnabled(value:Boolean):void{ var childList:IChildList; var child:InteractiveObject; super.doubleClickEnabled = value; if ((this is IRawChildrenContainer)){ childList = IRawChildrenContainer(this).rawChildren; } else { childList = IChildList(this); }; var i:int; while (i < childList.numChildren) { child = (childList.getChildAt(i) as InteractiveObject); if (child){ child.doubleClickEnabled = value; }; i++; }; } public function prepareToPrint(target:IFlexDisplayObject):Object{ return (null); } public function get minHeight():Number{ if (!isNaN(explicitMinHeight)){ return (explicitMinHeight); }; return (measuredMinHeight); } public function notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void{ var child:ISimpleStyleClient; cachedTextFormat = null; var n:int = numChildren; var i:int; while (i < n) { child = (getChildAt(i) as ISimpleStyleClient); if (child){ child.styleChanged(styleProp); if ((child is IStyleClient)){ IStyleClient(child).notifyStyleChangeInChildren(styleProp, recursive); }; }; i++; }; } public function get contentMouseX():Number{ return (mouseX); } public function get contentMouseY():Number{ return (mouseY); } public function get tweeningProperties():Array{ return (_tweeningProperties); } public function set explicitMaxWidth(value:Number):void{ if (_explicitMaxWidth == value){ return; }; _explicitMaxWidth = value; invalidateSize(); var p:IInvalidating = (parent as IInvalidating); if (p){ p.invalidateSize(); p.invalidateDisplayList(); }; dispatchEvent(new Event("explicitMaxWidthChanged")); } public function set document(value:Object):void{ var child:IUIComponent; var n:int = numChildren; var i:int; while (i < n) { child = (getChildAt(i) as IUIComponent); if (!child){ } else { if ((((child.document == _document)) || ((child.document == ApplicationGlobals.application)))){ child.document = value; }; }; i++; }; _document = value; } public function validateSize(recursive:Boolean=false):void{ var i:int; var child:DisplayObject; var sizeChanging:Boolean; var p:IInvalidating; if (recursive){ i = 0; while (i < numChildren) { child = getChildAt(i); if ((child is ILayoutManagerClient)){ (child as ILayoutManagerClient).validateSize(true); }; i++; }; }; if (invalidateSizeFlag){ sizeChanging = measureSizes(); if (((sizeChanging) && (includeInLayout))){ invalidateDisplayList(); p = (parent as IInvalidating); if (p){ p.invalidateSize(); p.invalidateDisplayList(); }; }; }; } public function get validationSubField():String{ return (_validationSubField); } override public function dispatchEvent(event:Event):Boolean{ if (dispatchEventHook != null){ dispatchEventHook(event, this); }; return (super.dispatchEvent(event)); } public function set id(value:String):void{ _id = value; } private function overlay_resizeHandler(event:Event):void{ fillOverlay(overlay, overlayColor, null); } public function set updateCompletePendingFlag(value:Boolean):void{ _updateCompletePendingFlag = value; } final mx_internal function get $height():Number{ return (super.height); } protected function attachOverlay():void{ addChild(overlay); } public function get explicitMinHeight():Number{ return (_explicitMinHeight); } override public function set height(value:Number):void{ var p:IInvalidating; if (explicitHeight != value){ explicitHeight = value; invalidateSize(); }; if (_height != value){ invalidateProperties(); invalidateDisplayList(); p = (parent as IInvalidating); if (((p) && (includeInLayout))){ p.invalidateSize(); p.invalidateDisplayList(); }; _height = value; dispatchEvent(new Event("heightChanged")); }; } public function get numAutomationChildren():int{ if (automationDelegate){ return (automationDelegate.numAutomationChildren); }; return (0); } public function get parentApplication():Object{ var p:UIComponent; var o:Object = systemManager.document; if (o == this){ p = (o.systemManager.parent as UIComponent); o = (p) ? p.systemManager.document : null; }; return (o); } public function localToContent(point:Point):Point{ return (point); } public function get repeaterIndex():int{ return ((_repeaterIndices) ? _repeaterIndices[(_repeaterIndices.length - 1)] : -1); } private function removeState(stateName:String, lastState:String):void{ var overrides:Array; var i:int; var state:State = getState(stateName); if (stateName == lastState){ return; }; if (state){ state.dispatchExitState(); overrides = state.overrides; i = overrides.length; while (i) { overrides[(i - 1)].remove(this); i--; }; if (state.basedOn != lastState){ removeState(state.basedOn, lastState); }; }; } public function setStyle(styleProp:String, newValue):void{ if (styleProp == "styleName"){ styleName = newValue; return; }; if (EffectManager.getEventForEffectTrigger(styleProp) != ""){ EffectManager.setStyle(styleProp, this); }; var isInheritingStyle:Boolean = StyleManager.isInheritingStyle(styleProp); var isProtoChainInitialized = !((inheritingStyles == UIComponent.STYLE_UNINITIALIZED)); var valueChanged = !((getStyle(styleProp) == newValue)); if (!_styleDeclaration){ _styleDeclaration = new CSSStyleDeclaration(); _styleDeclaration.setStyle(styleProp, newValue); if (isProtoChainInitialized){ regenerateStyleCache(isInheritingStyle); }; } else { _styleDeclaration.setStyle(styleProp, newValue); }; if (((isProtoChainInitialized) && (valueChanged))){ styleChanged(styleProp); notifyStyleChangeInChildren(styleProp, isInheritingStyle); }; } public function get showInAutomationHierarchy():Boolean{ return (_showInAutomationHierarchy); } public function get systemManager():ISystemManager{ var r:DisplayObject; var o:DisplayObjectContainer; var ui:IUIComponent; if (((!(_systemManager)) || (_systemManagerDirty))){ r = root; if (((r) && (!((r is Stage))))){ _systemManager = (r as ISystemManager); } else { if (r){ _systemManager = (Stage(r).getChildAt(0) as ISystemManager); } else { o = parent; while (o) { ui = (o as IUIComponent); if (ui){ _systemManager = ui.systemManager; break; }; o = o.parent; }; }; }; _systemManagerDirty = false; }; return (_systemManager); } private function isBaseState(stateName:String):Boolean{ return (((!(stateName)) || ((stateName == "")))); } public function set enabled(value:Boolean):void{ _enabled = value; cachedTextFormat = null; invalidateDisplayList(); dispatchEvent(new Event("enabledChanged")); } public function set focusEnabled(value:Boolean):void{ _focusEnabled = value; } public function get minWidth():Number{ if (!isNaN(explicitMinWidth)){ return (explicitMinWidth); }; return (measuredMinWidth); } private function setFocusLater(event:Event=null):void{ var sm:ISystemManager = systemManager; if (((sm) && (sm.stage))){ sm.stage.removeEventListener(Event.ENTER_FRAME, setFocusLater); if (UIComponentGlobals.nextFocusObject){ sm.stage.focus = UIComponentGlobals.nextFocusObject; }; UIComponentGlobals.nextFocusObject = null; }; } public function get currentState():String{ return ((_currentStateChanged) ? requestedCurrentState : _currentState); } public function initializeRepeaterArrays(parent:IRepeaterClient):void{ if (((((((parent) && (parent.instanceIndices))) && (!(_instanceIndices)))) && (!(parent.isDocument)))){ _instanceIndices = parent.instanceIndices; _repeaters = parent.repeaters; _repeaterIndices = parent.repeaterIndices; }; } public function get baselinePosition():Number{ if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0){ return (NaN); }; if (!validateBaselinePosition()){ return (NaN); }; var lineMetrics:TextLineMetrics = measureText("Wj"); if (height < ((2 + lineMetrics.ascent) + 2)){ return (int((height + ((lineMetrics.ascent - height) / 2)))); }; return ((2 + lineMetrics.ascent)); } public function get measuredWidth():Number{ return (_measuredWidth); } public function set instanceIndices(value:Array):void{ _instanceIndices = value; } public function set cachePolicy(value:String):void{ if (_cachePolicy != value){ _cachePolicy = value; if (value == UIComponentCachePolicy.OFF){ cacheAsBitmap = false; } else { if (value == UIComponentCachePolicy.ON){ cacheAsBitmap = true; } else { cacheAsBitmap = (cacheAsBitmapCount > 0); }; }; }; } public function get automationValue():Array{ if (automationDelegate){ return (automationDelegate.automationValue); }; return ([]); } private function addedHandler(event:Event):void{ if (event.eventPhase != EventPhase.AT_TARGET){ return; }; if ((((parent is IContainer)) && (IContainer(parent).creatingContentPane))){ event.stopImmediatePropagation(); return; }; } public function parentChanged(p:DisplayObjectContainer):void{ if (!p){ _parent = null; _nestLevel = 0; } else { if ((p is IStyleClient)){ _parent = p; } else { if ((p is ISystemManager)){ _parent = p; } else { _parent = p.parent; }; }; }; } public function get owner():DisplayObjectContainer{ return ((_owner) ? _owner : parent); } public function get processedDescriptors():Boolean{ return (_processedDescriptors); } override public function addChildAt(child:DisplayObject, index:int):DisplayObject{ var formerParent:DisplayObjectContainer = child.parent; if (((formerParent) && (!((formerParent is Loader))))){ formerParent.removeChild(child); }; if (((overlayReferenceCount) && (!((child == overlay))))){ index = Math.min(index, Math.max(0, (super.numChildren - 1))); }; addingChild(child); $addChildAt(child, index); childAdded(child); return (child); } public function get maxWidth():Number{ return ((isNaN(explicitMaxWidth)) ? DEFAULT_MAX_WIDTH : explicitMaxWidth); } override public function set alpha(value:Number):void{ super.alpha = value; dispatchEvent(new Event("alphaChanged")); } private function removedHandler(event:Event):void{ if (event.eventPhase != EventPhase.AT_TARGET){ return; }; if ((((parent is IContainer)) && (IContainer(parent).creatingContentPane))){ event.stopImmediatePropagation(); return; }; _systemManagerDirty = true; } public function callLater(method:Function, args:Array=null):void{ methodQueue.push(new MethodQueueElement(method, args)); var sm:ISystemManager = systemManager; if (((sm) && (sm.stage))){ if (!listeningForRender){ sm.stage.addEventListener(Event.RENDER, callLaterDispatcher); sm.stage.addEventListener(Event.ENTER_FRAME, callLaterDispatcher); listeningForRender = true; }; sm.stage.invalidate(); }; } public function get initialized():Boolean{ return (_initialized); } private function callLaterDispatcher2(event:Event):void{ var mqe:MethodQueueElement; if (UIComponentGlobals.callLaterSuspendCount > 0){ return; }; var sm:ISystemManager = systemManager; if (((((sm) && (sm.stage))) && (listeningForRender))){ sm.stage.removeEventListener(Event.RENDER, callLaterDispatcher); sm.stage.removeEventListener(Event.ENTER_FRAME, callLaterDispatcher); listeningForRender = false; }; var queue:Array = methodQueue; methodQueue = []; var n:int = queue.length; var i:int; while (i < n) { mqe = MethodQueueElement(queue[i]); mqe.method.apply(null, mqe.args); i++; }; } public function measureHTMLText(htmlText:String):TextLineMetrics{ return (determineTextFormatFromStyles().measureHTMLText(htmlText)); } public function set descriptor(value:UIComponentDescriptor):void{ _descriptor = value; } private function getState(stateName:String):State{ if (((!(states)) || (isBaseState(stateName)))){ return (null); }; var i:int; while (i < states.length) { if (states[i].name == stateName){ return (states[i]); }; i++; }; var message:String = resourceManager.getString("core", "stateUndefined", [stateName]); throw (new ArgumentError(message)); } public function validateProperties():void{ if (invalidatePropertiesFlag){ commitProperties(); invalidatePropertiesFlag = false; }; } mx_internal function get documentDescriptor():UIComponentDescriptor{ return (_documentDescriptor); } public function set includeInLayout(value:Boolean):void{ var p:IInvalidating; if (_includeInLayout != value){ _includeInLayout = value; p = (parent as IInvalidating); if (p){ p.invalidateSize(); p.invalidateDisplayList(); }; dispatchEvent(new Event("includeInLayoutChanged")); }; } public function getClassStyleDeclarations():Array{ var myApplicationDomain:ApplicationDomain; var cache:Array; var myRoot:DisplayObject; var s:CSSStyleDeclaration; var factory:IFlexModuleFactory = ModuleManager.getAssociatedFactory(this); if (factory != null){ myApplicationDomain = ApplicationDomain(factory.info()["currentDomain"]); } else { myRoot = SystemManager.getSWFRoot(this); if (!myRoot){ return ([]); }; myApplicationDomain = myRoot.loaderInfo.applicationDomain; }; var className:String = getQualifiedClassName(this); className = className.replace("::", "."); cache = StyleManager.typeSelectorCache[className]; if (cache){ return (cache); }; var decls:Array = []; var classNames:Array = []; var caches:Array = []; var declcache:Array = []; while (((((!((className == null))) && (!((className == "mx.core.UIComponent"))))) && (!((className == "mx.core.UITextField"))))) { cache = StyleManager.typeSelectorCache[className]; if (cache){ decls = decls.concat(cache); break; }; s = StyleManager.getStyleDeclaration(className); if (s){ decls.unshift(s); classNames.push(className); caches.push(classNames); declcache.push(decls); decls = []; classNames = []; } else { classNames.push(className); }; className = getQualifiedSuperclassName(myApplicationDomain.getDefinition(className)); className = className.replace("::", "."); continue; var _slot1 = e; className = null; }; caches.push(classNames); declcache.push(decls); decls = []; while (caches.length) { classNames = caches.pop(); decls = decls.concat(declcache.pop()); while (classNames.length) { StyleManager.typeSelectorCache[classNames.pop()] = decls; }; }; return (decls); } public function set measuredMinWidth(value:Number):void{ _measuredMinWidth = value; } private function initializeState(stateName:String):void{ var state:State = getState(stateName); while (state) { state.initialize(); state = getState(state.basedOn); }; } mx_internal function initProtoChain():void{ var classSelector:CSSStyleDeclaration; var inheritChain:Object; var typeSelector:CSSStyleDeclaration; if (styleName){ if ((styleName is CSSStyleDeclaration)){ classSelector = CSSStyleDeclaration(styleName); } else { if ((((styleName is IFlexDisplayObject)) || ((styleName is IStyleClient)))){ StyleProtoChain.initProtoChainForUIComponentStyleName(this); return; }; if ((styleName is String)){ classSelector = StyleManager.getStyleDeclaration(("." + styleName)); }; }; }; var nonInheritChain:Object = StyleManager.stylesRoot; if (((nonInheritChain) && (nonInheritChain.effects))){ registerEffects(nonInheritChain.effects); }; var p:IStyleClient = (parent as IStyleClient); if (p){ inheritChain = p.inheritingStyles; if (inheritChain == UIComponent.STYLE_UNINITIALIZED){ inheritChain = nonInheritChain; }; } else { if (isPopUp){ if ((((((FlexVersion.compatibilityVersion >= FlexVersion.VERSION_3_0)) && (_owner))) && ((_owner is IStyleClient)))){ inheritChain = IStyleClient(_owner).inheritingStyles; } else { inheritChain = ApplicationGlobals.application.inheritingStyles; }; } else { inheritChain = StyleManager.stylesRoot; }; }; var typeSelectors:Array = getClassStyleDeclarations(); var n:int = typeSelectors.length; var i:int; while (i < n) { typeSelector = typeSelectors[i]; inheritChain = typeSelector.addStyleToProtoChain(inheritChain, this); nonInheritChain = typeSelector.addStyleToProtoChain(nonInheritChain, this); if (typeSelector.effects){ registerEffects(typeSelector.effects); }; i++; }; if (classSelector){ inheritChain = classSelector.addStyleToProtoChain(inheritChain, this); nonInheritChain = classSelector.addStyleToProtoChain(nonInheritChain, this); if (classSelector.effects){ registerEffects(classSelector.effects); }; }; inheritingStyles = (_styleDeclaration) ? _styleDeclaration.addStyleToProtoChain(inheritChain, this) : inheritChain; nonInheritingStyles = (_styleDeclaration) ? _styleDeclaration.addStyleToProtoChain(nonInheritChain, this) : nonInheritChain; } public function get repeaterIndices():Array{ return ((_repeaterIndices) ? _repeaterIndices.slice() : []); } override public function removeChild(child:DisplayObject):DisplayObject{ removingChild(child); $removeChild(child); childRemoved(child); return (child); } private function focusObj_moveHandler(event:MoveEvent):void{ adjustFocusRect(); } public function get styleDeclaration():CSSStyleDeclaration{ return (_styleDeclaration); } override public function get doubleClickEnabled():Boolean{ return (super.doubleClickEnabled); } public function contentToLocal(point:Point):Point{ return (point); } private function creationCompleteHandler(event:FlexEvent):void{ if (_currentStateChanged){ _currentStateChanged = false; commitCurrentState(); validateNow(); }; removeEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler); } public function set measuredHeight(value:Number):void{ _measuredHeight = value; } protected function createChildren():void{ } public function get activeEffects():Array{ return (_effectsStarted); } override public function setChildIndex(child:DisplayObject, newIndex:int):void{ if (((overlayReferenceCount) && (!((child == overlay))))){ newIndex = Math.min(newIndex, Math.max(0, (super.numChildren - 2))); }; super.setChildIndex(child, newIndex); } public function regenerateStyleCache(recursive:Boolean):void{ var child:DisplayObject; initProtoChain(); var childList:IChildList = ((this is IRawChildrenContainer)) ? IRawChildrenContainer(this).rawChildren : IChildList(this); var n:int = childList.numChildren; var i:int; while (i < n) { child = childList.getChildAt(i); if ((child is IStyleClient)){ if (IStyleClient(child).inheritingStyles != UIComponent.STYLE_UNINITIALIZED){ IStyleClient(child).regenerateStyleCache(recursive); }; } else { if ((child is IUITextField)){ if (IUITextField(child).inheritingStyles){ StyleProtoChain.initTextField(IUITextField(child)); }; }; }; i++; }; } public function get updateCompletePendingFlag():Boolean{ return (_updateCompletePendingFlag); } protected function focusOutHandler(event:FocusEvent):void{ if (isOurFocus(DisplayObject(event.target))){ drawFocus(false); }; } public function getFocus():InteractiveObject{ var sm:ISystemManager = systemManager; if (!sm){ return (null); }; if (UIComponentGlobals.nextFocusObject){ return (UIComponentGlobals.nextFocusObject); }; return (sm.stage.focus); } public function endEffectsStarted():void{ var len:int = _effectsStarted.length; var i:int; while (i < len) { _effectsStarted[i].end(); i++; }; } protected function get unscaledHeight():Number{ return ((height / Math.abs(scaleY))); } public function get enabled():Boolean{ return (_enabled); } public function get focusEnabled():Boolean{ return (_focusEnabled); } override public function set cacheAsBitmap(value:Boolean):void{ super.cacheAsBitmap = value; cacheAsBitmapCount = (value) ? 1 : 0; } mx_internal function removeOverlay():void{ if ((((((overlayReferenceCount > 0)) && ((--overlayReferenceCount == 0)))) && (overlay))){ removeEventListener("resize", overlay_resizeHandler); if (super.getChildByName("overlay")){ $removeChild(overlay); }; overlay = null; }; } public function set cacheHeuristic(value:Boolean):void{ if (_cachePolicy == UIComponentCachePolicy.AUTO){ if (value){ cacheAsBitmapCount++; } else { if (cacheAsBitmapCount != 0){ cacheAsBitmapCount--; }; }; super.cacheAsBitmap = !((cacheAsBitmapCount == 0)); }; } public function get cachePolicy():String{ return (_cachePolicy); } public function set maxHeight(value:Number):void{ if (explicitMaxHeight == value){ return; }; explicitMaxHeight = value; } public function getConstraintValue(constraintName:String){ return (getStyle(constraintName)); } public function set focusManager(value:IFocusManager):void{ _focusManager = value; } public function clearStyle(styleProp:String):void{ setStyle(styleProp, undefined); } public function get descriptor():UIComponentDescriptor{ return (_descriptor); } public function set nonInheritingStyles(value:Object):void{ _nonInheritingStyles = value; } public function get cursorManager():ICursorManager{ var cm:ICursorManager; var o:DisplayObject = parent; while (o) { if ((((o is IUIComponent)) && (("cursorManager" in o)))){ cm = o["cursorManager"]; return (cm); }; o = o.parent; }; return (CursorManager.getInstance()); } public function set automationDelegate(value:Object):void{ _automationDelegate = (value as IAutomationObject); } public function get measuredMinWidth():Number{ return (_measuredMinWidth); } public function createReferenceOnParentDocument(parentDocument:IFlexDisplayObject):void{ var indices:Array; var r:Object; var n:int; var i:int; var event:PropertyChangeEvent; var s:Object; if (((id) && (!((id == ""))))){ indices = _instanceIndices; if (!indices){ parentDocument[id] = this; } else { r = parentDocument[id]; if (!(r is Array)){ r = (parentDocument[id] = []); }; n = indices.length; i = 0; while (i < (n - 1)) { s = r[indices[i]]; if (!(s is Array)){ s = (r[indices[i]] = []); }; r = s; i++; }; r[indices[(n - 1)]] = this; event = PropertyChangeEvent.createUpdateEvent(parentDocument, id, parentDocument[id], parentDocument[id]); parentDocument.dispatchEvent(event); }; }; } public function get repeater():IRepeater{ return ((_repeaters) ? _repeaters[(_repeaters.length - 1)] : null); } public function set isPopUp(value:Boolean):void{ _isPopUp = value; } public function get measuredHeight():Number{ return (_measuredHeight); } public function initialize():void{ if (initialized){ return; }; dispatchEvent(new FlexEvent(FlexEvent.PREINITIALIZE)); createChildren(); childrenCreated(); initializeAccessibility(); initializationComplete(); } override public function set width(value:Number):void{ var p:IInvalidating; if (explicitWidth != value){ explicitWidth = value; invalidateSize(); }; if (_width != value){ invalidateProperties(); invalidateDisplayList(); p = (parent as IInvalidating); if (((p) && (includeInLayout))){ p.invalidateSize(); p.invalidateDisplayList(); }; _width = value; dispatchEvent(new Event("widthChanged")); }; } public function set percentHeight(value:Number):void{ if (_percentHeight == value){ return; }; if (!isNaN(value)){ _explicitHeight = NaN; }; _percentHeight = value; var p:IInvalidating = (parent as IInvalidating); if (p){ p.invalidateSize(); p.invalidateDisplayList(); }; } final mx_internal function set $visible(value:Boolean):void{ super.visible = value; } private function findCommonBaseState(state1:String, state2:String):String{ var firstState:State = getState(state1); var secondState:State = getState(state2); if (((!(firstState)) || (!(secondState)))){ return (""); }; if (((isBaseState(firstState.basedOn)) && (isBaseState(secondState.basedOn)))){ return (""); }; var firstBaseStates:Array = getBaseStates(firstState); var secondBaseStates:Array = getBaseStates(secondState); var commonBase:String = ""; while (firstBaseStates[(firstBaseStates.length - 1)] == secondBaseStates[(secondBaseStates.length - 1)]) { commonBase = firstBaseStates.pop(); secondBaseStates.pop(); if (((!(firstBaseStates.length)) || (!(secondBaseStates.length)))){ break; }; }; if (((firstBaseStates.length) && ((firstBaseStates[(firstBaseStates.length - 1)] == secondState.name)))){ commonBase = secondState.name; } else { if (((secondBaseStates.length) && ((secondBaseStates[(secondBaseStates.length - 1)] == firstState.name)))){ commonBase = firstState.name; }; }; return (commonBase); } mx_internal function childRemoved(child:DisplayObject):void{ if ((child is IUIComponent)){ if (IUIComponent(child).document != child){ IUIComponent(child).document = null; }; IUIComponent(child).parentChanged(null); }; } final mx_internal function $removeChildAt(index:int):DisplayObject{ return (super.removeChildAt(index)); } public function get maxHeight():Number{ return ((isNaN(explicitMaxHeight)) ? DEFAULT_MAX_HEIGHT : explicitMaxHeight); } protected function initializeAccessibility():void{ if (UIComponent.createAccessibilityImplementation != null){ UIComponent.createAccessibilityImplementation(this); }; } public function set explicitMaxHeight(value:Number):void{ if (_explicitMaxHeight == value){ return; }; _explicitMaxHeight = value; invalidateSize(); var p:IInvalidating = (parent as IInvalidating); if (p){ p.invalidateSize(); p.invalidateDisplayList(); }; dispatchEvent(new Event("explicitMaxHeightChanged")); } public function get focusManager():IFocusManager{ if (_focusManager){ return (_focusManager); }; var o:DisplayObject = parent; while (o) { if ((o is IFocusManagerContainer)){ return (IFocusManagerContainer(o).focusManager); }; o = o.parent; }; return (null); } public function set styleName(value:Object):void{ if (_styleName === value){ return; }; _styleName = value; if (inheritingStyles == UIComponent.STYLE_UNINITIALIZED){ return; }; regenerateStyleCache(true); initThemeColor(); styleChanged("styleName"); notifyStyleChangeInChildren("styleName", true); } public function get automationDelegate():Object{ return (_automationDelegate); } protected function get resourceManager():IResourceManager{ return (_resourceManager); } mx_internal function validateBaselinePosition():Boolean{ var w:Number; var h:Number; if (!parent){ return (false); }; if ((((width == 0)) && ((height == 0)))){ validateNow(); w = getExplicitOrMeasuredWidth(); h = getExplicitOrMeasuredHeight(); setActualSize(w, h); }; validateNow(); return (true); } mx_internal function cancelAllCallLaters():void{ var sm:ISystemManager = systemManager; if (((sm) && (sm.stage))){ if (listeningForRender){ sm.stage.removeEventListener(Event.RENDER, callLaterDispatcher); sm.stage.removeEventListener(Event.ENTER_FRAME, callLaterDispatcher); listeningForRender = false; }; }; methodQueue.splice(0); } private function updateCompleteHandler(event:FlexEvent):void{ UIComponentGlobals.layoutManager.removeEventListener(FlexEvent.UPDATE_COMPLETE, updateCompleteHandler); processEffectFinished(_endingEffectInstances); _endingEffectInstances = []; } public function styleChanged(styleProp:String):void{ if ((((this is IFontContextComponent)) && (hasFontContextChanged()))){ invalidateProperties(); }; if (((((!(styleProp)) || ((styleProp == "styleName")))) || (StyleManager.isSizeInvalidatingStyle(styleProp)))){ invalidateSize(); }; if (((((!(styleProp)) || ((styleProp == "styleName")))) || ((styleProp == "themeColor")))){ initThemeColor(); }; invalidateDisplayList(); if ((parent is IInvalidating)){ if (StyleManager.isParentSizeInvalidatingStyle(styleProp)){ IInvalidating(parent).invalidateSize(); }; if (StyleManager.isParentDisplayListInvalidatingStyle(styleProp)){ IInvalidating(parent).invalidateDisplayList(); }; }; } final mx_internal function get $visible():Boolean{ return (super.visible); } public function drawRoundRect(x:Number, y:Number, w:Number, h:Number, r:Object=null, c:Object=null, alpha:Object=null, rot:Object=null, gradient:String=null, ratios:Array=null, hole:Object=null):void{ var ellipseSize:Number; var alphas:Array; var matrix:Matrix; var holeR:Object; var g:Graphics = graphics; if (((!(w)) || (!(h)))){ return; }; if (c !== null){ if ((c is Array)){ if ((alpha is Array)){ alphas = (alpha as Array); } else { alphas = [alpha, alpha]; }; if (!ratios){ ratios = [0, 0xFF]; }; matrix = null; if (rot){ if ((rot is Matrix)){ matrix = Matrix(rot); } else { matrix = new Matrix(); if ((rot is Number)){ matrix.createGradientBox(w, h, ((Number(rot) * Math.PI) / 180), x, y); } else { matrix.createGradientBox(rot.w, rot.h, rot.r, rot.x, rot.y); }; }; }; if (gradient == GradientType.RADIAL){ g.beginGradientFill(GradientType.RADIAL, (c as Array), alphas, ratios, matrix); } else { g.beginGradientFill(GradientType.LINEAR, (c as Array), alphas, ratios, matrix); }; } else { g.beginFill(Number(c), Number(alpha)); }; }; if (!r){ g.drawRect(x, y, w, h); } else { if ((r is Number)){ ellipseSize = (Number(r) * 2); g.drawRoundRect(x, y, w, h, ellipseSize, ellipseSize); } else { GraphicsUtil.drawRoundRectComplex(g, x, y, w, h, r.tl, r.tr, r.bl, r.br); }; }; if (hole){ holeR = hole.r; if ((holeR is Number)){ ellipseSize = (Number(holeR) * 2); g.drawRoundRect(hole.x, hole.y, hole.w, hole.h, ellipseSize, ellipseSize); } else { GraphicsUtil.drawRoundRectComplex(g, hole.x, hole.y, hole.w, hole.h, holeR.tl, holeR.tr, holeR.bl, holeR.br); }; }; if (c !== null){ g.endFill(); }; } public function move(x:Number, y:Number):void{ var changed:Boolean; if (x != super.x){ super.x = x; dispatchEvent(new Event("xChanged")); changed = true; }; if (y != super.y){ super.y = y; dispatchEvent(new Event("yChanged")); changed = true; }; if (changed){ dispatchMoveEvent(); }; } public function set toolTip(value:String):void{ var oldValue:String = _toolTip; _toolTip = value; ToolTipManager.registerToolTip(this, oldValue, value); dispatchEvent(new Event("toolTipChanged")); } public function set repeaters(value:Array):void{ _repeaters = value; } public function get explicitMaxHeight():Number{ return (_explicitMaxHeight); } public function measureText(text:String):TextLineMetrics{ return (determineTextFormatFromStyles().measureText(text)); } public function get styleName():Object{ return (_styleName); } protected function createInModuleContext(moduleFactory:IFlexModuleFactory, className:String):Object{ var newObject:Object; if (moduleFactory){ newObject = moduleFactory.create(className); }; return (newObject); } public function get parentDocument():Object{ var p:IUIComponent; var sm:ISystemManager; if (document == this){ p = (parent as IUIComponent); if (p){ return (p.document); }; sm = (parent as ISystemManager); if (sm){ return (sm.document); }; return (null); //unresolved jump }; return (document); } protected function childrenCreated():void{ invalidateProperties(); invalidateSize(); invalidateDisplayList(); } public function set flexContextMenu(value:IFlexContextMenu):void{ if (_flexContextMenu){ _flexContextMenu.unsetContextMenu(this); }; _flexContextMenu = value; if (value != null){ _flexContextMenu.setContextMenu(this); }; } public function set explicitWidth(value:Number):void{ if (_explicitWidth == value){ return; }; if (!isNaN(value)){ _percentWidth = NaN; }; _explicitWidth = value; invalidateSize(); var p:IInvalidating = (parent as IInvalidating); if (((p) && (includeInLayout))){ p.invalidateSize(); p.invalidateDisplayList(); }; dispatchEvent(new Event("explicitWidthChanged")); } private function setBorderColorForErrorString():void{ if (((!(_errorString)) || ((_errorString.length == 0)))){ if (!isNaN(origBorderColor)){ setStyle("borderColor", origBorderColor); saveBorderColor = true; }; } else { if (saveBorderColor){ saveBorderColor = false; origBorderColor = getStyle("borderColor"); }; setStyle("borderColor", getStyle("errorColor")); }; styleChanged("themeColor"); var focusManager:IFocusManager = focusManager; var focusObj:DisplayObject = (focusManager) ? DisplayObject(focusManager.getFocus()) : null; if (((((focusManager) && (focusManager.showFocusIndicator))) && ((focusObj == this)))){ drawFocus(true); }; } public function get explicitWidth():Number{ return (_explicitWidth); } public function invalidateSize():void{ if (!invalidateSizeFlag){ invalidateSizeFlag = true; if (((parent) && (UIComponentGlobals.layoutManager))){ UIComponentGlobals.layoutManager.invalidateSize(this); }; }; } public function set measuredMinHeight(value:Number):void{ _measuredMinHeight = value; } protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{ } override public function set filters(value:Array):void{ var n:int; var i:int; var e:IEventDispatcher; if (_filters){ n = _filters.length; i = 0; while (i < n) { e = (_filters[i] as IEventDispatcher); if (e){ e.removeEventListener("change", filterChangeHandler); }; i++; }; }; _filters = value; if (_filters){ n = _filters.length; i = 0; while (i < n) { e = (_filters[i] as IEventDispatcher); if (e){ e.addEventListener("change", filterChangeHandler); }; i++; }; }; super.filters = _filters; } private static function get embeddedFontRegistry():IEmbeddedFontRegistry{ if (!_embeddedFontRegistry){ _embeddedFontRegistry = IEmbeddedFontRegistry(Singleton.getInstance("mx.core::IEmbeddedFontRegistry")); }; return (_embeddedFontRegistry); } public static function resumeBackgroundProcessing():void{ var sm:ISystemManager; if (UIComponentGlobals.callLaterSuspendCount > 0){ UIComponentGlobals.callLaterSuspendCount--; if (UIComponentGlobals.callLaterSuspendCount == 0){ sm = SystemManagerGlobals.topLevelSystemManagers[0]; if (((sm) && (sm.stage))){ sm.stage.invalidate(); }; }; }; } public static function suspendBackgroundProcessing():void{ UIComponentGlobals.callLaterSuspendCount++; } } }//package mx.core class MethodQueueElement { public var method:Function; public var args:Array; private function MethodQueueElement(method:Function, args:Array=null){ super(); this.method = method; this.args = args; } }
Section 130
//UIComponentCachePolicy (mx.core.UIComponentCachePolicy) package mx.core { public final class UIComponentCachePolicy { public static const AUTO:String = "auto"; public static const ON:String = "on"; mx_internal static const VERSION:String = "3.0.0.0"; public static const OFF:String = "off"; public function UIComponentCachePolicy(){ super(); } } }//package mx.core
Section 131
//UIComponentDescriptor (mx.core.UIComponentDescriptor) package mx.core { public class UIComponentDescriptor extends ComponentDescriptor { mx_internal var instanceIndices:Array; public var stylesFactory:Function; public var effects:Array; mx_internal var repeaters:Array; mx_internal var repeaterIndices:Array; mx_internal static const VERSION:String = "3.0.0.0"; public function UIComponentDescriptor(descriptorProperties:Object){ super(descriptorProperties); } override public function toString():String{ return (("UIComponentDescriptor_" + id)); } } }//package mx.core
Section 132
//UIComponentGlobals (mx.core.UIComponentGlobals) package mx.core { import flash.display.*; import flash.geom.*; import mx.managers.*; public class UIComponentGlobals { mx_internal static var callLaterSuspendCount:int = 0; mx_internal static var layoutManager:ILayoutManager; mx_internal static var nextFocusObject:InteractiveObject; mx_internal static var designTime:Boolean = false; mx_internal static var tempMatrix:Matrix = new Matrix(); mx_internal static var callLaterDispatcherCount:int = 0; private static var _catchCallLaterExceptions:Boolean = false; public function UIComponentGlobals(){ super(); } public static function set catchCallLaterExceptions(value:Boolean):void{ _catchCallLaterExceptions = value; } public static function get designMode():Boolean{ return (designTime); } public static function set designMode(value:Boolean):void{ designTime = value; } public static function get catchCallLaterExceptions():Boolean{ return (_catchCallLaterExceptions); } } }//package mx.core
Section 133
//UITextField (mx.core.UITextField) package mx.core { import flash.events.*; import mx.styles.*; import flash.display.*; import flash.text.*; import mx.resources.*; import mx.managers.*; import mx.automation.*; import flash.utils.*; import mx.utils.*; public class UITextField extends FlexTextField implements IAutomationObject, IIMESupport, IFlexModule, IInvalidating, ISimpleStyleClient, IToolTipManagerClient, IUITextField { private var _enabled:Boolean;// = true private var untruncatedText:String; private var cachedEmbeddedFont:EmbeddedFont;// = null private var cachedTextFormat:TextFormat; private var _automationDelegate:IAutomationObject; private var _automationName:String; private var _styleName:Object; private var _document:Object; mx_internal var _toolTip:String; private var _nestLevel:int;// = 0 private var _explicitHeight:Number; private var _moduleFactory:IFlexModuleFactory; private var _initialized:Boolean;// = false private var _nonInheritingStyles:Object; private var _inheritingStyles:Object; private var _includeInLayout:Boolean;// = true private var invalidateDisplayListFlag:Boolean;// = true mx_internal var explicitColor:uint;// = 4294967295 private var _processedDescriptors:Boolean;// = true private var _updateCompletePendingFlag:Boolean;// = false private var explicitHTMLText:String;// = null mx_internal var _parent:DisplayObjectContainer; private var _imeMode:String;// = null private var resourceManager:IResourceManager; mx_internal var styleChangedFlag:Boolean;// = true private var _ignorePadding:Boolean;// = true private var _owner:DisplayObjectContainer; private var _explicitWidth:Number; mx_internal static const TEXT_WIDTH_PADDING:int = 5; mx_internal static const TEXT_HEIGHT_PADDING:int = 4; mx_internal static const VERSION:String = "3.0.0.0"; private static var truncationIndicatorResource:String; private static var _embeddedFontRegistry:IEmbeddedFontRegistry; mx_internal static var debuggingBorders:Boolean = false; public function UITextField(){ resourceManager = ResourceManager.getInstance(); _inheritingStyles = UIComponent.STYLE_UNINITIALIZED; _nonInheritingStyles = UIComponent.STYLE_UNINITIALIZED; super(); super.text = ""; focusRect = false; selectable = false; tabEnabled = false; if (debuggingBorders){ border = true; }; if (!truncationIndicatorResource){ truncationIndicatorResource = resourceManager.getString("core", "truncationIndicator"); }; addEventListener(Event.CHANGE, changeHandler); addEventListener("textFieldStyleChange", textFieldStyleChangeHandler); resourceManager.addEventListener(Event.CHANGE, resourceManager_changeHandler, false, 0, true); } public function set imeMode(value:String):void{ _imeMode = value; } public function get nestLevel():int{ return (_nestLevel); } private function textFieldStyleChangeHandler(event:Event):void{ if (explicitHTMLText != null){ super.htmlText = explicitHTMLText; }; } public function truncateToFit(truncationIndicator:String=null):Boolean{ var s:String; if (!truncationIndicator){ truncationIndicator = truncationIndicatorResource; }; validateNow(); var originalText:String = super.text; untruncatedText = originalText; var w:Number = width; if (((!((originalText == ""))) && (((textWidth + TEXT_WIDTH_PADDING) > (w + 1E-14))))){ var _local5 = originalText; super.text = _local5; s = _local5; originalText.slice(0, Math.floor(((w / (textWidth + TEXT_WIDTH_PADDING)) * originalText.length))); while ((((s.length > 1)) && (((textWidth + TEXT_WIDTH_PADDING) > w)))) { s = s.slice(0, -1); super.text = (s + truncationIndicator); }; return (true); }; return (false); } public function set nestLevel(value:int):void{ if ((((value > 1)) && (!((_nestLevel == value))))){ _nestLevel = value; StyleProtoChain.initTextField(this); styleChangedFlag = true; validateNow(); }; } public function get minHeight():Number{ return (0); } public function getExplicitOrMeasuredHeight():Number{ return ((isNaN(explicitHeight)) ? measuredHeight : explicitHeight); } public function getStyle(styleProp:String){ if (StyleManager.inheritingStyles[styleProp]){ return ((inheritingStyles) ? inheritingStyles[styleProp] : IStyleClient(parent).getStyle(styleProp)); //unresolved jump }; return ((nonInheritingStyles) ? nonInheritingStyles[styleProp] : IStyleClient(parent).getStyle(styleProp)); } public function get className():String{ var name:String = getQualifiedClassName(this); var index:int = name.indexOf("::"); if (index != -1){ name = name.substr((index + 2)); }; return (name); } public function setColor(color:uint):void{ explicitColor = color; styleChangedFlag = true; invalidateDisplayListFlag = true; validateNow(); } override public function replaceText(beginIndex:int, endIndex:int, newText:String):void{ super.replaceText(beginIndex, endIndex, newText); dispatchEvent(new Event("textReplace")); } private function creatingSystemManager():ISystemManager{ return ((((!((moduleFactory == null))) && ((moduleFactory is ISystemManager)))) ? ISystemManager(moduleFactory) : systemManager); } public function set document(value:Object):void{ _document = value; } public function get automationName():String{ if (_automationName){ return (_automationName); }; if (automationDelegate){ return (automationDelegate.automationName); }; return (""); } public function get explicitMinHeight():Number{ return (NaN); } public function get focusPane():Sprite{ return (null); } public function getTextStyles():TextFormat{ var textFormat:TextFormat = new TextFormat(); textFormat.align = getStyle("textAlign"); textFormat.bold = (getStyle("fontWeight") == "bold"); if (enabled){ if (explicitColor == StyleManager.NOT_A_COLOR){ textFormat.color = getStyle("color"); } else { textFormat.color = explicitColor; }; } else { textFormat.color = getStyle("disabledColor"); }; textFormat.font = StringUtil.trimArrayElements(getStyle("fontFamily"), ","); textFormat.indent = getStyle("textIndent"); textFormat.italic = (getStyle("fontStyle") == "italic"); textFormat.kerning = getStyle("kerning"); textFormat.leading = getStyle("leading"); textFormat.leftMargin = (ignorePadding) ? 0 : getStyle("paddingLeft"); textFormat.letterSpacing = getStyle("letterSpacing"); textFormat.rightMargin = (ignorePadding) ? 0 : getStyle("paddingRight"); textFormat.size = getStyle("fontSize"); textFormat.underline = (getStyle("textDecoration") == "underline"); cachedTextFormat = textFormat; return (textFormat); } override public function set text(value:String):void{ if (!value){ value = ""; }; if (((!(isHTML)) && ((super.text == value)))){ return; }; super.text = value; explicitHTMLText = null; if (invalidateDisplayListFlag){ validateNow(); }; } public function getExplicitOrMeasuredWidth():Number{ return ((isNaN(explicitWidth)) ? measuredWidth : explicitWidth); } public function get showInAutomationHierarchy():Boolean{ return (true); } public function set automationName(value:String):void{ _automationName = value; } public function get systemManager():ISystemManager{ var ui:IUIComponent; var o:DisplayObject = parent; while (o) { ui = (o as IUIComponent); if (ui){ return (ui.systemManager); }; o = o.parent; }; return (null); } public function setStyle(styleProp:String, value):void{ } public function get percentWidth():Number{ return (NaN); } public function get explicitHeight():Number{ return (_explicitHeight); } public function get baselinePosition():Number{ var tlm:TextLineMetrics; if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0){ tlm = getLineMetrics(0); return (((height - 4) - tlm.descent)); }; if (!parent){ return (NaN); }; var isEmpty = (text == ""); if (isEmpty){ super.text = "Wj"; }; tlm = getLineMetrics(0); if (isEmpty){ super.text = ""; }; return ((2 + tlm.ascent)); } public function set enabled(value:Boolean):void{ mouseEnabled = value; _enabled = value; styleChanged("color"); } public function get minWidth():Number{ return (0); } public function get automationValue():Array{ if (automationDelegate){ return (automationDelegate.automationValue); }; return ([""]); } public function get tweeningProperties():Array{ return (null); } public function get measuredWidth():Number{ validateNow(); if (!stage){ return ((textWidth + TEXT_WIDTH_PADDING)); }; return (((textWidth * transform.concatenatedMatrix.d) + TEXT_WIDTH_PADDING)); } public function set tweeningProperties(value:Array):void{ } public function createAutomationIDPart(child:IAutomationObject):Object{ return (null); } override public function get parent():DisplayObjectContainer{ return ((_parent) ? _parent : super.parent); } public function set updateCompletePendingFlag(value:Boolean):void{ _updateCompletePendingFlag = value; } public function setActualSize(w:Number, h:Number):void{ if (width != w){ width = w; }; if (height != h){ height = h; }; } public function get numAutomationChildren():int{ return (0); } public function set focusPane(value:Sprite):void{ } public function getAutomationChildAt(index:int):IAutomationObject{ return (null); } public function get inheritingStyles():Object{ return (_inheritingStyles); } public function get owner():DisplayObjectContainer{ return ((_owner) ? _owner : parent); } public function parentChanged(p:DisplayObjectContainer):void{ if (!p){ _parent = null; _nestLevel = 0; } else { if ((p is IStyleClient)){ _parent = p; } else { if ((p is SystemManager)){ _parent = p; } else { _parent = p.parent; }; }; }; } public function get processedDescriptors():Boolean{ return (_processedDescriptors); } public function get maxWidth():Number{ return (UIComponent.DEFAULT_MAX_WIDTH); } private function getEmbeddedFont(fontName:String, bold:Boolean, italic:Boolean):EmbeddedFont{ if (cachedEmbeddedFont){ if ((((cachedEmbeddedFont.fontName == fontName)) && ((cachedEmbeddedFont.fontStyle == EmbeddedFontRegistry.getFontStyle(bold, italic))))){ return (cachedEmbeddedFont); }; }; cachedEmbeddedFont = new EmbeddedFont(fontName, bold, italic); return (cachedEmbeddedFont); } public function get initialized():Boolean{ return (_initialized); } public function invalidateDisplayList():void{ invalidateDisplayListFlag = true; } public function invalidateProperties():void{ } override public function insertXMLText(beginIndex:int, endIndex:int, richText:String, pasting:Boolean=false):void{ super.insertXMLText(beginIndex, endIndex, richText, pasting); dispatchEvent(new Event("textInsert")); } public function set includeInLayout(value:Boolean):void{ var p:IInvalidating; if (_includeInLayout != value){ _includeInLayout = value; p = (parent as IInvalidating); if (p){ p.invalidateSize(); p.invalidateDisplayList(); }; }; } override public function set htmlText(value:String):void{ if (!value){ value = ""; }; if (((isHTML) && ((super.htmlText == value)))){ return; }; if (((cachedTextFormat) && ((styleSheet == null)))){ defaultTextFormat = cachedTextFormat; }; super.htmlText = value; explicitHTMLText = value; if (invalidateDisplayListFlag){ validateNow(); }; } public function set showInAutomationHierarchy(value:Boolean):void{ } private function resourceManager_changeHandler(event:Event):void{ truncationIndicatorResource = resourceManager.getString("core", "truncationIndicator"); if (untruncatedText != null){ super.text = untruncatedText; truncateToFit(); }; } public function set measuredMinWidth(value:Number):void{ } public function set explicitHeight(value:Number):void{ _explicitHeight = value; } public function get explicitMinWidth():Number{ return (NaN); } public function set percentWidth(value:Number):void{ } public function get imeMode():String{ return (_imeMode); } public function get moduleFactory():IFlexModuleFactory{ return (_moduleFactory); } public function set systemManager(value:ISystemManager):void{ } public function get explicitMaxWidth():Number{ return (NaN); } public function get document():Object{ return (_document); } public function get updateCompletePendingFlag():Boolean{ return (_updateCompletePendingFlag); } public function replayAutomatableEvent(event:Event):Boolean{ if (automationDelegate){ return (automationDelegate.replayAutomatableEvent(event)); }; return (false); } public function get enabled():Boolean{ return (_enabled); } public function set owner(value:DisplayObjectContainer):void{ _owner = value; } public function get automationTabularData():Object{ return (null); } public function set nonInheritingStyles(value:Object):void{ _nonInheritingStyles = value; } public function get includeInLayout():Boolean{ return (_includeInLayout); } public function get measuredMinWidth():Number{ return (0); } public function set isPopUp(value:Boolean):void{ } public function set automationDelegate(value:Object):void{ _automationDelegate = (value as IAutomationObject); } public function get measuredHeight():Number{ validateNow(); if (!stage){ return ((textHeight + TEXT_HEIGHT_PADDING)); }; return (((textHeight * transform.concatenatedMatrix.a) + TEXT_HEIGHT_PADDING)); } public function set processedDescriptors(value:Boolean):void{ _processedDescriptors = value; } public function setFocus():void{ systemManager.stage.focus = this; } public function initialize():void{ } public function set percentHeight(value:Number):void{ } public function resolveAutomationIDPart(criteria:Object):Array{ return ([]); } public function set inheritingStyles(value:Object):void{ _inheritingStyles = value; } public function getUITextFormat():UITextFormat{ validateNow(); var textFormat:UITextFormat = new UITextFormat(creatingSystemManager()); textFormat.moduleFactory = moduleFactory; textFormat.copyFrom(getTextFormat()); textFormat.antiAliasType = antiAliasType; textFormat.gridFitType = gridFitType; textFormat.sharpness = sharpness; textFormat.thickness = thickness; return (textFormat); } private function changeHandler(event:Event):void{ explicitHTMLText = null; } public function set initialized(value:Boolean):void{ _initialized = value; } public function get nonZeroTextHeight():Number{ var result:Number; if (super.text == ""){ super.text = "Wj"; result = textHeight; super.text = ""; return (result); }; return (textHeight); } public function owns(child:DisplayObject):Boolean{ return ((child == this)); } override public function setTextFormat(format:TextFormat, beginIndex:int=-1, endIndex:int=-1):void{ if (styleSheet){ return; }; super.setTextFormat(format, beginIndex, endIndex); dispatchEvent(new Event("textFormatChange")); } public function get nonInheritingStyles():Object{ return (_nonInheritingStyles); } public function setVisible(visible:Boolean, noEvent:Boolean=false):void{ this.visible = visible; } public function get maxHeight():Number{ return (UIComponent.DEFAULT_MAX_HEIGHT); } public function get automationDelegate():Object{ return (_automationDelegate); } public function get isPopUp():Boolean{ return (false); } public function set ignorePadding(value:Boolean):void{ _ignorePadding = value; styleChanged(null); } public function set styleName(value:Object):void{ if (_styleName === value){ return; }; _styleName = value; if (parent){ StyleProtoChain.initTextField(this); styleChanged("styleName"); }; } public function styleChanged(styleProp:String):void{ styleChangedFlag = true; if (!invalidateDisplayListFlag){ invalidateDisplayListFlag = true; if (("callLater" in parent)){ Object(parent).callLater(validateNow); }; }; } public function get percentHeight():Number{ return (NaN); } private function get isHTML():Boolean{ return (!((explicitHTMLText == null))); } public function get explicitMaxHeight():Number{ return (NaN); } public function get styleName():Object{ return (_styleName); } public function set explicitWidth(value:Number):void{ _explicitWidth = value; } public function validateNow():void{ var textFormat:TextFormat; var embeddedFont:EmbeddedFont; var fontModuleFactory:IFlexModuleFactory; var sm:ISystemManager; if (!parent){ return; }; if (((!(isNaN(explicitWidth))) && (!((super.width == explicitWidth))))){ super.width = ((explicitWidth)>4) ? explicitWidth : 4; }; if (((!(isNaN(explicitHeight))) && (!((super.height == explicitHeight))))){ super.height = explicitHeight; }; if (styleChangedFlag){ textFormat = getTextStyles(); if (textFormat.font){ embeddedFont = getEmbeddedFont(textFormat.font, textFormat.bold, textFormat.italic); fontModuleFactory = embeddedFontRegistry.getAssociatedModuleFactory(embeddedFont, moduleFactory); if (fontModuleFactory != null){ embedFonts = true; } else { sm = creatingSystemManager(); embedFonts = ((!((sm == null))) && (sm.isFontFaceEmbedded(textFormat))); }; } else { embedFonts = getStyle("embedFonts"); }; if (getStyle("fontAntiAliasType") != undefined){ antiAliasType = getStyle("fontAntiAliasType"); gridFitType = getStyle("fontGridFitType"); sharpness = getStyle("fontSharpness"); thickness = getStyle("fontThickness"); }; if (!styleSheet){ super.setTextFormat(textFormat); defaultTextFormat = textFormat; }; dispatchEvent(new Event("textFieldStyleChange")); }; styleChangedFlag = false; invalidateDisplayListFlag = false; } public function set toolTip(value:String):void{ var oldValue:String = _toolTip; _toolTip = value; ToolTipManager.registerToolTip(this, oldValue, value); } public function move(x:Number, y:Number):void{ if (this.x != x){ this.x = x; }; if (this.y != y){ this.y = y; }; } public function get toolTip():String{ return (_toolTip); } public function get ignorePadding():Boolean{ return (_ignorePadding); } public function get explicitWidth():Number{ return (_explicitWidth); } public function invalidateSize():void{ invalidateDisplayListFlag = true; } public function set measuredMinHeight(value:Number):void{ } public function get measuredMinHeight():Number{ return (0); } public function set moduleFactory(factory:IFlexModuleFactory):void{ _moduleFactory = factory; } private static function get embeddedFontRegistry():IEmbeddedFontRegistry{ if (!_embeddedFontRegistry){ _embeddedFontRegistry = IEmbeddedFontRegistry(Singleton.getInstance("mx.core::IEmbeddedFontRegistry")); }; return (_embeddedFontRegistry); } } }//package mx.core
Section 134
//UITextFormat (mx.core.UITextFormat) package mx.core { import flash.text.*; import mx.managers.*; public class UITextFormat extends TextFormat { private var systemManager:ISystemManager; public var sharpness:Number; public var gridFitType:String; public var antiAliasType:String; public var thickness:Number; private var cachedEmbeddedFont:EmbeddedFont;// = null private var _moduleFactory:IFlexModuleFactory; mx_internal static const VERSION:String = "3.0.0.0"; private static var _embeddedFontRegistry:IEmbeddedFontRegistry; private static var _textFieldFactory:ITextFieldFactory; public function UITextFormat(systemManager:ISystemManager, font:String=null, size:Object=null, color:Object=null, bold:Object=null, italic:Object=null, underline:Object=null, url:String=null, target:String=null, align:String=null, leftMargin:Object=null, rightMargin:Object=null, indent:Object=null, leading:Object=null){ this.systemManager = systemManager; super(font, size, color, bold, italic, underline, url, target, align, leftMargin, rightMargin, indent, leading); } public function set moduleFactory(value:IFlexModuleFactory):void{ _moduleFactory = value; } mx_internal function copyFrom(source:TextFormat):void{ font = source.font; size = source.size; color = source.color; bold = source.bold; italic = source.italic; underline = source.underline; url = source.url; target = source.target; align = source.align; leftMargin = source.leftMargin; rightMargin = source.rightMargin; indent = source.indent; leading = source.leading; } private function getEmbeddedFont(fontName:String, bold:Boolean, italic:Boolean):EmbeddedFont{ if (cachedEmbeddedFont){ if ((((cachedEmbeddedFont.fontName == fontName)) && ((cachedEmbeddedFont.fontStyle == EmbeddedFontRegistry.getFontStyle(bold, italic))))){ return (cachedEmbeddedFont); }; }; cachedEmbeddedFont = new EmbeddedFont(fontName, bold, italic); return (cachedEmbeddedFont); } public function measureText(text:String, roundUp:Boolean=true):TextLineMetrics{ return (measure(text, false, roundUp)); } private function measure(s:String, html:Boolean, roundUp:Boolean):TextLineMetrics{ if (!s){ s = ""; }; var embeddedFont:Boolean; var fontModuleFactory:IFlexModuleFactory = embeddedFontRegistry.getAssociatedModuleFactory(getEmbeddedFont(font, bold, italic), moduleFactory); embeddedFont = !((fontModuleFactory == null)); if (fontModuleFactory == null){ fontModuleFactory = systemManager; }; var measurementTextField:TextField; measurementTextField = TextField(textFieldFactory.createTextField(fontModuleFactory)); if (html){ measurementTextField.htmlText = ""; } else { measurementTextField.text = ""; }; measurementTextField.defaultTextFormat = this; if (font){ measurementTextField.embedFonts = ((embeddedFont) || (((!((systemManager == null))) && (systemManager.isFontFaceEmbedded(this))))); } else { measurementTextField.embedFonts = false; }; measurementTextField.antiAliasType = antiAliasType; measurementTextField.gridFitType = gridFitType; measurementTextField.sharpness = sharpness; measurementTextField.thickness = thickness; if (html){ measurementTextField.htmlText = s; } else { measurementTextField.text = s; }; var lineMetrics:TextLineMetrics = measurementTextField.getLineMetrics(0); if (roundUp){ lineMetrics.width = Math.ceil(lineMetrics.width); lineMetrics.height = Math.ceil(lineMetrics.height); }; return (lineMetrics); } public function measureHTMLText(htmlText:String, roundUp:Boolean=true):TextLineMetrics{ return (measure(htmlText, true, roundUp)); } public function get moduleFactory():IFlexModuleFactory{ return (_moduleFactory); } private static function get embeddedFontRegistry():IEmbeddedFontRegistry{ if (!_embeddedFontRegistry){ _embeddedFontRegistry = IEmbeddedFontRegistry(Singleton.getInstance("mx.core::IEmbeddedFontRegistry")); }; return (_embeddedFontRegistry); } private static function get textFieldFactory():ITextFieldFactory{ if (!_textFieldFactory){ _textFieldFactory = ITextFieldFactory(Singleton.getInstance("mx.core::ITextFieldFactory")); }; return (_textFieldFactory); } } }//package mx.core
Section 135
//AddRemoveEffectTargetFilter (mx.effects.effectClasses.AddRemoveEffectTargetFilter) package mx.effects.effectClasses { import mx.core.*; import mx.effects.*; public class AddRemoveEffectTargetFilter extends EffectTargetFilter { public var add:Boolean;// = true mx_internal static const VERSION:String = "3.0.0.0"; public function AddRemoveEffectTargetFilter(){ super(); filterProperties = ["parent"]; } override protected function defaultFilterFunction(propChanges:Array, instanceTarget:Object):Boolean{ var props:PropertyChanges; var n:int = propChanges.length; var i:int; while (i < n) { props = propChanges[i]; if (props.target == instanceTarget){ if (add){ return ((((props.start["parent"] == null)) && (!((props.end["parent"] == null))))); }; return (((!((props.start["parent"] == null))) && ((props.end["parent"] == null)))); }; i++; }; return (false); } } }//package mx.effects.effectClasses
Section 136
//HideShowEffectTargetFilter (mx.effects.effectClasses.HideShowEffectTargetFilter) package mx.effects.effectClasses { import mx.core.*; import mx.effects.*; public class HideShowEffectTargetFilter extends EffectTargetFilter { public var show:Boolean;// = true mx_internal static const VERSION:String = "3.0.0.0"; public function HideShowEffectTargetFilter(){ super(); filterProperties = ["visible"]; } override protected function defaultFilterFunction(propChanges:Array, instanceTarget:Object):Boolean{ var props:PropertyChanges; var n:int = propChanges.length; var i:int; while (i < n) { props = propChanges[i]; if (props.target == instanceTarget){ return ((props.end["visible"] == show)); }; i++; }; return (false); } } }//package mx.effects.effectClasses
Section 137
//PropertyChanges (mx.effects.effectClasses.PropertyChanges) package mx.effects.effectClasses { import mx.core.*; public class PropertyChanges { public var target:Object; public var start:Object; public var end:Object; mx_internal static const VERSION:String = "3.0.0.0"; public function PropertyChanges(target:Object){ end = {}; start = {}; super(); this.target = target; } } }//package mx.effects.effectClasses
Section 138
//TweenEffectInstance (mx.effects.effectClasses.TweenEffectInstance) package mx.effects.effectClasses { import mx.core.*; import mx.events.*; import mx.effects.*; public class TweenEffectInstance extends EffectInstance { private var _seekTime:Number;// = 0 public var easingFunction:Function; public var tween:Tween; mx_internal var needToLayout:Boolean;// = false mx_internal static const VERSION:String = "3.0.0.0"; public function TweenEffectInstance(target:Object){ super(target); } override public function stop():void{ super.stop(); if (tween){ tween.stop(); }; } mx_internal function applyTweenStartValues():void{ if (duration > 0){ onTweenUpdate(tween.getCurrentValue(0)); }; } override public function get playheadTime():Number{ if (tween){ return ((tween.playheadTime + super.playheadTime)); }; return (0); } protected function createTween(listener:Object, startValue:Object, endValue:Object, duration:Number=-1, minFps:Number=-1):Tween{ var newTween:Tween = new Tween(listener, startValue, endValue, duration, minFps); newTween.addEventListener(TweenEvent.TWEEN_START, tweenEventHandler); newTween.addEventListener(TweenEvent.TWEEN_UPDATE, tweenEventHandler); newTween.addEventListener(TweenEvent.TWEEN_END, tweenEventHandler); if (easingFunction != null){ newTween.easingFunction = easingFunction; }; if (_seekTime > 0){ newTween.seek(_seekTime); }; newTween.playReversed = playReversed; return (newTween); } private function tweenEventHandler(event:TweenEvent):void{ dispatchEvent(event); } override public function end():void{ stopRepeat = true; if (delayTimer){ delayTimer.reset(); }; if (tween){ tween.endTween(); tween = null; }; } override public function reverse():void{ super.reverse(); if (tween){ tween.reverse(); }; super.playReversed = !(playReversed); } override mx_internal function set playReversed(value:Boolean):void{ super.playReversed = value; if (tween){ tween.playReversed = value; }; } override public function resume():void{ super.resume(); if (tween){ tween.resume(); }; } public function onTweenEnd(value:Object):void{ onTweenUpdate(value); tween = null; if (needToLayout){ UIComponentGlobals.layoutManager.validateNow(); }; finishRepeat(); } public function onTweenUpdate(value:Object):void{ } override public function pause():void{ super.pause(); if (tween){ tween.pause(); }; } public function seek(playheadTime:Number):void{ if (tween){ tween.seek(playheadTime); } else { _seekTime = playheadTime; }; } } }//package mx.effects.effectClasses
Section 139
//ZoomInstance (mx.effects.effectClasses.ZoomInstance) package mx.effects.effectClasses { import mx.core.*; import flash.events.*; import mx.events.*; import mx.effects.*; public class ZoomInstance extends TweenEffectInstance { private var newY:Number; public var originY:Number; private var origX:Number; private var origY:Number; public var originX:Number; private var origPercentHeight:Number; public var zoomWidthFrom:Number; public var zoomWidthTo:Number; private var newX:Number; public var captureRollEvents:Boolean; private var origPercentWidth:Number; public var zoomHeightFrom:Number; private var origScaleX:Number; public var zoomHeightTo:Number; private var origScaleY:Number; private var scaledOriginX:Number; private var scaledOriginY:Number; private var show:Boolean;// = true private var _mouseHasMoved:Boolean;// = false mx_internal static const VERSION:String = "3.0.0.0"; public function ZoomInstance(target:Object){ super(target); } override public function finishEffect():void{ if (captureRollEvents){ target.removeEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false); target.removeEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false); target.removeEventListener(MouseEvent.MOUSE_MOVE, mouseEventHandler, false); }; super.finishEffect(); } private function getScaleFromWidth(value:Number):Number{ return ((value / (target.width / Math.abs(target.scaleX)))); } override public function initEffect(event:Event):void{ super.initEffect(event); if ((((event.type == FlexEvent.HIDE)) || ((event.type == Event.REMOVED)))){ show = false; }; } private function getScaleFromHeight(value:Number):Number{ return ((value / (target.height / Math.abs(target.scaleY)))); } private function applyPropertyChanges():void{ var useSize:Boolean; var useScale:Boolean; var values:PropertyChanges = propertyChanges; if (values){ useSize = false; useScale = false; if (values.end["scaleX"] !== undefined){ zoomWidthFrom = (isNaN(zoomWidthFrom)) ? target.scaleX : zoomWidthFrom; zoomWidthTo = (isNaN(zoomWidthTo)) ? values.end["scaleX"] : zoomWidthTo; useScale = true; }; if (values.end["scaleY"] !== undefined){ zoomHeightFrom = (isNaN(zoomHeightFrom)) ? target.scaleY : zoomHeightFrom; zoomHeightTo = (isNaN(zoomHeightTo)) ? values.end["scaleY"] : zoomHeightTo; useScale = true; }; if (useScale){ return; }; if (values.end["width"] !== undefined){ zoomWidthFrom = (isNaN(zoomWidthFrom)) ? getScaleFromWidth(target.width) : zoomWidthFrom; zoomWidthTo = (isNaN(zoomWidthTo)) ? getScaleFromWidth(values.end["width"]) : zoomWidthTo; useSize = true; }; if (values.end["height"] !== undefined){ zoomHeightFrom = (isNaN(zoomHeightFrom)) ? getScaleFromHeight(target.height) : zoomHeightFrom; zoomHeightTo = (isNaN(zoomHeightTo)) ? getScaleFromHeight(values.end["height"]) : zoomHeightTo; useSize = true; }; if (useSize){ return; }; if (values.end["visible"] !== undefined){ show = values.end["visible"]; }; }; } private function mouseEventHandler(event:MouseEvent):void{ if (event.type == MouseEvent.MOUSE_MOVE){ _mouseHasMoved = true; } else { if ((((event.type == MouseEvent.ROLL_OUT)) || ((event.type == MouseEvent.ROLL_OVER)))){ if (!_mouseHasMoved){ event.stopImmediatePropagation(); }; _mouseHasMoved = false; }; }; } override public function play():void{ super.play(); applyPropertyChanges(); if (((((((isNaN(zoomWidthFrom)) && (isNaN(zoomWidthTo)))) && (isNaN(zoomHeightFrom)))) && (isNaN(zoomHeightTo)))){ if (show){ zoomWidthFrom = (zoomHeightFrom = 0); zoomWidthTo = target.scaleX; zoomHeightTo = target.scaleY; } else { zoomWidthFrom = target.scaleX; zoomHeightFrom = target.scaleY; zoomWidthTo = (zoomHeightTo = 0); }; } else { if (((isNaN(zoomWidthFrom)) && (isNaN(zoomWidthTo)))){ zoomWidthFrom = (zoomWidthTo = target.scaleX); } else { if (((isNaN(zoomHeightFrom)) && (isNaN(zoomHeightTo)))){ zoomHeightFrom = (zoomHeightTo = target.scaleY); }; }; if (isNaN(zoomWidthFrom)){ zoomWidthFrom = target.scaleX; } else { if (isNaN(zoomWidthTo)){ zoomWidthTo = ((zoomWidthFrom)==1) ? 0 : 1; }; }; if (isNaN(zoomHeightFrom)){ zoomHeightFrom = target.scaleY; } else { if (isNaN(zoomHeightTo)){ zoomHeightTo = ((zoomHeightFrom)==1) ? 0 : 1; }; }; }; if (zoomWidthFrom < 0.01){ zoomWidthFrom = 0.01; }; if (zoomWidthTo < 0.01){ zoomWidthTo = 0.01; }; if (zoomHeightFrom < 0.01){ zoomHeightFrom = 0.01; }; if (zoomHeightTo < 0.01){ zoomHeightTo = 0.01; }; origScaleX = target.scaleX; origScaleY = target.scaleY; newX = (origX = target.x); newY = (origY = target.y); if (isNaN(originX)){ scaledOriginX = (target.width / 2); } else { scaledOriginX = (originX * origScaleX); }; if (isNaN(originY)){ scaledOriginY = (target.height / 2); } else { scaledOriginY = (originY * origScaleY); }; scaledOriginX = Number(scaledOriginX.toFixed(1)); scaledOriginY = Number(scaledOriginY.toFixed(1)); origPercentWidth = target.percentWidth; if (!isNaN(origPercentWidth)){ target.width = target.width; }; origPercentHeight = target.percentHeight; if (!isNaN(origPercentHeight)){ target.height = target.height; }; tween = createTween(this, [zoomWidthFrom, zoomHeightFrom], [zoomWidthTo, zoomHeightTo], duration); if (captureRollEvents){ target.addEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false); target.addEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false); target.addEventListener(MouseEvent.MOUSE_MOVE, mouseEventHandler, false); }; } override public function onTweenEnd(value:Object):void{ var curWidth:Number; var curHeight:Number; if (!isNaN(origPercentWidth)){ curWidth = target.width; target.percentWidth = origPercentWidth; if (((target.parent) && ((target.parent.autoLayout == false)))){ target.mx_internal::_width = curWidth; }; }; if (!isNaN(origPercentHeight)){ curHeight = target.height; target.percentHeight = origPercentHeight; if (((target.parent) && ((target.parent.autoLayout == false)))){ target.mx_internal::_height = curHeight; }; }; super.onTweenEnd(value); if (mx_internal::hideOnEffectEnd){ EffectManager.suspendEventHandling(); target.scaleX = origScaleX; target.scaleY = origScaleY; target.move(origX, origY); EffectManager.resumeEventHandling(); }; } override public function onTweenUpdate(value:Object):void{ EffectManager.suspendEventHandling(); if (Math.abs((newX - target.x)) > 0.1){ origX = (origX + (Number(target.x.toFixed(1)) - newX)); }; if (Math.abs((newY - target.y)) > 0.1){ origY = (origY + (Number(target.y.toFixed(1)) - newY)); }; target.scaleX = value[0]; target.scaleY = value[1]; var ratioX:Number = (value[0] / origScaleX); var ratioY:Number = (value[1] / origScaleY); var newOriginX:Number = (scaledOriginX * ratioX); var newOriginY:Number = (scaledOriginY * ratioY); newX = ((scaledOriginX - newOriginX) + origX); newY = ((scaledOriginY - newOriginY) + origY); newX = Number(newX.toFixed(1)); newY = Number(newY.toFixed(1)); target.move(newX, newY); tween.mx_internal::needToLayout = true; EffectManager.resumeEventHandling(); } } }//package mx.effects.effectClasses
Section 140
//Effect (mx.effects.Effect) package mx.effects { import mx.core.*; import flash.events.*; import mx.events.*; import mx.managers.*; import mx.effects.effectClasses.*; import flash.utils.*; public class Effect extends EventDispatcher implements IEffect { private var _perElementOffset:Number;// = 0 private var _hideFocusRing:Boolean;// = false private var _customFilter:EffectTargetFilter; public var repeatCount:int;// = 1 public var suspendBackgroundProcessing:Boolean;// = false public var startDelay:int;// = 0 private var _relevantProperties:Array; private var _callValidateNow:Boolean;// = false mx_internal var applyActualDimensions:Boolean;// = true private var _filter:String; private var _triggerEvent:Event; private var _effectTargetHost:IEffectTargetHost; mx_internal var durationExplicitlySet:Boolean;// = false public var repeatDelay:int;// = 0 private var _targets:Array; mx_internal var propertyChangesArray:Array; mx_internal var filterObject:EffectTargetFilter; protected var endValuesCaptured:Boolean;// = false public var instanceClass:Class; private var _duration:Number;// = 500 private var isPaused:Boolean;// = false private var _relevantStyles:Array; private var _instances:Array; mx_internal static const VERSION:String = "3.0.0.0"; public function Effect(target:Object=null){ _instances = []; instanceClass = IEffectInstance; _relevantStyles = []; _targets = []; super(); this.target = target; } public function get targets():Array{ return (_targets); } public function set targets(value:Array):void{ var n:int = value.length; var i:int = (n - 1); while (i > 0) { if (value[i] == null){ value.splice(i, 1); }; i--; }; _targets = value; } public function set hideFocusRing(value:Boolean):void{ _hideFocusRing = value; } public function get hideFocusRing():Boolean{ return (_hideFocusRing); } public function stop():void{ var instance:IEffectInstance; var n:int = _instances.length; var i:int = n; while (i >= 0) { instance = IEffectInstance(_instances[i]); if (instance){ instance.stop(); }; i--; }; } public function captureStartValues():void{ var n:int; var i:int; if (targets.length > 0){ propertyChangesArray = []; _callValidateNow = true; n = targets.length; i = 0; while (i < n) { propertyChangesArray.push(new PropertyChanges(targets[i])); i++; }; propertyChangesArray = captureValues(propertyChangesArray, true); }; endValuesCaptured = false; } mx_internal function captureValues(propChanges:Array, setStartValues:Boolean):Array{ var valueMap:Object; var target:Object; var n:int; var i:int; var m:int; var j:int; var effectProps:Array = (filterObject) ? mergeArrays(relevantProperties, filterObject.filterProperties) : relevantProperties; if (((effectProps) && ((effectProps.length > 0)))){ n = propChanges.length; i = 0; while (i < n) { target = propChanges[i].target; valueMap = (setStartValues) ? propChanges[i].start : propChanges[i].end; m = effectProps.length; j = 0; while (j < m) { valueMap[effectProps[j]] = getValueFromTarget(target, effectProps[j]); j++; }; i++; }; }; var styles:Array = (filterObject) ? mergeArrays(relevantStyles, filterObject.filterStyles) : relevantStyles; if (((styles) && ((styles.length > 0)))){ n = propChanges.length; i = 0; while (i < n) { target = propChanges[i].target; valueMap = (setStartValues) ? propChanges[i].start : propChanges[i].end; m = styles.length; j = 0; while (j < m) { valueMap[styles[j]] = target.getStyle(styles[j]); j++; }; i++; }; }; return (propChanges); } protected function getValueFromTarget(target:Object, property:String){ if ((property in target)){ return (target[property]); }; return (undefined); } public function set target(value:Object):void{ _targets.splice(0); if (value){ _targets[0] = value; }; } public function get className():String{ var name:String = getQualifiedClassName(this); var index:int = name.indexOf("::"); if (index != -1){ name = name.substr((index + 2)); }; return (name); } public function set perElementOffset(value:Number):void{ _perElementOffset = value; } public function resume():void{ var n:int; var i:int; if (((isPlaying) && (isPaused))){ isPaused = false; n = _instances.length; i = 0; while (i < n) { IEffectInstance(_instances[i]).resume(); i++; }; }; } public function set duration(value:Number):void{ durationExplicitlySet = true; _duration = value; } public function play(targets:Array=null, playReversedFromEnd:Boolean=false):Array{ var newInstance:IEffectInstance; if ((((targets == null)) && (!((propertyChangesArray == null))))){ if (_callValidateNow){ LayoutManager.getInstance().validateNow(); }; if (!endValuesCaptured){ propertyChangesArray = captureValues(propertyChangesArray, false); }; propertyChangesArray = stripUnchangedValues(propertyChangesArray); applyStartValues(propertyChangesArray, this.targets); }; var newInstances:Array = createInstances(targets); var n:int = newInstances.length; var i:int; while (i < n) { newInstance = IEffectInstance(newInstances[i]); Object(newInstance).playReversed = playReversedFromEnd; newInstance.startEffect(); i++; }; return (newInstances); } public function captureEndValues():void{ propertyChangesArray = captureValues(propertyChangesArray, false); endValuesCaptured = true; } protected function filterInstance(propChanges:Array, target:Object):Boolean{ if (filterObject){ return (filterObject.filterInstance(propChanges, effectTargetHost, target)); }; return (true); } public function get customFilter():EffectTargetFilter{ return (_customFilter); } public function get effectTargetHost():IEffectTargetHost{ return (_effectTargetHost); } public function set relevantProperties(value:Array):void{ _relevantProperties = value; } public function captureMoreStartValues(targets:Array):void{ var additionalPropertyChangesArray:Array; var i:int; if (targets.length > 0){ additionalPropertyChangesArray = []; i = 0; while (i < targets.length) { additionalPropertyChangesArray.push(new PropertyChanges(targets[i])); i++; }; additionalPropertyChangesArray = captureValues(additionalPropertyChangesArray, true); propertyChangesArray = propertyChangesArray.concat(additionalPropertyChangesArray); }; } public function deleteInstance(instance:IEffectInstance):void{ EventDispatcher(instance).removeEventListener(EffectEvent.EFFECT_START, effectStartHandler); EventDispatcher(instance).removeEventListener(EffectEvent.EFFECT_END, effectEndHandler); var n:int = _instances.length; var i:int; while (i < n) { if (_instances[i] === instance){ _instances.splice(i, 1); }; i++; }; } public function get filter():String{ return (_filter); } public function set triggerEvent(value:Event):void{ _triggerEvent = value; } public function get target():Object{ if (_targets.length > 0){ return (_targets[0]); }; return (null); } public function get duration():Number{ return (_duration); } public function set customFilter(value:EffectTargetFilter):void{ _customFilter = value; filterObject = value; } public function get perElementOffset():Number{ return (_perElementOffset); } public function set effectTargetHost(value:IEffectTargetHost):void{ _effectTargetHost = value; } public function get isPlaying():Boolean{ return (((_instances) && ((_instances.length > 0)))); } protected function effectEndHandler(event:EffectEvent):void{ var instance:IEffectInstance = IEffectInstance(event.effectInstance); deleteInstance(instance); dispatchEvent(event); } public function get relevantProperties():Array{ if (_relevantProperties){ return (_relevantProperties); }; return (getAffectedProperties()); } public function createInstance(target:Object=null):IEffectInstance{ var n:int; var i:int; if (!target){ target = this.target; }; var newInstance:IEffectInstance; var props:PropertyChanges; var create:Boolean; var setPropsArray:Boolean; if (propertyChangesArray){ setPropsArray = true; create = filterInstance(propertyChangesArray, target); }; if (create){ newInstance = IEffectInstance(new instanceClass(target)); initInstance(newInstance); if (setPropsArray){ n = propertyChangesArray.length; i = 0; while (i < n) { if (propertyChangesArray[i].target == target){ newInstance.propertyChanges = propertyChangesArray[i]; }; i++; }; }; EventDispatcher(newInstance).addEventListener(EffectEvent.EFFECT_START, effectStartHandler); EventDispatcher(newInstance).addEventListener(EffectEvent.EFFECT_END, effectEndHandler); _instances.push(newInstance); if (triggerEvent){ newInstance.initEffect(triggerEvent); }; }; return (newInstance); } protected function effectStartHandler(event:EffectEvent):void{ dispatchEvent(event); } public function getAffectedProperties():Array{ return ([]); } public function set relevantStyles(value:Array):void{ _relevantStyles = value; } public function get triggerEvent():Event{ return (_triggerEvent); } protected function applyValueToTarget(target:Object, property:String, value, props:Object):void{ var target = target; var property = property; var value = value; var props = props; if ((property in target)){ if (((((applyActualDimensions) && ((target is IFlexDisplayObject)))) && ((property == "height")))){ target.setActualSize(target.width, value); } else { if (((((applyActualDimensions) && ((target is IFlexDisplayObject)))) && ((property == "width")))){ target.setActualSize(value, target.height); } else { target[property] = value; }; }; //unresolved jump var _slot1 = e; }; } protected function initInstance(instance:IEffectInstance):void{ instance.duration = duration; Object(instance).durationExplicitlySet = durationExplicitlySet; instance.effect = this; instance.effectTargetHost = effectTargetHost; instance.hideFocusRing = hideFocusRing; instance.repeatCount = repeatCount; instance.repeatDelay = repeatDelay; instance.startDelay = startDelay; instance.suspendBackgroundProcessing = suspendBackgroundProcessing; } mx_internal function applyStartValues(propChanges:Array, targets:Array):void{ var m:int; var j:int; var target:Object; var apply:Boolean; var effectProps:Array = relevantProperties; var n:int = propChanges.length; var i:int; while (i < n) { target = propChanges[i].target; apply = false; m = targets.length; j = 0; while (j < m) { if (targets[j] == target){ apply = filterInstance(propChanges, target); break; }; j++; }; if (apply){ m = effectProps.length; j = 0; while (j < m) { if ((((effectProps[j] in propChanges[i].start)) && ((effectProps[j] in target)))){ applyValueToTarget(target, effectProps[j], propChanges[i].start[effectProps[j]], propChanges[i].start); }; j++; }; m = relevantStyles.length; j = 0; while (j < m) { if ((relevantStyles[j] in propChanges[i].start)){ target.setStyle(relevantStyles[j], propChanges[i].start[relevantStyles[j]]); }; j++; }; }; i++; }; } public function end(effectInstance:IEffectInstance=null):void{ var n:int; var i:int; var instance:IEffectInstance; if (effectInstance){ effectInstance.end(); } else { n = _instances.length; i = n; while (i >= 0) { instance = IEffectInstance(_instances[i]); if (instance){ instance.end(); }; i--; }; }; } public function get relevantStyles():Array{ return (_relevantStyles); } public function createInstances(targets:Array=null):Array{ var newInstance:IEffectInstance; if (!targets){ targets = this.targets; }; var newInstances:Array = []; var n:int = targets.length; var offsetDelay:Number = 0; var i:int; while (i < n) { newInstance = createInstance(targets[i]); if (newInstance){ newInstance.startDelay = (newInstance.startDelay + offsetDelay); offsetDelay = (offsetDelay + perElementOffset); newInstances.push(newInstance); }; i++; }; triggerEvent = null; return (newInstances); } public function pause():void{ var n:int; var i:int; if (((isPlaying) && (!(isPaused)))){ isPaused = true; n = _instances.length; i = 0; while (i < n) { IEffectInstance(_instances[i]).pause(); i++; }; }; } public function set filter(value:String):void{ if (!customFilter){ _filter = value; switch (value){ case "add": case "remove": filterObject = new AddRemoveEffectTargetFilter(); AddRemoveEffectTargetFilter(filterObject).add = (value == "add"); break; case "hide": case "show": filterObject = new HideShowEffectTargetFilter(); HideShowEffectTargetFilter(filterObject).show = (value == "show"); break; case "move": filterObject = new EffectTargetFilter(); filterObject.filterProperties = ["x", "y"]; break; case "resize": filterObject = new EffectTargetFilter(); filterObject.filterProperties = ["width", "height"]; break; case "addItem": filterObject = new EffectTargetFilter(); filterObject.requiredSemantics = {added:true}; break; case "removeItem": filterObject = new EffectTargetFilter(); filterObject.requiredSemantics = {removed:true}; break; case "replacedItem": filterObject = new EffectTargetFilter(); filterObject.requiredSemantics = {replaced:true}; break; case "replacementItem": filterObject = new EffectTargetFilter(); filterObject.requiredSemantics = {replacement:true}; break; default: filterObject = null; break; }; }; } public function reverse():void{ var n:int; var i:int; if (isPlaying){ n = _instances.length; i = 0; while (i < n) { IEffectInstance(_instances[i]).reverse(); i++; }; }; } private static function mergeArrays(a1:Array, a2:Array):Array{ var i2:int; var addIt:Boolean; var i1:int; if (a2){ i2 = 0; while (i2 < a2.length) { addIt = true; i1 = 0; while (i1 < a1.length) { if (a1[i1] == a2[i2]){ addIt = false; break; }; i1++; }; if (addIt){ a1.push(a2[i2]); }; i2++; }; }; return (a1); } private static function stripUnchangedValues(propChanges:Array):Array{ var prop:Object; var i:int; while (i < propChanges.length) { for (prop in propChanges[i].start) { if ((((propChanges[i].start[prop] == propChanges[i].end[prop])) || ((((((((typeof(propChanges[i].start[prop]) == "number")) && ((typeof(propChanges[i].end[prop]) == "number")))) && (isNaN(propChanges[i].start[prop])))) && (isNaN(propChanges[i].end[prop])))))){ delete propChanges[i].start[prop]; delete propChanges[i].end[prop]; }; }; i++; }; return (propChanges); } } }//package mx.effects
Section 141
//EffectInstance (mx.effects.EffectInstance) package mx.effects { import mx.core.*; import flash.events.*; import mx.events.*; import mx.effects.effectClasses.*; import flash.utils.*; public class EffectInstance extends EventDispatcher implements IEffectInstance { private var _hideFocusRing:Boolean; private var delayStartTime:Number;// = 0 mx_internal var stopRepeat:Boolean;// = false private var playCount:int;// = 0 private var _repeatCount:int;// = 0 private var _suspendBackgroundProcessing:Boolean;// = false mx_internal var delayTimer:Timer; private var _triggerEvent:Event; private var _effectTargetHost:IEffectTargetHost; mx_internal var parentCompositeEffectInstance:EffectInstance; mx_internal var durationExplicitlySet:Boolean;// = false private var _effect:IEffect; private var _target:Object; mx_internal var hideOnEffectEnd:Boolean;// = false private var _startDelay:int;// = 0 private var delayElapsedTime:Number;// = 0 private var _repeatDelay:int;// = 0 private var _propertyChanges:PropertyChanges; private var _duration:Number;// = 500 private var _playReversed:Boolean; mx_internal static const VERSION:String = "3.0.0.0"; public function EffectInstance(target:Object){ super(); this.target = target; } public function get playheadTime():Number{ return ((((Math.max((playCount - 1), 0) * duration) + (Math.max((playCount - 2), 0) * repeatDelay)) + (playReversed) ? 0 : startDelay)); } public function get hideFocusRing():Boolean{ return (_hideFocusRing); } public function stop():void{ if (delayTimer){ delayTimer.reset(); }; stopRepeat = true; finishEffect(); } public function finishEffect():void{ playCount = 0; dispatchEvent(new EffectEvent(EffectEvent.EFFECT_END, false, false, this)); if (target){ target.dispatchEvent(new EffectEvent(EffectEvent.EFFECT_END, false, false, this)); }; if ((target is UIComponent)){ UIComponent(target).effectFinished(this); }; EffectManager.effectFinished(this); } public function set hideFocusRing(value:Boolean):void{ _hideFocusRing = value; } public function finishRepeat():void{ if (((((!(stopRepeat)) && (!((playCount == 0))))) && ((((playCount < repeatCount)) || ((repeatCount == 0)))))){ if (repeatDelay > 0){ delayTimer = new Timer(repeatDelay, 1); delayStartTime = getTimer(); delayTimer.addEventListener(TimerEvent.TIMER, delayTimerHandler); delayTimer.start(); } else { play(); }; } else { finishEffect(); }; } mx_internal function get playReversed():Boolean{ return (_playReversed); } public function set effect(value:IEffect):void{ _effect = value; } public function get className():String{ var name:String = getQualifiedClassName(this); var index:int = name.indexOf("::"); if (index != -1){ name = name.substr((index + 2)); }; return (name); } public function set duration(value:Number):void{ durationExplicitlySet = true; _duration = value; } mx_internal function set playReversed(value:Boolean):void{ _playReversed = value; } public function resume():void{ if (((((delayTimer) && (!(delayTimer.running)))) && (!(isNaN(delayElapsedTime))))){ delayTimer.delay = (playReversed) ? delayElapsedTime : (delayTimer.delay - delayElapsedTime); delayTimer.start(); }; } public function get propertyChanges():PropertyChanges{ return (_propertyChanges); } public function set target(value:Object):void{ _target = value; } public function get repeatCount():int{ return (_repeatCount); } mx_internal function playWithNoDuration():void{ duration = 0; repeatCount = 1; repeatDelay = 0; startDelay = 0; startEffect(); } public function get startDelay():int{ return (_startDelay); } mx_internal function get actualDuration():Number{ var value:Number = NaN; if (repeatCount > 0){ value = (((duration * repeatCount) + ((repeatDelay * repeatCount) - 1)) + startDelay); }; return (value); } public function play():void{ playCount++; dispatchEvent(new EffectEvent(EffectEvent.EFFECT_START, false, false, this)); if (target){ target.dispatchEvent(new EffectEvent(EffectEvent.EFFECT_START, false, false, this)); }; } public function get suspendBackgroundProcessing():Boolean{ return (_suspendBackgroundProcessing); } public function get effectTargetHost():IEffectTargetHost{ return (_effectTargetHost); } public function set repeatDelay(value:int):void{ _repeatDelay = value; } public function set propertyChanges(value:PropertyChanges):void{ _propertyChanges = value; } mx_internal function eventHandler(event:Event):void{ if ((((event.type == FlexEvent.SHOW)) && ((hideOnEffectEnd == true)))){ hideOnEffectEnd = false; event.target.removeEventListener(FlexEvent.SHOW, eventHandler); }; } public function set repeatCount(value:int):void{ _repeatCount = value; } private function delayTimerHandler(event:TimerEvent):void{ delayTimer.reset(); delayStartTime = NaN; delayElapsedTime = NaN; play(); } public function set suspendBackgroundProcessing(value:Boolean):void{ _suspendBackgroundProcessing = value; } public function set triggerEvent(value:Event):void{ _triggerEvent = value; } public function set startDelay(value:int):void{ _startDelay = value; } public function get effect():IEffect{ return (_effect); } public function set effectTargetHost(value:IEffectTargetHost):void{ _effectTargetHost = value; } public function get target():Object{ return (_target); } public function startEffect():void{ EffectManager.effectStarted(this); if ((target is UIComponent)){ UIComponent(target).effectStarted(this); }; if ((((startDelay > 0)) && (!(playReversed)))){ delayTimer = new Timer(startDelay, 1); delayStartTime = getTimer(); delayTimer.addEventListener(TimerEvent.TIMER, delayTimerHandler); delayTimer.start(); } else { play(); }; } public function get repeatDelay():int{ return (_repeatDelay); } public function get duration():Number{ if (((!(durationExplicitlySet)) && (parentCompositeEffectInstance))){ return (parentCompositeEffectInstance.duration); }; return (_duration); } public function initEffect(event:Event):void{ triggerEvent = event; switch (event.type){ case "resizeStart": case "resizeEnd": if (!durationExplicitlySet){ duration = 250; }; break; case FlexEvent.HIDE: target.setVisible(true, true); hideOnEffectEnd = true; target.addEventListener(FlexEvent.SHOW, eventHandler); break; }; } public function get triggerEvent():Event{ return (_triggerEvent); } public function end():void{ if (delayTimer){ delayTimer.reset(); }; stopRepeat = true; finishEffect(); } public function reverse():void{ if (repeatCount > 0){ playCount = ((repeatCount - playCount) + 1); }; } public function pause():void{ if (((((delayTimer) && (delayTimer.running))) && (!(isNaN(delayStartTime))))){ delayTimer.stop(); delayElapsedTime = (getTimer() - delayStartTime); }; } } }//package mx.effects
Section 142
//EffectManager (mx.effects.EffectManager) package mx.effects { import mx.core.*; import flash.events.*; import flash.display.*; import mx.events.*; import mx.resources.*; import flash.utils.*; public class EffectManager extends EventDispatcher { mx_internal static const VERSION:String = "3.0.0.0"; private static var _resourceManager:IResourceManager; private static var effects:Dictionary = new Dictionary(true); mx_internal static var effectsPlaying:Array = []; private static var targetsInfo:Array = []; private static var effectTriggersForEvent:Object = {}; mx_internal static var lastEffectCreated:Effect; private static var eventHandlingSuspendCount:Number = 0; private static var eventsForEffectTriggers:Object = {}; public function EffectManager(){ super(); } public static function suspendEventHandling():void{ eventHandlingSuspendCount++; } mx_internal static function registerEffectTrigger(name:String, event:String):void{ var strLen:Number; if (name != ""){ if (event == ""){ strLen = name.length; if ((((strLen > 6)) && ((name.substring((strLen - 6)) == "Effect")))){ event = name.substring(0, (strLen - 6)); }; }; if (event != ""){ effectTriggersForEvent[event] = name; eventsForEffectTriggers[name] = event; }; }; } private static function removedEffectHandler(target:DisplayObject, parent:DisplayObjectContainer, index:int, eventObj:Event):void{ suspendEventHandling(); parent.addChildAt(target, index); resumeEventHandling(); createAndPlayEffect(eventObj, target); } private static function createAndPlayEffect(eventObj:Event, target:Object):void{ var n:int; var i:int; var m:int; var j:int; var message:String; var type:String; var tweeningProperties:Array; var effectProperties:Array; var affectedProps:Array; var runningInstances:Array; var otherInst:EffectInstance; var effectInst:Effect = createEffectForType(target, eventObj.type); if (!effectInst){ return; }; if ((((effectInst is Zoom)) && ((eventObj.type == MoveEvent.MOVE)))){ message = resourceManager.getString("effects", "incorrectTrigger"); throw (new Error(message)); }; if (target.initialized == false){ type = eventObj.type; if ((((((((((type == MoveEvent.MOVE)) || ((type == ResizeEvent.RESIZE)))) || ((type == FlexEvent.SHOW)))) || ((type == FlexEvent.HIDE)))) || ((type == Event.CHANGE)))){ effectInst = null; return; }; }; if ((effectInst.target is IUIComponent)){ tweeningProperties = IUIComponent(effectInst.target).tweeningProperties; if (((tweeningProperties) && ((tweeningProperties.length > 0)))){ effectProperties = effectInst.getAffectedProperties(); n = tweeningProperties.length; m = effectProperties.length; i = 0; while (i < n) { j = 0; while (j < m) { if (tweeningProperties[i] == effectProperties[j]){ effectInst = null; return; }; j++; }; i++; }; }; }; if ((((effectInst.target is UIComponent)) && (UIComponent(effectInst.target).isEffectStarted))){ affectedProps = effectInst.getAffectedProperties(); i = 0; while (i < affectedProps.length) { runningInstances = effectInst.target.getEffectsForProperty(affectedProps[i]); if (runningInstances.length > 0){ if (eventObj.type == ResizeEvent.RESIZE){ return; }; j = 0; while (j < runningInstances.length) { otherInst = runningInstances[j]; if ((((eventObj.type == FlexEvent.SHOW)) && (otherInst.hideOnEffectEnd))){ otherInst.target.removeEventListener(FlexEvent.SHOW, otherInst.eventHandler); otherInst.hideOnEffectEnd = false; }; otherInst.end(); j++; }; }; i++; }; }; effectInst.triggerEvent = eventObj; effectInst.addEventListener(EffectEvent.EFFECT_END, EffectManager.effectEndHandler); lastEffectCreated = effectInst; var instances:Array = effectInst.play(); n = instances.length; i = 0; while (i < n) { effectsPlaying.push(new EffectNode(effectInst, instances[i])); i++; }; if (effectInst.suspendBackgroundProcessing){ UIComponent.suspendBackgroundProcessing(); }; } public static function endEffectsForTarget(target:IUIComponent):void{ var otherInst:EffectInstance; var n:int = effectsPlaying.length; var i:int = (n - 1); while (i >= 0) { otherInst = effectsPlaying[i].instance; if (otherInst.target == target){ otherInst.end(); }; i--; }; } private static function cacheOrUncacheTargetAsBitmap(target:IUIComponent, effectStart:Boolean=true, bitmapEffect:Boolean=true):void{ var n:int; var i:int; var info:Object; n = targetsInfo.length; i = 0; while (i < n) { if (targetsInfo[i].target == target){ info = targetsInfo[i]; break; }; i++; }; if (!info){ info = {target:target, bitmapEffectsCount:0, vectorEffectsCount:0}; targetsInfo.push(info); }; if (effectStart){ if (bitmapEffect){ info.bitmapEffectsCount++; if ((((info.vectorEffectsCount == 0)) && ((target is IDeferredInstantiationUIComponent)))){ IDeferredInstantiationUIComponent(target).cacheHeuristic = true; }; } else { if ((((((info.vectorEffectsCount++ == 0)) && ((target is IDeferredInstantiationUIComponent)))) && ((IDeferredInstantiationUIComponent(target).cachePolicy == UIComponentCachePolicy.AUTO)))){ target.cacheAsBitmap = false; }; }; } else { if (bitmapEffect){ if (info.bitmapEffectsCount != 0){ info.bitmapEffectsCount--; }; if ((target is IDeferredInstantiationUIComponent)){ IDeferredInstantiationUIComponent(target).cacheHeuristic = false; }; } else { if (info.vectorEffectsCount != 0){ if ((((--info.vectorEffectsCount == 0)) && (!((info.bitmapEffectsCount == 0))))){ n = info.bitmapEffectsCount; i = 0; while (i < n) { if ((target is IDeferredInstantiationUIComponent)){ IDeferredInstantiationUIComponent(target).cacheHeuristic = true; }; i++; }; }; }; }; if ((((info.bitmapEffectsCount == 0)) && ((info.vectorEffectsCount == 0)))){ n = targetsInfo.length; i = 0; while (i < n) { if (targetsInfo[i].target == target){ targetsInfo.splice(i, 1); break; }; i++; }; }; }; } mx_internal static function eventHandler(eventObj:Event):void{ var focusEventObj:FocusEvent; var targ:DisplayObject; var i:int; var parent:DisplayObjectContainer; var index:int; if (!(eventObj.currentTarget is IFlexDisplayObject)){ return; }; if (eventHandlingSuspendCount > 0){ return; }; if ((((eventObj is FocusEvent)) && ((((eventObj.type == FocusEvent.FOCUS_OUT)) || ((eventObj.type == FocusEvent.FOCUS_IN)))))){ focusEventObj = FocusEvent(eventObj); if (((focusEventObj.relatedObject) && (((focusEventObj.currentTarget.contains(focusEventObj.relatedObject)) || ((focusEventObj.currentTarget == focusEventObj.relatedObject)))))){ return; }; }; if ((((((eventObj.type == Event.ADDED)) || ((eventObj.type == Event.REMOVED)))) && (!((eventObj.target == eventObj.currentTarget))))){ return; }; if (eventObj.type == Event.REMOVED){ if ((eventObj.target is UIComponent)){ if (UIComponent(eventObj.target).initialized == false){ return; }; if (UIComponent(eventObj.target).isEffectStarted){ i = 0; while (i < UIComponent(eventObj.target)._effectsStarted.length) { if (UIComponent(eventObj.target)._effectsStarted[i].triggerEvent.type == Event.REMOVED){ return; }; i++; }; }; }; targ = (eventObj.target as DisplayObject); if (targ != null){ parent = (targ.parent as DisplayObjectContainer); if (parent != null){ index = parent.getChildIndex(targ); if (index >= 0){ if ((targ is UIComponent)){ UIComponent(targ).callLater(removedEffectHandler, [targ, parent, index, eventObj]); }; }; }; }; } else { createAndPlayEffect(eventObj, eventObj.currentTarget); }; } mx_internal static function endBitmapEffect(target:IUIComponent):void{ cacheOrUncacheTargetAsBitmap(target, false, true); } private static function animateSameProperty(a:Effect, b:Effect, c:EffectInstance):Boolean{ var aProps:Array; var bProps:Array; var n:int; var m:int; var i:int; var j:int; if (a.target == c.target){ aProps = a.getAffectedProperties(); bProps = b.getAffectedProperties(); n = aProps.length; m = bProps.length; i = 0; while (i < n) { j = 0; while (j < m) { if (aProps[i] == bProps[j]){ return (true); }; j++; }; i++; }; }; return (false); } mx_internal static function effectFinished(effect:EffectInstance):void{ delete effects[effect]; } mx_internal static function effectsInEffect():Boolean{ var i:*; for (i in effects) { return (true); }; return (false); } mx_internal static function effectEndHandler(event:EffectEvent):void{ var targ:DisplayObject; var parent:DisplayObjectContainer; var effectInst:IEffectInstance = event.effectInstance; var n:int = effectsPlaying.length; var i:int = (n - 1); while (i >= 0) { if (effectsPlaying[i].instance == effectInst){ effectsPlaying.splice(i, 1); break; }; i--; }; if (Object(effectInst).hideOnEffectEnd == true){ effectInst.target.removeEventListener(FlexEvent.SHOW, Object(effectInst).eventHandler); effectInst.target.setVisible(false, true); }; if (((effectInst.triggerEvent) && ((effectInst.triggerEvent.type == Event.REMOVED)))){ targ = (effectInst.target as DisplayObject); if (targ != null){ parent = (targ.parent as DisplayObjectContainer); if (parent != null){ suspendEventHandling(); parent.removeChild(targ); resumeEventHandling(); }; }; }; if (effectInst.suspendBackgroundProcessing){ UIComponent.resumeBackgroundProcessing(); }; } mx_internal static function startBitmapEffect(target:IUIComponent):void{ cacheOrUncacheTargetAsBitmap(target, true, true); } mx_internal static function setStyle(styleProp:String, target):void{ var eventName:String = eventsForEffectTriggers[styleProp]; if (((!((eventName == null))) && (!((eventName == ""))))){ target.addEventListener(eventName, EffectManager.eventHandler, false, EventPriority.EFFECT); }; } mx_internal static function getEventForEffectTrigger(effectTrigger:String):String{ var effectTrigger = effectTrigger; if (eventsForEffectTriggers){ return (eventsForEffectTriggers[effectTrigger]); //unresolved jump var _slot1 = e; return (""); }; return (""); } mx_internal static function createEffectForType(target:Object, type:String):Effect{ var cls:Class; var effectObj:Effect; var doc:Object; var target = target; var type = type; var trigger:String = effectTriggersForEvent[type]; if (trigger == ""){ trigger = (type + "Effect"); }; var value:Object = target.getStyle(trigger); if (!value){ return (null); }; if ((value is Class)){ cls = Class(value); return (new cls(target)); }; if ((value is String)){ doc = target.parentDocument; if (!doc){ doc = ApplicationGlobals.application; }; effectObj = doc[value]; } else { if ((value is Effect)){ effectObj = Effect(value); }; }; if (effectObj){ effectObj.target = target; return (effectObj); }; //unresolved jump var _slot1 = e; var effectClass:Class = Class(target.systemManager.getDefinitionByName(("mx.effects." + value))); if (effectClass){ return (new effectClass(target)); }; return (null); } mx_internal static function effectStarted(effect:EffectInstance):void{ effects[effect] = 1; } public static function resumeEventHandling():void{ eventHandlingSuspendCount--; } mx_internal static function startVectorEffect(target:IUIComponent):void{ cacheOrUncacheTargetAsBitmap(target, true, false); } mx_internal static function endVectorEffect(target:IUIComponent):void{ cacheOrUncacheTargetAsBitmap(target, false, false); } private static function get resourceManager():IResourceManager{ if (!_resourceManager){ _resourceManager = ResourceManager.getInstance(); }; return (_resourceManager); } } }//package mx.effects class EffectNode { public var factory:Effect; public var instance:EffectInstance; private function EffectNode(factory:Effect, instance:EffectInstance){ super(); this.factory = factory; this.instance = instance; } }
Section 143
//EffectTargetFilter (mx.effects.EffectTargetFilter) package mx.effects { import mx.core.*; import mx.effects.effectClasses.*; public class EffectTargetFilter { public var filterFunction:Function; public var filterStyles:Array; public var filterProperties:Array; public var requiredSemantics:Object;// = null mx_internal static const VERSION:String = "3.0.0.0"; public function EffectTargetFilter(){ filterFunction = defaultFilterFunctionEx; filterProperties = []; filterStyles = []; super(); } protected function defaultFilterFunctionEx(propChanges:Array, semanticsProvider:IEffectTargetHost, target:Object):Boolean{ var prop:String; if (requiredSemantics){ for (prop in requiredSemantics) { if (!semanticsProvider){ return (false); }; if (semanticsProvider.getRendererSemanticValue(target, prop) != requiredSemantics[prop]){ return (false); }; }; return (true); }; return (defaultFilterFunction(propChanges, target)); } protected function defaultFilterFunction(propChanges:Array, instanceTarget:Object):Boolean{ var props:PropertyChanges; var triggers:Array; var m:int; var j:int; var n:int = propChanges.length; var i:int; while (i < n) { props = propChanges[i]; if (props.target == instanceTarget){ triggers = filterProperties.concat(filterStyles); m = triggers.length; j = 0; while (j < m) { if (((!((props.start[triggers[j]] === undefined))) && (!((props.end[triggers[j]] == props.start[triggers[j]]))))){ return (true); }; j++; }; }; i++; }; return (false); } public function filterInstance(propChanges:Array, semanticsProvider:IEffectTargetHost, target:Object):Boolean{ if (filterFunction.length == 2){ return (filterFunction(propChanges, target)); }; return (filterFunction(propChanges, semanticsProvider, target)); } } }//package mx.effects
Section 144
//IAbstractEffect (mx.effects.IAbstractEffect) package mx.effects { import flash.events.*; public interface IAbstractEffect extends IEventDispatcher { } }//package mx.effects
Section 145
//IEffect (mx.effects.IEffect) package mx.effects { import flash.events.*; public interface IEffect extends IAbstractEffect { function captureMoreStartValues(mx.effects:IEffect/mx.effects:IEffect:className/get:Array):void; function get triggerEvent():Event; function set targets(mx.effects:IEffect/mx.effects:IEffect:className/get:Array):void; function captureStartValues():void; function get hideFocusRing():Boolean; function get customFilter():EffectTargetFilter; function get effectTargetHost():IEffectTargetHost; function set triggerEvent(mx.effects:IEffect/mx.effects:IEffect:className/get:Event):void; function set hideFocusRing(mx.effects:IEffect/mx.effects:IEffect:className/get:Boolean):void; function captureEndValues():void; function get target():Object; function set customFilter(mx.effects:IEffect/mx.effects:IEffect:className/get:EffectTargetFilter):void; function get duration():Number; function get perElementOffset():Number; function get targets():Array; function set effectTargetHost(mx.effects:IEffect/mx.effects:IEffect:className/get:IEffectTargetHost):void; function get relevantStyles():Array; function set relevantProperties(mx.effects:IEffect/mx.effects:IEffect:className/get:Array):void; function set target(mx.effects:IEffect/mx.effects:IEffect:className/get:Object):void; function get className():String; function get isPlaying():Boolean; function deleteInstance(mx.effects:IEffect/mx.effects:IEffect:className/get:IEffectInstance):void; function set duration(mx.effects:IEffect/mx.effects:IEffect:className/get:Number):void; function createInstances(EffectTargetFilter:Array=null):Array; function end(mx.effects:IEffect/mx.effects:IEffect:className/get:IEffectInstance=null):void; function set perElementOffset(mx.effects:IEffect/mx.effects:IEffect:className/get:Number):void; function resume():void; function stop():void; function set filter(mx.effects:IEffect/mx.effects:IEffect:className/get:String):void; function createInstance(void:Object=null):IEffectInstance; function play(_arg1:Array=null, _arg2:Boolean=false):Array; function pause():void; function get relevantProperties():Array; function get filter():String; function reverse():void; function getAffectedProperties():Array; function set relevantStyles(mx.effects:IEffect/mx.effects:IEffect:className/get:Array):void; } }//package mx.effects
Section 146
//IEffectInstance (mx.effects.IEffectInstance) package mx.effects { import flash.events.*; import mx.effects.effectClasses.*; public interface IEffectInstance { function get playheadTime():Number; function get triggerEvent():Event; function set triggerEvent(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:Event):void; function get hideFocusRing():Boolean; function initEffect(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:Event):void; function set startDelay(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:int):void; function get effectTargetHost():IEffectTargetHost; function finishEffect():void; function set hideFocusRing(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:Boolean):void; function finishRepeat():void; function set repeatDelay(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:int):void; function get effect():IEffect; function startEffect():void; function get duration():Number; function get target():Object; function get startDelay():int; function stop():void; function set effectTargetHost(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:IEffectTargetHost):void; function set propertyChanges(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:PropertyChanges):void; function set effect(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:IEffect):void; function get className():String; function set duration(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:Number):void; function set target(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:Object):void; function end():void; function resume():void; function get propertyChanges():PropertyChanges; function set repeatCount(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:int):void; function reverse():void; function get repeatCount():int; function pause():void; function get repeatDelay():int; function set suspendBackgroundProcessing(mx.effects:IEffectInstance/mx.effects:IEffectInstance:className/get:Boolean):void; function play():void; function get suspendBackgroundProcessing():Boolean; } }//package mx.effects
Section 147
//IEffectTargetHost (mx.effects.IEffectTargetHost) package mx.effects { public interface IEffectTargetHost { function unconstrainRenderer(:Object):void; function removeDataEffectItem(:Object):void; function getRendererSemanticValue(_arg1:Object, _arg2:String):Object; function addDataEffectItem(:Object):void; } }//package mx.effects
Section 148
//Tween (mx.effects.Tween) package mx.effects { import mx.core.*; import flash.events.*; import mx.events.*; import flash.utils.*; public class Tween extends EventDispatcher { private var started:Boolean;// = false private var previousUpdateTime:Number; public var duration:Number;// = 3000 private var id:int; private var arrayMode:Boolean; private var _isPlaying:Boolean;// = true private var startValue:Object; public var listener:Object; private var userEquation:Function; mx_internal var needToLayout:Boolean;// = false private var updateFunction:Function; private var _doSeek:Boolean;// = false mx_internal var startTime:Number; private var endFunction:Function; private var endValue:Object; private var _doReverse:Boolean;// = false private var _playheadTime:Number;// = 0 private var _invertValues:Boolean;// = false private var maxDelay:Number;// = 87.5 mx_internal static const VERSION:String = "3.0.0.0"; private static var timer:Timer = null; private static var interval:Number = 10; mx_internal static var activeTweens:Array = []; mx_internal static var intervalTime:Number = NAN; public function Tween(listener:Object, startValue:Object, endValue:Object, duration:Number=-1, minFps:Number=-1, updateFunction:Function=null, endFunction:Function=null){ userEquation = defaultEasingFunction; super(); if (!listener){ return; }; if ((startValue is Array)){ arrayMode = true; }; this.listener = listener; this.startValue = startValue; this.endValue = endValue; if (((!(isNaN(duration))) && (!((duration == -1))))){ this.duration = duration; }; if (((!(isNaN(minFps))) && (!((minFps == -1))))){ maxDelay = (1000 / minFps); }; this.updateFunction = updateFunction; this.endFunction = endFunction; if (duration == 0){ id = -1; endTween(); } else { Tween.addTween(this); }; } mx_internal function get playheadTime():Number{ return (_playheadTime); } public function stop():void{ if (id >= 0){ Tween.removeTweenAt(id); }; } mx_internal function get playReversed():Boolean{ return (_invertValues); } mx_internal function set playReversed(value:Boolean):void{ _invertValues = value; } public function resume():void{ _isPlaying = true; startTime = (intervalTime - _playheadTime); if (_doReverse){ reverse(); _doReverse = false; }; } public function setTweenHandlers(updateFunction:Function, endFunction:Function):void{ this.updateFunction = updateFunction; this.endFunction = endFunction; } private function defaultEasingFunction(t:Number, b:Number, c:Number, d:Number):Number{ return ((((c / 2) * (Math.sin((Math.PI * ((t / d) - 0.5))) + 1)) + b)); } public function set easingFunction(value:Function):void{ userEquation = value; } public function endTween():void{ var event:TweenEvent = new TweenEvent(TweenEvent.TWEEN_END); var value:Object = getCurrentValue(duration); event.value = value; dispatchEvent(event); if (endFunction != null){ endFunction(value); } else { listener.onTweenEnd(value); }; if (id >= 0){ Tween.removeTweenAt(id); }; } public function reverse():void{ if (_isPlaying){ _doReverse = false; seek((duration - _playheadTime)); _invertValues = !(_invertValues); } else { _doReverse = !(_doReverse); }; } mx_internal function getCurrentValue(currentTime:Number):Object{ var returnArray:Array; var n:int; var i:int; if (duration == 0){ return (endValue); }; if (_invertValues){ currentTime = (duration - currentTime); }; if (arrayMode){ returnArray = []; n = startValue.length; i = 0; while (i < n) { returnArray[i] = userEquation(currentTime, startValue[i], (endValue[i] - startValue[i]), duration); i++; }; return (returnArray); //unresolved jump }; return (userEquation(currentTime, startValue, (Number(endValue) - Number(startValue)), duration)); } mx_internal function doInterval():Boolean{ var currentTime:Number; var currentValue:Object; var event:TweenEvent; var startEvent:TweenEvent; var tweenEnded:Boolean; previousUpdateTime = intervalTime; if (((_isPlaying) || (_doSeek))){ currentTime = (intervalTime - startTime); _playheadTime = currentTime; currentValue = getCurrentValue(currentTime); if ((((currentTime >= duration)) && (!(_doSeek)))){ endTween(); tweenEnded = true; } else { if (!started){ startEvent = new TweenEvent(TweenEvent.TWEEN_START); dispatchEvent(startEvent); started = true; }; event = new TweenEvent(TweenEvent.TWEEN_UPDATE); event.value = currentValue; dispatchEvent(event); if (updateFunction != null){ updateFunction(currentValue); } else { listener.onTweenUpdate(currentValue); }; }; _doSeek = false; }; return (tweenEnded); } public function pause():void{ _isPlaying = false; } public function seek(playheadTime:Number):void{ var clockTime:Number = intervalTime; previousUpdateTime = clockTime; startTime = (clockTime - playheadTime); _doSeek = true; } mx_internal static function removeTween(tween:Tween):void{ removeTweenAt(tween.id); } private static function addTween(tween:Tween):void{ tween.id = activeTweens.length; activeTweens.push(tween); if (!timer){ timer = new Timer(interval); timer.addEventListener(TimerEvent.TIMER, timerHandler); timer.start(); } else { timer.start(); }; if (isNaN(intervalTime)){ intervalTime = getTimer(); }; tween.startTime = (tween.previousUpdateTime = intervalTime); } private static function timerHandler(event:TimerEvent):void{ var tween:Tween; var needToLayout:Boolean; var oldTime:Number = intervalTime; intervalTime = getTimer(); var n:int = activeTweens.length; var i:int = n; while (i >= 0) { tween = Tween(activeTweens[i]); if (tween){ tween.needToLayout = false; tween.doInterval(); if (tween.needToLayout){ needToLayout = true; }; }; i--; }; if (needToLayout){ UIComponentGlobals.layoutManager.validateNow(); }; event.updateAfterEvent(); } private static function removeTweenAt(index:int):void{ var curTween:Tween; if ((((index >= activeTweens.length)) || ((index < 0)))){ return; }; activeTweens.splice(index, 1); var n:int = activeTweens.length; var i:int = index; while (i < n) { curTween = Tween(activeTweens[i]); curTween.id--; i++; }; if (n == 0){ intervalTime = NaN; timer.reset(); }; } } }//package mx.effects
Section 149
//TweenEffect (mx.effects.TweenEffect) package mx.effects { import mx.core.*; import flash.events.*; import mx.events.*; import mx.effects.effectClasses.*; public class TweenEffect extends Effect { public var easingFunction:Function;// = null mx_internal static const VERSION:String = "3.0.0.0"; public function TweenEffect(target:Object=null){ super(target); instanceClass = TweenEffectInstance; } protected function tweenEventHandler(event:TweenEvent):void{ dispatchEvent(event); } override protected function initInstance(instance:IEffectInstance):void{ super.initInstance(instance); TweenEffectInstance(instance).easingFunction = easingFunction; EventDispatcher(instance).addEventListener(TweenEvent.TWEEN_START, tweenEventHandler); EventDispatcher(instance).addEventListener(TweenEvent.TWEEN_UPDATE, tweenEventHandler); EventDispatcher(instance).addEventListener(TweenEvent.TWEEN_END, tweenEventHandler); } } }//package mx.effects
Section 150
//Zoom (mx.effects.Zoom) package mx.effects { import mx.core.*; import mx.effects.effectClasses.*; public class Zoom extends TweenEffect { public var zoomHeightFrom:Number; public var zoomWidthTo:Number; public var originX:Number; public var zoomHeightTo:Number; public var originY:Number; public var captureRollEvents:Boolean; public var zoomWidthFrom:Number; mx_internal static const VERSION:String = "3.0.0.0"; private static var AFFECTED_PROPERTIES:Array = ["scaleX", "scaleY", "x", "y", "width", "height"]; public function Zoom(target:Object=null){ super(target); instanceClass = ZoomInstance; applyActualDimensions = false; relevantProperties = ["scaleX", "scaleY", "width", "height", "visible"]; } override protected function initInstance(instance:IEffectInstance):void{ var zoomInstance:ZoomInstance; super.initInstance(instance); zoomInstance = ZoomInstance(instance); zoomInstance.zoomWidthFrom = zoomWidthFrom; zoomInstance.zoomWidthTo = zoomWidthTo; zoomInstance.zoomHeightFrom = zoomHeightFrom; zoomInstance.zoomHeightTo = zoomHeightTo; zoomInstance.originX = originX; zoomInstance.originY = originY; zoomInstance.captureRollEvents = captureRollEvents; } override public function getAffectedProperties():Array{ return (AFFECTED_PROPERTIES); } } }//package mx.effects
Section 151
//ChildExistenceChangedEvent (mx.events.ChildExistenceChangedEvent) package mx.events { import mx.core.*; import flash.events.*; import flash.display.*; public class ChildExistenceChangedEvent extends Event { public var relatedObject:DisplayObject; public static const CHILD_REMOVE:String = "childRemove"; mx_internal static const VERSION:String = "3.0.0.0"; public static const OVERLAY_CREATED:String = "overlayCreated"; public static const CHILD_ADD:String = "childAdd"; public function ChildExistenceChangedEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, relatedObject:DisplayObject=null){ super(type, bubbles, cancelable); this.relatedObject = relatedObject; } override public function clone():Event{ return (new ChildExistenceChangedEvent(type, bubbles, cancelable, relatedObject)); } } }//package mx.events
Section 152
//DragEvent (mx.events.DragEvent) package mx.events { import mx.core.*; import flash.events.*; public class DragEvent extends MouseEvent { public var draggedItem:Object; public var action:String; public var dragInitiator:IUIComponent; public var dragSource:DragSource; public static const DRAG_DROP:String = "dragDrop"; public static const DRAG_COMPLETE:String = "dragComplete"; public static const DRAG_EXIT:String = "dragExit"; public static const DRAG_ENTER:String = "dragEnter"; public static const DRAG_START:String = "dragStart"; mx_internal static const VERSION:String = "3.0.0.0"; public static const DRAG_OVER:String = "dragOver"; public function DragEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=true, dragInitiator:IUIComponent=null, dragSource:DragSource=null, action:String=null, ctrlKey:Boolean=false, altKey:Boolean=false, shiftKey:Boolean=false){ super(type, bubbles, cancelable); this.dragInitiator = dragInitiator; this.dragSource = dragSource; this.action = action; this.ctrlKey = ctrlKey; this.altKey = altKey; this.shiftKey = shiftKey; } override public function clone():Event{ var cloneEvent:DragEvent = new DragEvent(type, bubbles, cancelable, dragInitiator, dragSource, action, ctrlKey, altKey, shiftKey); cloneEvent.relatedObject = this.relatedObject; cloneEvent.localX = this.localX; cloneEvent.localY = this.localY; return (cloneEvent); } } }//package mx.events
Section 153
//DynamicEvent (mx.events.DynamicEvent) package mx.events { import mx.core.*; import flash.events.*; public dynamic class DynamicEvent extends Event { mx_internal static const VERSION:String = "3.0.0.0"; public function DynamicEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){ super(type, bubbles, cancelable); } override public function clone():Event{ var p:String; var event:DynamicEvent = new DynamicEvent(type, bubbles, cancelable); for (p in this) { event[p] = this[p]; }; return (event); } } }//package mx.events
Section 154
//EffectEvent (mx.events.EffectEvent) package mx.events { import mx.core.*; import flash.events.*; import mx.effects.*; public class EffectEvent extends Event { public var effectInstance:IEffectInstance; public static const EFFECT_START:String = "effectStart"; mx_internal static const VERSION:String = "3.0.0.0"; public static const EFFECT_END:String = "effectEnd"; public function EffectEvent(eventType:String, bubbles:Boolean=false, cancelable:Boolean=false, effectInstance:IEffectInstance=null){ super(eventType, bubbles, cancelable); this.effectInstance = effectInstance; } override public function clone():Event{ return (new EffectEvent(type, bubbles, cancelable, effectInstance)); } } }//package mx.events
Section 155
//FlexEvent (mx.events.FlexEvent) package mx.events { import mx.core.*; import flash.events.*; public class FlexEvent extends Event { public static const ADD:String = "add"; public static const TRANSFORM_CHANGE:String = "transformChange"; public static const INIT_COMPLETE:String = "initComplete"; public static const REMOVE:String = "remove"; public static const BUTTON_DOWN:String = "buttonDown"; public static const EXIT_STATE:String = "exitState"; public static const CREATION_COMPLETE:String = "creationComplete"; public static const REPEAT:String = "repeat"; public static const LOADING:String = "loading"; public static const REPEAT_START:String = "repeatStart"; public static const INITIALIZE:String = "initialize"; public static const ENTER_STATE:String = "enterState"; public static const URL_CHANGED:String = "urlChanged"; public static const REPEAT_END:String = "repeatEnd"; mx_internal static const VERSION:String = "3.0.0.0"; public static const HIDE:String = "hide"; public static const ENTER:String = "enter"; public static const PRELOADER_DONE:String = "preloaderDone"; public static const CURSOR_UPDATE:String = "cursorUpdate"; public static const PREINITIALIZE:String = "preinitialize"; public static const INVALID:String = "invalid"; public static const IDLE:String = "idle"; public static const VALID:String = "valid"; public static const DATA_CHANGE:String = "dataChange"; public static const APPLICATION_COMPLETE:String = "applicationComplete"; public static const VALUE_COMMIT:String = "valueCommit"; public static const UPDATE_COMPLETE:String = "updateComplete"; public static const INIT_PROGRESS:String = "initProgress"; public static const SHOW:String = "show"; public function FlexEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false){ super(type, bubbles, cancelable); } override public function clone():Event{ return (new FlexEvent(type, bubbles, cancelable)); } } }//package mx.events
Section 156
//FlexMouseEvent (mx.events.FlexMouseEvent) package mx.events { import mx.core.*; import flash.events.*; import flash.display.*; public class FlexMouseEvent extends MouseEvent { public static const MOUSE_DOWN_OUTSIDE:String = "mouseDownOutside"; public static const MOUSE_WHEEL_OUTSIDE:String = "mouseWheelOutside"; mx_internal static const VERSION:String = "3.0.0.0"; public function FlexMouseEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, localX:Number=0, localY:Number=0, relatedObject:InteractiveObject=null, ctrlKey:Boolean=false, altKey:Boolean=false, shiftKey:Boolean=false, buttonDown:Boolean=false, delta:int=0){ super(type, bubbles, cancelable, localX, localY, relatedObject, ctrlKey, altKey, shiftKey, buttonDown, delta); } override public function clone():Event{ return (new FlexMouseEvent(type, bubbles, cancelable, localX, localY, relatedObject, ctrlKey, altKey, shiftKey, buttonDown, delta)); } } }//package mx.events
Section 157
//ModuleEvent (mx.events.ModuleEvent) package mx.events { import mx.core.*; import flash.events.*; import mx.modules.*; public class ModuleEvent extends ProgressEvent { public var errorText:String; private var _module:IModuleInfo; public static const READY:String = "ready"; public static const ERROR:String = "error"; public static const PROGRESS:String = "progress"; mx_internal static const VERSION:String = "3.0.0.0"; public static const SETUP:String = "setup"; public static const UNLOAD:String = "unload"; public function ModuleEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:uint=0, bytesTotal:uint=0, errorText:String=null, module:IModuleInfo=null){ super(type, bubbles, cancelable, bytesLoaded, bytesTotal); this.errorText = errorText; this._module = module; } public function get module():IModuleInfo{ if (_module){ return (_module); }; return ((target as IModuleInfo)); } override public function clone():Event{ return (new ModuleEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText, module)); } } }//package mx.events
Section 158
//MoveEvent (mx.events.MoveEvent) package mx.events { import mx.core.*; import flash.events.*; public class MoveEvent extends Event { public var oldX:Number; public var oldY:Number; mx_internal static const VERSION:String = "3.0.0.0"; public static const MOVE:String = "move"; public function MoveEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, oldX:Number=NaN, oldY:Number=NaN){ super(type, bubbles, cancelable); this.oldX = oldX; this.oldY = oldY; } override public function clone():Event{ return (new MoveEvent(type, bubbles, cancelable, oldX, oldY)); } } }//package mx.events
Section 159
//PropertyChangeEvent (mx.events.PropertyChangeEvent) package mx.events { import mx.core.*; import flash.events.*; public class PropertyChangeEvent extends Event { public var newValue:Object; public var kind:String; public var property:Object; public var oldValue:Object; public var source:Object; mx_internal static const VERSION:String = "3.0.0.0"; public static const PROPERTY_CHANGE:String = "propertyChange"; public function PropertyChangeEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, kind:String=null, property:Object=null, oldValue:Object=null, newValue:Object=null, source:Object=null){ super(type, bubbles, cancelable); this.kind = kind; this.property = property; this.oldValue = oldValue; this.newValue = newValue; this.source = source; } override public function clone():Event{ return (new PropertyChangeEvent(type, bubbles, cancelable, kind, property, oldValue, newValue, source)); } public static function createUpdateEvent(source:Object, property:Object, oldValue:Object, newValue:Object):PropertyChangeEvent{ var event:PropertyChangeEvent = new PropertyChangeEvent(PROPERTY_CHANGE); event.kind = PropertyChangeEventKind.UPDATE; event.oldValue = oldValue; event.newValue = newValue; event.source = source; event.property = property; return (event); } } }//package mx.events
Section 160
//PropertyChangeEventKind (mx.events.PropertyChangeEventKind) package mx.events { import mx.core.*; public final class PropertyChangeEventKind { mx_internal static const VERSION:String = "3.0.0.0"; public static const UPDATE:String = "update"; public static const DELETE:String = "delete"; public function PropertyChangeEventKind(){ super(); } } }//package mx.events
Section 161
//ResizeEvent (mx.events.ResizeEvent) package mx.events { import mx.core.*; import flash.events.*; public class ResizeEvent extends Event { public var oldHeight:Number; public var oldWidth:Number; mx_internal static const VERSION:String = "3.0.0.0"; public static const RESIZE:String = "resize"; public function ResizeEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, oldWidth:Number=NaN, oldHeight:Number=NaN){ super(type, bubbles, cancelable); this.oldWidth = oldWidth; this.oldHeight = oldHeight; } override public function clone():Event{ return (new ResizeEvent(type, bubbles, cancelable, oldWidth, oldHeight)); } } }//package mx.events
Section 162
//ResourceEvent (mx.events.ResourceEvent) package mx.events { import mx.core.*; import flash.events.*; public class ResourceEvent extends ProgressEvent { public var errorText:String; mx_internal static const VERSION:String = "3.0.0.0"; public static const COMPLETE:String = "complete"; public static const PROGRESS:String = "progress"; public static const ERROR:String = "error"; public function ResourceEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:uint=0, bytesTotal:uint=0, errorText:String=null){ super(type, bubbles, cancelable, bytesLoaded, bytesTotal); this.errorText = errorText; } override public function clone():Event{ return (new ResourceEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText)); } } }//package mx.events
Section 163
//RSLEvent (mx.events.RSLEvent) package mx.events { import mx.core.*; import flash.events.*; import flash.net.*; public class RSLEvent extends ProgressEvent { public var errorText:String; public var rslIndex:int; public var rslTotal:int; public var url:URLRequest; public static const RSL_PROGRESS:String = "rslProgress"; public static const RSL_ERROR:String = "rslError"; mx_internal static const VERSION:String = "3.0.0.0"; public static const RSL_COMPLETE:String = "rslComplete"; public function RSLEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:int=-1, bytesTotal:int=-1, rslIndex:int=-1, rslTotal:int=-1, url:URLRequest=null, errorText:String=null){ super(type, bubbles, cancelable, bytesLoaded, bytesTotal); this.rslIndex = rslIndex; this.rslTotal = rslTotal; this.url = url; this.errorText = errorText; } override public function clone():Event{ return (new RSLEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, rslIndex, rslTotal, url, errorText)); } } }//package mx.events
Section 164
//StateChangeEvent (mx.events.StateChangeEvent) package mx.events { import mx.core.*; import flash.events.*; public class StateChangeEvent extends Event { public var newState:String; public var oldState:String; public static const CURRENT_STATE_CHANGING:String = "currentStateChanging"; public static const CURRENT_STATE_CHANGE:String = "currentStateChange"; mx_internal static const VERSION:String = "3.0.0.0"; public function StateChangeEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, oldState:String=null, newState:String=null){ super(type, bubbles, cancelable); this.oldState = oldState; this.newState = newState; } override public function clone():Event{ return (new StateChangeEvent(type, bubbles, cancelable, oldState, newState)); } } }//package mx.events
Section 165
//StyleEvent (mx.events.StyleEvent) package mx.events { import mx.core.*; import flash.events.*; public class StyleEvent extends ProgressEvent { public var errorText:String; mx_internal static const VERSION:String = "3.0.0.0"; public static const COMPLETE:String = "complete"; public static const PROGRESS:String = "progress"; public static const ERROR:String = "error"; public function StyleEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, bytesLoaded:uint=0, bytesTotal:uint=0, errorText:String=null){ super(type, bubbles, cancelable, bytesLoaded, bytesTotal); this.errorText = errorText; } override public function clone():Event{ return (new StyleEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, errorText)); } } }//package mx.events
Section 166
//ToolTipEvent (mx.events.ToolTipEvent) package mx.events { import mx.core.*; import flash.events.*; public class ToolTipEvent extends Event { public var toolTip:IToolTip; public static const TOOL_TIP_SHOWN:String = "toolTipShown"; public static const TOOL_TIP_CREATE:String = "toolTipCreate"; public static const TOOL_TIP_SHOW:String = "toolTipShow"; public static const TOOL_TIP_HIDE:String = "toolTipHide"; public static const TOOL_TIP_END:String = "toolTipEnd"; mx_internal static const VERSION:String = "3.0.0.0"; public static const TOOL_TIP_START:String = "toolTipStart"; public function ToolTipEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, toolTip:IToolTip=null){ super(type, bubbles, cancelable); this.toolTip = toolTip; } override public function clone():Event{ return (new ToolTipEvent(type, bubbles, cancelable, toolTip)); } } }//package mx.events
Section 167
//TweenEvent (mx.events.TweenEvent) package mx.events { import mx.core.*; import flash.events.*; public class TweenEvent extends Event { public var value:Object; public static const TWEEN_END:String = "tweenEnd"; mx_internal static const VERSION:String = "3.0.0.0"; public static const TWEEN_UPDATE:String = "tweenUpdate"; public static const TWEEN_START:String = "tweenStart"; public function TweenEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, value:Object=null){ super(type, bubbles, cancelable); this.value = value; } override public function clone():Event{ return (new TweenEvent(type, bubbles, cancelable, value)); } } }//package mx.events
Section 168
//ValidationResultEvent (mx.events.ValidationResultEvent) package mx.events { import mx.core.*; import flash.events.*; public class ValidationResultEvent extends Event { public var results:Array; public var field:String; public static const INVALID:String = "invalid"; mx_internal static const VERSION:String = "3.0.0.0"; public static const VALID:String = "valid"; public function ValidationResultEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, field:String=null, results:Array=null){ super(type, bubbles, cancelable); this.field = field; this.results = results; } public function get message():String{ var msg:String = ""; var n:int = results.length; var i:int; while (i < n) { if (results[i].isError){ msg = (msg + ((msg == "")) ? "" : "\n"); msg = (msg + results[i].errorMessage); }; i++; }; return (msg); } override public function clone():Event{ return (new ValidationResultEvent(type, bubbles, cancelable, field, results)); } } }//package mx.events
Section 169
//RectangularDropShadow (mx.graphics.RectangularDropShadow) package mx.graphics { import mx.core.*; import flash.display.*; import flash.geom.*; import mx.utils.*; import flash.filters.*; public class RectangularDropShadow { private var leftShadow:BitmapData; private var _tlRadius:Number;// = 0 private var _trRadius:Number;// = 0 private var _angle:Number;// = 45 private var topShadow:BitmapData; private var _distance:Number;// = 4 private var rightShadow:BitmapData; private var _alpha:Number;// = 0.4 private var shadow:BitmapData; private var _brRadius:Number;// = 0 private var _blRadius:Number;// = 0 private var _color:int;// = 0 private var bottomShadow:BitmapData; private var changed:Boolean;// = true mx_internal static const VERSION:String = "3.0.0.0"; public function RectangularDropShadow(){ super(); } public function get blRadius():Number{ return (_blRadius); } public function set brRadius(value:Number):void{ if (_brRadius != value){ _brRadius = value; changed = true; }; } public function set color(value:int):void{ if (_color != value){ _color = value; changed = true; }; } public function drawShadow(g:Graphics, x:Number, y:Number, width:Number, height:Number):void{ var tlWidth:Number; var tlHeight:Number; var trWidth:Number; var trHeight:Number; var blWidth:Number; var blHeight:Number; var brWidth:Number; var brHeight:Number; if (changed){ createShadowBitmaps(); changed = false; }; width = Math.ceil(width); height = Math.ceil(height); var leftThickness:int = (leftShadow) ? leftShadow.width : 0; var rightThickness:int = (rightShadow) ? rightShadow.width : 0; var topThickness:int = (topShadow) ? topShadow.height : 0; var bottomThickness:int = (bottomShadow) ? bottomShadow.height : 0; var widthThickness:int = (leftThickness + rightThickness); var heightThickness:int = (topThickness + bottomThickness); var maxCornerHeight:Number = ((height + heightThickness) / 2); var maxCornerWidth:Number = ((width + widthThickness) / 2); var matrix:Matrix = new Matrix(); if (((leftShadow) || (topShadow))){ tlWidth = Math.min((tlRadius + widthThickness), maxCornerWidth); tlHeight = Math.min((tlRadius + heightThickness), maxCornerHeight); matrix.tx = (x - leftThickness); matrix.ty = (y - topThickness); g.beginBitmapFill(shadow, matrix); g.drawRect((x - leftThickness), (y - topThickness), tlWidth, tlHeight); g.endFill(); }; if (((rightShadow) || (topShadow))){ trWidth = Math.min((trRadius + widthThickness), maxCornerWidth); trHeight = Math.min((trRadius + heightThickness), maxCornerHeight); matrix.tx = (((x + width) + rightThickness) - shadow.width); matrix.ty = (y - topThickness); g.beginBitmapFill(shadow, matrix); g.drawRect((((x + width) + rightThickness) - trWidth), (y - topThickness), trWidth, trHeight); g.endFill(); }; if (((leftShadow) || (bottomShadow))){ blWidth = Math.min((blRadius + widthThickness), maxCornerWidth); blHeight = Math.min((blRadius + heightThickness), maxCornerHeight); matrix.tx = (x - leftThickness); matrix.ty = (((y + height) + bottomThickness) - shadow.height); g.beginBitmapFill(shadow, matrix); g.drawRect((x - leftThickness), (((y + height) + bottomThickness) - blHeight), blWidth, blHeight); g.endFill(); }; if (((rightShadow) || (bottomShadow))){ brWidth = Math.min((brRadius + widthThickness), maxCornerWidth); brHeight = Math.min((brRadius + heightThickness), maxCornerHeight); matrix.tx = (((x + width) + rightThickness) - shadow.width); matrix.ty = (((y + height) + bottomThickness) - shadow.height); g.beginBitmapFill(shadow, matrix); g.drawRect((((x + width) + rightThickness) - brWidth), (((y + height) + bottomThickness) - brHeight), brWidth, brHeight); g.endFill(); }; if (leftShadow){ matrix.tx = (x - leftThickness); matrix.ty = 0; g.beginBitmapFill(leftShadow, matrix); g.drawRect((x - leftThickness), ((y - topThickness) + tlHeight), leftThickness, ((((height + topThickness) + bottomThickness) - tlHeight) - blHeight)); g.endFill(); }; if (rightShadow){ matrix.tx = (x + width); matrix.ty = 0; g.beginBitmapFill(rightShadow, matrix); g.drawRect((x + width), ((y - topThickness) + trHeight), rightThickness, ((((height + topThickness) + bottomThickness) - trHeight) - brHeight)); g.endFill(); }; if (topShadow){ matrix.tx = 0; matrix.ty = (y - topThickness); g.beginBitmapFill(topShadow, matrix); g.drawRect(((x - leftThickness) + tlWidth), (y - topThickness), ((((width + leftThickness) + rightThickness) - tlWidth) - trWidth), topThickness); g.endFill(); }; if (bottomShadow){ matrix.tx = 0; matrix.ty = (y + height); g.beginBitmapFill(bottomShadow, matrix); g.drawRect(((x - leftThickness) + blWidth), (y + height), ((((width + leftThickness) + rightThickness) - blWidth) - brWidth), bottomThickness); g.endFill(); }; } public function get brRadius():Number{ return (_brRadius); } public function get angle():Number{ return (_angle); } private function createShadowBitmaps():void{ var roundRectWidth:Number = ((Math.max(tlRadius, blRadius) + (2 * distance)) + Math.max(trRadius, brRadius)); var roundRectHeight:Number = ((Math.max(tlRadius, trRadius) + (2 * distance)) + Math.max(blRadius, brRadius)); if ((((roundRectWidth < 0)) || ((roundRectHeight < 0)))){ return; }; var roundRect:Shape = new FlexShape(); var g:Graphics = roundRect.graphics; g.beginFill(0xFFFFFF); GraphicsUtil.drawRoundRectComplex(g, 0, 0, roundRectWidth, roundRectHeight, tlRadius, trRadius, blRadius, brRadius); g.endFill(); var roundRectBitmap:BitmapData = new BitmapData(roundRectWidth, roundRectHeight, true, 0); roundRectBitmap.draw(roundRect, new Matrix()); var filter:DropShadowFilter = new DropShadowFilter(distance, angle, color, alpha); filter.knockout = true; var inputRect:Rectangle = new Rectangle(0, 0, roundRectWidth, roundRectHeight); var outputRect:Rectangle = roundRectBitmap.generateFilterRect(inputRect, filter); var leftThickness:Number = (inputRect.left - outputRect.left); var rightThickness:Number = (outputRect.right - inputRect.right); var topThickness:Number = (inputRect.top - outputRect.top); var bottomThickness:Number = (outputRect.bottom - inputRect.bottom); shadow = new BitmapData(outputRect.width, outputRect.height); shadow.applyFilter(roundRectBitmap, inputRect, new Point(leftThickness, topThickness), filter); var origin:Point = new Point(0, 0); var rect:Rectangle = new Rectangle(); if (leftThickness > 0){ rect.x = 0; rect.y = ((tlRadius + topThickness) + bottomThickness); rect.width = leftThickness; rect.height = 1; leftShadow = new BitmapData(leftThickness, 1); leftShadow.copyPixels(shadow, rect, origin); } else { leftShadow = null; }; if (rightThickness > 0){ rect.x = (shadow.width - rightThickness); rect.y = ((trRadius + topThickness) + bottomThickness); rect.width = rightThickness; rect.height = 1; rightShadow = new BitmapData(rightThickness, 1); rightShadow.copyPixels(shadow, rect, origin); } else { rightShadow = null; }; if (topThickness > 0){ rect.x = ((tlRadius + leftThickness) + rightThickness); rect.y = 0; rect.width = 1; rect.height = topThickness; topShadow = new BitmapData(1, topThickness); topShadow.copyPixels(shadow, rect, origin); } else { topShadow = null; }; if (bottomThickness > 0){ rect.x = ((blRadius + leftThickness) + rightThickness); rect.y = (shadow.height - bottomThickness); rect.width = 1; rect.height = bottomThickness; bottomShadow = new BitmapData(1, bottomThickness); bottomShadow.copyPixels(shadow, rect, origin); } else { bottomShadow = null; }; } public function get alpha():Number{ return (_alpha); } public function get color():int{ return (_color); } public function set angle(value:Number):void{ if (_angle != value){ _angle = value; changed = true; }; } public function set trRadius(value:Number):void{ if (_trRadius != value){ _trRadius = value; changed = true; }; } public function set tlRadius(value:Number):void{ if (_tlRadius != value){ _tlRadius = value; changed = true; }; } public function get trRadius():Number{ return (_trRadius); } public function set distance(value:Number):void{ if (_distance != value){ _distance = value; changed = true; }; } public function get distance():Number{ return (_distance); } public function get tlRadius():Number{ return (_tlRadius); } public function set alpha(value:Number):void{ if (_alpha != value){ _alpha = value; changed = true; }; } public function set blRadius(value:Number):void{ if (_blRadius != value){ _blRadius = value; changed = true; }; } } }//package mx.graphics
Section 170
//RoundedRectangle (mx.graphics.RoundedRectangle) package mx.graphics { import mx.core.*; import flash.geom.*; public class RoundedRectangle extends Rectangle { public var cornerRadius:Number;// = 0 mx_internal static const VERSION:String = "3.0.0.0"; public function RoundedRectangle(x:Number=0, y:Number=0, width:Number=0, height:Number=0, cornerRadius:Number=0){ super(x, y, width, height); this.cornerRadius = cornerRadius; } } }//package mx.graphics
Section 171
//PriorityQueue (mx.managers.layoutClasses.PriorityQueue) package mx.managers.layoutClasses { import mx.core.*; import flash.display.*; import mx.managers.*; public class PriorityQueue { private var maxPriority:int;// = -1 private var arrayOfArrays:Array; private var minPriority:int;// = 0 mx_internal static const VERSION:String = "3.0.0.0"; public function PriorityQueue(){ arrayOfArrays = []; super(); } public function addObject(obj:Object, priority:int):void{ if (!arrayOfArrays[priority]){ arrayOfArrays[priority] = []; }; arrayOfArrays[priority].push(obj); if (maxPriority < minPriority){ minPriority = (maxPriority = priority); } else { if (priority < minPriority){ minPriority = priority; }; if (priority > maxPriority){ maxPriority = priority; }; }; } public function removeSmallest():Object{ var obj:Object; if (minPriority <= maxPriority){ while (((!(arrayOfArrays[minPriority])) || ((arrayOfArrays[minPriority].length == 0)))) { minPriority++; if (minPriority > maxPriority){ return (null); }; }; obj = arrayOfArrays[minPriority].shift(); while (((!(arrayOfArrays[minPriority])) || ((arrayOfArrays[minPriority].length == 0)))) { minPriority++; if (minPriority > maxPriority){ break; }; }; }; return (obj); } public function removeLargestChild(client:ILayoutManagerClient):Object{ var i:int; var obj:Object; var max:int = maxPriority; var min:int = client.nestLevel; while (min <= max) { if (((arrayOfArrays[max]) && ((arrayOfArrays[max].length > 0)))){ i = 0; while (i < arrayOfArrays[max].length) { if (contains(DisplayObject(client), arrayOfArrays[max][i])){ obj = arrayOfArrays[max][i]; arrayOfArrays[max].splice(i, 1); return (obj); }; i++; }; max--; } else { if (max == maxPriority){ maxPriority--; }; max--; if (max < min){ break; }; }; }; return (obj); } public function isEmpty():Boolean{ return ((minPriority > maxPriority)); } public function removeLargest():Object{ var obj:Object; if (minPriority <= maxPriority){ while (((!(arrayOfArrays[maxPriority])) || ((arrayOfArrays[maxPriority].length == 0)))) { maxPriority--; if (maxPriority < minPriority){ return (null); }; }; obj = arrayOfArrays[maxPriority].shift(); while (((!(arrayOfArrays[maxPriority])) || ((arrayOfArrays[maxPriority].length == 0)))) { maxPriority--; if (maxPriority < minPriority){ break; }; }; }; return (obj); } public function removeSmallestChild(client:ILayoutManagerClient):Object{ var i:int; var obj:Object; var min:int = client.nestLevel; while (min <= maxPriority) { if (((arrayOfArrays[min]) && ((arrayOfArrays[min].length > 0)))){ i = 0; while (i < arrayOfArrays[min].length) { if (contains(DisplayObject(client), arrayOfArrays[min][i])){ obj = arrayOfArrays[min][i]; arrayOfArrays[min].splice(i, 1); return (obj); }; i++; }; min++; } else { if (min == minPriority){ minPriority++; }; min++; if (min > maxPriority){ break; }; }; }; return (obj); } public function removeAll():void{ arrayOfArrays.splice(0); minPriority = 0; maxPriority = -1; } private function contains(parent:DisplayObject, child:DisplayObject):Boolean{ var rawChildren:IChildList; if ((parent is IRawChildrenContainer)){ rawChildren = IRawChildrenContainer(parent).rawChildren; return (rawChildren.contains(child)); }; if ((parent is DisplayObjectContainer)){ return (DisplayObjectContainer(parent).contains(child)); }; return ((parent == child)); } } }//package mx.managers.layoutClasses
Section 172
//CursorManager (mx.managers.CursorManager) package mx.managers { import mx.core.*; public class CursorManager { mx_internal static const VERSION:String = "3.0.0.0"; public static const NO_CURSOR:int = 0; private static var _impl:ICursorManager; private static var implClassDependency:CursorManagerImpl; public function CursorManager(){ super(); } public static function set currentCursorYOffset(value:Number):void{ impl.currentCursorYOffset = value; } mx_internal static function registerToUseBusyCursor(source:Object):void{ impl.registerToUseBusyCursor(source); } public static function get currentCursorID():int{ return (impl.currentCursorID); } public static function getInstance():ICursorManager{ return (impl); } public static function removeBusyCursor():void{ impl.removeBusyCursor(); } public static function setCursor(cursorClass:Class, priority:int=2, xOffset:Number=0, yOffset:Number=0):int{ return (impl.setCursor(cursorClass, priority, xOffset, yOffset)); } public static function set currentCursorID(value:int):void{ impl.currentCursorID = value; } mx_internal static function unRegisterToUseBusyCursor(source:Object):void{ impl.unRegisterToUseBusyCursor(source); } private static function get impl():ICursorManager{ if (!_impl){ _impl = ICursorManager(Singleton.getInstance("mx.managers::ICursorManager")); }; return (_impl); } public static function removeAllCursors():void{ impl.removeAllCursors(); } public static function setBusyCursor():void{ impl.setBusyCursor(); } public static function showCursor():void{ impl.showCursor(); } public static function hideCursor():void{ impl.hideCursor(); } public static function removeCursor(cursorID:int):void{ impl.removeCursor(cursorID); } public static function get currentCursorXOffset():Number{ return (impl.currentCursorXOffset); } public static function get currentCursorYOffset():Number{ return (impl.currentCursorYOffset); } public static function set currentCursorXOffset(value:Number):void{ impl.currentCursorXOffset = value; } } }//package mx.managers
Section 173
//CursorManagerImpl (mx.managers.CursorManagerImpl) package mx.managers { import mx.core.*; import flash.events.*; import mx.styles.*; import flash.display.*; import flash.text.*; import flash.ui.*; public class CursorManagerImpl implements ICursorManager { private var showSystemCursor:Boolean;// = false private var nextCursorID:int;// = 1 private var systemManager:ISystemManager;// = null private var cursorList:Array; private var _currentCursorYOffset:Number;// = 0 private var cursorHolder:Sprite; private var currentCursor:DisplayObject; private var _currentCursorID:int;// = 0 private var listenForContextMenu:Boolean;// = false private var showCustomCursor:Boolean;// = false private var initialized:Boolean;// = false private var overTextField:Boolean;// = false private var _currentCursorXOffset:Number;// = 0 private var busyCursorList:Array; private var overLink:Boolean;// = false private var sourceArray:Array; mx_internal static const VERSION:String = "3.0.0.0"; private static var instance:ICursorManager; public function CursorManagerImpl(systemManager:ISystemManager=null){ cursorList = []; busyCursorList = []; sourceArray = []; super(); if (((instance) && (!(systemManager)))){ throw (new Error("Instance already exists.")); }; if (systemManager){ this.systemManager = systemManager; } else { this.systemManager = ApplicationGlobals.application.systemManager; }; } public function set currentCursorYOffset(value:Number):void{ _currentCursorYOffset = value; } public function get currentCursorXOffset():Number{ return (_currentCursorXOffset); } public function removeCursor(cursorID:int):void{ var i:Object; var item:CursorQueueItem; for (i in cursorList) { item = cursorList[i]; if (item.cursorID == cursorID){ cursorList.splice(i, 1); showCurrentCursor(); break; }; }; } public function get currentCursorID():int{ return (_currentCursorID); } public function set currentCursorID(value:int):void{ _currentCursorID = value; } public function removeAllCursors():void{ cursorList.splice(0); showCurrentCursor(); } private function priorityCompare(a:CursorQueueItem, b:CursorQueueItem):int{ if (a.priority < b.priority){ return (-1); }; if (a.priority == b.priority){ return (0); }; return (1); } public function setBusyCursor():void{ var cursorManagerStyleDeclaration:CSSStyleDeclaration = StyleManager.getStyleDeclaration("CursorManager"); var busyCursorClass:Class = cursorManagerStyleDeclaration.getStyle("busyCursor"); busyCursorList.push(setCursor(busyCursorClass, CursorManagerPriority.LOW)); } public function showCursor():void{ if (cursorHolder){ cursorHolder.visible = true; }; } private function findSource(target:Object):int{ var n:int = sourceArray.length; var i:int; while (i < n) { if (sourceArray[i] === target){ return (i); }; i++; }; return (-1); } private function showCurrentCursor():void{ var app:InteractiveObject; var sm:InteractiveObject; var item:CursorQueueItem; var tempSystemManager:ISystemManager; if (cursorList.length > 0){ if (!initialized){ cursorHolder = new FlexSprite(); cursorHolder.name = "cursorHolder"; cursorHolder.mouseEnabled = false; initialized = true; }; item = cursorList[0]; if (currentCursorID == CursorManager.NO_CURSOR){ Mouse.hide(); }; if (item.cursorID != currentCursorID){ if (cursorHolder.numChildren > 0){ cursorHolder.removeChildAt(0); }; currentCursor = new item.cursorClass(); if (currentCursor){ if ((currentCursor is InteractiveObject)){ InteractiveObject(currentCursor).mouseEnabled = false; }; tempSystemManager = (item.systemManager) ? item.systemManager : ApplicationGlobals.application.systemManager; if (((systemManager) && (!((systemManager == tempSystemManager))))){ systemManager.cursorChildren.removeChild(cursorHolder); }; systemManager = tempSystemManager; if (!systemManager.cursorChildren.contains(cursorHolder)){ systemManager.cursorChildren.addChild(cursorHolder); }; cursorHolder.addChild(currentCursor); if (!listenForContextMenu){ app = (systemManager.document as InteractiveObject); if (((app) && (app.contextMenu))){ app.contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, contextMenu_menuSelectHandler); listenForContextMenu = true; }; sm = (systemManager as InteractiveObject); if (((sm) && (sm.contextMenu))){ sm.contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, contextMenu_menuSelectHandler); listenForContextMenu = true; }; }; if ((systemManager is SystemManager)){ cursorHolder.x = (SystemManager(systemManager).mouseX + item.x); cursorHolder.y = (SystemManager(systemManager).mouseY + item.y); } else { if ((systemManager is DisplayObject)){ cursorHolder.x = (DisplayObject(systemManager).mouseX + item.x); cursorHolder.y = (DisplayObject(systemManager).mouseY + item.y); } else { cursorHolder.x = item.x; cursorHolder.y = item.y; }; }; systemManager.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true, EventPriority.CURSOR_MANAGEMENT); }; currentCursorID = item.cursorID; currentCursorXOffset = item.x; currentCursorYOffset = item.y; }; } else { if (currentCursorID != CursorManager.NO_CURSOR){ currentCursorID = CursorManager.NO_CURSOR; currentCursorXOffset = 0; currentCursorYOffset = 0; systemManager.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true); cursorHolder.removeChild(currentCursor); if (listenForContextMenu){ app = (systemManager.document as InteractiveObject); if (((app) && (app.contextMenu))){ app.contextMenu.removeEventListener(ContextMenuEvent.MENU_SELECT, contextMenu_menuSelectHandler); }; sm = (systemManager as InteractiveObject); if (((sm) && (sm.contextMenu))){ sm.contextMenu.removeEventListener(ContextMenuEvent.MENU_SELECT, contextMenu_menuSelectHandler); }; listenForContextMenu = false; }; }; Mouse.show(); }; } public function get currentCursorYOffset():Number{ return (_currentCursorYOffset); } private function contextMenu_menuSelectHandler(event:ContextMenuEvent):void{ showCustomCursor = true; systemManager.stage.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); } public function hideCursor():void{ if (cursorHolder){ cursorHolder.visible = false; }; } public function registerToUseBusyCursor(source:Object):void{ if (((source) && ((source is EventDispatcher)))){ source.addEventListener(ProgressEvent.PROGRESS, progressHandler); source.addEventListener(Event.COMPLETE, completeHandler); source.addEventListener(IOErrorEvent.IO_ERROR, completeHandler); }; } private function completeHandler(event:Event):void{ var sourceIndex:int = findSource(event.target); if (sourceIndex != -1){ sourceArray.splice(sourceIndex, 1); removeBusyCursor(); }; } public function setCursor(cursorClass:Class, priority:int=2, xOffset:Number=0, yOffset:Number=0):int{ var cursorID:int = nextCursorID++; var item:CursorQueueItem = new CursorQueueItem(); item.cursorID = cursorID; item.cursorClass = cursorClass; item.priority = priority; item.x = xOffset; item.y = yOffset; if (systemManager){ item.systemManager = systemManager; } else { item.systemManager = ApplicationGlobals.application.systemManager; }; cursorList.push(item); cursorList.sort(priorityCompare); showCurrentCursor(); return (cursorID); } private function progressHandler(event:ProgressEvent):void{ var sourceIndex:int = findSource(event.target); if (sourceIndex == -1){ sourceArray.push(event.target); setBusyCursor(); }; } public function removeBusyCursor():void{ if (busyCursorList.length > 0){ removeCursor(int(busyCursorList.pop())); }; } private function mouseMoveHandler(event:MouseEvent):void{ if ((systemManager is SystemManager)){ cursorHolder.x = (SystemManager(systemManager).mouseX + currentCursorXOffset); cursorHolder.y = (SystemManager(systemManager).mouseY + currentCursorYOffset); } else { if ((systemManager is DisplayObject)){ cursorHolder.x = (DisplayObject(systemManager).mouseX + currentCursorXOffset); cursorHolder.y = (DisplayObject(systemManager).mouseY + currentCursorYOffset); } else { cursorHolder.x = currentCursorXOffset; cursorHolder.y = currentCursorYOffset; }; }; var target:Object = event.target; if (((((!(overTextField)) && ((target is TextField)))) && ((target.type == TextFieldType.INPUT)))){ overTextField = true; showSystemCursor = true; } else { if (((overTextField) && (!((((target is TextField)) && ((target.type == TextFieldType.INPUT))))))){ overTextField = false; showCustomCursor = true; }; }; if (showSystemCursor){ showSystemCursor = false; cursorHolder.visible = false; Mouse.show(); }; if (showCustomCursor){ showCustomCursor = false; cursorHolder.visible = true; Mouse.hide(); }; } public function unRegisterToUseBusyCursor(source:Object):void{ if (((source) && ((source is EventDispatcher)))){ source.removeEventListener(ProgressEvent.PROGRESS, progressHandler); source.removeEventListener(Event.COMPLETE, completeHandler); source.removeEventListener(IOErrorEvent.IO_ERROR, completeHandler); }; } private function mouseOverHandler(event:MouseEvent):void{ systemManager.stage.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); mouseMoveHandler(event); } public function set currentCursorXOffset(value:Number):void{ _currentCursorXOffset = value; } public static function getInstance():ICursorManager{ if (!instance){ instance = new (CursorManagerImpl); }; return (instance); } } }//package mx.managers import mx.core.*; class CursorQueueItem { public var priority:int;// = 2 public var cursorClass:Class;// = null public var cursorID:int;// = 0 public var x:Number; public var y:Number; public var systemManager:ISystemManager; mx_internal static const VERSION:String = "3.0.0.0"; private function CursorQueueItem(){ super(); } }
Section 174
//CursorManagerPriority (mx.managers.CursorManagerPriority) package mx.managers { import mx.core.*; public final class CursorManagerPriority { public static const HIGH:int = 1; public static const MEDIUM:int = 2; mx_internal static const VERSION:String = "3.0.0.0"; public static const LOW:int = 3; public function CursorManagerPriority(){ super(); } } }//package mx.managers
Section 175
//ICursorManager (mx.managers.ICursorManager) package mx.managers { public interface ICursorManager { function removeAllCursors():void; function set currentCursorYOffset(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ICursorManager.as:Number):void; function removeBusyCursor():void; function unRegisterToUseBusyCursor(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ICursorManager.as:Object):void; function hideCursor():void; function get currentCursorID():int; function registerToUseBusyCursor(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ICursorManager.as:Object):void; function setBusyCursor():void; function showCursor():void; function set currentCursorID(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ICursorManager.as:int):void; function setCursor(_arg1:Class, _arg2:int=2, _arg3:Number=0, _arg4:Number=0):int; function removeCursor(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ICursorManager.as:int):void; function get currentCursorXOffset():Number; function get currentCursorYOffset():Number; function set currentCursorXOffset(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ICursorManager.as:Number):void; } }//package mx.managers
Section 176
//IFocusManager (mx.managers.IFocusManager) package mx.managers { import mx.core.*; import flash.display.*; public interface IFocusManager { function get focusPane():Sprite; function getFocus():IFocusManagerComponent; function deactivate():void; function set defaultButton(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:IButton):void; function set focusPane(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:Sprite):void; function set showFocusIndicator(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:Boolean):void; function get defaultButtonEnabled():Boolean; function findFocusManagerComponent(value:InteractiveObject):IFocusManagerComponent; function get nextTabIndex():int; function get defaultButton():IButton; function get showFocusIndicator():Boolean; function setFocus(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:IFocusManagerComponent):void; function activate():void; function showFocus():void; function set defaultButtonEnabled(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManager.as:Boolean):void; function hideFocus():void; function getNextFocusManagerComponent(value:Boolean=false):IFocusManagerComponent; } }//package mx.managers
Section 177
//IFocusManagerComponent (mx.managers.IFocusManagerComponent) package mx.managers { public interface IFocusManagerComponent { function set focusEnabled(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManagerComponent.as:Boolean):void; function drawFocus(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManagerComponent.as:Boolean):void; function setFocus():void; function get focusEnabled():Boolean; function get tabEnabled():Boolean; function get tabIndex():int; function get mouseFocusEnabled():Boolean; } }//package mx.managers
Section 178
//IFocusManagerContainer (mx.managers.IFocusManagerContainer) package mx.managers { import flash.events.*; import flash.display.*; public interface IFocusManagerContainer extends IEventDispatcher { function set focusManager(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IFocusManagerContainer.as:IFocusManager):void; function get focusManager():IFocusManager; function get systemManager():ISystemManager; function contains(mx.managers:DisplayObject):Boolean; } }//package mx.managers
Section 179
//ILayoutManager (mx.managers.ILayoutManager) package mx.managers { import flash.events.*; public interface ILayoutManager extends IEventDispatcher { function validateNow():void; function validateClient(_arg1:ILayoutManagerClient, _arg2:Boolean=false):void; function isInvalid():Boolean; function invalidateDisplayList(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManager.as:ILayoutManagerClient):void; function set usePhasedInstantiation(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManager.as:Boolean):void; function invalidateSize(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManager.as:ILayoutManagerClient):void; function get usePhasedInstantiation():Boolean; function invalidateProperties(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManager.as:ILayoutManagerClient):void; } }//package mx.managers
Section 180
//ILayoutManagerClient (mx.managers.ILayoutManagerClient) package mx.managers { import flash.events.*; public interface ILayoutManagerClient extends IEventDispatcher { function get updateCompletePendingFlag():Boolean; function set updateCompletePendingFlag(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:Boolean):void; function set initialized(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:Boolean):void; function validateProperties():void; function validateDisplayList():void; function get nestLevel():int; function get initialized():Boolean; function get processedDescriptors():Boolean; function validateSize(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:Boolean=false):void; function set nestLevel(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:int):void; function set processedDescriptors(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ILayoutManagerClient.as:Boolean):void; } }//package mx.managers
Section 181
//ISystemManager (mx.managers.ISystemManager) package mx.managers { import mx.core.*; import flash.events.*; import flash.display.*; import flash.geom.*; import flash.text.*; public interface ISystemManager extends IEventDispatcher, IChildList, IFlexModuleFactory { function get focusPane():Sprite; function get loaderInfo():LoaderInfo; function get toolTipChildren():IChildList; function set focusPane(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:Sprite):void; function isTopLevel():Boolean; function get popUpChildren():IChildList; function get screen():Rectangle; function isFontFaceEmbedded(mx.managers:ISystemManager/mx.managers:ISystemManager:focusPane/get:TextFormat):Boolean; function get rawChildren():IChildList; function get topLevelSystemManager():ISystemManager; function getDefinitionByName(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;ISystemManager.as:String):Object; function activate(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void; function deactivate(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void; function get cursorChildren():IChildList; function set document(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:Object):void; function get embeddedFontList():Object; function set numModalWindows(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:int):void; function removeFocusManager(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void; function get document():Object; function get numModalWindows():int; function addFocusManager(mx.managers:ISystemManager/mx.managers:ISystemManager:cursorChildren/get:IFocusManagerContainer):void; function get stage():Stage; } }//package mx.managers
Section 182
//IToolTipManager2 (mx.managers.IToolTipManager2) package mx.managers { import mx.core.*; import flash.display.*; import mx.effects.*; public interface IToolTipManager2 { function registerToolTip(_arg1:DisplayObject, _arg2:String, _arg3:String):void; function get enabled():Boolean; function set enabled(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:Boolean):void; function get scrubDelay():Number; function set hideEffect(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:IAbstractEffect):void; function createToolTip(_arg1:String, _arg2:Number, _arg3:Number, _arg4:String=null, _arg5:IUIComponent=null):IToolTip; function set scrubDelay(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:Number):void; function set hideDelay(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:Number):void; function get currentTarget():DisplayObject; function set showDelay(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:Number):void; function get showDelay():Number; function get showEffect():IAbstractEffect; function get hideDelay():Number; function get currentToolTip():IToolTip; function get hideEffect():IAbstractEffect; function set currentToolTip(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:IToolTip):void; function get toolTipClass():Class; function registerErrorString(_arg1:DisplayObject, _arg2:String, _arg3:String):void; function destroyToolTip(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:IToolTip):void; function set toolTipClass(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:Class):void; function sizeTip(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:IToolTip):void; function set currentTarget(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:DisplayObject):void; function set showEffect(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManager2.as:IAbstractEffect):void; } }//package mx.managers
Section 183
//IToolTipManagerClient (mx.managers.IToolTipManagerClient) package mx.managers { import mx.core.*; public interface IToolTipManagerClient extends IFlexDisplayObject { function get toolTip():String; function set toolTip(E:\dev\3.0.x\frameworks\projects\framework\src;mx\managers;IToolTipManagerClient.as:String):void; } }//package mx.managers
Section 184
//LayoutManager (mx.managers.LayoutManager) package mx.managers { import mx.core.*; import flash.events.*; import flash.display.*; import mx.events.*; import mx.managers.layoutClasses.*; public class LayoutManager extends EventDispatcher implements ILayoutManager { private var invalidateClientPropertiesFlag:Boolean;// = false private var invalidateDisplayListQueue:PriorityQueue; private var updateCompleteQueue:PriorityQueue; private var invalidateDisplayListFlag:Boolean;// = false private var invalidateClientSizeFlag:Boolean;// = false private var invalidateSizeQueue:PriorityQueue; private var originalFrameRate:Number; private var invalidatePropertiesFlag:Boolean;// = false private var invalidatePropertiesQueue:PriorityQueue; private var invalidateSizeFlag:Boolean;// = false private var callLaterPending:Boolean;// = false private var _usePhasedInstantiation:Boolean;// = false private var callLaterObject:UIComponent; private var targetLevel:int;// = 2147483647 mx_internal static const VERSION:String = "3.0.0.0"; private static var instance:LayoutManager; public function LayoutManager(){ updateCompleteQueue = new PriorityQueue(); invalidatePropertiesQueue = new PriorityQueue(); invalidateSizeQueue = new PriorityQueue(); invalidateDisplayListQueue = new PriorityQueue(); super(); } public function set usePhasedInstantiation(value:Boolean):void{ var stage:Stage; if (_usePhasedInstantiation != value){ _usePhasedInstantiation = value; stage = SystemManagerGlobals.topLevelSystemManagers[0].stage; if (value){ originalFrameRate = stage.frameRate; stage.frameRate = 1000; } else { stage.frameRate = originalFrameRate; }; }; } private function waitAFrame():void{ callLaterObject.callLater(doPhasedInstantiation); } public function validateClient(target:ILayoutManagerClient, skipDisplayList:Boolean=false):void{ var obj:ILayoutManagerClient; var i:int; var done:Boolean; var oldTargetLevel:int = targetLevel; if (targetLevel == int.MAX_VALUE){ targetLevel = target.nestLevel; }; while (!(done)) { done = true; obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target)); while (obj) { obj.validateProperties(); if (!obj.updateCompletePendingFlag){ updateCompleteQueue.addObject(obj, obj.nestLevel); obj.updateCompletePendingFlag = true; }; obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target)); }; if (invalidatePropertiesQueue.isEmpty()){ invalidatePropertiesFlag = false; invalidateClientPropertiesFlag = false; }; obj = ILayoutManagerClient(invalidateSizeQueue.removeLargestChild(target)); while (obj) { obj.validateSize(); if (!obj.updateCompletePendingFlag){ updateCompleteQueue.addObject(obj, obj.nestLevel); obj.updateCompletePendingFlag = true; }; if (invalidateClientPropertiesFlag){ obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target)); if (obj){ invalidatePropertiesQueue.addObject(obj, obj.nestLevel); done = false; break; }; }; obj = ILayoutManagerClient(invalidateSizeQueue.removeLargestChild(target)); }; if (invalidateSizeQueue.isEmpty()){ invalidateSizeFlag = false; invalidateClientSizeFlag = false; }; if (!skipDisplayList){ obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallestChild(target)); while (obj) { obj.validateDisplayList(); if (!obj.updateCompletePendingFlag){ updateCompleteQueue.addObject(obj, obj.nestLevel); obj.updateCompletePendingFlag = true; }; if (invalidateClientPropertiesFlag){ obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target)); if (obj){ invalidatePropertiesQueue.addObject(obj, obj.nestLevel); done = false; break; }; }; if (invalidateClientSizeFlag){ obj = ILayoutManagerClient(invalidateSizeQueue.removeLargestChild(target)); if (obj){ invalidateSizeQueue.addObject(obj, obj.nestLevel); done = false; break; }; }; obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallestChild(target)); }; if (invalidateDisplayListQueue.isEmpty()){ invalidateDisplayListFlag = false; }; }; }; if (oldTargetLevel == int.MAX_VALUE){ targetLevel = int.MAX_VALUE; if (!skipDisplayList){ obj = ILayoutManagerClient(updateCompleteQueue.removeLargestChild(target)); while (obj) { if (!obj.initialized){ obj.initialized = true; }; obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE)); obj.updateCompletePendingFlag = false; obj = ILayoutManagerClient(updateCompleteQueue.removeLargestChild(target)); }; }; }; } private function validateProperties():void{ var obj:ILayoutManagerClient = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallest()); while (obj) { obj.validateProperties(); if (!obj.updateCompletePendingFlag){ updateCompleteQueue.addObject(obj, obj.nestLevel); obj.updateCompletePendingFlag = true; }; obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallest()); }; if (invalidatePropertiesQueue.isEmpty()){ invalidatePropertiesFlag = false; }; } public function invalidateProperties(obj:ILayoutManagerClient):void{ if (((!(invalidatePropertiesFlag)) && (ApplicationGlobals.application.systemManager))){ invalidatePropertiesFlag = true; if (!callLaterPending){ if (!callLaterObject){ callLaterObject = new UIComponent(); callLaterObject.systemManager = ApplicationGlobals.application.systemManager; callLaterObject.callLater(waitAFrame); } else { callLaterObject.callLater(doPhasedInstantiation); }; callLaterPending = true; }; }; if (targetLevel <= obj.nestLevel){ invalidateClientPropertiesFlag = true; }; invalidatePropertiesQueue.addObject(obj, obj.nestLevel); } public function invalidateDisplayList(obj:ILayoutManagerClient):void{ if (((!(invalidateDisplayListFlag)) && (ApplicationGlobals.application.systemManager))){ invalidateDisplayListFlag = true; if (!callLaterPending){ if (!callLaterObject){ callLaterObject = new UIComponent(); callLaterObject.systemManager = ApplicationGlobals.application.systemManager; callLaterObject.callLater(waitAFrame); } else { callLaterObject.callLater(doPhasedInstantiation); }; callLaterPending = true; }; }; invalidateDisplayListQueue.addObject(obj, obj.nestLevel); } private function validateDisplayList():void{ var obj:ILayoutManagerClient = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallest()); while (obj) { obj.validateDisplayList(); if (!obj.updateCompletePendingFlag){ updateCompleteQueue.addObject(obj, obj.nestLevel); obj.updateCompletePendingFlag = true; }; obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallest()); }; if (invalidateDisplayListQueue.isEmpty()){ invalidateDisplayListFlag = false; }; } public function validateNow():void{ var infiniteLoopGuard:int; if (!usePhasedInstantiation){ infiniteLoopGuard = 0; while (((callLaterPending) && ((infiniteLoopGuard < 100)))) { doPhasedInstantiation(); }; }; } private function validateSize():void{ var obj:ILayoutManagerClient = ILayoutManagerClient(invalidateSizeQueue.removeLargest()); while (obj) { obj.validateSize(); if (!obj.updateCompletePendingFlag){ updateCompleteQueue.addObject(obj, obj.nestLevel); obj.updateCompletePendingFlag = true; }; obj = ILayoutManagerClient(invalidateSizeQueue.removeLargest()); }; if (invalidateSizeQueue.isEmpty()){ invalidateSizeFlag = false; }; } private function doPhasedInstantiation():void{ var obj:ILayoutManagerClient; if (usePhasedInstantiation){ if (invalidatePropertiesFlag){ validateProperties(); ApplicationGlobals.application.dispatchEvent(new Event("validatePropertiesComplete")); } else { if (invalidateSizeFlag){ validateSize(); ApplicationGlobals.application.dispatchEvent(new Event("validateSizeComplete")); } else { if (invalidateDisplayListFlag){ validateDisplayList(); ApplicationGlobals.application.dispatchEvent(new Event("validateDisplayListComplete")); }; }; }; } else { if (invalidatePropertiesFlag){ validateProperties(); }; if (invalidateSizeFlag){ validateSize(); }; if (invalidateDisplayListFlag){ validateDisplayList(); }; }; if (((((invalidatePropertiesFlag) || (invalidateSizeFlag))) || (invalidateDisplayListFlag))){ callLaterObject.callLater(doPhasedInstantiation); } else { usePhasedInstantiation = false; callLaterPending = false; obj = ILayoutManagerClient(updateCompleteQueue.removeLargest()); while (obj) { if (((!(obj.initialized)) && (obj.processedDescriptors))){ obj.initialized = true; }; obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE)); obj.updateCompletePendingFlag = false; obj = ILayoutManagerClient(updateCompleteQueue.removeLargest()); }; dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE)); }; } public function isInvalid():Boolean{ return (((((invalidatePropertiesFlag) || (invalidateSizeFlag))) || (invalidateDisplayListFlag))); } public function get usePhasedInstantiation():Boolean{ return (_usePhasedInstantiation); } public function invalidateSize(obj:ILayoutManagerClient):void{ if (((!(invalidateSizeFlag)) && (ApplicationGlobals.application.systemManager))){ invalidateSizeFlag = true; if (!callLaterPending){ if (!callLaterObject){ callLaterObject = new UIComponent(); callLaterObject.systemManager = ApplicationGlobals.application.systemManager; callLaterObject.callLater(waitAFrame); } else { callLaterObject.callLater(doPhasedInstantiation); }; callLaterPending = true; }; }; if (targetLevel <= obj.nestLevel){ invalidateClientSizeFlag = true; }; invalidateSizeQueue.addObject(obj, obj.nestLevel); } public static function getInstance():LayoutManager{ if (!instance){ instance = new (LayoutManager); }; return (instance); } } }//package mx.managers
Section 185
//SystemChildrenList (mx.managers.SystemChildrenList) package mx.managers { import mx.core.*; import flash.display.*; import flash.geom.*; public class SystemChildrenList implements IChildList { private var lowerBoundReference:QName; private var upperBoundReference:QName; private var owner:SystemManager; mx_internal static const VERSION:String = "3.0.0.0"; public function SystemChildrenList(owner:SystemManager, lowerBoundReference:QName, upperBoundReference:QName){ super(); this.owner = owner; this.lowerBoundReference = lowerBoundReference; this.upperBoundReference = upperBoundReference; } public function getChildAt(index:int):DisplayObject{ var _local3 = owner; var retval:DisplayObject = _local3.mx_internal::rawChildren_getChildAt((owner[lowerBoundReference] + index)); return (retval); } public function getChildByName(name:String):DisplayObject{ return (owner.mx_internal::rawChildren_getChildByName(name)); } public function removeChildAt(index:int):DisplayObject{ var _local3 = owner; var child:DisplayObject = _local3.mx_internal::rawChildren_removeChildAt((index + owner[lowerBoundReference])); _local3 = owner; var _local4 = upperBoundReference; var _local5 = (_local3[_local4] - 1); _local3[_local4] = _local5; return (child); } public function getChildIndex(child:DisplayObject):int{ var retval:int = owner.mx_internal::rawChildren_getChildIndex(child); retval = (retval - owner[lowerBoundReference]); return (retval); } public function addChildAt(child:DisplayObject, index:int):DisplayObject{ var _local3 = owner; _local3.mx_internal::rawChildren_addChildAt(child, (owner[lowerBoundReference] + index)); _local3 = owner; var _local4 = upperBoundReference; var _local5 = (_local3[_local4] + 1); _local3[_local4] = _local5; return (child); } public function getObjectsUnderPoint(point:Point):Array{ return (owner.mx_internal::rawChildren_getObjectsUnderPoint(point)); } public function setChildIndex(child:DisplayObject, newIndex:int):void{ var _local3 = owner; _local3.mx_internal::rawChildren_setChildIndex(child, (owner[lowerBoundReference] + newIndex)); } public function get numChildren():int{ return ((owner[upperBoundReference] - owner[lowerBoundReference])); } public function contains(child:DisplayObject):Boolean{ var childIndex:int; if (owner.mx_internal::rawChildren_contains(child)){ while (child.parent != owner) { child = child.parent; }; childIndex = owner.mx_internal::rawChildren_getChildIndex(child); if ((((childIndex >= owner[lowerBoundReference])) && ((childIndex < owner[upperBoundReference])))){ return (true); }; }; return (false); } public function removeChild(child:DisplayObject):DisplayObject{ var index:int = owner.mx_internal::rawChildren_getChildIndex(child); if ((((owner[lowerBoundReference] <= index)) && ((index < owner[upperBoundReference])))){ var _local3 = owner; _local3.mx_internal::rawChildren_removeChild(child); _local3 = owner; var _local4 = upperBoundReference; var _local5 = (_local3[_local4] - 1); _local3[_local4] = _local5; }; return (child); } public function addChild(child:DisplayObject):DisplayObject{ var _local2 = owner; _local2.mx_internal::rawChildren_addChildAt(child, owner[upperBoundReference]); _local2 = owner; var _local3 = upperBoundReference; var _local4 = (_local2[_local3] + 1); _local2[_local3] = _local4; return (child); } } }//package mx.managers
Section 186
//SystemManager (mx.managers.SystemManager) package mx.managers { import mx.core.*; import flash.events.*; import mx.styles.*; import flash.system.*; import flash.display.*; import flash.geom.*; import flash.text.*; import mx.events.*; import mx.resources.*; import flash.utils.*; import mx.preloaders.*; import mx.messaging.config.*; public class SystemManager extends MovieClip implements IChildList, IFlexDisplayObject, IFlexModuleFactory, ISystemManager { mx_internal var nestLevel:int;// = 0 private var forms:Array; private var mouseCatcher:Sprite; private var _height:Number; private var preloader:Preloader; private var _document:Object; private var _topLevelSystemManager:ISystemManager; private var _toolTipIndex:int;// = 0 private var _rawChildren:SystemRawChildrenList; private var _explicitHeight:Number; private var _toolTipChildren:SystemChildrenList; private var form:IFocusManagerContainer; private var _width:Number; private var initialized:Boolean;// = false private var _focusPane:Sprite; private var _fontList:Object;// = null private var isStageRoot:Boolean;// = true private var _popUpChildren:SystemChildrenList; private var rslSizes:Array;// = null private var _topMostIndex:int;// = 0 private var nextFrameTimer:Timer;// = null private var topLevel:Boolean;// = true private var _cursorIndex:int;// = 0 mx_internal var _mouseX; mx_internal var _mouseY; private var _numModalWindows:int;// = 0 private var _screen:Rectangle; mx_internal var idleCounter:int;// = 0 private var _cursorChildren:SystemChildrenList; private var initCallbackFunctions:Array; private var _noTopMostIndex:int;// = 0 private var _applicationIndex:int;// = 1 private var idleTimer:Timer; private var doneExecutingInitCallbacks:Boolean;// = false private var _explicitWidth:Number; mx_internal var topLevelWindow:IUIComponent; private static const IDLE_THRESHOLD:Number = 1000; private static const IDLE_INTERVAL:Number = 100; mx_internal static const VERSION:String = "3.0.0.0"; mx_internal static var lastSystemManager:SystemManager; mx_internal static var allSystemManagers:Dictionary = new Dictionary(true); public function SystemManager(){ initCallbackFunctions = []; forms = []; super(); if (stage){ stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; }; if ((((SystemManagerGlobals.topLevelSystemManagers.length > 0)) && (!(stage)))){ topLevel = false; }; if (!stage){ isStageRoot = false; }; if (topLevel){ SystemManagerGlobals.topLevelSystemManagers.push(this); }; lastSystemManager = this; var compiledLocales:Array = info()["compiledLocales"]; ResourceBundle.locale = (((!((compiledLocales == null))) && ((compiledLocales.length > 0)))) ? compiledLocales[0] : "en_US"; executeCallbacks(); stop(); if (((topLevel) && (!((currentFrame == 1))))){ throw (new Error((("The SystemManager constructor was called when the currentFrame was at " + currentFrame) + " Please add this SWF to bug 129782."))); }; if (((root) && (root.loaderInfo))){ root.loaderInfo.addEventListener(Event.INIT, initHandler); }; } mx_internal function addingChild(child:DisplayObject):void{ var obj:DisplayObjectContainer; var newNestLevel = 1; if (!topLevel){ obj = parent.parent; while (obj) { if ((obj is ILayoutManagerClient)){ newNestLevel = (ILayoutManagerClient(obj).nestLevel + 1); break; }; obj = obj.parent; }; }; nestLevel = newNestLevel; if ((child is IUIComponent)){ IUIComponent(child).systemManager = this; }; var uiComponentClassName:Class = Class(getDefinitionByName("mx.core.UIComponent")); if ((((child is IUIComponent)) && (!(IUIComponent(child).document)))){ IUIComponent(child).document = document; }; if ((child is ILayoutManagerClient)){ ILayoutManagerClient(child).nestLevel = (nestLevel + 1); }; if ((child is InteractiveObject)){ if (doubleClickEnabled){ InteractiveObject(child).doubleClickEnabled = true; }; }; if ((child is IUIComponent)){ IUIComponent(child).parentChanged(this); }; if ((child is IStyleClient)){ IStyleClient(child).regenerateStyleCache(true); }; if ((child is ISimpleStyleClient)){ ISimpleStyleClient(child).styleChanged(null); }; if ((child is IStyleClient)){ IStyleClient(child).notifyStyleChangeInChildren(null, true); }; if (((uiComponentClassName) && ((child is uiComponentClassName)))){ uiComponentClassName(child).initThemeColor(); }; if (((uiComponentClassName) && ((child is uiComponentClassName)))){ uiComponentClassName(child).stylesInitialized(); }; } private function idleTimer_timerHandler(event:TimerEvent):void{ idleCounter++; if ((idleCounter * IDLE_INTERVAL) > IDLE_THRESHOLD){ dispatchEvent(new FlexEvent(FlexEvent.IDLE)); }; } public function getExplicitOrMeasuredHeight():Number{ return ((isNaN(explicitHeight)) ? measuredHeight : explicitHeight); } mx_internal function notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void{ var child:IStyleClient; var foundTopLevelWindow:Boolean; var n:int = rawChildren.numChildren; var i:int; while (i < n) { child = (rawChildren.getChildAt(i) as IStyleClient); if (child){ child.styleChanged(styleProp); child.notifyStyleChangeInChildren(styleProp, recursive); }; if (isTopLevelWindow(DisplayObject(child))){ foundTopLevelWindow = true; }; n = rawChildren.numChildren; i++; }; if (((!(foundTopLevelWindow)) && ((topLevelWindow is IStyleClient)))){ IStyleClient(topLevelWindow).styleChanged(styleProp); IStyleClient(topLevelWindow).notifyStyleChangeInChildren(styleProp, recursive); }; } mx_internal function rawChildren_getObjectsUnderPoint(pt:Point):Array{ return (super.getObjectsUnderPoint(pt)); } private function initHandler(event:Event):void{ allSystemManagers[this] = this.loaderInfo.url; root.loaderInfo.removeEventListener(Event.INIT, initHandler); var docFrame:int = ((totalFrames)==1) ? 0 : 1; addFrameScript(docFrame, docFrameHandler); var f:int = (docFrame + 1); while (f < totalFrames) { addFrameScript(f, extraFrameHandler); f++; }; initialize(); } override public function contains(child:DisplayObject):Boolean{ var childIndex:int; var i:int; var myChild:DisplayObject; if (super.contains(child)){ if (child.parent == this){ childIndex = super.getChildIndex(child); if (childIndex < noTopMostIndex){ return (true); }; } else { i = 0; while (i < noTopMostIndex) { myChild = super.getChildAt(i); if ((myChild is IRawChildrenContainer)){ if (IRawChildrenContainer(myChild).rawChildren.contains(child)){ return (true); }; }; if ((myChild is DisplayObjectContainer)){ if (DisplayObjectContainer(myChild).contains(child)){ return (true); }; }; i++; }; }; }; return (false); } public function getDefinitionByName(name:String):Object{ var definition:Object; var domain:ApplicationDomain = (((!(topLevel)) && ((parent is Loader)))) ? Loader(parent).contentLoaderInfo.applicationDomain : (info()["currentDomain"] as ApplicationDomain); if (domain.hasDefinition(name)){ definition = domain.getDefinition(name); }; return (definition); } public function get embeddedFontList():Object{ var o:Object; var p:String; var fl:Object; if (_fontList == null){ _fontList = {}; o = info()["fonts"]; for (p in o) { _fontList[p] = o[p]; }; if (((!(topLevel)) && (_topLevelSystemManager))){ fl = _topLevelSystemManager.embeddedFontList; for (p in fl) { _fontList[p] = fl[p]; }; }; }; return (_fontList); } mx_internal function set cursorIndex(value:int):void{ var delta:int = (value - _cursorIndex); _cursorIndex = value; } public function set document(value:Object):void{ _document = value; } override public function getChildAt(index:int):DisplayObject{ return (super.getChildAt((applicationIndex + index))); } public function get rawChildren():IChildList{ if (!_rawChildren){ _rawChildren = new SystemRawChildrenList(this); }; return (_rawChildren); } override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void{ if ((((type == FlexEvent.IDLE)) && (!(idleTimer)))){ idleTimer = new Timer(IDLE_INTERVAL); idleTimer.addEventListener(TimerEvent.TIMER, idleTimer_timerHandler); idleTimer.start(); addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true); addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true); }; super.addEventListener(type, listener, useCapture, priority, useWeakReference); } public function removeFocusManager(f:IFocusManagerContainer):void{ var n:int = forms.length; var i:int; while (i < n) { if (forms[i] == f){ if (form == f){ deactivate(f); }; forms.splice(i, 1); return; }; i++; }; } private function mouseMoveHandler(event:MouseEvent):void{ idleCounter = 0; } public function get focusPane():Sprite{ return (_focusPane); } override public function get mouseX():Number{ if (_mouseX === undefined){ return (super.mouseX); }; return (_mouseX); } private function mouseDownHandler(event:MouseEvent):void{ var n:int; var p:DisplayObject; var isApplication:Boolean; var i:int; var j:int; var index:int; var newIndex:int; var childList:IChildList; idleCounter = 0; if (numModalWindows == 0){ if (forms.length > 1){ n = forms.length; p = DisplayObject(event.target); isApplication = document.rawChildren.contains(p); while (p) { i = 0; while (i < n) { if (forms[i] == p){ j = 0; if (((!((p == form))) && ((p is IFocusManagerContainer)))){ activate(IFocusManagerContainer(p)); }; if (popUpChildren.contains(p)){ childList = popUpChildren; } else { childList = this; }; index = childList.getChildIndex(p); newIndex = index; n = forms.length; j = 0; while (j < n) { if (childList.contains(forms[j])){ if (childList.getChildIndex(forms[j]) > index){ newIndex = Math.max(childList.getChildIndex(forms[j]), newIndex); }; }; j++; }; if ((((newIndex > index)) && (!(isApplication)))){ childList.setChildIndex(p, newIndex); }; return; }; i++; }; p = p.parent; }; }; }; } public function get screen():Rectangle{ if (!_screen){ Stage_resizeHandler(); }; return (_screen); } mx_internal function set topMostIndex(value:int):void{ var delta:int = (value - _topMostIndex); _topMostIndex = value; toolTipIndex = (toolTipIndex + delta); } mx_internal function docFrameHandler(event:Event=null):void{ var textFieldFactory:TextFieldFactory; var n:int; var i:int; var c:Class; Singleton.registerClass("mx.managers::IBrowserManager", Class(getDefinitionByName("mx.managers::BrowserManagerImpl"))); Singleton.registerClass("mx.managers::ICursorManager", Class(getDefinitionByName("mx.managers::CursorManagerImpl"))); Singleton.registerClass("mx.managers::IHistoryManager", Class(getDefinitionByName("mx.managers::HistoryManagerImpl"))); Singleton.registerClass("mx.managers::ILayoutManager", Class(getDefinitionByName("mx.managers::LayoutManager"))); Singleton.registerClass("mx.managers::IPopUpManager", Class(getDefinitionByName("mx.managers::PopUpManagerImpl"))); Singleton.registerClass("mx.managers::IToolTipManager2", Class(getDefinitionByName("mx.managers::ToolTipManagerImpl"))); if (Capabilities.playerType == "Desktop"){ Singleton.registerClass("mx.managers::IDragManager", Class(getDefinitionByName("mx.managers::NativeDragManagerImpl"))); if (Singleton.getClass("mx.managers::IDragManager") == null){ Singleton.registerClass("mx.managers::IDragManager", Class(getDefinitionByName("mx.managers::DragManagerImpl"))); }; } else { Singleton.registerClass("mx.managers::IDragManager", Class(getDefinitionByName("mx.managers::DragManagerImpl"))); }; Singleton.registerClass("mx.core::ITextFieldFactory", Class(getDefinitionByName("mx.core::TextFieldFactory"))); executeCallbacks(); doneExecutingInitCallbacks = true; var mixinList:Array = info()["mixins"]; if (((mixinList) && ((mixinList.length > 0)))){ n = mixinList.length; i = 0; while (i < n) { c = Class(getDefinitionByName(mixinList[i])); var _local7 = c; _local7["init"](this); i++; }; }; installCompiledResourceBundles(); initializeTopLevelWindow(null); deferredNextFrame(); } private function Stage_resizeHandler(event:Event=null):void{ var w:Number = stage.stageWidth; var h:Number = stage.stageHeight; var m:Number = loaderInfo.width; var n:Number = loaderInfo.height; var x:Number = ((m - w) / 2); var y:Number = ((n - h) / 2); var align:String = stage.align; if (align == StageAlign.TOP){ y = 0; } else { if (align == StageAlign.BOTTOM){ y = (n - h); } else { if (align == StageAlign.LEFT){ x = 0; } else { if (align == StageAlign.RIGHT){ x = (m - w); } else { if ((((align == StageAlign.TOP_LEFT)) || ((align == "LT")))){ y = 0; x = 0; } else { if (align == StageAlign.TOP_RIGHT){ y = 0; x = (m - w); } else { if (align == StageAlign.BOTTOM_LEFT){ y = (n - h); x = 0; } else { if (align == StageAlign.BOTTOM_RIGHT){ y = (n - h); x = (m - w); }; }; }; }; }; }; }; }; if (!_screen){ _screen = new Rectangle(); }; _screen.x = x; _screen.y = y; _screen.width = w; _screen.height = h; if (isStageRoot){ _width = stage.stageWidth; _height = stage.stageHeight; }; if (event){ resizeMouseCatcher(); dispatchEvent(event); }; } public function get explicitHeight():Number{ return (_explicitHeight); } public function get preloaderBackgroundSize():String{ return (info()["backgroundSize"]); } public function isTopLevel():Boolean{ return (topLevel); } override public function get mouseY():Number{ if (_mouseY === undefined){ return (super.mouseY); }; return (_mouseY); } public function getExplicitOrMeasuredWidth():Number{ return ((isNaN(explicitWidth)) ? measuredWidth : explicitWidth); } public function deactivate(f:IFocusManagerContainer):void{ var newForm:IFocusManagerContainer; var n:int; var i:int; var g:IFocusManagerContainer; if (form){ if ((((form == f)) && ((forms.length > 1)))){ form.focusManager.deactivate(); n = forms.length; i = 0; while (i < n) { g = forms[i]; if (g == f){ i = (i + 1); while (i < n) { g = forms[i]; if ((((Sprite(g).visible == true)) && (IUIComponent(g).enabled))){ newForm = g; }; i++; }; form = newForm; break; } else { if (((Sprite(g).visible) && (IUIComponent(g).enabled))){ newForm = g; }; }; i++; }; if (form){ form.focusManager.activate(); }; }; }; } override public function getChildByName(name:String):DisplayObject{ return (super.getChildByName(name)); } override public function addChildAt(child:DisplayObject, index:int):DisplayObject{ noTopMostIndex++; return (rawChildren_addChildAt(child, (applicationIndex + index))); } public function get measuredWidth():Number{ return ((topLevelWindow) ? topLevelWindow.getExplicitOrMeasuredWidth() : loaderInfo.width); } public function info():Object{ return ({}); } mx_internal function get toolTipIndex():int{ return (_toolTipIndex); } public function setActualSize(newWidth:Number, newHeight:Number):void{ if (isStageRoot){ return; }; _width = newWidth; _height = newHeight; if (mouseCatcher){ mouseCatcher.width = newWidth; mouseCatcher.height = newHeight; }; dispatchEvent(new Event(Event.RESIZE)); } public function set focusPane(value:Sprite):void{ if (value){ addChild(value); value.x = 0; value.y = 0; value.scrollRect = null; _focusPane = value; } else { removeChild(_focusPane); _focusPane = null; }; } mx_internal function set applicationIndex(value:int):void{ _applicationIndex = value; } private function executeCallbacks():void{ var initFunction:Function; if (!parent){ return; }; while (initCallbackFunctions.length > 0) { initFunction = initCallbackFunctions.shift(); initFunction(this); }; } public function get popUpChildren():IChildList{ if (!topLevel){ return (_topLevelSystemManager.popUpChildren); }; if (!_popUpChildren){ _popUpChildren = new SystemChildrenList(this, new QName(mx_internal, "noTopMostIndex"), new QName(mx_internal, "topMostIndex")); }; return (_popUpChildren); } public function set explicitHeight(value:Number):void{ _explicitHeight = value; } override public function removeChild(child:DisplayObject):DisplayObject{ noTopMostIndex--; return (rawChildren_removeChild(child)); } override public function addChild(child:DisplayObject):DisplayObject{ noTopMostIndex++; return (rawChildren_addChildAt(child, (noTopMostIndex - 1))); } public function create(... _args):Object{ var url:String; var dot:int; var slash:int; var mainClassName:String = info()["mainClassName"]; if (mainClassName == null){ url = loaderInfo.loaderURL; dot = url.lastIndexOf("."); slash = url.lastIndexOf("/"); mainClassName = url.substring((slash + 1), dot); }; var mainClass:Class = Class(getDefinitionByName(mainClassName)); return ((mainClass) ? new (mainClass) : null); } override public function get stage():Stage{ var s:Stage = super.stage; if (s){ return (s); }; if (((!(topLevel)) && (_topLevelSystemManager))){ return (_topLevelSystemManager.stage); }; return (null); } mx_internal function rawChildren_removeChild(child:DisplayObject):DisplayObject{ removingChild(child); super.removeChild(child); childRemoved(child); return (child); } final mx_internal function get $numChildren():int{ return (super.numChildren); } public function get toolTipChildren():IChildList{ if (!topLevel){ return (_topLevelSystemManager.toolTipChildren); }; if (!_toolTipChildren){ _toolTipChildren = new SystemChildrenList(this, new QName(mx_internal, "topMostIndex"), new QName(mx_internal, "toolTipIndex")); }; return (_toolTipChildren); } override public function getChildIndex(child:DisplayObject):int{ return ((super.getChildIndex(child) - applicationIndex)); } private function mouseUpHandler(event:MouseEvent):void{ idleCounter = 0; } mx_internal function rawChildren_getChildIndex(child:DisplayObject):int{ return (super.getChildIndex(child)); } public function activate(f:IFocusManagerContainer):void{ var z:IFocusManagerContainer; if (form){ if (((!((form == f))) && ((forms.length > 1)))){ z = form; z.focusManager.deactivate(); }; }; form = f; if (f.focusManager){ f.focusManager.activate(); }; } private function deferredNextFrame():void{ if ((currentFrame + 1) > totalFrames){ return; }; if ((currentFrame + 1) <= framesLoaded){ nextFrame(); } else { nextFrameTimer = new Timer(100); nextFrameTimer.addEventListener(TimerEvent.TIMER, nextFrameTimerHandler); nextFrameTimer.start(); }; } mx_internal function get cursorIndex():int{ return (_cursorIndex); } mx_internal function rawChildren_contains(child:DisplayObject):Boolean{ return (super.contains(child)); } override public function setChildIndex(child:DisplayObject, newIndex:int):void{ super.setChildIndex(child, (applicationIndex + newIndex)); } public function get document():Object{ return (_document); } private function resizeMouseCatcher():void{ var g:Graphics; if (mouseCatcher){ g = mouseCatcher.graphics; g.clear(); g.beginFill(0, 0); g.drawRect(0, 0, stage.stageWidth, stage.stageHeight); g.endFill(); }; } override public function get height():Number{ return (_height); } mx_internal function rawChildren_getChildAt(index:int):DisplayObject{ return (super.getChildAt(index)); } mx_internal function set noTopMostIndex(value:int):void{ var delta:int = (value - _noTopMostIndex); _noTopMostIndex = value; topMostIndex = (topMostIndex + delta); } override public function getObjectsUnderPoint(point:Point):Array{ var child:DisplayObject; var temp:Array; var children:Array = []; var n:int = topMostIndex; var i:int; while (i < n) { child = super.getChildAt(i); if ((child is DisplayObjectContainer)){ temp = DisplayObjectContainer(child).getObjectsUnderPoint(point); if (temp){ children = children.concat(temp); }; }; i++; }; return (children); } mx_internal function get topMostIndex():int{ return (_topMostIndex); } mx_internal function regenerateStyleCache(recursive:Boolean):void{ var child:IStyleClient; var foundTopLevelWindow:Boolean; var n:int = rawChildren.numChildren; var i:int; while (i < n) { child = (rawChildren.getChildAt(i) as IStyleClient); if (child){ child.regenerateStyleCache(recursive); }; if (isTopLevelWindow(DisplayObject(child))){ foundTopLevelWindow = true; }; n = rawChildren.numChildren; i++; }; if (((!(foundTopLevelWindow)) && ((topLevelWindow is IStyleClient)))){ IStyleClient(topLevelWindow).regenerateStyleCache(recursive); }; } public function addFocusManager(f:IFocusManagerContainer):void{ forms.push(f); } public function isFontFaceEmbedded(textFormat:TextFormat):Boolean{ var font:Font; var style:String; var fontName:String = textFormat.font; var fl:Array = Font.enumerateFonts(); var f:int; while (f < fl.length) { font = Font(fl[f]); if (font.fontName == fontName){ style = "regular"; if (((textFormat.bold) && (textFormat.italic))){ style = "boldItalic"; } else { if (textFormat.bold){ style = "bold"; } else { if (textFormat.italic){ style = "italic"; }; }; }; if (font.fontStyle == style){ return (true); }; }; f++; }; if (((((!(fontName)) || (!(embeddedFontList)))) || (!(embeddedFontList[fontName])))){ return (false); }; var info:Object = embeddedFontList[fontName]; return (!(((((((textFormat.bold) && (!(info.bold)))) || (((textFormat.italic) && (!(info.italic)))))) || (((((!(textFormat.bold)) && (!(textFormat.italic)))) && (!(info.regular))))))); } mx_internal function rawChildren_setChildIndex(child:DisplayObject, newIndex:int):void{ super.setChildIndex(child, newIndex); } mx_internal function childAdded(child:DisplayObject):void{ child.dispatchEvent(new FlexEvent(FlexEvent.ADD)); if ((child is IUIComponent)){ IUIComponent(child).initialize(); }; } override public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void{ if (type == FlexEvent.IDLE){ super.removeEventListener(type, listener, useCapture); if (((!(hasEventListener(FlexEvent.IDLE))) && (idleTimer))){ idleTimer.stop(); idleTimer = null; removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); }; } else { super.removeEventListener(type, listener, useCapture); }; } private function extraFrameHandler(event:Event=null):void{ var c:Class; var frameList:Object = info()["frames"]; if (((frameList) && (frameList[currentLabel]))){ c = Class(getDefinitionByName(frameList[currentLabel])); var _local4 = c; _local4["frame"](this); }; deferredNextFrame(); } public function get application():IUIComponent{ return (IUIComponent(_document)); } override public function removeChildAt(index:int):DisplayObject{ noTopMostIndex--; return (rawChildren_removeChildAt((applicationIndex + index))); } mx_internal function rawChildren_removeChildAt(index:int):DisplayObject{ var child:DisplayObject = super.getChildAt(index); removingChild(child); super.removeChildAt(index); childRemoved(child); return (child); } private function installCompiledResourceBundles():void{ var info:Object = this.info(); var applicationDomain:ApplicationDomain = (((!(topLevel)) && ((parent is Loader)))) ? Loader(parent).contentLoaderInfo.applicationDomain : info["currentDomain"]; var compiledLocales:Array = info["compiledLocales"]; var compiledResourceBundleNames:Array = info["compiledResourceBundleNames"]; var resourceManager:IResourceManager = ResourceManager.getInstance(); resourceManager.installCompiledResourceBundles(applicationDomain, compiledLocales, compiledResourceBundleNames); if (!resourceManager.localeChain){ resourceManager.localeChain = compiledLocales; }; } mx_internal function removingChild(child:DisplayObject):void{ child.dispatchEvent(new FlexEvent(FlexEvent.REMOVE)); } mx_internal function get applicationIndex():int{ return (_applicationIndex); } mx_internal function set toolTipIndex(value:int):void{ var delta:int = (value - _toolTipIndex); _toolTipIndex = value; cursorIndex = (cursorIndex + delta); } public function get cursorChildren():IChildList{ if (!topLevel){ return (_topLevelSystemManager.cursorChildren); }; if (!_cursorChildren){ _cursorChildren = new SystemChildrenList(this, new QName(mx_internal, "toolTipIndex"), new QName(mx_internal, "cursorIndex")); }; return (_cursorChildren); } public function get preloaderBackgroundImage():Object{ return (info()["backgroundImage"]); } public function set numModalWindows(value:int):void{ _numModalWindows = value; } public function get preloaderBackgroundAlpha():Number{ return (info()["backgroundAlpha"]); } mx_internal function rawChildren_getChildByName(name:String):DisplayObject{ return (super.getChildByName(name)); } private function preloader_preloaderDoneHandler(event:Event):void{ var app:IUIComponent = topLevelWindow; preloader.removeEventListener(FlexEvent.PRELOADER_DONE, preloader_preloaderDoneHandler); _popUpChildren.removeChild(preloader); preloader = null; mouseCatcher = new FlexSprite(); mouseCatcher.name = "mouseCatcher"; noTopMostIndex++; super.addChildAt(mouseCatcher, 0); resizeMouseCatcher(); if (!topLevel){ mouseCatcher.visible = false; mask = mouseCatcher; }; noTopMostIndex++; super.addChildAt(DisplayObject(app), 1); app.dispatchEvent(new FlexEvent(FlexEvent.APPLICATION_COMPLETE)); dispatchEvent(new FlexEvent(FlexEvent.APPLICATION_COMPLETE)); } public function get preloaderBackgroundColor():uint{ var value:* = info()["backgroundColor"]; if (value == undefined){ return (StyleManager.NOT_A_COLOR); }; return (StyleManager.getColorName(value)); } public function get topLevelSystemManager():ISystemManager{ if (topLevel){ return (this); }; return (_topLevelSystemManager); } mx_internal function initialize():void{ var n:int; var i:int; var fontRegistry:EmbeddedFontRegistry; var crossDomainRSLItem:Class; var cdNode:Object; var node:RSLItem; if (isStageRoot){ _width = stage.stageWidth; _height = stage.stageHeight; } else { _width = loaderInfo.width; _height = loaderInfo.height; }; preloader = new Preloader(); preloader.addEventListener(FlexEvent.INIT_PROGRESS, preloader_initProgressHandler); preloader.addEventListener(FlexEvent.PRELOADER_DONE, preloader_preloaderDoneHandler); if (!_popUpChildren){ _popUpChildren = new SystemChildrenList(this, new QName(mx_internal, "noTopMostIndex"), new QName(mx_internal, "topMostIndex")); }; _popUpChildren.addChild(preloader); var rsls:Array = info()["rsls"]; var cdRsls:Array = info()["cdRsls"]; var usePreloader:Boolean; if (info()["usePreloader"] != undefined){ usePreloader = info()["usePreloader"]; }; var preloaderDisplayClass:Class = (info()["preloader"] as Class); if (((usePreloader) && (!(preloaderDisplayClass)))){ preloaderDisplayClass = DownloadProgressBar; }; var rslList:Array = []; if (((cdRsls) && ((cdRsls.length > 0)))){ crossDomainRSLItem = Class(getDefinitionByName("mx.core::CrossDomainRSLItem")); n = cdRsls.length; i = 0; while (i < n) { cdNode = new crossDomainRSLItem(cdRsls[i]["rsls"], cdRsls[i]["policyFiles"], cdRsls[i]["digests"], cdRsls[i]["types"], cdRsls[i]["isSigned"]); rslList.push(cdNode); i++; }; }; if (((!((rsls == null))) && ((rsls.length > 0)))){ n = rsls.length; i = 0; while (i < n) { node = new RSLItem(rsls[i].url); rslList.push(node); i++; }; }; Singleton.registerClass("mx.resources::IResourceManager", Class(getDefinitionByName("mx.resources::ResourceManagerImpl"))); var resourceManager:IResourceManager = ResourceManager.getInstance(); Singleton.registerClass("mx.core::IEmbeddedFontRegistry", Class(getDefinitionByName("mx.core::EmbeddedFontRegistry"))); Singleton.registerClass("mx.styles::IStyleManager", Class(getDefinitionByName("mx.styles::StyleManagerImpl"))); Singleton.registerClass("mx.styles::IStyleManager2", Class(getDefinitionByName("mx.styles::StyleManagerImpl"))); var localeChainList:String = loaderInfo.parameters["localeChain"]; if (((!((localeChainList == null))) && (!((localeChainList == ""))))){ resourceManager.localeChain = localeChainList.split(","); }; var resourceModuleURLList:String = loaderInfo.parameters["resourceModuleURLs"]; var resourceModuleURLs:Array = (resourceModuleURLList) ? resourceModuleURLList.split(",") : null; preloader.initialize(usePreloader, preloaderDisplayClass, preloaderBackgroundColor, preloaderBackgroundAlpha, preloaderBackgroundImage, preloaderBackgroundSize, (isStageRoot) ? stage.stageWidth : loaderInfo.width, (isStageRoot) ? stage.stageHeight : loaderInfo.height, null, null, rslList, resourceModuleURLs); } private function appCreationCompleteHandler(event:FlexEvent):void{ var obj:DisplayObjectContainer; if (((!(topLevel)) && (parent))){ obj = parent.parent; while (obj) { if ((obj is IInvalidating)){ IInvalidating(obj).invalidateSize(); IInvalidating(obj).invalidateDisplayList(); return; }; obj = obj.parent; }; }; } public function get measuredHeight():Number{ return ((topLevelWindow) ? topLevelWindow.getExplicitOrMeasuredHeight() : loaderInfo.height); } mx_internal function rawChildren_addChildAt(child:DisplayObject, index:int):DisplayObject{ addingChild(child); super.addChildAt(child, index); childAdded(child); return (child); } private function nextFrameTimerHandler(event:TimerEvent):void{ if ((currentFrame + 1) <= framesLoaded){ nextFrame(); nextFrameTimer.removeEventListener(TimerEvent.TIMER, nextFrameTimerHandler); nextFrameTimer.reset(); }; } mx_internal function childRemoved(child:DisplayObject):void{ if ((child is IUIComponent)){ IUIComponent(child).parentChanged(null); }; } mx_internal function get noTopMostIndex():int{ return (_noTopMostIndex); } override public function get numChildren():int{ return ((noTopMostIndex - applicationIndex)); } private function initializeTopLevelWindow(event:Event):void{ var app:IUIComponent; var obj:DisplayObjectContainer; initialized = true; if (!parent){ return; }; if (!topLevel){ obj = parent.parent; if (!obj){ return; }; while (obj) { if ((obj is IUIComponent)){ _topLevelSystemManager = IUIComponent(obj).systemManager; break; }; obj = obj.parent; }; }; addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, true); if (((topLevel) && (stage))){ stage.addEventListener(Event.RESIZE, Stage_resizeHandler, false, 0, true); }; app = (topLevelWindow = IUIComponent(create())); document = app; if (document){ IEventDispatcher(app).addEventListener(FlexEvent.CREATION_COMPLETE, appCreationCompleteHandler); if (((topLevel) && (stage))){ LoaderConfig._url = loaderInfo.url; LoaderConfig._parameters = loaderInfo.parameters; _width = stage.stageWidth; _height = stage.stageHeight; IFlexDisplayObject(app).setActualSize(stage.stageWidth, stage.stageHeight); } else { IFlexDisplayObject(app).setActualSize(loaderInfo.width, loaderInfo.height); }; if (preloader){ preloader.registerApplication(app); }; addingChild(DisplayObject(app)); childAdded(DisplayObject(app)); } else { document = this; }; } public function get numModalWindows():int{ return (_numModalWindows); } public function isTopLevelWindow(object:DisplayObject):Boolean{ return ((((object is IUIComponent)) && ((IUIComponent(object) == topLevelWindow)))); } override public function get width():Number{ return (_width); } public function move(x:Number, y:Number):void{ } public function set explicitWidth(value:Number):void{ _explicitWidth = value; } private function preloader_initProgressHandler(event:Event):void{ preloader.removeEventListener(FlexEvent.INIT_PROGRESS, preloader_initProgressHandler); deferredNextFrame(); } public function get explicitWidth():Number{ return (_explicitWidth); } mx_internal function rawChildren_addChild(child:DisplayObject):DisplayObject{ addingChild(child); super.addChild(child); childAdded(child); return (child); } public static function getSWFRoot(object:Object):DisplayObject{ var p:*; var sm:ISystemManager; var domain:ApplicationDomain; var cls:Class; var object = object; var className:String = getQualifiedClassName(object); for (p in allSystemManagers) { sm = (p as ISystemManager); domain = sm.loaderInfo.applicationDomain; cls = Class(domain.getDefinition(className)); if ((object is cls)){ return ((sm as DisplayObject)); }; //unresolved jump var _slot1 = e; }; return (null); } mx_internal static function registerInitCallback(initFunction:Function):void{ if (((!(allSystemManagers)) || (!(lastSystemManager)))){ return; }; var sm:SystemManager = lastSystemManager; if (sm.doneExecutingInitCallbacks){ initFunction(sm); } else { sm.initCallbackFunctions.push(initFunction); }; } } }//package mx.managers
Section 187
//SystemManagerGlobals (mx.managers.SystemManagerGlobals) package mx.managers { public class SystemManagerGlobals { public static var topLevelSystemManagers:Array = []; public static var bootstrapLoaderInfoURL:String; public function SystemManagerGlobals(){ super(); } } }//package mx.managers
Section 188
//SystemRawChildrenList (mx.managers.SystemRawChildrenList) package mx.managers { import mx.core.*; import flash.display.*; import flash.geom.*; public class SystemRawChildrenList implements IChildList { private var owner:SystemManager; mx_internal static const VERSION:String = "3.0.0.0"; public function SystemRawChildrenList(owner:SystemManager){ super(); this.owner = owner; } public function getChildAt(index:int):DisplayObject{ return (owner.mx_internal::rawChildren_getChildAt(index)); } public function addChild(child:DisplayObject):DisplayObject{ return (owner.mx_internal::rawChildren_addChild(child)); } public function getChildIndex(child:DisplayObject):int{ return (owner.mx_internal::rawChildren_getChildIndex(child)); } public function setChildIndex(child:DisplayObject, newIndex:int):void{ var _local3 = owner; _local3.mx_internal::rawChildren_setChildIndex(child, newIndex); } public function getChildByName(name:String):DisplayObject{ return (owner.mx_internal::rawChildren_getChildByName(name)); } public function removeChildAt(index:int):DisplayObject{ return (owner.mx_internal::rawChildren_removeChildAt(index)); } public function get numChildren():int{ return (owner.mx_internal::$numChildren); } public function addChildAt(child:DisplayObject, index:int):DisplayObject{ return (owner.mx_internal::rawChildren_addChildAt(child, index)); } public function getObjectsUnderPoint(point:Point):Array{ return (owner.mx_internal::rawChildren_getObjectsUnderPoint(point)); } public function contains(child:DisplayObject):Boolean{ return (owner.mx_internal::rawChildren_contains(child)); } public function removeChild(child:DisplayObject):DisplayObject{ return (owner.mx_internal::rawChildren_removeChild(child)); } } }//package mx.managers
Section 189
//ToolTipManager (mx.managers.ToolTipManager) package mx.managers { import mx.core.*; import flash.events.*; import flash.display.*; import mx.effects.*; public class ToolTipManager extends EventDispatcher { mx_internal static const VERSION:String = "3.0.0.0"; private static var implClassDependency:ToolTipManagerImpl; private static var _impl:IToolTipManager2; public function ToolTipManager(){ super(); } mx_internal static function registerToolTip(target:DisplayObject, oldToolTip:String, newToolTip:String):void{ impl.registerToolTip(target, oldToolTip, newToolTip); } public static function get enabled():Boolean{ return (impl.enabled); } public static function set enabled(value:Boolean):void{ impl.enabled = value; } public static function createToolTip(text:String, x:Number, y:Number, errorTipBorderStyle:String=null, context:IUIComponent=null):IToolTip{ return (impl.createToolTip(text, x, y, errorTipBorderStyle, context)); } public static function set hideDelay(value:Number):void{ impl.hideDelay = value; } public static function set showDelay(value:Number):void{ impl.showDelay = value; } public static function get showDelay():Number{ return (impl.showDelay); } public static function destroyToolTip(toolTip:IToolTip):void{ return (impl.destroyToolTip(toolTip)); } public static function get scrubDelay():Number{ return (impl.scrubDelay); } public static function get toolTipClass():Class{ return (impl.toolTipClass); } mx_internal static function registerErrorString(target:DisplayObject, oldErrorString:String, newErrorString:String):void{ impl.registerErrorString(target, oldErrorString, newErrorString); } mx_internal static function sizeTip(toolTip:IToolTip):void{ impl.sizeTip(toolTip); } public static function set currentTarget(value:DisplayObject):void{ impl.currentTarget = value; } public static function set showEffect(value:IAbstractEffect):void{ impl.showEffect = value; } private static function get impl():IToolTipManager2{ if (!_impl){ _impl = IToolTipManager2(Singleton.getInstance("mx.managers::IToolTipManager2")); }; return (_impl); } public static function get hideDelay():Number{ return (impl.hideDelay); } public static function set hideEffect(value:IAbstractEffect):void{ impl.hideEffect = value; } public static function set scrubDelay(value:Number):void{ impl.scrubDelay = value; } public static function get currentToolTip():IToolTip{ return (impl.currentToolTip); } public static function set currentToolTip(value:IToolTip):void{ impl.currentToolTip = value; } public static function get showEffect():IAbstractEffect{ return (impl.showEffect); } public static function get currentTarget():DisplayObject{ return (impl.currentTarget); } public static function get hideEffect():IAbstractEffect{ return (impl.hideEffect); } public static function set toolTipClass(value:Class):void{ impl.toolTipClass = value; } } }//package mx.managers
Section 190
//ToolTipManagerImpl (mx.managers.ToolTipManagerImpl) package mx.managers { import mx.core.*; import flash.events.*; import mx.styles.*; import flash.display.*; import flash.geom.*; import mx.events.*; import mx.controls.*; import mx.effects.*; import flash.utils.*; import mx.validators.*; public class ToolTipManagerImpl extends EventDispatcher implements IToolTipManager2 { private var _enabled:Boolean;// = true mx_internal var isError:Boolean; private var _showDelay:Number;// = 500 private var _hideEffect:IAbstractEffect; mx_internal var hideTimer:Timer; private var _scrubDelay:Number;// = 100 private var _toolTipClass:Class; mx_internal var currentText:String; mx_internal var showTimer:Timer; private var _currentToolTip:IToolTip; mx_internal var scrubTimer:Timer; mx_internal var previousTarget:DisplayObject; private var _currentTarget:DisplayObject; private var _showEffect:IAbstractEffect; mx_internal var initialized:Boolean;// = false private var _hideDelay:Number;// = 10000 mx_internal static const VERSION:String = "3.0.0.0"; private static var instance:IToolTipManager2; public function ToolTipManagerImpl(){ _toolTipClass = ToolTip; super(); if (instance){ throw (new Error("Instance already exists.")); }; } mx_internal function systemManager_mouseDownHandler(event:MouseEvent):void{ reset(); } public function set showDelay(value:Number):void{ _showDelay = value; } mx_internal function hideEffectEnded():void{ var event:ToolTipEvent; reset(); if (previousTarget){ event = new ToolTipEvent(ToolTipEvent.TOOL_TIP_END); event.toolTip = currentToolTip; previousTarget.dispatchEvent(event); }; } public function set scrubDelay(value:Number):void{ _scrubDelay = value; } public function get currentToolTip():IToolTip{ return (_currentToolTip); } private function mouseIsOver(target:DisplayObject):Boolean{ if (((!(target)) || (!(target.stage)))){ return (false); }; if ((((target.stage.mouseX == 0)) && ((target.stage.mouseY == 0)))){ return (false); }; return (target.hitTestPoint(target.stage.mouseX, target.stage.mouseY, true)); } mx_internal function toolTipMouseOutHandler(event:MouseEvent):void{ checkIfTargetChanged(event.relatedObject); } public function get enabled():Boolean{ return (_enabled); } public function createToolTip(text:String, x:Number, y:Number, errorTipBorderStyle:String=null, context:IUIComponent=null):IToolTip{ var toolTip:ToolTip = new ToolTip(); var sm:ISystemManager = (context) ? context.systemManager : ApplicationGlobals.application.systemManager; sm.toolTipChildren.addChild(toolTip); if (errorTipBorderStyle){ toolTip.setStyle("styleName", "errorTip"); toolTip.setStyle("borderStyle", errorTipBorderStyle); }; toolTip.text = text; sizeTip(toolTip); toolTip.move(x, y); return ((toolTip as IToolTip)); } mx_internal function reset():void{ var sm:ISystemManager; showTimer.reset(); hideTimer.reset(); if (currentToolTip){ if (((showEffect) || (hideEffect))){ currentToolTip.removeEventListener(EffectEvent.EFFECT_END, effectEndHandler); }; EffectManager.endEffectsForTarget(currentToolTip); sm = currentToolTip.systemManager; sm.toolTipChildren.removeChild(DisplayObject(currentToolTip)); currentToolTip = null; scrubTimer.delay = scrubDelay; scrubTimer.reset(); if (scrubDelay > 0){ scrubTimer.delay = scrubDelay; scrubTimer.start(); }; }; } public function get toolTipClass():Class{ return (_toolTipClass); } public function set currentToolTip(value:IToolTip):void{ _currentToolTip = value; } private function hideImmediately(target:DisplayObject):void{ checkIfTargetChanged(null); } mx_internal function showTip():void{ var sm:ISystemManager; var event:ToolTipEvent = new ToolTipEvent(ToolTipEvent.TOOL_TIP_SHOW); event.toolTip = currentToolTip; currentTarget.dispatchEvent(event); if (isError){ currentTarget.addEventListener("change", changeHandler); } else { sm = getSystemManager(currentTarget); sm.addEventListener(MouseEvent.MOUSE_DOWN, systemManager_mouseDownHandler); }; currentToolTip.visible = true; if (!showEffect){ showEffectEnded(); }; } mx_internal function effectEndHandler(event:EffectEvent):void{ if (event.effectInstance.effect == showEffect){ showEffectEnded(); } else { if (event.effectInstance.effect == hideEffect){ hideEffectEnded(); }; }; } public function get hideDelay():Number{ return (_hideDelay); } public function get currentTarget():DisplayObject{ return (_currentTarget); } mx_internal function showEffectEnded():void{ var event:ToolTipEvent; if (hideDelay == 0){ hideTip(); } else { if (hideDelay < Infinity){ hideTimer.delay = hideDelay; hideTimer.start(); }; }; if (currentTarget){ event = new ToolTipEvent(ToolTipEvent.TOOL_TIP_SHOWN); event.toolTip = currentToolTip; currentTarget.dispatchEvent(event); }; } public function get hideEffect():IAbstractEffect{ return (_hideEffect); } mx_internal function changeHandler(event:Event):void{ reset(); } public function set enabled(value:Boolean):void{ _enabled = value; } mx_internal function errorTipMouseOverHandler(event:MouseEvent):void{ checkIfTargetChanged(DisplayObject(event.target)); } public function get showDelay():Number{ return (_showDelay); } public function registerErrorString(target:DisplayObject, oldErrorString:String, newErrorString:String):void{ if (((!(oldErrorString)) && (newErrorString))){ target.addEventListener(MouseEvent.MOUSE_OVER, errorTipMouseOverHandler); target.addEventListener(MouseEvent.MOUSE_OUT, errorTipMouseOutHandler); if (mouseIsOver(target)){ showImmediately(target); }; } else { if (((oldErrorString) && (!(newErrorString)))){ target.removeEventListener(MouseEvent.MOUSE_OVER, errorTipMouseOverHandler); target.removeEventListener(MouseEvent.MOUSE_OUT, errorTipMouseOutHandler); if (mouseIsOver(target)){ hideImmediately(target); }; }; }; } mx_internal function initialize():void{ if (!showTimer){ showTimer = new Timer(0, 1); showTimer.addEventListener(TimerEvent.TIMER, showTimer_timerHandler); }; if (!hideTimer){ hideTimer = new Timer(0, 1); hideTimer.addEventListener(TimerEvent.TIMER, hideTimer_timerHandler); }; if (!scrubTimer){ scrubTimer = new Timer(0, 1); }; initialized = true; } public function destroyToolTip(toolTip:IToolTip):void{ var sm:ISystemManager = toolTip.systemManager; sm.toolTipChildren.removeChild(DisplayObject(toolTip)); } public function get scrubDelay():Number{ return (_scrubDelay); } mx_internal function checkIfTargetChanged(displayObject:DisplayObject):void{ if (!enabled){ return; }; findTarget(displayObject); if (currentTarget != previousTarget){ targetChanged(); previousTarget = currentTarget; }; } public function set toolTipClass(value:Class):void{ _toolTipClass = value; } private function getGlobalBounds(obj:DisplayObject):Rectangle{ var upperLeft:Point = new Point(0, 0); upperLeft = obj.localToGlobal(upperLeft); return (new Rectangle(upperLeft.x, upperLeft.y, obj.width, obj.height)); } mx_internal function positionTip():void{ var x:Number; var y:Number; var targetGlobalBounds:Rectangle; var pos:Point; var ctt:IToolTip; var newWidth:Number; var oldWidth:Number; var toolTipWidth:Number; var toolTipHeight:Number; var screenWidth:Number = currentToolTip.screen.width; var screenHeight:Number = currentToolTip.screen.height; if (isError){ targetGlobalBounds = getGlobalBounds(currentTarget); x = (targetGlobalBounds.right + 4); y = (targetGlobalBounds.top - 1); if ((x + currentToolTip.width) > screenWidth){ newWidth = NaN; oldWidth = NaN; x = (targetGlobalBounds.left - 2); if (((x + currentToolTip.width) + 4) > screenWidth){ newWidth = ((screenWidth - x) - 4); oldWidth = Object(toolTipClass).maxWidth; Object(toolTipClass).maxWidth = newWidth; if ((currentToolTip is IStyleClient)){ IStyleClient(currentToolTip).setStyle("borderStyle", "errorTipAbove"); }; currentToolTip["text"] = currentToolTip["text"]; Object(toolTipClass).maxWidth = oldWidth; } else { if ((currentToolTip is IStyleClient)){ IStyleClient(currentToolTip).setStyle("borderStyle", "errorTipAbove"); }; currentToolTip["text"] = currentToolTip["text"]; }; if ((currentToolTip.height + 2) < targetGlobalBounds.top){ y = (targetGlobalBounds.top - (currentToolTip.height + 2)); } else { y = (targetGlobalBounds.bottom + 2); if (!isNaN(newWidth)){ Object(toolTipClass).maxWidth = newWidth; }; if ((currentToolTip is IStyleClient)){ IStyleClient(currentToolTip).setStyle("borderStyle", "errorTipBelow"); }; currentToolTip["text"] = currentToolTip["text"]; if (!isNaN(oldWidth)){ Object(toolTipClass).maxWidth = oldWidth; }; }; }; sizeTip(currentToolTip); pos = new Point(x, y); ctt = currentToolTip; pos = DisplayObject(ctt).root.globalToLocal(pos); x = pos.x; y = pos.y; } else { x = (ApplicationGlobals.application.mouseX + 11); y = (ApplicationGlobals.application.mouseY + 22); toolTipWidth = currentToolTip.width; if ((x + toolTipWidth) > screenWidth){ x = (screenWidth - toolTipWidth); }; toolTipHeight = currentToolTip.height; if ((y + toolTipHeight) > screenHeight){ y = (screenHeight - toolTipHeight); }; }; currentToolTip.move(x, y); } mx_internal function errorTipMouseOutHandler(event:MouseEvent):void{ checkIfTargetChanged(event.relatedObject); } mx_internal function findTarget(displayObject:DisplayObject):void{ while (displayObject) { if ((displayObject is IValidatorListener)){ currentText = IValidatorListener(displayObject).errorString; if (((!((currentText == null))) && (!((currentText == ""))))){ currentTarget = displayObject; isError = true; return; }; }; if ((displayObject is IToolTipManagerClient)){ currentText = IToolTipManagerClient(displayObject).toolTip; if (currentText != null){ currentTarget = displayObject; isError = false; return; }; }; displayObject = displayObject.parent; }; currentText = null; currentTarget = null; } public function registerToolTip(target:DisplayObject, oldToolTip:String, newToolTip:String):void{ if (((!(oldToolTip)) && (newToolTip))){ target.addEventListener(MouseEvent.MOUSE_OVER, toolTipMouseOverHandler); target.addEventListener(MouseEvent.MOUSE_OUT, toolTipMouseOutHandler); if (mouseIsOver(target)){ showImmediately(target); }; } else { if (((oldToolTip) && (!(newToolTip)))){ target.removeEventListener(MouseEvent.MOUSE_OVER, toolTipMouseOverHandler); target.removeEventListener(MouseEvent.MOUSE_OUT, toolTipMouseOutHandler); if (mouseIsOver(target)){ hideImmediately(target); }; }; }; } private function showImmediately(target:DisplayObject):void{ var oldShowDelay:Number = ToolTipManager.showDelay; ToolTipManager.showDelay = 0; checkIfTargetChanged(target); ToolTipManager.showDelay = oldShowDelay; } public function set hideDelay(value:Number):void{ _hideDelay = value; } private function getSystemManager(target:DisplayObject):ISystemManager{ return (((target is IUIComponent)) ? IUIComponent(target).systemManager : null); } public function set currentTarget(value:DisplayObject):void{ _currentTarget = value; } public function sizeTip(toolTip:IToolTip):void{ if ((toolTip is IInvalidating)){ IInvalidating(toolTip).validateNow(); }; toolTip.setActualSize(toolTip.getExplicitOrMeasuredWidth(), toolTip.getExplicitOrMeasuredHeight()); } mx_internal function showTimer_timerHandler(event:TimerEvent):void{ if (currentTarget){ createTip(); initializeTip(); positionTip(); showTip(); }; } mx_internal function hideTimer_timerHandler(event:TimerEvent):void{ hideTip(); } public function set showEffect(value:IAbstractEffect):void{ _showEffect = (value as IAbstractEffect); } public function set hideEffect(value:IAbstractEffect):void{ _hideEffect = (value as IAbstractEffect); } mx_internal function targetChanged():void{ var event:ToolTipEvent; if (!initialized){ initialize(); }; if (((previousTarget) && (currentToolTip))){ event = new ToolTipEvent(ToolTipEvent.TOOL_TIP_HIDE); event.toolTip = currentToolTip; previousTarget.dispatchEvent(event); }; reset(); if (currentTarget){ if (currentText == ""){ return; }; event = new ToolTipEvent(ToolTipEvent.TOOL_TIP_START); currentTarget.dispatchEvent(event); if ((((showDelay == 0)) || (scrubTimer.running))){ createTip(); initializeTip(); positionTip(); showTip(); } else { showTimer.delay = showDelay; showTimer.start(); }; }; } mx_internal function initializeTip():void{ if ((currentToolTip is ToolTip)){ ToolTip(currentToolTip).text = currentText; }; if (((isError) && ((currentToolTip is IStyleClient)))){ IStyleClient(currentToolTip).setStyle("styleName", "errorTip"); }; sizeTip(currentToolTip); if ((currentToolTip is IStyleClient)){ if (showEffect){ IStyleClient(currentToolTip).setStyle("showEffect", showEffect); }; if (hideEffect){ IStyleClient(currentToolTip).setStyle("hideEffect", hideEffect); }; }; if (((showEffect) || (hideEffect))){ currentToolTip.addEventListener(EffectEvent.EFFECT_END, effectEndHandler); }; } public function get showEffect():IAbstractEffect{ return (_showEffect); } mx_internal function toolTipMouseOverHandler(event:MouseEvent):void{ checkIfTargetChanged(DisplayObject(event.target)); } mx_internal function hideTip():void{ var event:ToolTipEvent; var sm:ISystemManager; if (previousTarget){ event = new ToolTipEvent(ToolTipEvent.TOOL_TIP_HIDE); event.toolTip = currentToolTip; previousTarget.dispatchEvent(event); }; if (currentToolTip){ currentToolTip.visible = false; }; if (isError){ if (currentTarget){ currentTarget.removeEventListener("change", changeHandler); }; } else { if (previousTarget){ sm = getSystemManager(previousTarget); sm.removeEventListener(MouseEvent.MOUSE_DOWN, systemManager_mouseDownHandler); }; }; if (!hideEffect){ hideEffectEnded(); }; } mx_internal function createTip():void{ var event:ToolTipEvent = new ToolTipEvent(ToolTipEvent.TOOL_TIP_CREATE); currentTarget.dispatchEvent(event); if (event.toolTip){ currentToolTip = event.toolTip; } else { currentToolTip = new toolTipClass(); }; currentToolTip.visible = false; var sm:ISystemManager = getSystemManager(currentTarget); sm.toolTipChildren.addChild(DisplayObject(currentToolTip)); } public static function getInstance():IToolTipManager2{ if (!instance){ instance = new (ToolTipManagerImpl); }; return (instance); } } }//package mx.managers
Section 191
//LoaderConfig (mx.messaging.config.LoaderConfig) package mx.messaging.config { import mx.core.*; public class LoaderConfig { mx_internal static const VERSION:String = "3.0.0.0"; mx_internal static var _url:String = null; mx_internal static var _parameters:Object; public function LoaderConfig(){ super(); } public static function get url():String{ return (_url); } public static function get parameters():Object{ return (_parameters); } } }//package mx.messaging.config
Section 192
//IModuleInfo (mx.modules.IModuleInfo) package mx.modules { import mx.core.*; import flash.events.*; import flash.system.*; public interface IModuleInfo extends IEventDispatcher { function get ready():Boolean; function get loaded():Boolean; function load(_arg1:ApplicationDomain=null, _arg2:SecurityDomain=null):void; function release():void; function get error():Boolean; function get data():Object; function publish(E:\dev\3.0.x\frameworks\projects\framework\src;mx\modules;IModuleInfo.as:IFlexModuleFactory):void; function get factory():IFlexModuleFactory; function set data(E:\dev\3.0.x\frameworks\projects\framework\src;mx\modules;IModuleInfo.as:Object):void; function get url():String; function get setup():Boolean; function unload():void; } }//package mx.modules
Section 193
//ModuleManager (mx.modules.ModuleManager) package mx.modules { import mx.core.*; public class ModuleManager { mx_internal static const VERSION:String = "3.0.0.0"; public function ModuleManager(){ super(); } public static function getModule(url:String):IModuleInfo{ return (getSingleton().getModule(url)); } private static function getSingleton():Object{ if (!ModuleManagerGlobals.managerSingleton){ ModuleManagerGlobals.managerSingleton = new ModuleManagerImpl(); }; return (ModuleManagerGlobals.managerSingleton); } public static function getAssociatedFactory(object:Object):IFlexModuleFactory{ return (getSingleton().getAssociatedFactory(object)); } } }//package mx.modules import mx.core.*; import flash.events.*; import flash.system.*; import flash.display.*; import mx.events.*; import flash.net.*; import flash.utils.*; class ModuleInfoProxy extends EventDispatcher implements IModuleInfo { private var _data:Object; private var info:ModuleInfo; private var referenced:Boolean;// = false private function ModuleInfoProxy(info:ModuleInfo){ super(); this.info = info; info.addEventListener(ModuleEvent.SETUP, moduleEventHandler, false, 0, true); info.addEventListener(ModuleEvent.PROGRESS, moduleEventHandler, false, 0, true); info.addEventListener(ModuleEvent.READY, moduleEventHandler, false, 0, true); info.addEventListener(ModuleEvent.ERROR, moduleEventHandler, false, 0, true); info.addEventListener(ModuleEvent.UNLOAD, moduleEventHandler, false, 0, true); } public function get loaded():Boolean{ return (info.loaded); } public function release():void{ if (referenced){ info.removeReference(); referenced = false; }; } public function get error():Boolean{ return (info.error); } public function get factory():IFlexModuleFactory{ return (info.factory); } public function publish(factory:IFlexModuleFactory):void{ info.publish(factory); } public function set data(value:Object):void{ _data = value; } public function get ready():Boolean{ return (info.ready); } public function load(applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):void{ var moduleEvent:ModuleEvent; info.resurrect(); if (!referenced){ info.addReference(); referenced = true; }; if (info.error){ dispatchEvent(new ModuleEvent(ModuleEvent.ERROR)); } else { if (info.loaded){ if (info.setup){ dispatchEvent(new ModuleEvent(ModuleEvent.SETUP)); if (info.ready){ moduleEvent = new ModuleEvent(ModuleEvent.PROGRESS); moduleEvent.bytesLoaded = info.size; moduleEvent.bytesTotal = info.size; dispatchEvent(moduleEvent); dispatchEvent(new ModuleEvent(ModuleEvent.READY)); }; }; } else { info.load(applicationDomain, securityDomain); }; }; } private function moduleEventHandler(event:ModuleEvent):void{ dispatchEvent(event); } public function get url():String{ return (info.url); } public function get data():Object{ return (_data); } public function get setup():Boolean{ return (info.setup); } public function unload():void{ info.unload(); info.removeEventListener(ModuleEvent.SETUP, moduleEventHandler); info.removeEventListener(ModuleEvent.PROGRESS, moduleEventHandler); info.removeEventListener(ModuleEvent.READY, moduleEventHandler); info.removeEventListener(ModuleEvent.ERROR, moduleEventHandler); info.removeEventListener(ModuleEvent.UNLOAD, moduleEventHandler); } } class ModuleManagerImpl extends EventDispatcher { private var moduleList:Object; private function ModuleManagerImpl(){ moduleList = {}; super(); } public function getModule(url:String):IModuleInfo{ var info:ModuleInfo = (moduleList[url] as ModuleInfo); if (!info){ info = new ModuleInfo(url); moduleList[url] = info; }; return (new ModuleInfoProxy(info)); } public function getAssociatedFactory(object:Object):IFlexModuleFactory{ var m:Object; var info:ModuleInfo; var domain:ApplicationDomain; var cls:Class; var object = object; var className:String = getQualifiedClassName(object); for each (m in moduleList) { info = (m as ModuleInfo); if (!info.ready){ } else { domain = info.applicationDomain; cls = Class(domain.getDefinition(className)); if ((object is cls)){ return (info.factory); }; //unresolved jump var _slot1 = error; }; }; return (null); } } class ModuleInfo extends EventDispatcher { private var _error:Boolean;// = false private var loader:Loader; private var factoryInfo:FactoryInfo; private var limbo:Dictionary; private var _loaded:Boolean;// = false private var _ready:Boolean;// = false private var numReferences:int;// = 0 private var _url:String; private var _setup:Boolean;// = false private function ModuleInfo(url:String){ super(); _url = url; } private function clearLoader():void{ if (loader){ if (loader.contentLoaderInfo){ loader.contentLoaderInfo.removeEventListener(Event.INIT, initHandler); loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandler); loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler); loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, errorHandler); loader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler); }; if (loader.content){ loader.content.removeEventListener("ready", readyHandler); }; //unresolved jump var _slot1 = error; if (_loaded){ loader.close(); //unresolved jump var _slot1 = error; }; loader.unload(); //unresolved jump var _slot1 = error; loader = null; }; } public function get size():int{ return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.bytesTotal : 0); } public function get loaded():Boolean{ return ((limbo) ? false : _loaded); } public function release():void{ if (((_ready) && (!(limbo)))){ limbo = new Dictionary(true); limbo[factoryInfo] = 1; factoryInfo = null; } else { unload(); }; } public function get error():Boolean{ return ((limbo) ? false : _error); } public function get factory():IFlexModuleFactory{ return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.factory : null); } public function completeHandler(event:Event):void{ var moduleEvent:ModuleEvent = new ModuleEvent(ModuleEvent.PROGRESS, event.bubbles, event.cancelable); moduleEvent.bytesLoaded = loader.contentLoaderInfo.bytesLoaded; moduleEvent.bytesTotal = loader.contentLoaderInfo.bytesTotal; dispatchEvent(moduleEvent); } public function publish(factory:IFlexModuleFactory):void{ if (factoryInfo){ return; }; if (_url.indexOf("published://") != 0){ return; }; factoryInfo = new FactoryInfo(); factoryInfo.factory = factory; _loaded = true; _setup = true; _ready = true; _error = false; dispatchEvent(new ModuleEvent(ModuleEvent.SETUP)); dispatchEvent(new ModuleEvent(ModuleEvent.PROGRESS)); dispatchEvent(new ModuleEvent(ModuleEvent.READY)); } public function initHandler(event:Event):void{ var moduleEvent:ModuleEvent; var event = event; factoryInfo = new FactoryInfo(); factoryInfo.factory = (loader.content as IFlexModuleFactory); //unresolved jump var _slot1 = error; if (!factoryInfo.factory){ moduleEvent = new ModuleEvent(ModuleEvent.ERROR, event.bubbles, event.cancelable); moduleEvent.bytesLoaded = 0; moduleEvent.bytesTotal = 0; moduleEvent.errorText = "SWF is not a loadable module"; dispatchEvent(moduleEvent); return; }; loader.content.addEventListener("ready", readyHandler); factoryInfo.applicationDomain = loader.contentLoaderInfo.applicationDomain; //unresolved jump var _slot1 = error; _setup = true; dispatchEvent(new ModuleEvent(ModuleEvent.SETUP)); } public function resurrect():void{ var f:Object; if (((!(factoryInfo)) && (limbo))){ for (f in limbo) { factoryInfo = (f as FactoryInfo); break; }; limbo = null; }; if (!factoryInfo){ if (_loaded){ dispatchEvent(new ModuleEvent(ModuleEvent.UNLOAD)); }; loader = null; _loaded = false; _setup = false; _ready = false; _error = false; }; } public function errorHandler(event:ErrorEvent):void{ _error = true; var moduleEvent:ModuleEvent = new ModuleEvent(ModuleEvent.ERROR, event.bubbles, event.cancelable); moduleEvent.bytesLoaded = 0; moduleEvent.bytesTotal = 0; moduleEvent.errorText = event.text; dispatchEvent(moduleEvent); } public function get ready():Boolean{ return ((limbo) ? false : _ready); } public function removeReference():void{ numReferences--; if (numReferences == 0){ release(); }; } public function addReference():void{ numReferences++; } public function progressHandler(event:ProgressEvent):void{ var moduleEvent:ModuleEvent = new ModuleEvent(ModuleEvent.PROGRESS, event.bubbles, event.cancelable); moduleEvent.bytesLoaded = event.bytesLoaded; moduleEvent.bytesTotal = event.bytesTotal; dispatchEvent(moduleEvent); } public function load(applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):void{ if (_loaded){ return; }; _loaded = true; limbo = null; if (_url.indexOf("published://") == 0){ return; }; var r:URLRequest = new URLRequest(_url); var c:LoaderContext = new LoaderContext(); c.applicationDomain = (applicationDomain) ? applicationDomain : new ApplicationDomain(ApplicationDomain.currentDomain); c.securityDomain = securityDomain; if ((((securityDomain == null)) && ((Security.sandboxType == Security.REMOTE)))){ c.securityDomain = SecurityDomain.currentDomain; }; loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler); loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler); loader.load(r, c); } public function get url():String{ return (_url); } public function get applicationDomain():ApplicationDomain{ return ((((!(limbo)) && (factoryInfo))) ? factoryInfo.applicationDomain : null); } public function readyHandler(event:Event):void{ _ready = true; factoryInfo.bytesTotal = loader.contentLoaderInfo.bytesTotal; clearLoader(); dispatchEvent(new ModuleEvent(ModuleEvent.READY)); } public function get setup():Boolean{ return ((limbo) ? false : _setup); } public function unload():void{ clearLoader(); if (_loaded){ dispatchEvent(new ModuleEvent(ModuleEvent.UNLOAD)); }; limbo = null; factoryInfo = null; _loaded = false; _setup = false; _ready = false; _error = false; } } class FactoryInfo { public var bytesTotal:int;// = 0 public var factory:IFlexModuleFactory; public var applicationDomain:ApplicationDomain; private function FactoryInfo(){ super(); } }
Section 194
//ModuleManagerGlobals (mx.modules.ModuleManagerGlobals) package mx.modules { public class ModuleManagerGlobals { public static var managerSingleton:Object = null; public function ModuleManagerGlobals(){ super(); } } }//package mx.modules
Section 195
//DownloadProgressBar (mx.preloaders.DownloadProgressBar) package mx.preloaders { import mx.core.*; import flash.events.*; import flash.system.*; import flash.display.*; import flash.geom.*; import flash.text.*; import mx.events.*; import mx.graphics.*; import flash.net.*; import flash.utils.*; public class DownloadProgressBar extends Sprite implements IPreloaderDisplay { protected var MINIMUM_DISPLAY_TIME:uint;// = 0 private var _barFrameRect:RoundedRectangle; private var _stageHeight:Number;// = 375 private var _stageWidth:Number;// = 500 private var _percentRect:Rectangle; private var _percentObj:TextField; private var _downloadingLabel:String;// = "Loading" private var _showProgressBar:Boolean;// = true private var _yOffset:Number;// = 20 private var _initProgressCount:uint;// = 0 private var _barSprite:Sprite; private var _visible:Boolean;// = false private var _barRect:RoundedRectangle; private var _showingDisplay:Boolean;// = false private var _backgroundSize:String;// = "" private var _initProgressTotal:uint;// = 12 private var _startedInit:Boolean;// = false private var _showLabel:Boolean;// = true private var _value:Number;// = 0 private var _labelRect:Rectangle; private var _backgroundImage:Object; private var _backgroundAlpha:Number;// = 1 private var _backgroundColor:uint; private var _startedLoading:Boolean;// = false private var _showPercentage:Boolean;// = false private var _barFrameSprite:Sprite; protected var DOWNLOAD_PERCENTAGE:uint;// = 60 private var _displayStartCount:uint;// = 0 private var _labelObj:TextField; private var _borderRect:RoundedRectangle; private var _maximum:Number;// = 0 private var _displayTime:int; private var _label:String;// = "" private var _preloader:Sprite; private var _xOffset:Number;// = 20 private var _startTime:int; mx_internal static const VERSION:String = "3.0.0.0"; private static var _initializingLabel:String = "Initializing"; public function DownloadProgressBar(){ _labelRect = labelRect; _percentRect = percentRect; _borderRect = borderRect; _barFrameRect = barFrameRect; _barRect = barRect; super(); } protected function getPercentLoaded(loaded:Number, total:Number):Number{ var perc:Number; if ((((((((loaded == 0)) || ((total == 0)))) || (isNaN(total)))) || (isNaN(loaded)))){ return (0); }; perc = ((100 * loaded) / total); if (((isNaN(perc)) || ((perc <= 0)))){ return (0); }; if (perc > 99){ return (99); }; return (Math.round(perc)); } protected function get labelFormat():TextFormat{ var tf:TextFormat = new TextFormat(); tf.color = 0x333333; tf.font = "Verdana"; tf.size = 10; return (tf); } private function calcScale():void{ var scale:Number; if ((((stageWidth < 160)) || ((stageHeight < 120)))){ scaleX = 1; scaleY = 1; } else { if ((((stageWidth < 240)) || ((stageHeight < 150)))){ createChildren(); scale = Math.min((stageWidth / 240), (stageHeight / 150)); scaleX = scale; scaleY = scale; } else { createChildren(); }; }; } protected function get percentRect():Rectangle{ return (new Rectangle(108, 4, 34, 16)); } protected function set showLabel(value:Boolean):void{ _showLabel = value; draw(); } private function calcBackgroundSize():Number{ var index:int; var percentage:Number = NaN; if (backgroundSize){ index = backgroundSize.indexOf("%"); if (index != -1){ percentage = Number(backgroundSize.substr(0, index)); }; }; return (percentage); } private function show():void{ _showingDisplay = true; calcScale(); draw(); _displayTime = getTimer(); } private function loadBackgroundImage(classOrString:Object):void{ var cls:Class; var newStyleObj:DisplayObject; var loader:Loader; var loaderContext:LoaderContext; var classOrString = classOrString; if (((classOrString) && ((classOrString as Class)))){ cls = Class(classOrString); initBackgroundImage(new (cls)); } else { if (((classOrString) && ((classOrString is String)))){ cls = Class(getDefinitionByName(String(classOrString))); //unresolved jump var _slot1 = e; if (cls){ newStyleObj = new (cls); initBackgroundImage(newStyleObj); } else { loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loader_completeHandler); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loader_ioErrorHandler); loaderContext = new LoaderContext(); loaderContext.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); loader.load(new URLRequest(String(classOrString)), loaderContext); }; }; }; } protected function set showPercentage(value:Boolean):void{ _showPercentage = value; draw(); } protected function get barFrameRect():RoundedRectangle{ return (new RoundedRectangle(14, 40, 154, 4)); } private function loader_ioErrorHandler(event:IOErrorEvent):void{ } protected function rslErrorHandler(event:RSLEvent):void{ _preloader.removeEventListener(ProgressEvent.PROGRESS, progressHandler); _preloader.removeEventListener(Event.COMPLETE, completeHandler); _preloader.removeEventListener(RSLEvent.RSL_PROGRESS, rslProgressHandler); _preloader.removeEventListener(RSLEvent.RSL_COMPLETE, rslCompleteHandler); _preloader.removeEventListener(RSLEvent.RSL_ERROR, rslErrorHandler); _preloader.removeEventListener(FlexEvent.INIT_PROGRESS, initProgressHandler); _preloader.removeEventListener(FlexEvent.INIT_COMPLETE, initCompleteHandler); if (!_showingDisplay){ show(); _showingDisplay = true; }; label = ((("RSL Error " + (event.rslIndex + 1)) + " of ") + event.rslTotal); var errorField:ErrorField = new ErrorField(this.parent); errorField.show(event.errorText); } protected function rslCompleteHandler(event:RSLEvent):void{ label = ((("Loaded library " + event.rslIndex) + " of ") + event.rslTotal); } protected function get borderRect():RoundedRectangle{ return (new RoundedRectangle(0, 0, 182, 60, 4)); } protected function showDisplayForDownloading(elapsedTime:int, event:ProgressEvent):Boolean{ return ((((elapsedTime > 700)) && ((event.bytesLoaded < (event.bytesTotal / 2))))); } protected function createChildren():void{ var labelObj:TextField; var percentObj:TextField; var g:Graphics = graphics; if (backgroundColor != 4294967295){ g.beginFill(backgroundColor, backgroundAlpha); g.drawRect(0, 0, stageWidth, stageHeight); }; if (backgroundImage != null){ loadBackgroundImage(backgroundImage); }; _barFrameSprite = new Sprite(); _barSprite = new Sprite(); addChild(_barFrameSprite); addChild(_barSprite); g.beginFill(0xCCCCCC, 0.4); g.drawRoundRect(calcX(_borderRect.x), calcY(_borderRect.y), _borderRect.width, _borderRect.height, (_borderRect.cornerRadius * 2), (_borderRect.cornerRadius * 2)); g.drawRoundRect(calcX((_borderRect.x + 1)), calcY((_borderRect.y + 1)), (_borderRect.width - 2), (_borderRect.height - 2), (_borderRect.cornerRadius - (1 * 2)), (_borderRect.cornerRadius - (1 * 2))); g.endFill(); g.beginFill(0xCCCCCC, 0.4); g.drawRoundRect(calcX((_borderRect.x + 1)), calcY((_borderRect.y + 1)), (_borderRect.width - 2), (_borderRect.height - 2), (_borderRect.cornerRadius - (1 * 2)), (_borderRect.cornerRadius - (1 * 2))); g.endFill(); var frame_g:Graphics = _barFrameSprite.graphics; var matrix:Matrix = new Matrix(); matrix.createGradientBox(_barFrameRect.width, _barFrameRect.height, (Math.PI / 2), calcX(_barFrameRect.x), calcY(_barFrameRect.y)); frame_g.beginGradientFill(GradientType.LINEAR, [6054502, 11909306], [1, 1], [0, 0xFF], matrix); frame_g.drawRoundRect(calcX(_barFrameRect.x), calcY(_barFrameRect.y), _barFrameRect.width, _barFrameRect.height, (_barFrameRect.cornerRadius * 2), (_barFrameRect.cornerRadius * 2)); frame_g.drawRoundRect(calcX((_barFrameRect.x + 1)), calcY((_barFrameRect.y + 1)), (_barFrameRect.width - 2), (_barFrameRect.height - 2), (_barFrameRect.cornerRadius * 2), (_barFrameRect.cornerRadius * 2)); frame_g.endFill(); _labelObj = new TextField(); _labelObj.x = calcX(_labelRect.x); _labelObj.y = calcY(_labelRect.y); _labelObj.width = _labelRect.width; _labelObj.height = _labelRect.height; _labelObj.selectable = false; _labelObj.defaultTextFormat = labelFormat; addChild(_labelObj); _percentObj = new TextField(); _percentObj.x = calcX(_percentRect.x); _percentObj.y = calcY(_percentRect.y); _percentObj.width = _percentRect.width; _percentObj.height = _percentRect.height; _percentObj.selectable = false; _percentObj.defaultTextFormat = percentFormat; addChild(_percentObj); var ds:RectangularDropShadow = new RectangularDropShadow(); ds.color = 0; ds.angle = 90; ds.alpha = 0.6; ds.distance = 2; ds.tlRadius = (ds.trRadius = (ds.blRadius = (ds.brRadius = _borderRect.cornerRadius))); ds.drawShadow(g, calcX(_borderRect.x), calcY(_borderRect.y), _borderRect.width, _borderRect.height); g.lineStyle(1, 0xFFFFFF, 0.3); g.moveTo((calcX(_borderRect.x) + _borderRect.cornerRadius), calcY(_borderRect.y)); g.lineTo(((calcX(_borderRect.x) - _borderRect.cornerRadius) + _borderRect.width), calcY(_borderRect.y)); } private function draw():void{ var percentage:Number; if (_startedLoading){ if (!_startedInit){ percentage = Math.round(((getPercentLoaded(_value, _maximum) * DOWNLOAD_PERCENTAGE) / 100)); } else { percentage = Math.round((((getPercentLoaded(_value, _maximum) * (100 - DOWNLOAD_PERCENTAGE)) / 100) + DOWNLOAD_PERCENTAGE)); }; } else { percentage = getPercentLoaded(_value, _maximum); }; if (_labelObj){ _labelObj.text = _label; }; if (_percentObj){ if (!_showPercentage){ _percentObj.visible = false; _percentObj.text = ""; } else { _percentObj.text = (String(percentage) + "%"); }; }; if (((_barSprite) && (_barFrameSprite))){ if (!_showProgressBar){ _barSprite.visible = false; _barFrameSprite.visible = false; } else { drawProgressBar(percentage); }; }; } private function timerHandler(event:Event=null):void{ dispatchEvent(new Event(Event.COMPLETE)); } private function hide():void{ } public function get backgroundSize():String{ return (_backgroundSize); } protected function center(width:Number, height:Number):void{ _xOffset = Math.floor(((width - _borderRect.width) / 2)); _yOffset = Math.floor(((height - _borderRect.height) / 2)); } protected function progressHandler(event:ProgressEvent):void{ var loaded:uint = event.bytesLoaded; var total:uint = event.bytesTotal; var elapsedTime:int = (getTimer() - _startTime); if (((_showingDisplay) || (showDisplayForDownloading(elapsedTime, event)))){ if (!_startedLoading){ show(); label = downloadingLabel; _startedLoading = true; }; setProgress(event.bytesLoaded, event.bytesTotal); }; } protected function initProgressHandler(event:Event):void{ var loaded:Number; var elapsedTime:int = (getTimer() - _startTime); _initProgressCount++; if (((!(_showingDisplay)) && (showDisplayForInit(elapsedTime, _initProgressCount)))){ _displayStartCount = _initProgressCount; show(); } else { if (_showingDisplay){ if (!_startedInit){ _startedInit = true; label = initializingLabel; }; loaded = ((100 * _initProgressCount) / (_initProgressTotal - _displayStartCount)); setProgress(loaded, 100); }; }; } protected function set downloadingLabel(value:String):void{ _downloadingLabel = value; } public function get stageWidth():Number{ return (_stageWidth); } protected function get showPercentage():Boolean{ return (_showPercentage); } override public function get visible():Boolean{ return (_visible); } public function set stageHeight(value:Number):void{ _stageHeight = value; } public function initialize():void{ _startTime = getTimer(); center(stageWidth, stageHeight); } protected function rslProgressHandler(event:RSLEvent):void{ } protected function get barRect():RoundedRectangle{ return (new RoundedRectangle(14, 39, 154, 6, 0)); } protected function get percentFormat():TextFormat{ var tf:TextFormat = new TextFormat(); tf.align = "right"; tf.color = 0; tf.font = "Verdana"; tf.size = 10; return (tf); } public function set backgroundImage(value:Object):void{ _backgroundImage = value; } private function calcX(base:Number):Number{ return ((base + _xOffset)); } private function calcY(base:Number):Number{ return ((base + _yOffset)); } public function set backgroundAlpha(value:Number):void{ _backgroundAlpha = value; } private function initCompleteHandler(event:Event):void{ var timer:Timer; var elapsedTime:int = (getTimer() - _displayTime); if (((_showingDisplay) && ((elapsedTime < MINIMUM_DISPLAY_TIME)))){ timer = new Timer((MINIMUM_DISPLAY_TIME - elapsedTime), 1); timer.addEventListener(TimerEvent.TIMER, timerHandler); timer.start(); } else { timerHandler(); }; } public function set backgroundColor(value:uint):void{ _backgroundColor = value; } private function initBackgroundImage(image:DisplayObject):void{ var sX:Number; var sY:Number; var scale:Number; addChildAt(image, 0); var backgroundImageWidth:Number = image.width; var backgroundImageHeight:Number = image.height; var percentage:Number = calcBackgroundSize(); if (isNaN(percentage)){ sX = 1; sY = 1; } else { scale = (percentage * 0.01); sX = ((scale * stageWidth) / backgroundImageWidth); sY = ((scale * stageHeight) / backgroundImageHeight); }; image.scaleX = sX; image.scaleY = sY; var offsetX:Number = Math.round((0.5 * (stageWidth - (backgroundImageWidth * sX)))); var offsetY:Number = Math.round((0.5 * (stageHeight - (backgroundImageHeight * sY)))); image.x = offsetX; image.y = offsetY; if (!isNaN(backgroundAlpha)){ image.alpha = backgroundAlpha; }; } public function set backgroundSize(value:String):void{ _backgroundSize = value; } protected function showDisplayForInit(elapsedTime:int, count:int):Boolean{ return ((((elapsedTime > 300)) && ((count == 2)))); } protected function get downloadingLabel():String{ return (_downloadingLabel); } private function loader_completeHandler(event:Event):void{ var target:DisplayObject = DisplayObject(LoaderInfo(event.target).loader); initBackgroundImage(target); } protected function setProgress(completed:Number, total:Number):void{ if (((((((!(isNaN(completed))) && (!(isNaN(total))))) && ((completed >= 0)))) && ((total > 0)))){ _value = Number(completed); _maximum = Number(total); draw(); }; } public function get stageHeight():Number{ return (_stageHeight); } public function get backgroundImage():Object{ return (_backgroundImage); } public function get backgroundAlpha():Number{ if (!isNaN(_backgroundAlpha)){ return (_backgroundAlpha); }; return (1); } private function drawProgressBar(percentage:Number):void{ var barY2:Number; var g:Graphics = _barSprite.graphics; g.clear(); var colors:Array = [0xFFFFFF, 0xFFFFFF]; var ratios:Array = [0, 0xFF]; var matrix:Matrix = new Matrix(); var barWidth:Number = ((_barRect.width * percentage) / 100); var barWidthSplit:Number = (barWidth / 2); var barHeight:Number = (_barRect.height - 4); var barX:Number = calcX(_barRect.x); var barY:Number = (calcY(_barRect.y) + 2); matrix.createGradientBox(barWidthSplit, barHeight, 0, barX, barY); g.beginGradientFill(GradientType.LINEAR, colors, [0.39, 0.85], ratios, matrix); g.drawRect(barX, barY, barWidthSplit, barHeight); matrix.createGradientBox(barWidthSplit, barHeight, 0, (barX + barWidthSplit), barY); g.beginGradientFill(GradientType.LINEAR, colors, [0.85, 1], ratios, matrix); g.drawRect((barX + barWidthSplit), barY, barWidthSplit, barHeight); barWidthSplit = (barWidth / 3); barHeight = _barRect.height; barY = calcY(_barRect.y); barY2 = ((barY + barHeight) - 1); matrix.createGradientBox(barWidthSplit, barHeight, 0, barX, barY); g.beginGradientFill(GradientType.LINEAR, colors, [0.05, 0.15], ratios, matrix); g.drawRect(barX, barY, barWidthSplit, 1); g.drawRect(barX, barY2, barWidthSplit, 1); matrix.createGradientBox(barWidthSplit, barHeight, 0, (barX + barWidthSplit), barY); g.beginGradientFill(GradientType.LINEAR, colors, [0.15, 0.25], ratios, matrix); g.drawRect((barX + barWidthSplit), barY, barWidthSplit, 1); g.drawRect((barX + barWidthSplit), barY2, barWidthSplit, 1); matrix.createGradientBox(barWidthSplit, barHeight, 0, (barX + (barWidthSplit * 2)), barY); g.beginGradientFill(GradientType.LINEAR, colors, [0.25, 0.1], ratios, matrix); g.drawRect((barX + (barWidthSplit * 2)), barY, barWidthSplit, 1); g.drawRect((barX + (barWidthSplit * 2)), barY2, barWidthSplit, 1); barWidthSplit = (barWidth / 3); barHeight = _barRect.height; barY = (calcY(_barRect.y) + 1); barY2 = ((calcY(_barRect.y) + barHeight) - 2); matrix.createGradientBox(barWidthSplit, barHeight, 0, barX, barY); g.beginGradientFill(GradientType.LINEAR, colors, [0.15, 0.3], ratios, matrix); g.drawRect(barX, barY, barWidthSplit, 1); g.drawRect(barX, barY2, barWidthSplit, 1); matrix.createGradientBox(barWidthSplit, barHeight, 0, (barX + barWidthSplit), barY); g.beginGradientFill(GradientType.LINEAR, colors, [0.3, 0.4], ratios, matrix); g.drawRect((barX + barWidthSplit), barY, barWidthSplit, 1); g.drawRect((barX + barWidthSplit), barY2, barWidthSplit, 1); matrix.createGradientBox(barWidthSplit, barHeight, 0, (barX + (barWidthSplit * 2)), barY); g.beginGradientFill(GradientType.LINEAR, colors, [0.4, 0.25], ratios, matrix); g.drawRect((barX + (barWidthSplit * 2)), barY, barWidthSplit, 1); g.drawRect((barX + (barWidthSplit * 2)), barY2, barWidthSplit, 1); } public function get backgroundColor():uint{ return (_backgroundColor); } public function set stageWidth(value:Number):void{ _stageWidth = value; } protected function completeHandler(event:Event):void{ } protected function set label(value:String):void{ if (!(value is Function)){ _label = value; }; draw(); } public function set preloader(value:Sprite):void{ _preloader = value; value.addEventListener(ProgressEvent.PROGRESS, progressHandler); value.addEventListener(Event.COMPLETE, completeHandler); value.addEventListener(RSLEvent.RSL_PROGRESS, rslProgressHandler); value.addEventListener(RSLEvent.RSL_COMPLETE, rslCompleteHandler); value.addEventListener(RSLEvent.RSL_ERROR, rslErrorHandler); value.addEventListener(FlexEvent.INIT_PROGRESS, initProgressHandler); value.addEventListener(FlexEvent.INIT_COMPLETE, initCompleteHandler); } protected function get label():String{ return (_label); } protected function get labelRect():Rectangle{ return (new Rectangle(14, 17, 100, 16)); } override public function set visible(value:Boolean):void{ if (((!(_visible)) && (value))){ show(); } else { if (((_visible) && (!(value)))){ hide(); }; }; _visible = value; } protected function get showLabel():Boolean{ return (_showLabel); } public static function get initializingLabel():String{ return (_initializingLabel); } public static function set initializingLabel(value:String):void{ _initializingLabel = value; } } }//package mx.preloaders import flash.system.*; import flash.display.*; import flash.text.*; class ErrorField extends Sprite { private const TEXT_MARGIN_PX:int = 10; private const MAX_WIDTH_INCHES:int = 6; private const MIN_WIDTH_INCHES:int = 2; private var parentContainer:DisplayObjectContainer; private function ErrorField(parent:DisplayObjectContainer){ super(); this.parentContainer = parent; } public function show(errorText:String):void{ if ((((errorText == null)) || ((errorText.length == 0)))){ return; }; var stage:Stage = parentContainer.stage; var textField:TextField = new TextField(); textField.autoSize = TextFieldAutoSize.LEFT; textField.multiline = true; textField.wordWrap = true; textField.background = true; textField.defaultTextFormat = labelFormat; textField.text = errorText; textField.width = Math.max((MIN_WIDTH_INCHES * Capabilities.screenDPI), (stage.stageWidth - (TEXT_MARGIN_PX * 2))); textField.width = Math.min((MAX_WIDTH_INCHES * Capabilities.screenDPI), textField.width); textField.y = Math.max(0, ((stage.stageHeight - TEXT_MARGIN_PX) - textField.height)); textField.x = ((stage.stageWidth - textField.width) / 2); parentContainer.addChild(this); this.addChild(textField); } protected function get labelFormat():TextFormat{ var tf:TextFormat = new TextFormat(); tf.color = 0; tf.font = "Verdana"; tf.size = 10; return (tf); } }
Section 196
//IPreloaderDisplay (mx.preloaders.IPreloaderDisplay) package mx.preloaders { import flash.events.*; import flash.display.*; public interface IPreloaderDisplay extends IEventDispatcher { function set backgroundAlpha(E:\dev\3.0.x\frameworks\projects\framework\src;mx\preloaders;IPreloaderDisplay.as:Number):void; function get stageHeight():Number; function get stageWidth():Number; function set backgroundColor(E:\dev\3.0.x\frameworks\projects\framework\src;mx\preloaders;IPreloaderDisplay.as:uint):void; function set preloader(E:\dev\3.0.x\frameworks\projects\framework\src;mx\preloaders;IPreloaderDisplay.as:Sprite):void; function get backgroundImage():Object; function get backgroundSize():String; function get backgroundAlpha():Number; function set stageHeight(E:\dev\3.0.x\frameworks\projects\framework\src;mx\preloaders;IPreloaderDisplay.as:Number):void; function get backgroundColor():uint; function set stageWidth(E:\dev\3.0.x\frameworks\projects\framework\src;mx\preloaders;IPreloaderDisplay.as:Number):void; function set backgroundImage(E:\dev\3.0.x\frameworks\projects\framework\src;mx\preloaders;IPreloaderDisplay.as:Object):void; function set backgroundSize(E:\dev\3.0.x\frameworks\projects\framework\src;mx\preloaders;IPreloaderDisplay.as:String):void; function initialize():void; } }//package mx.preloaders
Section 197
//Preloader (mx.preloaders.Preloader) package mx.preloaders { import mx.core.*; import flash.events.*; import flash.display.*; import mx.events.*; import flash.utils.*; public class Preloader extends Sprite { private var app:IEventDispatcher;// = null private var showDisplay:Boolean; private var timer:Timer; private var rslDone:Boolean;// = false private var displayClass:IPreloaderDisplay;// = null private var rslListLoader:RSLListLoader; mx_internal static const VERSION:String = "3.0.0.0"; public function Preloader(){ super(); } private function getByteValues():Object{ var li:LoaderInfo = root.loaderInfo; var loaded:int = li.bytesLoaded; var total:int = li.bytesTotal; var n:int = (rslListLoader) ? rslListLoader.getItemCount() : 0; var i:int; while (i < n) { loaded = (loaded + rslListLoader.getItem(i).loaded); total = (total + rslListLoader.getItem(i).total); i++; }; return ({loaded:loaded, total:total}); } private function appProgressHandler(event:Event):void{ dispatchEvent(new FlexEvent(FlexEvent.INIT_PROGRESS)); } private function dispatchAppEndEvent(event:Object=null):void{ dispatchEvent(new FlexEvent(FlexEvent.INIT_COMPLETE)); if (!showDisplay){ displayClassCompleteHandler(null); }; } private function ioErrorHandler(event:IOErrorEvent):void{ } private function appCreationCompleteHandler(event:FlexEvent):void{ dispatchAppEndEvent(); } mx_internal function rslErrorHandler(event:ErrorEvent):void{ var index:int = rslListLoader.getIndex(); var item:RSLItem = rslListLoader.getItem(index); var rslEvent:RSLEvent = new RSLEvent(RSLEvent.RSL_ERROR); rslEvent.bytesLoaded = 0; rslEvent.bytesTotal = 0; rslEvent.rslIndex = index; rslEvent.rslTotal = rslListLoader.getItemCount(); rslEvent.url = item.urlRequest; rslEvent.errorText = decodeURI(event.text); dispatchEvent(rslEvent); } public function initialize(showDisplay:Boolean, displayClassName:Class, backgroundColor:uint, backgroundAlpha:Number, backgroundImage:Object, backgroundSize:String, displayWidth:Number, displayHeight:Number, libs:Array=null, sizes:Array=null, rslList:Array=null, resourceModuleURLs:Array=null):void{ var n:int; var i:int; var node:RSLItem; var resourceModuleNode:ResourceModuleRSLItem; if (((((!((libs == null))) || (!((sizes == null))))) && (!((rslList == null))))){ throw (new Error("RSLs may only be specified by using libs and sizes or rslList, not both.")); }; root.loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); if (((libs) && ((libs.length > 0)))){ if (rslList == null){ rslList = []; }; n = libs.length; i = 0; while (i < n) { node = new RSLItem(libs[i]); rslList.push(node); i++; }; }; if (((resourceModuleURLs) && ((resourceModuleURLs.length > 0)))){ n = resourceModuleURLs.length; i = 0; while (i < n) { resourceModuleNode = new ResourceModuleRSLItem(resourceModuleURLs[i]); rslList.push(resourceModuleNode); i++; }; }; rslListLoader = new RSLListLoader(rslList); this.showDisplay = showDisplay; timer = new Timer(10); timer.addEventListener(TimerEvent.TIMER, timerHandler); timer.start(); if (showDisplay){ displayClass = new (displayClassName); displayClass.addEventListener(Event.COMPLETE, displayClassCompleteHandler); addChild(DisplayObject(displayClass)); displayClass.backgroundColor = backgroundColor; displayClass.backgroundAlpha = backgroundAlpha; displayClass.backgroundImage = backgroundImage; displayClass.backgroundSize = backgroundSize; displayClass.stageWidth = displayWidth; displayClass.stageHeight = displayHeight; displayClass.initialize(); displayClass.preloader = this; }; if (rslListLoader.getItemCount() > 0){ rslListLoader.load(mx_internal::rslProgressHandler, mx_internal::rslCompleteHandler, mx_internal::rslErrorHandler, mx_internal::rslErrorHandler, mx_internal::rslErrorHandler); } else { rslDone = true; }; } mx_internal function rslProgressHandler(event:ProgressEvent):void{ var index:int = rslListLoader.getIndex(); var item:RSLItem = rslListLoader.getItem(index); var rslEvent:RSLEvent = new RSLEvent(RSLEvent.RSL_PROGRESS); rslEvent.bytesLoaded = event.bytesLoaded; rslEvent.bytesTotal = event.bytesTotal; rslEvent.rslIndex = index; rslEvent.rslTotal = rslListLoader.getItemCount(); rslEvent.url = item.urlRequest; dispatchEvent(rslEvent); } public function registerApplication(app:IEventDispatcher):void{ app.addEventListener("validatePropertiesComplete", appProgressHandler); app.addEventListener("validateSizeComplete", appProgressHandler); app.addEventListener("validateDisplayListComplete", appProgressHandler); app.addEventListener(FlexEvent.CREATION_COMPLETE, appCreationCompleteHandler); this.app = app; } mx_internal function rslCompleteHandler(event:Event):void{ var index:int = rslListLoader.getIndex(); var item:RSLItem = rslListLoader.getItem(index); var rslEvent:RSLEvent = new RSLEvent(RSLEvent.RSL_COMPLETE); rslEvent.bytesLoaded = item.total; rslEvent.bytesTotal = item.total; rslEvent.rslIndex = index; rslEvent.rslTotal = rslListLoader.getItemCount(); rslEvent.url = item.urlRequest; dispatchEvent(rslEvent); rslDone = ((index + 1) == rslEvent.rslTotal); } private function timerHandler(event:TimerEvent):void{ if (!root){ return; }; var bytes:Object = getByteValues(); var loaded:int = bytes.loaded; var total:int = bytes.total; dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS, false, false, loaded, total)); if (((rslDone) && ((((((((loaded >= total)) && ((total > 0)))) || ((((total == 0)) && ((loaded > 0)))))) || ((((((root is MovieClip)) && ((MovieClip(root).totalFrames > 2)))) && ((MovieClip(root).framesLoaded >= 2)))))))){ timer.removeEventListener(TimerEvent.TIMER, timerHandler); timer.reset(); dispatchEvent(new Event(Event.COMPLETE)); dispatchEvent(new FlexEvent(FlexEvent.INIT_PROGRESS)); }; } private function displayClassCompleteHandler(event:Event):void{ if (displayClass){ displayClass.removeEventListener(Event.COMPLETE, displayClassCompleteHandler); }; if (root){ root.loaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); }; if (app){ app.removeEventListener("validatePropertiesComplete", appProgressHandler); app.removeEventListener("validateSizeComplete", appProgressHandler); app.removeEventListener("validateDisplayListComplete", appProgressHandler); app.removeEventListener(FlexEvent.CREATION_COMPLETE, appCreationCompleteHandler); app = null; }; dispatchEvent(new FlexEvent(FlexEvent.PRELOADER_DONE)); } } }//package mx.preloaders
Section 198
//IResourceBundle (mx.resources.IResourceBundle) package mx.resources { public interface IResourceBundle { function get content():Object; function get locale():String; function get bundleName():String; } }//package mx.resources
Section 199
//IResourceManager (mx.resources.IResourceManager) package mx.resources { import flash.events.*; import flash.system.*; public interface IResourceManager extends IEventDispatcher { function loadResourceModule(_arg1:String, _arg2:Boolean=true, _arg3:ApplicationDomain=null, _arg4:SecurityDomain=null):IEventDispatcher; function getBoolean(_arg1:String, _arg2:String, _arg3:String=null):Boolean; function getClass(_arg1:String, _arg2:String, _arg3:String=null):Class; function getLocales():Array; function removeResourceBundlesForLocale(E:\dev\3.0.x\frameworks\projects\framework\src;mx\resources;IResourceManager.as:String):void; function getResourceBundle(_arg1:String, _arg2:String):IResourceBundle; function get localeChain():Array; function getInt(_arg1:String, _arg2:String, _arg3:String=null):int; function update():void; function set localeChain(E:\dev\3.0.x\frameworks\projects\framework\src;mx\resources;IResourceManager.as:Array):void; function getUint(_arg1:String, _arg2:String, _arg3:String=null):uint; function addResourceBundle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\resources;IResourceManager.as:IResourceBundle):void; function getStringArray(_arg1:String, _arg2:String, _arg3:String=null):Array; function getBundleNamesForLocale(:String):Array; function removeResourceBundle(_arg1:String, _arg2:String):void; function getObject(_arg1:String, _arg2:String, _arg3:String=null); function getString(_arg1:String, _arg2:String, _arg3:Array=null, _arg4:String=null):String; function installCompiledResourceBundles(_arg1:ApplicationDomain, _arg2:Array, _arg3:Array):void; function unloadResourceModule(_arg1:String, _arg2:Boolean=true):void; function findResourceBundleWithResource(_arg1:String, _arg2:String):IResourceBundle; function getNumber(_arg1:String, _arg2:String, _arg3:String=null):Number; } }//package mx.resources
Section 200
//IResourceModule (mx.resources.IResourceModule) package mx.resources { public interface IResourceModule { function get resourceBundles():Array; } }//package mx.resources
Section 201
//ResourceBundle (mx.resources.ResourceBundle) package mx.resources { import mx.core.*; import flash.system.*; import mx.utils.*; public class ResourceBundle implements IResourceBundle { mx_internal var _locale:String; private var _content:Object; mx_internal var _bundleName:String; mx_internal static const VERSION:String = "3.0.0.0"; mx_internal static var backupApplicationDomain:ApplicationDomain; mx_internal static var locale:String; public function ResourceBundle(locale:String=null, bundleName:String=null){ _content = {}; super(); mx_internal::_locale = locale; mx_internal::_bundleName = bundleName; _content = getContent(); } protected function getContent():Object{ return ({}); } public function getString(key:String):String{ return (String(_getObject(key))); } public function get content():Object{ return (_content); } public function getBoolean(key:String, defaultValue:Boolean=true):Boolean{ var temp:String = _getObject(key).toLowerCase(); if (temp == "false"){ return (false); }; if (temp == "true"){ return (true); }; return (defaultValue); } public function getStringArray(key:String):Array{ var array:Array = _getObject(key).split(","); var n:int = array.length; var i:int; while (i < n) { array[i] = StringUtil.trim(array[i]); i++; }; return (array); } public function getObject(key:String):Object{ return (_getObject(key)); } private function _getObject(key:String):Object{ var value:Object = content[key]; if (!value){ throw (new Error(((("Key " + key) + " was not found in resource bundle ") + bundleName))); }; return (value); } public function get locale():String{ return (mx_internal::_locale); } public function get bundleName():String{ return (mx_internal::_bundleName); } public function getNumber(key:String):Number{ return (Number(_getObject(key))); } private static function getClassByName(name:String, domain:ApplicationDomain):Class{ var c:Class; if (domain.hasDefinition(name)){ c = (domain.getDefinition(name) as Class); }; return (c); } public static function getResourceBundle(baseName:String, currentDomain:ApplicationDomain=null):ResourceBundle{ var className:String; var bundleClass:Class; var bundleObj:Object; var bundle:ResourceBundle; if (!currentDomain){ currentDomain = ApplicationDomain.currentDomain; }; className = (((mx_internal::locale + "$") + baseName) + "_properties"); bundleClass = getClassByName(className, currentDomain); if (!bundleClass){ className = (baseName + "_properties"); bundleClass = getClassByName(className, currentDomain); }; if (!bundleClass){ className = baseName; bundleClass = getClassByName(className, currentDomain); }; if (((!(bundleClass)) && (mx_internal::backupApplicationDomain))){ className = (baseName + "_properties"); bundleClass = getClassByName(className, mx_internal::backupApplicationDomain); if (!bundleClass){ className = baseName; bundleClass = getClassByName(className, mx_internal::backupApplicationDomain); }; }; if (bundleClass){ bundleObj = new (bundleClass); if ((bundleObj is ResourceBundle)){ bundle = ResourceBundle(bundleObj); return (bundle); }; }; throw (new Error(("Could not find resource bundle " + baseName))); } } }//package mx.resources
Section 202
//ResourceManager (mx.resources.ResourceManager) package mx.resources { import mx.core.*; public class ResourceManager { mx_internal static const VERSION:String = "3.0.0.0"; private static var implClassDependency:ResourceManagerImpl; private static var instance:IResourceManager; public function ResourceManager(){ super(); } public static function getInstance():IResourceManager{ if (!instance){ instance = IResourceManager(Singleton.getInstance("mx.resources::IResourceManager")); }; return (instance); } } }//package mx.resources
Section 203
//ResourceManagerImpl (mx.resources.ResourceManagerImpl) package mx.resources { import mx.core.*; import flash.events.*; import flash.system.*; import mx.modules.*; import mx.events.*; import flash.utils.*; import mx.utils.*; public class ResourceManagerImpl extends EventDispatcher implements IResourceManager { private var resourceModules:Object; private var initializedForNonFrameworkApp:Boolean;// = false private var localeMap:Object; private var _localeChain:Array; mx_internal static const VERSION:String = "3.0.0.0"; private static var instance:IResourceManager; public function ResourceManagerImpl(){ localeMap = {}; resourceModules = {}; super(); } public function get localeChain():Array{ return (_localeChain); } public function set localeChain(value:Array):void{ _localeChain = value; update(); } public function getStringArray(bundleName:String, resourceName:String, locale:String=null):Array{ var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale); if (!resourceBundle){ return (null); }; var value:* = resourceBundle.content[resourceName]; var array:Array = String(value).split(","); var n:int = array.length; var i:int; while (i < n) { array[i] = StringUtil.trim(array[i]); i++; }; return (array); } mx_internal function installCompiledResourceBundle(applicationDomain:ApplicationDomain, locale:String, bundleName:String):void{ var packageName:String; var localName:String = bundleName; var colonIndex:int = bundleName.indexOf(":"); if (colonIndex != -1){ packageName = bundleName.substring(0, colonIndex); localName = bundleName.substring((colonIndex + 1)); }; if (getResourceBundle(locale, bundleName)){ return; }; var resourceBundleClassName = (((locale + "$") + localName) + "_properties"); if (packageName != null){ resourceBundleClassName = ((packageName + ".") + resourceBundleClassName); }; var bundleClass:Class; if (applicationDomain.hasDefinition(resourceBundleClassName)){ bundleClass = Class(applicationDomain.getDefinition(resourceBundleClassName)); }; if (!bundleClass){ resourceBundleClassName = bundleName; if (applicationDomain.hasDefinition(resourceBundleClassName)){ bundleClass = Class(applicationDomain.getDefinition(resourceBundleClassName)); }; }; if (!bundleClass){ resourceBundleClassName = (bundleName + "_properties"); if (applicationDomain.hasDefinition(resourceBundleClassName)){ bundleClass = Class(applicationDomain.getDefinition(resourceBundleClassName)); }; }; if (!bundleClass){ throw (new Error((((("Could not find compiled resource bundle '" + bundleName) + "' for locale '") + locale) + "'."))); }; var resourceBundle:ResourceBundle = ResourceBundle(new (bundleClass)); resourceBundle.mx_internal::_locale = locale; resourceBundle.mx_internal::_bundleName = bundleName; addResourceBundle(resourceBundle); } public function getString(bundleName:String, resourceName:String, parameters:Array=null, locale:String=null):String{ var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale); if (!resourceBundle){ return (null); }; var value:String = String(resourceBundle.content[resourceName]); if (parameters){ value = StringUtil.substitute(value, parameters); }; return (value); } public function loadResourceModule(url:String, updateFlag:Boolean=true, applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):IEventDispatcher{ var moduleInfo:IModuleInfo; var resourceEventDispatcher:ResourceEventDispatcher; var timer:Timer; var timerHandler:Function; var url = url; var updateFlag = updateFlag; var applicationDomain = applicationDomain; var securityDomain = securityDomain; moduleInfo = ModuleManager.getModule(url); resourceEventDispatcher = new ResourceEventDispatcher(moduleInfo); var readyHandler:Function = function (event:ModuleEvent):void{ var resourceModule:* = event.module.factory.create(); resourceModules[event.module.url].resourceModule = resourceModule; if (updateFlag){ update(); }; }; moduleInfo.addEventListener(ModuleEvent.READY, readyHandler, false, 0, true); var errorHandler:Function = function (event:ModuleEvent):void{ var resourceEvent:ResourceEvent; var message:String = ("Unable to load resource module from " + url); if (resourceEventDispatcher.willTrigger(ResourceEvent.ERROR)){ resourceEvent = new ResourceEvent(ResourceEvent.ERROR, event.bubbles, event.cancelable); resourceEvent.bytesLoaded = 0; resourceEvent.bytesTotal = 0; resourceEvent.errorText = message; resourceEventDispatcher.dispatchEvent(resourceEvent); } else { throw (new Error(message)); }; }; moduleInfo.addEventListener(ModuleEvent.ERROR, errorHandler, false, 0, true); resourceModules[url] = new ResourceModuleInfo(moduleInfo, readyHandler, errorHandler); timer = new Timer(0); timerHandler = function (event:TimerEvent):void{ timer.removeEventListener(TimerEvent.TIMER, timerHandler); timer.stop(); moduleInfo.load(applicationDomain, securityDomain); }; timer.addEventListener(TimerEvent.TIMER, timerHandler, false, 0, true); timer.start(); return (resourceEventDispatcher); } public function getLocales():Array{ var p:String; var locales:Array = []; for (p in localeMap) { locales.push(p); }; return (locales); } public function removeResourceBundlesForLocale(locale:String):void{ delete localeMap[locale]; } public function getResourceBundle(locale:String, bundleName:String):IResourceBundle{ var bundleMap:Object = localeMap[locale]; if (!bundleMap){ return (null); }; return (bundleMap[bundleName]); } private function dumpResourceModule(resourceModule):void{ var bundle:ResourceBundle; var p:String; for each (bundle in resourceModule.resourceBundles) { trace(bundle.locale, bundle.bundleName); for (p in bundle.content) { }; }; } public function getObject(bundleName:String, resourceName:String, locale:String=null){ var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale); if (!resourceBundle){ return (undefined); }; return (resourceBundle.content[resourceName]); } public function addResourceBundle(resourceBundle:IResourceBundle):void{ var locale:String = resourceBundle.locale; var bundleName:String = resourceBundle.bundleName; if (!localeMap[locale]){ localeMap[locale] = {}; }; localeMap[locale][bundleName] = resourceBundle; } private function findBundle(bundleName:String, resourceName:String, locale:String):IResourceBundle{ supportNonFrameworkApps(); return (((locale)!=null) ? getResourceBundle(locale, bundleName) : findResourceBundleWithResource(bundleName, resourceName)); } public function getInt(bundleName:String, resourceName:String, locale:String=null):int{ var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale); if (!resourceBundle){ return (0); }; var value:* = resourceBundle.content[resourceName]; return (int(value)); } private function supportNonFrameworkApps():void{ if (initializedForNonFrameworkApp){ return; }; initializedForNonFrameworkApp = true; if (getLocales().length > 0){ return; }; var applicationDomain:ApplicationDomain = ApplicationDomain.currentDomain; if (!applicationDomain.hasDefinition("_CompiledResourceBundleInfo")){ return; }; var c:Class = Class(applicationDomain.getDefinition("_CompiledResourceBundleInfo")); var locales:Array = c.compiledLocales; var bundleNames:Array = c.compiledResourceBundleNames; installCompiledResourceBundles(applicationDomain, locales, bundleNames); localeChain = locales; } public function getClass(bundleName:String, resourceName:String, locale:String=null):Class{ var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale); if (!resourceBundle){ return (null); }; var value:* = resourceBundle.content[resourceName]; return ((value as Class)); } public function getNumber(bundleName:String, resourceName:String, locale:String=null):Number{ var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale); if (!resourceBundle){ return (NaN); }; var value:* = resourceBundle.content[resourceName]; return (Number(value)); } public function update():void{ dispatchEvent(new Event(Event.CHANGE)); } public function getBundleNamesForLocale(locale:String):Array{ var p:String; var bundleNames:Array = []; for (p in localeMap[locale]) { bundleNames.push(p); }; return (bundleNames); } public function removeResourceBundle(locale:String, bundleName:String):void{ delete localeMap[locale][bundleName]; if (getBundleNamesForLocale(locale).length == 0){ delete localeMap[locale]; }; } public function installCompiledResourceBundles(applicationDomain:ApplicationDomain, locales:Array, bundleNames:Array):void{ var locale:String; var j:int; var bundleName:String; var n:int = (locales) ? locales.length : 0; var m:int = (bundleNames) ? bundleNames.length : 0; var i:int; while (i < n) { locale = locales[i]; j = 0; while (j < m) { bundleName = bundleNames[j]; mx_internal::installCompiledResourceBundle(applicationDomain, locale, bundleName); j++; }; i++; }; } public function findResourceBundleWithResource(bundleName:String, resourceName:String):IResourceBundle{ var locale:String; var bundleMap:Object; var bundle:ResourceBundle; if (!_localeChain){ return (null); }; var n:int = _localeChain.length; var i:int; while (i < n) { locale = localeChain[i]; bundleMap = localeMap[locale]; if (!bundleMap){ } else { bundle = bundleMap[bundleName]; if (!bundle){ } else { if ((resourceName in bundle.content)){ return (bundle); }; }; }; i++; }; return (null); } public function getUint(bundleName:String, resourceName:String, locale:String=null):uint{ var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale); if (!resourceBundle){ return (0); }; var value:* = resourceBundle.content[resourceName]; return (uint(value)); } public function getBoolean(bundleName:String, resourceName:String, locale:String=null):Boolean{ var resourceBundle:IResourceBundle = findBundle(bundleName, resourceName, locale); if (!resourceBundle){ return (false); }; var value:* = resourceBundle.content[resourceName]; return ((String(value).toLowerCase() == "true")); } public function unloadResourceModule(url:String, update:Boolean=true):void{ throw (new Error("unloadResourceModule() is not yet implemented.")); } public static function getInstance():IResourceManager{ if (!instance){ instance = new (ResourceManagerImpl); }; return (instance); } } }//package mx.resources import flash.events.*; import mx.modules.*; import mx.events.*; class ResourceModuleInfo { public var resourceModule:IResourceModule; public var errorHandler:Function; public var readyHandler:Function; public var moduleInfo:IModuleInfo; private function ResourceModuleInfo(moduleInfo:IModuleInfo, readyHandler:Function, errorHandler:Function){ super(); this.moduleInfo = moduleInfo; this.readyHandler = readyHandler; this.errorHandler = errorHandler; } } class ResourceEventDispatcher extends EventDispatcher { private function ResourceEventDispatcher(moduleInfo:IModuleInfo){ super(); moduleInfo.addEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler, false, 0, true); moduleInfo.addEventListener(ModuleEvent.PROGRESS, moduleInfo_progressHandler, false, 0, true); moduleInfo.addEventListener(ModuleEvent.READY, moduleInfo_readyHandler, false, 0, true); } private function moduleInfo_progressHandler(event:ModuleEvent):void{ var resourceEvent:ResourceEvent = new ResourceEvent(ResourceEvent.PROGRESS, event.bubbles, event.cancelable); resourceEvent.bytesLoaded = event.bytesLoaded; resourceEvent.bytesTotal = event.bytesTotal; dispatchEvent(resourceEvent); } private function moduleInfo_readyHandler(event:ModuleEvent):void{ var resourceEvent:ResourceEvent = new ResourceEvent(ResourceEvent.COMPLETE); dispatchEvent(resourceEvent); } private function moduleInfo_errorHandler(event:ModuleEvent):void{ var resourceEvent:ResourceEvent = new ResourceEvent(ResourceEvent.ERROR, event.bubbles, event.cancelable); resourceEvent.bytesLoaded = event.bytesLoaded; resourceEvent.bytesTotal = event.bytesTotal; resourceEvent.errorText = event.errorText; dispatchEvent(resourceEvent); } }
Section 204
//IResponder (mx.rpc.IResponder) package mx.rpc { public interface IResponder { function fault(:Object):void; function result(:Object):void; } }//package mx.rpc
Section 205
//ButtonSkin (mx.skins.halo.ButtonSkin) package mx.skins.halo { import mx.core.*; import mx.styles.*; import flash.display.*; import mx.skins.*; import mx.utils.*; public class ButtonSkin extends Border { mx_internal static const VERSION:String = "3.0.0.0"; private static var cache:Object = {}; public function ButtonSkin(){ super(); } override public function get measuredWidth():Number{ return (UIComponent.DEFAULT_MEASURED_MIN_WIDTH); } override public function get measuredHeight():Number{ return (UIComponent.DEFAULT_MEASURED_MIN_HEIGHT); } override protected function updateDisplayList(w:Number, h:Number):void{ var tmp:Number; var upFillColors:Array; var upFillAlphas:Array; var overFillColors:Array; var overFillAlphas:Array; var disFillColors:Array; var disFillAlphas:Array; super.updateDisplayList(w, h); var borderColor:uint = getStyle("borderColor"); var cornerRadius:Number = getStyle("cornerRadius"); var fillAlphas:Array = getStyle("fillAlphas"); var fillColors:Array = getStyle("fillColors"); StyleManager.getColorNames(fillColors); var highlightAlphas:Array = getStyle("highlightAlphas"); var themeColor:uint = getStyle("themeColor"); var derStyles:Object = calcDerivedStyles(themeColor, fillColors[0], fillColors[1]); var borderColorDrk1:Number = ColorUtil.adjustBrightness2(borderColor, -50); var themeColorDrk1:Number = ColorUtil.adjustBrightness2(themeColor, -25); var emph:Boolean; if ((parent is IButton)){ emph = IButton(parent).emphasized; }; var cr:Number = Math.max(0, cornerRadius); var cr1:Number = Math.max(0, (cornerRadius - 1)); var cr2:Number = Math.max(0, (cornerRadius - 2)); graphics.clear(); switch (name){ case "selectedUpSkin": case "selectedOverSkin": drawRoundRect(0, 0, w, h, cr, [themeColor, themeColorDrk1], 1, verticalGradientMatrix(0, 0, w, h)); drawRoundRect(1, 1, (w - 2), (h - 2), cr1, [fillColors[1], fillColors[1]], 1, verticalGradientMatrix(0, 0, (w - 2), (h - 2))); break; case "upSkin": upFillColors = [fillColors[0], fillColors[1]]; upFillAlphas = [fillAlphas[0], fillAlphas[1]]; if (emph){ drawRoundRect(0, 0, w, h, cr, [themeColor, themeColorDrk1], 1, verticalGradientMatrix(0, 0, w, h), GradientType.LINEAR, null, {x:2, y:2, w:(w - 4), h:(h - 4), r:(cornerRadius - 2)}); drawRoundRect(2, 2, (w - 4), (h - 4), cr2, upFillColors, upFillAlphas, verticalGradientMatrix(2, 2, (w - 2), (h - 2))); drawRoundRect(2, 2, (w - 4), ((h - 4) / 2), {tl:cr2, tr:cr2, bl:0, br:0}, [0xFFFFFF, 0xFFFFFF], highlightAlphas, verticalGradientMatrix(1, 1, (w - 2), ((h - 2) / 2))); } else { drawRoundRect(0, 0, w, h, cr, [borderColor, borderColorDrk1], 1, verticalGradientMatrix(0, 0, w, h), GradientType.LINEAR, null, {x:1, y:1, w:(w - 2), h:(h - 2), r:(cornerRadius - 1)}); drawRoundRect(1, 1, (w - 2), (h - 2), cr1, upFillColors, upFillAlphas, verticalGradientMatrix(1, 1, (w - 2), (h - 2))); drawRoundRect(1, 1, (w - 2), ((h - 2) / 2), {tl:cr1, tr:cr1, bl:0, br:0}, [0xFFFFFF, 0xFFFFFF], highlightAlphas, verticalGradientMatrix(1, 1, (w - 2), ((h - 2) / 2))); }; break; case "overSkin": if (fillColors.length > 2){ overFillColors = [fillColors[2], fillColors[3]]; } else { overFillColors = [fillColors[0], fillColors[1]]; }; if (fillAlphas.length > 2){ overFillAlphas = [fillAlphas[2], fillAlphas[3]]; } else { overFillAlphas = [fillAlphas[0], fillAlphas[1]]; }; drawRoundRect(0, 0, w, h, cr, [themeColor, themeColorDrk1], 1, verticalGradientMatrix(0, 0, w, h), GradientType.LINEAR, null, {x:1, y:1, w:(w - 2), h:(h - 2), r:(cornerRadius - 1)}); drawRoundRect(1, 1, (w - 2), (h - 2), cr1, overFillColors, overFillAlphas, verticalGradientMatrix(1, 1, (w - 2), (h - 2))); drawRoundRect(1, 1, (w - 2), ((h - 2) / 2), {tl:cr1, tr:cr1, bl:0, br:0}, [0xFFFFFF, 0xFFFFFF], highlightAlphas, verticalGradientMatrix(1, 1, (w - 2), ((h - 2) / 2))); break; case "downSkin": case "selectedDownSkin": drawRoundRect(0, 0, w, h, cr, [themeColor, themeColorDrk1], 1, verticalGradientMatrix(0, 0, w, h)); drawRoundRect(1, 1, (w - 2), (h - 2), cr1, [derStyles.fillColorPress1, derStyles.fillColorPress2], 1, verticalGradientMatrix(1, 1, (w - 2), (h - 2))); drawRoundRect(2, 2, (w - 4), ((h - 4) / 2), {tl:cr2, tr:cr2, bl:0, br:0}, [0xFFFFFF, 0xFFFFFF], highlightAlphas, verticalGradientMatrix(1, 1, (w - 2), ((h - 2) / 2))); break; case "disabledSkin": case "selectedDisabledSkin": disFillColors = [fillColors[0], fillColors[1]]; disFillAlphas = [Math.max(0, (fillAlphas[0] - 0.15)), Math.max(0, (fillAlphas[1] - 0.15))]; drawRoundRect(0, 0, w, h, cr, [borderColor, borderColorDrk1], 0.5, verticalGradientMatrix(0, 0, w, h), GradientType.LINEAR, null, {x:1, y:1, w:(w - 2), h:(h - 2), r:(cornerRadius - 1)}); drawRoundRect(1, 1, (w - 2), (h - 2), cr1, disFillColors, disFillAlphas, verticalGradientMatrix(1, 1, (w - 2), (h - 2))); break; }; } private static function calcDerivedStyles(themeColor:uint, fillColor0:uint, fillColor1:uint):Object{ var o:Object; var key:String = HaloColors.getCacheKey(themeColor, fillColor0, fillColor1); if (!cache[key]){ o = (cache[key] = {}); HaloColors.addHaloColors(o, themeColor, fillColor0, fillColor1); }; return (cache[key]); } } }//package mx.skins.halo
Section 206
//HaloBorder (mx.skins.halo.HaloBorder) package mx.skins.halo { import mx.core.*; import mx.styles.*; import flash.display.*; import mx.graphics.*; import mx.skins.*; import mx.utils.*; public class HaloBorder extends RectangularBorder { mx_internal var radiusObj:Object; mx_internal var backgroundHole:Object; mx_internal var radius:Number; mx_internal var bRoundedCorners:Boolean; mx_internal var backgroundColor:Object; private var dropShadow:RectangularDropShadow; protected var _borderMetrics:EdgeMetrics; mx_internal var backgroundAlphaName:String; mx_internal static const VERSION:String = "3.0.0.0"; private static var BORDER_WIDTHS:Object = {none:0, solid:1, inset:2, outset:2, alert:3, dropdown:2, menuBorder:1, comboNonEdit:2}; public function HaloBorder(){ super(); BORDER_WIDTHS["default"] = 3; } override public function styleChanged(styleProp:String):void{ if ((((((((((styleProp == null)) || ((styleProp == "styleName")))) || ((styleProp == "borderStyle")))) || ((styleProp == "borderThickness")))) || ((styleProp == "borderSides")))){ _borderMetrics = null; }; invalidateDisplayList(); } override protected function updateDisplayList(w:Number, h:Number):void{ if (((isNaN(w)) || (isNaN(h)))){ return; }; super.updateDisplayList(w, h); backgroundColor = getBackgroundColor(); bRoundedCorners = false; backgroundAlphaName = "backgroundAlpha"; backgroundHole = null; radius = 0; radiusObj = null; drawBorder(w, h); drawBackground(w, h); } mx_internal function drawBorder(w:Number, h:Number):void{ var backgroundAlpha:Number; var borderCapColor:uint; var borderColor:uint; var borderSides:String; var borderThickness:Number; var buttonColor:uint; var docked:Boolean; var dropdownBorderColor:uint; var fillColors:Array; var footerColors:Array; var highlightColor:uint; var shadowCapColor:uint; var shadowColor:uint; var themeColor:uint; var translucent:Boolean; var hole:Object; var borderColorDrk1:Number; var borderColorDrk2:Number; var borderColorLt1:Number; var borderInnerColor:Object; var contentAlpha:Number; var br:Number; var parentContainer:IContainer; var vm:EdgeMetrics; var showChrome:Boolean; var borderAlpha:Number; var fillAlphas:Array; var backgroundColorNum:uint; var bHasAllSides:Boolean; var holeRadius:Number; var borderStyle:String = getStyle("borderStyle"); var highlightAlphas:Array = getStyle("highlightAlphas"); var drawTopHighlight:Boolean; var g:Graphics = graphics; g.clear(); if (borderStyle){ switch (borderStyle){ case "none": break; case "inset": borderColor = getStyle("borderColor"); borderColorDrk1 = ColorUtil.adjustBrightness2(borderColor, -40); borderColorDrk2 = ColorUtil.adjustBrightness2(borderColor, 25); borderColorLt1 = ColorUtil.adjustBrightness2(borderColor, 40); borderInnerColor = backgroundColor; if ((((borderInnerColor === null)) || ((borderInnerColor === "")))){ borderInnerColor = borderColor; }; draw3dBorder(borderColorDrk2, borderColorDrk1, borderColorLt1, Number(borderInnerColor), Number(borderInnerColor), Number(borderInnerColor)); break; case "outset": borderColor = getStyle("borderColor"); borderColorDrk1 = ColorUtil.adjustBrightness2(borderColor, -40); borderColorDrk2 = ColorUtil.adjustBrightness2(borderColor, -25); borderColorLt1 = ColorUtil.adjustBrightness2(borderColor, 40); borderInnerColor = backgroundColor; if ((((borderInnerColor === null)) || ((borderInnerColor === "")))){ borderInnerColor = borderColor; }; draw3dBorder(borderColorDrk2, borderColorLt1, borderColorDrk1, Number(borderInnerColor), Number(borderInnerColor), Number(borderInnerColor)); break; case "alert": case "default": if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0){ contentAlpha = getStyle("backgroundAlpha"); backgroundAlpha = getStyle("borderAlpha"); backgroundAlphaName = "borderAlpha"; radius = getStyle("cornerRadius"); bRoundedCorners = (getStyle("roundedBottomCorners").toString().toLowerCase() == "true"); br = (bRoundedCorners) ? radius : 0; drawDropShadow(0, 0, w, h, radius, radius, br, br); if (!bRoundedCorners){ radiusObj = {}; }; parentContainer = (parent as IContainer); if (parentContainer){ vm = parentContainer.viewMetrics; backgroundHole = {x:vm.left, y:vm.top, w:Math.max(0, ((w - vm.left) - vm.right)), h:Math.max(0, ((h - vm.top) - vm.bottom)), r:0}; if ((((backgroundHole.w > 0)) && ((backgroundHole.h > 0)))){ if (contentAlpha != backgroundAlpha){ drawDropShadow(backgroundHole.x, backgroundHole.y, backgroundHole.w, backgroundHole.h, 0, 0, 0, 0); }; g.beginFill(Number(backgroundColor), contentAlpha); g.drawRect(backgroundHole.x, backgroundHole.y, backgroundHole.w, backgroundHole.h); g.endFill(); }; }; backgroundColor = getStyle("borderColor"); }; break; case "dropdown": dropdownBorderColor = getStyle("dropdownBorderColor"); drawDropShadow(0, 0, w, h, 4, 0, 0, 4); drawRoundRect(0, 0, w, h, {tl:4, tr:0, br:0, bl:4}, 5068126, 1); drawRoundRect(0, 0, w, h, {tl:4, tr:0, br:0, bl:4}, [0xFFFFFF, 0xFFFFFF], [0.7, 0], verticalGradientMatrix(0, 0, w, h)); drawRoundRect(1, 1, (w - 1), (h - 2), {tl:3, tr:0, br:0, bl:3}, 0xFFFFFF, 1); drawRoundRect(1, 2, (w - 1), (h - 3), {tl:3, tr:0, br:0, bl:3}, [0xEEEEEE, 0xFFFFFF], 1, verticalGradientMatrix(0, 0, (w - 1), (h - 3))); if (!isNaN(dropdownBorderColor)){ drawRoundRect(0, 0, (w + 1), h, {tl:4, tr:0, br:0, bl:4}, dropdownBorderColor, 0.5); drawRoundRect(1, 1, (w - 1), (h - 2), {tl:3, tr:0, br:0, bl:3}, 0xFFFFFF, 1); drawRoundRect(1, 2, (w - 1), (h - 3), {tl:3, tr:0, br:0, bl:3}, [0xEEEEEE, 0xFFFFFF], 1, verticalGradientMatrix(0, 0, (w - 1), (h - 3))); }; backgroundColor = null; break; case "menuBorder": borderColor = getStyle("borderColor"); drawRoundRect(0, 0, w, h, 0, borderColor, 1); drawDropShadow(1, 1, (w - 2), (h - 2), 0, 0, 0, 0); break; case "comboNonEdit": break; case "controlBar": if ((((w == 0)) || ((h == 0)))){ backgroundColor = null; break; }; footerColors = getStyle("footerColors"); showChrome = !((footerColors == null)); borderAlpha = getStyle("borderAlpha"); if (showChrome){ g.lineStyle(0, ((footerColors.length > 0)) ? footerColors[1] : footerColors[0], borderAlpha); g.moveTo(0, 0); g.lineTo(w, 0); g.lineStyle(0, 0, 0); if (((((parent) && (parent.parent))) && ((parent.parent is IStyleClient)))){ radius = IStyleClient(parent.parent).getStyle("cornerRadius"); borderAlpha = IStyleClient(parent.parent).getStyle("borderAlpha"); }; if (isNaN(radius)){ radius = 0; }; if (IStyleClient(parent.parent).getStyle("roundedBottomCorners").toString().toLowerCase() != "true"){ radius = 0; }; drawRoundRect(0, 1, w, (h - 1), {tl:0, tr:0, bl:radius, br:radius}, footerColors, borderAlpha, verticalGradientMatrix(0, 0, w, h)); if ((((footerColors.length > 1)) && (!((footerColors[0] == footerColors[1]))))){ drawRoundRect(0, 1, w, (h - 1), {tl:0, tr:0, bl:radius, br:radius}, [0xFFFFFF, 0xFFFFFF], highlightAlphas, verticalGradientMatrix(0, 0, w, h)); drawRoundRect(1, 2, (w - 2), (h - 3), {tl:0, tr:0, bl:(radius - 1), br:(radius - 1)}, footerColors, borderAlpha, verticalGradientMatrix(0, 0, w, h)); }; }; backgroundColor = null; break; case "applicationControlBar": fillColors = getStyle("fillColors"); backgroundAlpha = getStyle("backgroundAlpha"); highlightAlphas = getStyle("highlightAlphas"); fillAlphas = getStyle("fillAlphas"); docked = getStyle("docked"); backgroundColorNum = uint(backgroundColor); radius = getStyle("cornerRadius"); if (!radius){ radius = 0; }; drawDropShadow(0, 1, w, (h - 1), radius, radius, radius, radius); if (((!((backgroundColor === null))) && (StyleManager.isValidStyleValue(backgroundColor)))){ drawRoundRect(0, 1, w, (h - 1), radius, backgroundColorNum, backgroundAlpha, verticalGradientMatrix(0, 0, w, h)); }; drawRoundRect(0, 1, w, (h - 1), radius, fillColors, fillAlphas, verticalGradientMatrix(0, 0, w, h)); drawRoundRect(0, 1, w, ((h / 2) - 1), {tl:radius, tr:radius, bl:0, br:0}, [0xFFFFFF, 0xFFFFFF], highlightAlphas, verticalGradientMatrix(0, 0, w, ((h / 2) - 1))); drawRoundRect(0, 1, w, (h - 1), {tl:radius, tr:radius, bl:0, br:0}, 0xFFFFFF, 0.3, null, GradientType.LINEAR, null, {x:0, y:2, w:w, h:(h - 2), r:{tl:radius, tr:radius, bl:0, br:0}}); backgroundColor = null; break; default: borderColor = getStyle("borderColor"); borderThickness = getStyle("borderThickness"); borderSides = getStyle("borderSides"); bHasAllSides = true; radius = getStyle("cornerRadius"); bRoundedCorners = (getStyle("roundedBottomCorners").toString().toLowerCase() == "true"); holeRadius = Math.max((radius - borderThickness), 0); hole = {x:borderThickness, y:borderThickness, w:(w - (borderThickness * 2)), h:(h - (borderThickness * 2)), r:holeRadius}; if (!bRoundedCorners){ radiusObj = {tl:radius, tr:radius, bl:0, br:0}; hole.r = {tl:holeRadius, tr:holeRadius, bl:0, br:0}; }; if (borderSides != "left top right bottom"){ hole.r = {tl:holeRadius, tr:holeRadius, bl:(bRoundedCorners) ? holeRadius : 0, br:(bRoundedCorners) ? holeRadius : 0}; radiusObj = {tl:radius, tr:radius, bl:(bRoundedCorners) ? radius : 0, br:(bRoundedCorners) ? radius : 0}; borderSides = borderSides.toLowerCase(); if (borderSides.indexOf("left") == -1){ hole.x = 0; hole.w = (hole.w + borderThickness); hole.r.tl = 0; hole.r.bl = 0; radiusObj.tl = 0; radiusObj.bl = 0; bHasAllSides = false; }; if (borderSides.indexOf("top") == -1){ hole.y = 0; hole.h = (hole.h + borderThickness); hole.r.tl = 0; hole.r.tr = 0; radiusObj.tl = 0; radiusObj.tr = 0; bHasAllSides = false; }; if (borderSides.indexOf("right") == -1){ hole.w = (hole.w + borderThickness); hole.r.tr = 0; hole.r.br = 0; radiusObj.tr = 0; radiusObj.br = 0; bHasAllSides = false; }; if (borderSides.indexOf("bottom") == -1){ hole.h = (hole.h + borderThickness); hole.r.bl = 0; hole.r.br = 0; radiusObj.bl = 0; radiusObj.br = 0; bHasAllSides = false; }; }; if ((((radius == 0)) && (bHasAllSides))){ drawDropShadow(0, 0, w, h, 0, 0, 0, 0); g.beginFill(borderColor); g.drawRect(0, 0, w, h); g.drawRect(borderThickness, borderThickness, (w - (2 * borderThickness)), (h - (2 * borderThickness))); g.endFill(); } else { if (radiusObj){ drawDropShadow(0, 0, w, h, radiusObj.tl, radiusObj.tr, radiusObj.br, radiusObj.bl); drawRoundRect(0, 0, w, h, radiusObj, borderColor, 1, null, null, null, hole); radiusObj.tl = Math.max((radius - borderThickness), 0); radiusObj.tr = Math.max((radius - borderThickness), 0); radiusObj.bl = (bRoundedCorners) ? Math.max((radius - borderThickness), 0) : 0; radiusObj.br = (bRoundedCorners) ? Math.max((radius - borderThickness), 0) : 0; } else { drawDropShadow(0, 0, w, h, radius, radius, radius, radius); drawRoundRect(0, 0, w, h, radius, borderColor, 1, null, null, null, hole); radius = Math.max((getStyle("cornerRadius") - borderThickness), 0); }; }; }; }; } mx_internal function drawBackground(w:Number, h:Number):void{ var nd:Number; var alpha:Number; var bm:EdgeMetrics; var g:Graphics; var bottom:Number; var bottomRadius:Number; var highlightAlphas:Array; var highlightAlpha:Number; if (((((((!((backgroundColor === null))) && (!((backgroundColor === ""))))) || (getStyle("mouseShield")))) || (getStyle("mouseShieldChildren")))){ nd = Number(backgroundColor); alpha = 1; bm = getBackgroundColorMetrics(); g = graphics; if (((((isNaN(nd)) || ((backgroundColor === "")))) || ((backgroundColor === null)))){ alpha = 0; nd = 0xFFFFFF; } else { alpha = getStyle(backgroundAlphaName); }; if (((!((radius == 0))) || (backgroundHole))){ bottom = bm.bottom; if (radiusObj){ bottomRadius = (bRoundedCorners) ? radius : 0; radiusObj = {tl:radius, tr:radius, bl:bottomRadius, br:bottomRadius}; drawRoundRect(bm.left, bm.top, (width - (bm.left + bm.right)), (height - (bm.top + bottom)), radiusObj, nd, alpha, null, GradientType.LINEAR, null, backgroundHole); } else { drawRoundRect(bm.left, bm.top, (width - (bm.left + bm.right)), (height - (bm.top + bottom)), radius, nd, alpha, null, GradientType.LINEAR, null, backgroundHole); }; } else { g.beginFill(nd, alpha); g.drawRect(bm.left, bm.top, ((w - bm.right) - bm.left), ((h - bm.bottom) - bm.top)); g.endFill(); }; }; var borderStyle:String = getStyle("borderStyle"); if ((((((FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0)) && ((((borderStyle == "alert")) || ((borderStyle == "default")))))) && ((getStyle("headerColors") == null)))){ highlightAlphas = getStyle("highlightAlphas"); highlightAlpha = (highlightAlphas) ? highlightAlphas[0] : 0.3; drawRoundRect(0, 0, w, h, {tl:radius, tr:radius, bl:0, br:0}, 0xFFFFFF, highlightAlpha, null, GradientType.LINEAR, null, {x:0, y:1, w:w, h:(h - 1), r:{tl:radius, tr:radius, bl:0, br:0}}); }; } mx_internal function drawDropShadow(x:Number, y:Number, width:Number, height:Number, tlRadius:Number, trRadius:Number, brRadius:Number, blRadius:Number):void{ var angle:Number; var docked:Boolean; if ((((((((getStyle("dropShadowEnabled") == false)) || ((getStyle("dropShadowEnabled") == "false")))) || ((width == 0)))) || ((height == 0)))){ return; }; var distance:Number = getStyle("shadowDistance"); var direction:String = getStyle("shadowDirection"); if (getStyle("borderStyle") == "applicationControlBar"){ docked = getStyle("docked"); angle = (docked) ? 90 : getDropShadowAngle(distance, direction); distance = Math.abs(distance); } else { angle = getDropShadowAngle(distance, direction); distance = (Math.abs(distance) + 2); }; if (!dropShadow){ dropShadow = new RectangularDropShadow(); }; dropShadow.distance = distance; dropShadow.angle = angle; dropShadow.color = getStyle("dropShadowColor"); dropShadow.alpha = 0.4; dropShadow.tlRadius = tlRadius; dropShadow.trRadius = trRadius; dropShadow.blRadius = blRadius; dropShadow.brRadius = brRadius; dropShadow.drawShadow(graphics, x, y, width, height); } mx_internal function getBackgroundColor():Object{ var color:Object; var p:IUIComponent = (parent as IUIComponent); if (((p) && (!(p.enabled)))){ color = getStyle("backgroundDisabledColor"); if (((!((color === null))) && (StyleManager.isValidStyleValue(color)))){ return (color); }; }; return (getStyle("backgroundColor")); } mx_internal function draw3dBorder(c1:Number, c2:Number, c3:Number, c4:Number, c5:Number, c6:Number):void{ var w:Number = width; var h:Number = height; drawDropShadow(0, 0, width, height, 0, 0, 0, 0); var g:Graphics = graphics; g.beginFill(c1); g.drawRect(0, 0, w, h); g.drawRect(1, 0, (w - 2), h); g.endFill(); g.beginFill(c2); g.drawRect(1, 0, (w - 2), 1); g.endFill(); g.beginFill(c3); g.drawRect(1, (h - 1), (w - 2), 1); g.endFill(); g.beginFill(c4); g.drawRect(1, 1, (w - 2), 1); g.endFill(); g.beginFill(c5); g.drawRect(1, (h - 2), (w - 2), 1); g.endFill(); g.beginFill(c6); g.drawRect(1, 2, (w - 2), (h - 4)); g.drawRect(2, 2, (w - 4), (h - 4)); g.endFill(); } mx_internal function getBackgroundColorMetrics():EdgeMetrics{ return (borderMetrics); } mx_internal function getDropShadowAngle(distance:Number, direction:String):Number{ if (direction == "left"){ return (((distance >= 0)) ? 135 : 225); } else { if (direction == "right"){ return (((distance >= 0)) ? 45 : 315); //unresolved jump }; }; return (!NULL!); } override public function get borderMetrics():EdgeMetrics{ var borderThickness:Number; var borderSides:String; if (_borderMetrics){ return (_borderMetrics); }; var borderStyle:String = getStyle("borderStyle"); if ((((borderStyle == "default")) || ((borderStyle == "alert")))){ if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0){ _borderMetrics = new EdgeMetrics(0, 0, 0, 0); } else { return (EdgeMetrics.EMPTY); }; } else { if ((((borderStyle == "controlBar")) || ((borderStyle == "applicationControlBar")))){ _borderMetrics = new EdgeMetrics(1, 1, 1, 1); } else { if (borderStyle == "solid"){ borderThickness = getStyle("borderThickness"); if (isNaN(borderThickness)){ borderThickness = 0; }; _borderMetrics = new EdgeMetrics(borderThickness, borderThickness, borderThickness, borderThickness); borderSides = getStyle("borderSides"); if (borderSides != "left top right bottom"){ if (borderSides.indexOf("left") == -1){ _borderMetrics.left = 0; }; if (borderSides.indexOf("top") == -1){ _borderMetrics.top = 0; }; if (borderSides.indexOf("right") == -1){ _borderMetrics.right = 0; }; if (borderSides.indexOf("bottom") == -1){ _borderMetrics.bottom = 0; }; }; } else { borderThickness = BORDER_WIDTHS[borderStyle]; if (isNaN(borderThickness)){ borderThickness = 0; }; _borderMetrics = new EdgeMetrics(borderThickness, borderThickness, borderThickness, borderThickness); }; }; }; return (_borderMetrics); } } }//package mx.skins.halo
Section 207
//HaloColors (mx.skins.halo.HaloColors) package mx.skins.halo { import mx.core.*; import mx.utils.*; public class HaloColors { mx_internal static const VERSION:String = "3.0.0.0"; private static var cache:Object = {}; public function HaloColors(){ super(); } public static function getCacheKey(... _args):String{ return (_args.join(",")); } public static function addHaloColors(colors:Object, themeColor:uint, fillColor0:uint, fillColor1:uint):void{ var key:String = getCacheKey(themeColor, fillColor0, fillColor1); var o:Object = cache[key]; if (!o){ o = (cache[key] = {}); o.themeColLgt = ColorUtil.adjustBrightness(themeColor, 100); o.themeColDrk1 = ColorUtil.adjustBrightness(themeColor, -75); o.themeColDrk2 = ColorUtil.adjustBrightness(themeColor, -25); o.fillColorBright1 = ColorUtil.adjustBrightness2(fillColor0, 15); o.fillColorBright2 = ColorUtil.adjustBrightness2(fillColor1, 15); o.fillColorPress1 = ColorUtil.adjustBrightness2(themeColor, 85); o.fillColorPress2 = ColorUtil.adjustBrightness2(themeColor, 60); o.bevelHighlight1 = ColorUtil.adjustBrightness2(fillColor0, 40); o.bevelHighlight2 = ColorUtil.adjustBrightness2(fillColor1, 40); }; colors.themeColLgt = o.themeColLgt; colors.themeColDrk1 = o.themeColDrk1; colors.themeColDrk2 = o.themeColDrk2; colors.fillColorBright1 = o.fillColorBright1; colors.fillColorBright2 = o.fillColorBright2; colors.fillColorPress1 = o.fillColorPress1; colors.fillColorPress2 = o.fillColorPress2; colors.bevelHighlight1 = o.bevelHighlight1; colors.bevelHighlight2 = o.bevelHighlight2; } } }//package mx.skins.halo
Section 208
//HaloFocusRect (mx.skins.halo.HaloFocusRect) package mx.skins.halo { import mx.core.*; import mx.styles.*; import flash.display.*; import mx.skins.*; import mx.utils.*; public class HaloFocusRect extends ProgrammaticSkin implements IStyleClient { private var _focusColor:Number; mx_internal static const VERSION:String = "3.0.0.0"; public function HaloFocusRect(){ super(); } public function get inheritingStyles():Object{ return (styleName.inheritingStyles); } public function set inheritingStyles(value:Object):void{ } public function notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void{ } public function registerEffects(effects:Array):void{ } public function regenerateStyleCache(recursive:Boolean):void{ } public function get styleDeclaration():CSSStyleDeclaration{ return (CSSStyleDeclaration(styleName)); } public function getClassStyleDeclarations():Array{ return ([]); } public function get className():String{ return ("HaloFocusRect"); } public function clearStyle(styleProp:String):void{ if (styleProp == "focusColor"){ _focusColor = NaN; }; } public function setStyle(styleProp:String, newValue):void{ if (styleProp == "focusColor"){ _focusColor = newValue; }; } public function set nonInheritingStyles(value:Object):void{ } public function get nonInheritingStyles():Object{ return (styleName.nonInheritingStyles); } override protected function updateDisplayList(w:Number, h:Number):void{ var tl:Number; var bl:Number; var tr:Number; var br:Number; var nr:Number; var ellipseSize:Number; super.updateDisplayList(w, h); var focusBlendMode:String = getStyle("focusBlendMode"); var focusAlpha:Number = getStyle("focusAlpha"); var focusColor:Number = getStyle("focusColor"); var cornerRadius:Number = getStyle("cornerRadius"); var focusThickness:Number = getStyle("focusThickness"); var focusRoundedCorners:String = getStyle("focusRoundedCorners"); var themeColor:Number = getStyle("themeColor"); var rectColor:Number = focusColor; if (isNaN(rectColor)){ rectColor = themeColor; }; var g:Graphics = graphics; g.clear(); blendMode = focusBlendMode; if (((!((focusRoundedCorners == "tl tr bl br"))) && ((cornerRadius > 0)))){ tl = 0; bl = 0; tr = 0; br = 0; nr = (cornerRadius + focusThickness); if (focusRoundedCorners.indexOf("tl") >= 0){ tl = nr; }; if (focusRoundedCorners.indexOf("tr") >= 0){ tr = nr; }; if (focusRoundedCorners.indexOf("bl") >= 0){ bl = nr; }; if (focusRoundedCorners.indexOf("br") >= 0){ br = nr; }; g.beginFill(rectColor, focusAlpha); GraphicsUtil.drawRoundRectComplex(g, 0, 0, w, h, tl, tr, bl, br); tl = (tl) ? cornerRadius : 0; tr = (tr) ? cornerRadius : 0; bl = (bl) ? cornerRadius : 0; br = (br) ? cornerRadius : 0; GraphicsUtil.drawRoundRectComplex(g, focusThickness, focusThickness, (w - (2 * focusThickness)), (h - (2 * focusThickness)), tl, tr, bl, br); g.endFill(); nr = (cornerRadius + (focusThickness / 2)); tl = (tl) ? nr : 0; tr = (tr) ? nr : 0; bl = (bl) ? nr : 0; br = (br) ? nr : 0; g.beginFill(rectColor, focusAlpha); GraphicsUtil.drawRoundRectComplex(g, (focusThickness / 2), (focusThickness / 2), (w - focusThickness), (h - focusThickness), tl, tr, bl, br); tl = (tl) ? cornerRadius : 0; tr = (tr) ? cornerRadius : 0; bl = (bl) ? cornerRadius : 0; br = (br) ? cornerRadius : 0; GraphicsUtil.drawRoundRectComplex(g, focusThickness, focusThickness, (w - (2 * focusThickness)), (h - (2 * focusThickness)), tl, tr, bl, br); g.endFill(); } else { g.beginFill(rectColor, focusAlpha); ellipseSize = (((cornerRadius > 0)) ? (cornerRadius + focusThickness) : 0 * 2); g.drawRoundRect(0, 0, w, h, ellipseSize, ellipseSize); ellipseSize = (cornerRadius * 2); g.drawRoundRect(focusThickness, focusThickness, (w - (2 * focusThickness)), (h - (2 * focusThickness)), ellipseSize, ellipseSize); g.endFill(); g.beginFill(rectColor, focusAlpha); ellipseSize = (((cornerRadius > 0)) ? (cornerRadius + (focusThickness / 2)) : 0 * 2); g.drawRoundRect((focusThickness / 2), (focusThickness / 2), (w - focusThickness), (h - focusThickness), ellipseSize, ellipseSize); ellipseSize = (cornerRadius * 2); g.drawRoundRect(focusThickness, focusThickness, (w - (2 * focusThickness)), (h - (2 * focusThickness)), ellipseSize, ellipseSize); g.endFill(); }; } override public function getStyle(styleProp:String){ return (((styleProp == "focusColor")) ? _focusColor : super.getStyle(styleProp)); } public function set styleDeclaration(value:CSSStyleDeclaration):void{ } } }//package mx.skins.halo
Section 209
//Border (mx.skins.Border) package mx.skins { import mx.core.*; public class Border extends ProgrammaticSkin implements IBorder { mx_internal static const VERSION:String = "3.0.0.0"; public function Border(){ super(); } public function get borderMetrics():EdgeMetrics{ return (EdgeMetrics.EMPTY); } } }//package mx.skins
Section 210
//ProgrammaticSkin (mx.skins.ProgrammaticSkin) package mx.skins { import mx.core.*; import mx.styles.*; import flash.display.*; import flash.geom.*; import mx.managers.*; import mx.utils.*; public class ProgrammaticSkin extends FlexShape implements IFlexDisplayObject, IInvalidating, ILayoutManagerClient, ISimpleStyleClient, IProgrammaticSkin { private var _initialized:Boolean;// = false private var _height:Number; private var invalidateDisplayListFlag:Boolean;// = false private var _styleName:IStyleClient; private var _nestLevel:int;// = 0 private var _processedDescriptors:Boolean;// = false private var _updateCompletePendingFlag:Boolean;// = true private var _width:Number; mx_internal static const VERSION:String = "3.0.0.0"; private static var tempMatrix:Matrix = new Matrix(); public function ProgrammaticSkin(){ super(); _width = measuredWidth; _height = measuredHeight; } public function getStyle(styleProp:String){ return (_styleName.getStyle(styleProp)); } protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{ } public function get nestLevel():int{ return (_nestLevel); } public function set nestLevel(value:int):void{ _nestLevel = value; invalidateDisplayList(); } override public function get height():Number{ return (_height); } public function get updateCompletePendingFlag():Boolean{ return (_updateCompletePendingFlag); } protected function verticalGradientMatrix(x:Number, y:Number, width:Number, height:Number):Matrix{ return (rotatedGradientMatrix(x, y, width, height, 90)); } public function validateSize(recursive:Boolean=false):void{ } public function invalidateDisplayList():void{ if (((!(invalidateDisplayListFlag)) && ((nestLevel > 0)))){ invalidateDisplayListFlag = true; UIComponentGlobals.layoutManager.invalidateDisplayList(this); }; } public function set updateCompletePendingFlag(value:Boolean):void{ _updateCompletePendingFlag = value; } protected function horizontalGradientMatrix(x:Number, y:Number, width:Number, height:Number):Matrix{ return (rotatedGradientMatrix(x, y, width, height, 0)); } override public function set height(value:Number):void{ _height = value; invalidateDisplayList(); } public function set processedDescriptors(value:Boolean):void{ _processedDescriptors = value; } public function validateDisplayList():void{ invalidateDisplayListFlag = false; updateDisplayList(width, height); } public function get measuredWidth():Number{ return (0); } override public function set width(value:Number):void{ _width = value; invalidateDisplayList(); } public function get measuredHeight():Number{ return (0); } public function set initialized(value:Boolean):void{ _initialized = value; } protected function drawRoundRect(x:Number, y:Number, width:Number, height:Number, cornerRadius:Object=null, color:Object=null, alpha:Object=null, gradientMatrix:Matrix=null, gradientType:String="linear", gradientRatios:Array=null, hole:Object=null):void{ var ellipseSize:Number; var alphas:Array; var holeR:Object; var g:Graphics = graphics; if ((((width == 0)) || ((height == 0)))){ return; }; if (color !== null){ if ((color is uint)){ g.beginFill(uint(color), Number(alpha)); } else { if ((color is Array)){ alphas = ((alpha is Array)) ? (alpha as Array) : [alpha, alpha]; if (!gradientRatios){ gradientRatios = [0, 0xFF]; }; g.beginGradientFill(gradientType, (color as Array), alphas, gradientRatios, gradientMatrix); }; }; }; if (!cornerRadius){ g.drawRect(x, y, width, height); } else { if ((cornerRadius is Number)){ ellipseSize = (Number(cornerRadius) * 2); g.drawRoundRect(x, y, width, height, ellipseSize, ellipseSize); } else { GraphicsUtil.drawRoundRectComplex(g, x, y, width, height, cornerRadius.tl, cornerRadius.tr, cornerRadius.bl, cornerRadius.br); }; }; if (hole){ holeR = hole.r; if ((holeR is Number)){ ellipseSize = (Number(holeR) * 2); g.drawRoundRect(hole.x, hole.y, hole.w, hole.h, ellipseSize, ellipseSize); } else { GraphicsUtil.drawRoundRectComplex(g, hole.x, hole.y, hole.w, hole.h, holeR.tl, holeR.tr, holeR.bl, holeR.br); }; }; if (color !== null){ g.endFill(); }; } public function get processedDescriptors():Boolean{ return (_processedDescriptors); } public function set styleName(value:Object):void{ if (_styleName != value){ _styleName = (value as IStyleClient); invalidateDisplayList(); }; } public function setActualSize(newWidth:Number, newHeight:Number):void{ var changed:Boolean; if (_width != newWidth){ _width = newWidth; changed = true; }; if (_height != newHeight){ _height = newHeight; changed = true; }; if (changed){ invalidateDisplayList(); }; } public function styleChanged(styleProp:String):void{ invalidateDisplayList(); } override public function get width():Number{ return (_width); } public function invalidateProperties():void{ } public function get initialized():Boolean{ return (_initialized); } protected function rotatedGradientMatrix(x:Number, y:Number, width:Number, height:Number, rotation:Number):Matrix{ tempMatrix.createGradientBox(width, height, ((rotation * Math.PI) / 180), x, y); return (tempMatrix); } public function move(x:Number, y:Number):void{ this.x = x; this.y = y; } public function get styleName():Object{ return (_styleName); } public function validateNow():void{ if (invalidateDisplayListFlag){ validateDisplayList(); }; } public function invalidateSize():void{ } public function validateProperties():void{ } } }//package mx.skins
Section 211
//RectangularBorder (mx.skins.RectangularBorder) package mx.skins { import mx.core.*; import flash.events.*; import mx.styles.*; import flash.system.*; import flash.display.*; import flash.geom.*; import mx.resources.*; import flash.net.*; import flash.utils.*; public class RectangularBorder extends Border implements IRectangularBorder { private var backgroundImage:DisplayObject; private var backgroundImageHeight:Number; private var _backgroundImageBounds:Rectangle; private var backgroundImageStyle:Object; private var backgroundImageWidth:Number; private var resourceManager:IResourceManager; mx_internal static const VERSION:String = "3.0.0.0"; public function RectangularBorder(){ resourceManager = ResourceManager.getInstance(); super(); addEventListener(Event.REMOVED, removedHandler); } public function layoutBackgroundImage():void{ var sW:Number; var sH:Number; var sX:Number; var sY:Number; var scale:Number; var g:Graphics; var p:DisplayObject = parent; var bm:EdgeMetrics = ((p is IContainer)) ? IContainer(p).viewMetrics : borderMetrics; var scrollableBk = !((getStyle("backgroundAttachment") == "fixed")); if (_backgroundImageBounds){ sW = _backgroundImageBounds.width; sH = _backgroundImageBounds.height; } else { sW = ((width - bm.left) - bm.right); sH = ((height - bm.top) - bm.bottom); }; var percentage:Number = getBackgroundSize(); if (isNaN(percentage)){ sX = 1; sY = 1; } else { scale = (percentage * 0.01); sX = ((scale * sW) / backgroundImageWidth); sY = ((scale * sH) / backgroundImageHeight); }; backgroundImage.scaleX = sX; backgroundImage.scaleY = sY; var offsetX:Number = Math.round((0.5 * (sW - (backgroundImageWidth * sX)))); var offsetY:Number = Math.round((0.5 * (sH - (backgroundImageHeight * sY)))); backgroundImage.x = bm.left; backgroundImage.y = bm.top; var backgroundMask:Shape = Shape(backgroundImage.mask); backgroundMask.x = bm.left; backgroundMask.y = bm.top; if (((scrollableBk) && ((p is IContainer)))){ offsetX = (offsetX - IContainer(p).horizontalScrollPosition); offsetY = (offsetY - IContainer(p).verticalScrollPosition); }; backgroundImage.alpha = getStyle("backgroundAlpha"); backgroundImage.x = (backgroundImage.x + offsetX); backgroundImage.y = (backgroundImage.y + offsetY); var maskWidth:Number = ((width - bm.left) - bm.right); var maskHeight:Number = ((height - bm.top) - bm.bottom); if (((!((backgroundMask.width == maskWidth))) || (!((backgroundMask.height == maskHeight))))){ g = backgroundMask.graphics; g.clear(); g.beginFill(0xFFFFFF); g.drawRect(0, 0, maskWidth, maskHeight); g.endFill(); }; } public function set backgroundImageBounds(value:Rectangle):void{ _backgroundImageBounds = value; invalidateDisplayList(); } private function getBackgroundSize():Number{ var index:int; var percentage:Number = NaN; var backgroundSize:Object = getStyle("backgroundSize"); if (((backgroundSize) && ((backgroundSize is String)))){ index = backgroundSize.indexOf("%"); if (index != -1){ percentage = Number(backgroundSize.substr(0, index)); }; }; return (percentage); } private function removedHandler(event:Event):void{ var childrenList:IChildList; if (backgroundImage){ childrenList = ((parent is IRawChildrenContainer)) ? IRawChildrenContainer(parent).rawChildren : IChildList(parent); childrenList.removeChild(backgroundImage.mask); childrenList.removeChild(backgroundImage); backgroundImage = null; }; } private function initBackgroundImage(image:DisplayObject):void{ backgroundImage = image; if ((image is Loader)){ backgroundImageWidth = Loader(image).contentLoaderInfo.width; backgroundImageHeight = Loader(image).contentLoaderInfo.height; } else { backgroundImageWidth = backgroundImage.width; backgroundImageHeight = backgroundImage.height; if ((image is ISimpleStyleClient)){ ISimpleStyleClient(image).styleName = styleName; }; }; var childrenList:IChildList = ((parent is IRawChildrenContainer)) ? IRawChildrenContainer(parent).rawChildren : IChildList(parent); var backgroundMask:Shape = new FlexShape(); backgroundMask.name = "backgroundMask"; backgroundMask.x = 0; backgroundMask.y = 0; childrenList.addChild(backgroundMask); var myIndex:int = childrenList.getChildIndex(this); childrenList.addChildAt(backgroundImage, (myIndex + 1)); backgroundImage.mask = backgroundMask; } public function get backgroundImageBounds():Rectangle{ return (_backgroundImageBounds); } public function get hasBackgroundImage():Boolean{ return (!((backgroundImage == null))); } private function completeEventHandler(event:Event):void{ if (!parent){ return; }; var target:DisplayObject = DisplayObject(LoaderInfo(event.target).loader); initBackgroundImage(target); layoutBackgroundImage(); dispatchEvent(event.clone()); } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{ var cls:Class; var newStyleObj:DisplayObject; var loader:Loader; var loaderContext:LoaderContext; var message:String; var unscaledWidth = unscaledWidth; var unscaledHeight = unscaledHeight; if (!parent){ return; }; var newStyle:Object = getStyle("backgroundImage"); if (newStyle != backgroundImageStyle){ removedHandler(null); backgroundImageStyle = newStyle; if (((newStyle) && ((newStyle as Class)))){ cls = Class(newStyle); initBackgroundImage(new (cls)); } else { if (((newStyle) && ((newStyle is String)))){ cls = Class(getDefinitionByName(String(newStyle))); //unresolved jump var _slot1 = e; if (cls){ newStyleObj = new (cls); initBackgroundImage(newStyleObj); } else { loader = new FlexLoader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeEventHandler); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorEventHandler); loader.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, errorEventHandler); loaderContext = new LoaderContext(); loaderContext.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); loader.load(new URLRequest(String(newStyle)), loaderContext); }; } else { if (newStyle){ message = resourceManager.getString("skins", "notLoaded", [newStyle]); throw (new Error(message)); }; }; }; }; if (backgroundImage){ layoutBackgroundImage(); }; } private function errorEventHandler(event:Event):void{ } } }//package mx.skins
Section 212
//IOverride (mx.states.IOverride) package mx.states { import mx.core.*; public interface IOverride { function initialize():void; function remove(:UIComponent):void; function apply(:UIComponent):void; } }//package mx.states
Section 213
//State (mx.states.State) package mx.states { import mx.core.*; import flash.events.*; import mx.events.*; public class State extends EventDispatcher { public var basedOn:String; private var initialized:Boolean;// = false public var overrides:Array; public var name:String; mx_internal static const VERSION:String = "3.0.0.0"; public function State(){ overrides = []; super(); } mx_internal function initialize():void{ var i:int; if (!initialized){ initialized = true; i = 0; while (i < overrides.length) { IOverride(overrides[i]).initialize(); i++; }; }; } mx_internal function dispatchExitState():void{ dispatchEvent(new FlexEvent(FlexEvent.EXIT_STATE)); } mx_internal function dispatchEnterState():void{ dispatchEvent(new FlexEvent(FlexEvent.ENTER_STATE)); } } }//package mx.states
Section 214
//Transition (mx.states.Transition) package mx.states { import mx.core.*; import mx.effects.*; public class Transition { public var effect:IEffect; public var toState:String;// = "*" public var fromState:String;// = "*" mx_internal static const VERSION:String = "3.0.0.0"; public function Transition(){ super(); } } }//package mx.states
Section 215
//CSSStyleDeclaration (mx.styles.CSSStyleDeclaration) package mx.styles { import mx.core.*; import flash.events.*; import flash.display.*; import mx.managers.*; import flash.utils.*; public class CSSStyleDeclaration extends EventDispatcher { mx_internal var effects:Array; protected var overrides:Object; public var defaultFactory:Function; public var factory:Function; mx_internal var selectorRefCount:int;// = 0 private var styleManager:IStyleManager2; private var clones:Dictionary; mx_internal static const VERSION:String = "3.0.0.0"; private static const NOT_A_COLOR:uint = 4294967295; private static const FILTERMAP_PROP:String = "__reserved__filterMap"; public function CSSStyleDeclaration(selector:String=null){ clones = new Dictionary(true); super(); if (selector){ styleManager = (Singleton.getInstance("mx.styles::IStyleManager2") as IStyleManager2); styleManager.setStyleDeclaration(selector, this, false); }; } mx_internal function addStyleToProtoChain(chain:Object, target:DisplayObject, filterMap:Object=null):Object{ var p:String; var emptyObjectFactory:Function; var filteredChain:Object; var filterObjectFactory:Function; var i:String; var chain = chain; var target = target; var filterMap = filterMap; var nodeAddedToChain:Boolean; var originalChain:Object = chain; if (filterMap){ chain = {}; }; if (defaultFactory != null){ defaultFactory.prototype = chain; chain = new defaultFactory(); nodeAddedToChain = true; }; if (factory != null){ factory.prototype = chain; chain = new factory(); nodeAddedToChain = true; }; if (overrides){ if ((((defaultFactory == null)) && ((factory == null)))){ emptyObjectFactory = function ():void{ }; emptyObjectFactory.prototype = chain; chain = new (emptyObjectFactory); nodeAddedToChain = true; }; for (p in overrides) { if (overrides[p] === undefined){ delete chain[p]; } else { chain[p] = overrides[p]; }; }; }; if (filterMap){ if (nodeAddedToChain){ filteredChain = {}; filterObjectFactory = function ():void{ }; filterObjectFactory.prototype = originalChain; filteredChain = new (filterObjectFactory); for (i in chain) { if (filterMap[i] != null){ filteredChain[filterMap[i]] = chain[i]; }; }; chain = filteredChain; chain[FILTERMAP_PROP] = filterMap; } else { chain = originalChain; }; }; if (nodeAddedToChain){ clones[chain] = 1; }; return (chain); } public function getStyle(styleProp:String){ var o:*; var v:*; if (overrides){ if ((((styleProp in overrides)) && ((overrides[styleProp] === undefined)))){ return (undefined); }; v = overrides[styleProp]; if (v !== undefined){ return (v); }; }; if (factory != null){ factory.prototype = {}; o = new factory(); v = o[styleProp]; if (v !== undefined){ return (v); }; }; if (defaultFactory != null){ defaultFactory.prototype = {}; o = new defaultFactory(); v = o[styleProp]; if (v !== undefined){ return (v); }; }; return (undefined); } public function clearStyle(styleProp:String):void{ setStyle(styleProp, undefined); } public function setStyle(styleProp:String, newValue):void{ var i:int; var sm:Object; var oldValue:Object = getStyle(styleProp); var regenerate:Boolean; if ((((((((((selectorRefCount > 0)) && ((factory == null)))) && ((defaultFactory == null)))) && (!(overrides)))) && (!((oldValue === newValue))))){ regenerate = true; }; if (newValue !== undefined){ setStyle(styleProp, newValue); } else { if (newValue == oldValue){ return; }; setStyle(styleProp, newValue); }; var sms:Array = SystemManagerGlobals.topLevelSystemManagers; var n:int = sms.length; if (regenerate){ i = 0; while (i < n) { sm = sms[i]; sm.regenerateStyleCache(true); i++; }; }; i = 0; while (i < n) { sm = sms[i]; sm.notifyStyleChangeInChildren(styleProp, true); i++; }; } private function clearStyleAttr(styleProp:String):void{ var clone:*; if (!overrides){ overrides = {}; }; overrides[styleProp] = undefined; for (clone in clones) { delete clone[styleProp]; }; } mx_internal function createProtoChainRoot():Object{ var root:Object = {}; if (defaultFactory != null){ defaultFactory.prototype = root; root = new defaultFactory(); }; if (factory != null){ factory.prototype = root; root = new factory(); }; clones[root] = 1; return (root); } mx_internal function clearOverride(styleProp:String):void{ if (((overrides) && (overrides[styleProp]))){ delete overrides[styleProp]; }; } mx_internal function setStyle(styleProp:String, value):void{ var o:Object; var clone:*; var colorNumber:Number; var cloneFilter:Object; if (value === undefined){ clearStyleAttr(styleProp); return; }; if ((value is String)){ if (!styleManager){ styleManager = (Singleton.getInstance("mx.styles::IStyleManager2") as IStyleManager2); }; colorNumber = styleManager.getColorName(value); if (colorNumber != NOT_A_COLOR){ value = colorNumber; }; }; if (defaultFactory != null){ o = new defaultFactory(); if (o[styleProp] !== value){ if (!overrides){ overrides = {}; }; overrides[styleProp] = value; } else { if (overrides){ delete overrides[styleProp]; }; }; }; if (factory != null){ o = new factory(); if (o[styleProp] !== value){ if (!overrides){ overrides = {}; }; overrides[styleProp] = value; } else { if (overrides){ delete overrides[styleProp]; }; }; }; if ((((defaultFactory == null)) && ((factory == null)))){ if (!overrides){ overrides = {}; }; overrides[styleProp] = value; }; for (clone in clones) { cloneFilter = clone[FILTERMAP_PROP]; if (cloneFilter){ if (cloneFilter[styleProp] != null){ clone[cloneFilter[styleProp]] = value; }; } else { clone[styleProp] = value; }; }; } } }//package mx.styles
Section 216
//ISimpleStyleClient (mx.styles.ISimpleStyleClient) package mx.styles { public interface ISimpleStyleClient { function set styleName(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;ISimpleStyleClient.as:Object):void; function styleChanged(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;ISimpleStyleClient.as:String):void; function get styleName():Object; } }//package mx.styles
Section 217
//IStyleClient (mx.styles.IStyleClient) package mx.styles { public interface IStyleClient extends ISimpleStyleClient { function regenerateStyleCache(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:Boolean):void; function get className():String; function clearStyle(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:String):void; function getClassStyleDeclarations():Array; function get inheritingStyles():Object; function set nonInheritingStyles(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:Object):void; function setStyle(_arg1:String, _arg2):void; function get styleDeclaration():CSSStyleDeclaration; function set styleDeclaration(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:CSSStyleDeclaration):void; function get nonInheritingStyles():Object; function set inheritingStyles(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:Object):void; function getStyle(*:String); function notifyStyleChangeInChildren(_arg1:String, _arg2:Boolean):void; function registerEffects(mx.styles:IStyleClient/mx.styles:IStyleClient:className/get:Array):void; } }//package mx.styles
Section 218
//IStyleManager (mx.styles.IStyleManager) package mx.styles { import flash.events.*; public interface IStyleManager { function isColorName(value:String):Boolean; function registerParentDisplayListInvalidatingStyle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:String):void; function registerInheritingStyle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:String):void; function set stylesRoot(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:Object):void; function get typeSelectorCache():Object; function styleDeclarationsChanged():void; function setStyleDeclaration(_arg1:String, _arg2:CSSStyleDeclaration, _arg3:Boolean):void; function isParentDisplayListInvalidatingStyle(value:String):Boolean; function isSizeInvalidatingStyle(value:String):Boolean; function get inheritingStyles():Object; function isValidStyleValue(value):Boolean; function isParentSizeInvalidatingStyle(value:String):Boolean; function getColorName(mx.styles:IStyleManager/mx.styles:IStyleManager:inheritingStyles/set:Object):uint; function set typeSelectorCache(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:Object):void; function unloadStyleDeclarations(_arg1:String, _arg2:Boolean=true):void; function getColorNames(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:Array):void; function loadStyleDeclarations(_arg1:String, _arg2:Boolean=true, _arg3:Boolean=false):IEventDispatcher; function isInheritingStyle(value:String):Boolean; function set inheritingStyles(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:Object):void; function get stylesRoot():Object; function initProtoChainRoots():void; function registerColorName(_arg1:String, _arg2:uint):void; function registerParentSizeInvalidatingStyle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:String):void; function registerSizeInvalidatingStyle(E:\dev\3.0.x\frameworks\projects\framework\src;mx\styles;IStyleManager.as:String):void; function clearStyleDeclaration(_arg1:String, _arg2:Boolean):void; function isInheritingTextFormatStyle(value:String):Boolean; function getStyleDeclaration(mx.styles:IStyleManager/mx.styles:IStyleManager:inheritingStyles/get:String):CSSStyleDeclaration; } }//package mx.styles
Section 219
//IStyleManager2 (mx.styles.IStyleManager2) package mx.styles { import flash.events.*; import flash.system.*; public interface IStyleManager2 extends IStyleManager { function get selectors():Array; function loadStyleDeclarations2(_arg1:String, _arg2:Boolean=true, _arg3:ApplicationDomain=null, _arg4:SecurityDomain=null):IEventDispatcher; } }//package mx.styles
Section 220
//IStyleModule (mx.styles.IStyleModule) package mx.styles { public interface IStyleModule { function unload():void; } }//package mx.styles
Section 221
//StyleManager (mx.styles.StyleManager) package mx.styles { import mx.core.*; import flash.events.*; import flash.system.*; public class StyleManager { mx_internal static const VERSION:String = "3.0.0.0"; public static const NOT_A_COLOR:uint = 4294967295; private static var _impl:IStyleManager2; private static var implClassDependency:StyleManagerImpl; public function StyleManager(){ super(); } public static function isParentSizeInvalidatingStyle(styleName:String):Boolean{ return (impl.isParentSizeInvalidatingStyle(styleName)); } public static function registerInheritingStyle(styleName:String):void{ impl.registerInheritingStyle(styleName); } mx_internal static function set stylesRoot(value:Object):void{ impl.stylesRoot = value; } mx_internal static function get inheritingStyles():Object{ return (impl.inheritingStyles); } mx_internal static function styleDeclarationsChanged():void{ impl.styleDeclarationsChanged(); } public static function setStyleDeclaration(selector:String, styleDeclaration:CSSStyleDeclaration, update:Boolean):void{ impl.setStyleDeclaration(selector, styleDeclaration, update); } public static function registerParentDisplayListInvalidatingStyle(styleName:String):void{ impl.registerParentDisplayListInvalidatingStyle(styleName); } mx_internal static function get typeSelectorCache():Object{ return (impl.typeSelectorCache); } mx_internal static function set inheritingStyles(value:Object):void{ impl.inheritingStyles = value; } public static function isColorName(colorName:String):Boolean{ return (impl.isColorName(colorName)); } public static function isParentDisplayListInvalidatingStyle(styleName:String):Boolean{ return (impl.isParentDisplayListInvalidatingStyle(styleName)); } public static function isSizeInvalidatingStyle(styleName:String):Boolean{ return (impl.isSizeInvalidatingStyle(styleName)); } public static function getColorName(colorName:Object):uint{ return (impl.getColorName(colorName)); } mx_internal static function set typeSelectorCache(value:Object):void{ impl.typeSelectorCache = value; } public static function unloadStyleDeclarations(url:String, update:Boolean=true):void{ impl.unloadStyleDeclarations(url, update); } public static function getColorNames(colors:Array):void{ impl.getColorNames(colors); } public static function loadStyleDeclarations(url:String, update:Boolean=true, trustContent:Boolean=false, applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):IEventDispatcher{ return (impl.loadStyleDeclarations2(url, update, applicationDomain, securityDomain)); } private static function get impl():IStyleManager2{ if (!_impl){ _impl = IStyleManager2(Singleton.getInstance("mx.styles::IStyleManager2")); }; return (_impl); } public static function isValidStyleValue(value):Boolean{ return (impl.isValidStyleValue(value)); } mx_internal static function get stylesRoot():Object{ return (impl.stylesRoot); } public static function isInheritingStyle(styleName:String):Boolean{ return (impl.isInheritingStyle(styleName)); } mx_internal static function initProtoChainRoots():void{ impl.initProtoChainRoots(); } public static function registerParentSizeInvalidatingStyle(styleName:String):void{ impl.registerParentSizeInvalidatingStyle(styleName); } public static function get selectors():Array{ return (impl.selectors); } public static function registerSizeInvalidatingStyle(styleName:String):void{ impl.registerSizeInvalidatingStyle(styleName); } public static function clearStyleDeclaration(selector:String, update:Boolean):void{ impl.clearStyleDeclaration(selector, update); } public static function registerColorName(colorName:String, colorValue:uint):void{ impl.registerColorName(colorName, colorValue); } public static function isInheritingTextFormatStyle(styleName:String):Boolean{ return (impl.isInheritingTextFormatStyle(styleName)); } public static function getStyleDeclaration(selector:String):CSSStyleDeclaration{ return (impl.getStyleDeclaration(selector)); } } }//package mx.styles
Section 222
//StyleManagerImpl (mx.styles.StyleManagerImpl) package mx.styles { import mx.core.*; import flash.events.*; import flash.system.*; import mx.modules.*; import mx.events.*; import mx.resources.*; import mx.managers.*; import flash.utils.*; public class StyleManagerImpl implements IStyleManager2 { private var _stylesRoot:Object; private var _selectors:Object; private var styleModules:Object; private var _inheritingStyles:Object; private var resourceManager:IResourceManager; private var _typeSelectorCache:Object; mx_internal static const VERSION:String = "3.0.0.0"; private static var parentSizeInvalidatingStyles:Object = {bottom:true, horizontalCenter:true, left:true, right:true, top:true, verticalCenter:true, baseline:true}; private static var colorNames:Object = {transparent:"transparent", black:0, blue:0xFF, green:0x8000, gray:0x808080, silver:0xC0C0C0, lime:0xFF00, olive:0x808000, white:0xFFFFFF, yellow:0xFFFF00, maroon:0x800000, navy:128, red:0xFF0000, purple:0x800080, teal:0x8080, fuchsia:0xFF00FF, aqua:0xFFFF, magenta:0xFF00FF, cyan:0xFFFF, halogreen:8453965, haloblue:40447, haloorange:0xFFB600, halosilver:11455193}; private static var inheritingTextFormatStyles:Object = {align:true, bold:true, color:true, font:true, indent:true, italic:true, size:true}; private static var instance:IStyleManager2; private static var parentDisplayListInvalidatingStyles:Object = {bottom:true, horizontalCenter:true, left:true, right:true, top:true, verticalCenter:true, baseline:true}; private static var sizeInvalidatingStyles:Object = {borderStyle:true, borderThickness:true, fontAntiAliasType:true, fontFamily:true, fontGridFitType:true, fontSharpness:true, fontSize:true, fontStyle:true, fontThickness:true, fontWeight:true, headerHeight:true, horizontalAlign:true, horizontalGap:true, kerning:true, leading:true, letterSpacing:true, paddingBottom:true, paddingLeft:true, paddingRight:true, paddingTop:true, strokeWidth:true, tabHeight:true, tabWidth:true, verticalAlign:true, verticalGap:true}; public function StyleManagerImpl(){ _selectors = {}; styleModules = {}; resourceManager = ResourceManager.getInstance(); _inheritingStyles = {}; _typeSelectorCache = {}; super(); } public function setStyleDeclaration(selector:String, styleDeclaration:CSSStyleDeclaration, update:Boolean):void{ styleDeclaration.selectorRefCount++; _selectors[selector] = styleDeclaration; typeSelectorCache = {}; if (update){ styleDeclarationsChanged(); }; } public function registerParentDisplayListInvalidatingStyle(styleName:String):void{ parentDisplayListInvalidatingStyles[styleName] = true; } public function getStyleDeclaration(selector:String):CSSStyleDeclaration{ var index:int; if (selector.charAt(0) != "."){ index = selector.lastIndexOf("."); if (index != -1){ selector = selector.substr((index + 1)); }; }; return (_selectors[selector]); } public function set typeSelectorCache(value:Object):void{ _typeSelectorCache = value; } public function isColorName(colorName:String):Boolean{ return (!((colorNames[colorName.toLowerCase()] === undefined))); } public function set inheritingStyles(value:Object):void{ _inheritingStyles = value; } public function getColorNames(colors:Array):void{ var colorNumber:uint; if (!colors){ return; }; var n:int = colors.length; var i:int; while (i < n) { if (((!((colors[i] == null))) && (isNaN(colors[i])))){ colorNumber = getColorName(colors[i]); if (colorNumber != StyleManager.NOT_A_COLOR){ colors[i] = colorNumber; }; }; i++; }; } public function isInheritingTextFormatStyle(styleName:String):Boolean{ return ((inheritingTextFormatStyles[styleName] == true)); } public function registerParentSizeInvalidatingStyle(styleName:String):void{ parentSizeInvalidatingStyles[styleName] = true; } public function registerColorName(colorName:String, colorValue:uint):void{ colorNames[colorName.toLowerCase()] = colorValue; } public function isParentSizeInvalidatingStyle(styleName:String):Boolean{ return ((parentSizeInvalidatingStyles[styleName] == true)); } public function registerInheritingStyle(styleName:String):void{ inheritingStyles[styleName] = true; } public function set stylesRoot(value:Object):void{ _stylesRoot = value; } public function get typeSelectorCache():Object{ return (_typeSelectorCache); } public function isParentDisplayListInvalidatingStyle(styleName:String):Boolean{ return ((parentDisplayListInvalidatingStyles[styleName] == true)); } public function isSizeInvalidatingStyle(styleName:String):Boolean{ return ((sizeInvalidatingStyles[styleName] == true)); } public function styleDeclarationsChanged():void{ var sm:Object; var sms:Array = SystemManagerGlobals.topLevelSystemManagers; var n:int = sms.length; var i:int; while (i < n) { sm = sms[i]; sm.regenerateStyleCache(true); sm.notifyStyleChangeInChildren(null, true); i++; }; } public function isValidStyleValue(value):Boolean{ return (!((value === undefined))); } public function loadStyleDeclarations(url:String, update:Boolean=true, trustContent:Boolean=false):IEventDispatcher{ return (loadStyleDeclarations2(url, update)); } public function get inheritingStyles():Object{ return (_inheritingStyles); } public function unloadStyleDeclarations(url:String, update:Boolean=true):void{ var module:IModuleInfo; var styleModuleInfo:StyleModuleInfo = styleModules[url]; if (styleModuleInfo){ styleModuleInfo.styleModule.unload(); module = styleModuleInfo.module; module.unload(); module.removeEventListener(ModuleEvent.READY, styleModuleInfo.readyHandler); module.removeEventListener(ModuleEvent.ERROR, styleModuleInfo.errorHandler); styleModules[url] = null; }; if (update){ styleDeclarationsChanged(); }; } public function getColorName(colorName:Object):uint{ var n:Number; var c:*; if ((colorName is String)){ if (colorName.charAt(0) == "#"){ n = Number(("0x" + colorName.slice(1))); return ((isNaN(n)) ? StyleManager.NOT_A_COLOR : uint(n)); }; if ((((colorName.charAt(1) == "x")) && ((colorName.charAt(0) == "0")))){ n = Number(colorName); return ((isNaN(n)) ? StyleManager.NOT_A_COLOR : uint(n)); }; c = colorNames[colorName.toLowerCase()]; if (c === undefined){ return (StyleManager.NOT_A_COLOR); }; return (uint(c)); }; return (uint(colorName)); } public function isInheritingStyle(styleName:String):Boolean{ return ((inheritingStyles[styleName] == true)); } public function get stylesRoot():Object{ return (_stylesRoot); } public function initProtoChainRoots():void{ if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0){ delete _inheritingStyles["textDecoration"]; delete _inheritingStyles["leading"]; }; if (!stylesRoot){ stylesRoot = _selectors["global"].addStyleToProtoChain({}, null); }; } public function loadStyleDeclarations2(url:String, update:Boolean=true, applicationDomain:ApplicationDomain=null, securityDomain:SecurityDomain=null):IEventDispatcher{ var module:IModuleInfo; var styleEventDispatcher:StyleEventDispatcher; var timer:Timer; var timerHandler:Function; var url = url; var update = update; var applicationDomain = applicationDomain; var securityDomain = securityDomain; module = ModuleManager.getModule(url); var readyHandler:Function = function (moduleEvent:ModuleEvent):void{ var styleModule:IStyleModule = IStyleModule(moduleEvent.module.factory.create()); styleModules[moduleEvent.module.url].styleModule = styleModule; if (update){ styleDeclarationsChanged(); }; }; module.addEventListener(ModuleEvent.READY, readyHandler, false, 0, true); styleEventDispatcher = new StyleEventDispatcher(module); var errorHandler:Function = function (moduleEvent:ModuleEvent):void{ var styleEvent:StyleEvent; var errorText:String = resourceManager.getString("styles", "unableToLoad", [moduleEvent.errorText, url]); if (styleEventDispatcher.willTrigger(StyleEvent.ERROR)){ styleEvent = new StyleEvent(StyleEvent.ERROR, moduleEvent.bubbles, moduleEvent.cancelable); styleEvent.bytesLoaded = 0; styleEvent.bytesTotal = 0; styleEvent.errorText = errorText; styleEventDispatcher.dispatchEvent(styleEvent); } else { throw (new Error(errorText)); }; }; module.addEventListener(ModuleEvent.ERROR, errorHandler, false, 0, true); styleModules[url] = new StyleModuleInfo(module, readyHandler, errorHandler); timer = new Timer(0); timerHandler = function (event:TimerEvent):void{ timer.removeEventListener(TimerEvent.TIMER, timerHandler); timer.stop(); module.load(applicationDomain, securityDomain); }; timer.addEventListener(TimerEvent.TIMER, timerHandler, false, 0, true); timer.start(); return (styleEventDispatcher); } public function registerSizeInvalidatingStyle(styleName:String):void{ sizeInvalidatingStyles[styleName] = true; } public function clearStyleDeclaration(selector:String, update:Boolean):void{ var styleDeclaration:CSSStyleDeclaration = getStyleDeclaration(selector); if (((styleDeclaration) && ((styleDeclaration.selectorRefCount > 0)))){ styleDeclaration.selectorRefCount--; }; delete _selectors[selector]; if (update){ styleDeclarationsChanged(); }; } public function get selectors():Array{ var i:String; var theSelectors:Array = []; for (i in _selectors) { theSelectors.push(i); }; return (theSelectors); } public static function getInstance():IStyleManager2{ if (!instance){ instance = new (StyleManagerImpl); }; return (instance); } } }//package mx.styles import flash.events.*; import mx.modules.*; import mx.events.*; class StyleEventDispatcher extends EventDispatcher { private function StyleEventDispatcher(moduleInfo:IModuleInfo){ super(); moduleInfo.addEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler, false, 0, true); moduleInfo.addEventListener(ModuleEvent.PROGRESS, moduleInfo_progressHandler, false, 0, true); moduleInfo.addEventListener(ModuleEvent.READY, moduleInfo_readyHandler, false, 0, true); } private function moduleInfo_progressHandler(event:ModuleEvent):void{ var styleEvent:StyleEvent = new StyleEvent(StyleEvent.PROGRESS, event.bubbles, event.cancelable); styleEvent.bytesLoaded = event.bytesLoaded; styleEvent.bytesTotal = event.bytesTotal; dispatchEvent(styleEvent); } private function moduleInfo_readyHandler(event:ModuleEvent):void{ var styleEvent:StyleEvent = new StyleEvent(StyleEvent.COMPLETE); dispatchEvent(styleEvent); } private function moduleInfo_errorHandler(event:ModuleEvent):void{ var styleEvent:StyleEvent = new StyleEvent(StyleEvent.ERROR, event.bubbles, event.cancelable); styleEvent.bytesLoaded = event.bytesLoaded; styleEvent.bytesTotal = event.bytesTotal; styleEvent.errorText = event.errorText; dispatchEvent(styleEvent); } } class StyleModuleInfo { public var errorHandler:Function; public var readyHandler:Function; public var module:IModuleInfo; public var styleModule:IStyleModule; private function StyleModuleInfo(module:IModuleInfo, readyHandler:Function, errorHandler:Function){ super(); this.module = module; this.readyHandler = readyHandler; this.errorHandler = errorHandler; } }
Section 223
//StyleProtoChain (mx.styles.StyleProtoChain) package mx.styles { import mx.core.*; import flash.display.*; public class StyleProtoChain { mx_internal static const VERSION:String = "3.0.0.0"; public function StyleProtoChain(){ super(); } public static function initProtoChainForUIComponentStyleName(obj:IStyleClient):void{ var typeSelector:CSSStyleDeclaration; var styleName:IStyleClient = IStyleClient(obj.styleName); var target:DisplayObject = (obj as DisplayObject); var nonInheritChain:Object = styleName.nonInheritingStyles; if (((!(nonInheritChain)) || ((nonInheritChain == UIComponent.STYLE_UNINITIALIZED)))){ nonInheritChain = StyleManager.stylesRoot; if (nonInheritChain.effects){ obj.registerEffects(nonInheritChain.effects); }; }; var inheritChain:Object = styleName.inheritingStyles; if (((!(inheritChain)) || ((inheritChain == UIComponent.STYLE_UNINITIALIZED)))){ inheritChain = StyleManager.stylesRoot; }; var typeSelectors:Array = obj.getClassStyleDeclarations(); var n:int = typeSelectors.length; if ((styleName is StyleProxy)){ if (n == 0){ nonInheritChain = addProperties(nonInheritChain, styleName, false); }; target = (StyleProxy(styleName).source as DisplayObject); }; var i:int; while (i < n) { typeSelector = typeSelectors[i]; inheritChain = typeSelector.addStyleToProtoChain(inheritChain, target); inheritChain = addProperties(inheritChain, styleName, true); nonInheritChain = typeSelector.addStyleToProtoChain(nonInheritChain, target); nonInheritChain = addProperties(nonInheritChain, styleName, false); if (typeSelector.effects){ obj.registerEffects(typeSelector.effects); }; i++; }; obj.inheritingStyles = (obj.styleDeclaration) ? obj.styleDeclaration.addStyleToProtoChain(inheritChain, target) : inheritChain; obj.nonInheritingStyles = (obj.styleDeclaration) ? obj.styleDeclaration.addStyleToProtoChain(nonInheritChain, target) : nonInheritChain; } private static function addProperties(chain:Object, obj:IStyleClient, bInheriting:Boolean):Object{ var typeSelector:CSSStyleDeclaration; var classSelector:CSSStyleDeclaration; var filterMap:Object = ((((obj is StyleProxy)) && (!(bInheriting)))) ? StyleProxy(obj).filterMap : null; var curObj:IStyleClient = obj; while ((curObj is StyleProxy)) { curObj = StyleProxy(curObj).source; }; var target:DisplayObject = (curObj as DisplayObject); var typeSelectors:Array = obj.getClassStyleDeclarations(); var n:int = typeSelectors.length; var i:int; while (i < n) { typeSelector = typeSelectors[i]; chain = typeSelector.addStyleToProtoChain(chain, target, filterMap); if (typeSelector.effects){ obj.registerEffects(typeSelector.effects); }; i++; }; var styleName:Object = obj.styleName; if (styleName){ if (typeof(styleName) == "object"){ if ((styleName is CSSStyleDeclaration)){ classSelector = CSSStyleDeclaration(styleName); } else { chain = addProperties(chain, IStyleClient(styleName), bInheriting); }; } else { classSelector = StyleManager.getStyleDeclaration(("." + styleName)); }; if (classSelector){ chain = classSelector.addStyleToProtoChain(chain, target, filterMap); if (classSelector.effects){ obj.registerEffects(classSelector.effects); }; }; }; if (obj.styleDeclaration){ chain = obj.styleDeclaration.addStyleToProtoChain(chain, target, filterMap); }; return (chain); } public static function initTextField(obj:IUITextField):void{ var classSelector:CSSStyleDeclaration; var styleName:Object = obj.styleName; if (styleName){ if (typeof(styleName) == "object"){ if ((styleName is CSSStyleDeclaration)){ classSelector = CSSStyleDeclaration(styleName); } else { if ((styleName is StyleProxy)){ obj.inheritingStyles = IStyleClient(styleName).inheritingStyles; obj.nonInheritingStyles = addProperties(StyleManager.stylesRoot, IStyleClient(styleName), false); return; }; obj.inheritingStyles = IStyleClient(styleName).inheritingStyles; obj.nonInheritingStyles = IStyleClient(styleName).nonInheritingStyles; return; }; } else { classSelector = StyleManager.getStyleDeclaration(("." + styleName)); }; }; var inheritChain:Object = IStyleClient(obj.parent).inheritingStyles; var nonInheritChain:Object = StyleManager.stylesRoot; if (!inheritChain){ inheritChain = StyleManager.stylesRoot; }; if (classSelector){ inheritChain = classSelector.addStyleToProtoChain(inheritChain, DisplayObject(obj)); nonInheritChain = classSelector.addStyleToProtoChain(nonInheritChain, DisplayObject(obj)); }; obj.inheritingStyles = inheritChain; obj.nonInheritingStyles = nonInheritChain; } } }//package mx.styles
Section 224
//StyleProxy (mx.styles.StyleProxy) package mx.styles { import mx.core.*; public class StyleProxy implements IStyleClient { private var _source:IStyleClient; private var _filterMap:Object; mx_internal static const VERSION:String = "3.0.0.0"; public function StyleProxy(source:IStyleClient, filterMap:Object){ super(); this.filterMap = filterMap; this.source = source; } public function styleChanged(styleProp:String):void{ return (_source.styleChanged(styleProp)); } public function get filterMap():Object{ return (((FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0)) ? null : _filterMap); } public function set filterMap(value:Object):void{ _filterMap = value; } public function get styleDeclaration():CSSStyleDeclaration{ return (_source.styleDeclaration); } public function notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void{ return (_source.notifyStyleChangeInChildren(styleProp, recursive)); } public function set inheritingStyles(value:Object):void{ } public function get source():IStyleClient{ return (_source); } public function get styleName():Object{ if ((_source.styleName is IStyleClient)){ return (new StyleProxy(IStyleClient(_source.styleName), filterMap)); }; return (_source.styleName); } public function registerEffects(effects:Array):void{ return (_source.registerEffects(effects)); } public function regenerateStyleCache(recursive:Boolean):void{ _source.regenerateStyleCache(recursive); } public function get inheritingStyles():Object{ return (_source.inheritingStyles); } public function get className():String{ return (_source.className); } public function clearStyle(styleProp:String):void{ _source.clearStyle(styleProp); } public function getClassStyleDeclarations():Array{ return (_source.getClassStyleDeclarations()); } public function set nonInheritingStyles(value:Object):void{ } public function setStyle(styleProp:String, newValue):void{ _source.setStyle(styleProp, newValue); } public function get nonInheritingStyles():Object{ return (((FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0)) ? _source.nonInheritingStyles : null); } public function set styleName(value:Object):void{ _source.styleName = value; } public function getStyle(styleProp:String){ return (_source.getStyle(styleProp)); } public function set source(value:IStyleClient):void{ _source = value; } public function set styleDeclaration(value:CSSStyleDeclaration):void{ _source.styleDeclaration = styleDeclaration; } } }//package mx.styles
Section 225
//ColorUtil (mx.utils.ColorUtil) package mx.utils { import mx.core.*; public class ColorUtil { mx_internal static const VERSION:String = "3.0.0.0"; public function ColorUtil(){ super(); } public static function adjustBrightness2(rgb:uint, brite:Number):uint{ var r:Number; var g:Number; var b:Number; if (brite == 0){ return (rgb); }; if (brite < 0){ brite = ((100 + brite) / 100); r = (((rgb >> 16) & 0xFF) * brite); g = (((rgb >> 8) & 0xFF) * brite); b = ((rgb & 0xFF) * brite); } else { brite = (brite / 100); r = ((rgb >> 16) & 0xFF); g = ((rgb >> 8) & 0xFF); b = (rgb & 0xFF); r = (r + ((0xFF - r) * brite)); g = (g + ((0xFF - g) * brite)); b = (b + ((0xFF - b) * brite)); r = Math.min(r, 0xFF); g = Math.min(g, 0xFF); b = Math.min(b, 0xFF); }; return ((((r << 16) | (g << 8)) | b)); } public static function rgbMultiply(rgb1:uint, rgb2:uint):uint{ var r1:Number = ((rgb1 >> 16) & 0xFF); var g1:Number = ((rgb1 >> 8) & 0xFF); var b1:Number = (rgb1 & 0xFF); var r2:Number = ((rgb2 >> 16) & 0xFF); var g2:Number = ((rgb2 >> 8) & 0xFF); var b2:Number = (rgb2 & 0xFF); return ((((((r1 * r2) / 0xFF) << 16) | (((g1 * g2) / 0xFF) << 8)) | ((b1 * b2) / 0xFF))); } public static function adjustBrightness(rgb:uint, brite:Number):uint{ var r:Number = Math.max(Math.min((((rgb >> 16) & 0xFF) + brite), 0xFF), 0); var g:Number = Math.max(Math.min((((rgb >> 8) & 0xFF) + brite), 0xFF), 0); var b:Number = Math.max(Math.min(((rgb & 0xFF) + brite), 0xFF), 0); return ((((r << 16) | (g << 8)) | b)); } } }//package mx.utils
Section 226
//GraphicsUtil (mx.utils.GraphicsUtil) package mx.utils { import mx.core.*; import flash.display.*; public class GraphicsUtil { mx_internal static const VERSION:String = "3.0.0.0"; public function GraphicsUtil(){ super(); } public static function drawRoundRectComplex(graphics:Graphics, x:Number, y:Number, width:Number, height:Number, topLeftRadius:Number, topRightRadius:Number, bottomLeftRadius:Number, bottomRightRadius:Number):void{ var xw:Number = (x + width); var yh:Number = (y + height); var minSize:Number = ((width < height)) ? (width * 2) : (height * 2); topLeftRadius = ((topLeftRadius < minSize)) ? topLeftRadius : minSize; topRightRadius = ((topRightRadius < minSize)) ? topRightRadius : minSize; bottomLeftRadius = ((bottomLeftRadius < minSize)) ? bottomLeftRadius : minSize; bottomRightRadius = ((bottomRightRadius < minSize)) ? bottomRightRadius : minSize; var a:Number = (bottomRightRadius * 0.292893218813453); var s:Number = (bottomRightRadius * 0.585786437626905); graphics.moveTo(xw, (yh - bottomRightRadius)); graphics.curveTo(xw, (yh - s), (xw - a), (yh - a)); graphics.curveTo((xw - s), yh, (xw - bottomRightRadius), yh); a = (bottomLeftRadius * 0.292893218813453); s = (bottomLeftRadius * 0.585786437626905); graphics.lineTo((x + bottomLeftRadius), yh); graphics.curveTo((x + s), yh, (x + a), (yh - a)); graphics.curveTo(x, (yh - s), x, (yh - bottomLeftRadius)); a = (topLeftRadius * 0.292893218813453); s = (topLeftRadius * 0.585786437626905); graphics.lineTo(x, (y + topLeftRadius)); graphics.curveTo(x, (y + s), (x + a), (y + a)); graphics.curveTo((x + s), y, (x + topLeftRadius), y); a = (topRightRadius * 0.292893218813453); s = (topRightRadius * 0.585786437626905); graphics.lineTo((xw - topRightRadius), y); graphics.curveTo((xw - s), y, (xw - a), (y + a)); graphics.curveTo(xw, (y + s), xw, (y + topRightRadius)); graphics.lineTo(xw, (yh - bottomRightRadius)); } } }//package mx.utils
Section 227
//NameUtil (mx.utils.NameUtil) package mx.utils { import mx.core.*; import flash.display.*; import flash.utils.*; public class NameUtil { mx_internal static const VERSION:String = "3.0.0.0"; private static var counter:int = 0; public function NameUtil(){ super(); } public static function displayObjectToString(displayObject:DisplayObject):String{ var result:String; var s:String; var indices:Array; var o:DisplayObject = displayObject; while (o != null) { if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){ break; }; s = o.name; if ((o is IRepeaterClient)){ indices = IRepeaterClient(o).instanceIndices; if (indices){ s = (s + (("[" + indices.join("][")) + "]")); }; }; result = ((result == null)) ? s : ((s + ".") + result); o = o.parent; }; return (result); } public static function createUniqueName(object:Object):String{ if (!object){ return (null); }; var name:String = getQualifiedClassName(object); var index:int = name.indexOf("::"); if (index != -1){ name = name.substr((index + 2)); }; var charCode:int = name.charCodeAt((name.length - 1)); if ((((charCode >= 48)) && ((charCode <= 57)))){ name = (name + "_"); }; return ((name + counter++)); } } }//package mx.utils
Section 228
//StringUtil (mx.utils.StringUtil) package mx.utils { import mx.core.*; public class StringUtil { mx_internal static const VERSION:String = "3.0.0.0"; public function StringUtil(){ super(); } public static function trim(str:String):String{ if (str == null){ return (""); }; var startIndex:int; while (isWhitespace(str.charAt(startIndex))) { startIndex++; }; var endIndex:int = (str.length - 1); while (isWhitespace(str.charAt(endIndex))) { endIndex--; }; if (endIndex >= startIndex){ return (str.slice(startIndex, (endIndex + 1))); }; return (""); } public static function isWhitespace(character:String):Boolean{ switch (character){ case " ": case "\t": case "\r": case "\n": case "\f": return (true); default: return (false); }; } public static function substitute(str:String, ... _args):String{ var args:Array; if (str == null){ return (""); }; var len:uint = _args.length; if ((((len == 1)) && ((_args[0] is Array)))){ args = (_args[0] as Array); len = args.length; } else { args = _args; }; var i:int; while (i < len) { str = str.replace(new RegExp((("\\{" + i) + "\\}"), "g"), args[i]); i++; }; return (str); } public static function trimArrayElements(value:String, delimiter:String):String{ var items:Array; var len:int; var i:int; if (((!((value == ""))) && (!((value == null))))){ items = value.split(delimiter); len = items.length; i = 0; while (i < len) { items[i] = StringUtil.trim(items[i]); i++; }; if (len > 0){ value = items.join(delimiter); }; }; return (value); } } }//package mx.utils
Section 229
//IValidatorListener (mx.validators.IValidatorListener) package mx.validators { import mx.events.*; public interface IValidatorListener { function set errorString(E:\dev\3.0.x\frameworks\projects\framework\src;mx\validators;IValidatorListener.as:String):void; function get validationSubField():String; function validationResultHandler(E:\dev\3.0.x\frameworks\projects\framework\src;mx\validators;IValidatorListener.as:ValidationResultEvent):void; function set validationSubField(E:\dev\3.0.x\frameworks\projects\framework\src;mx\validators;IValidatorListener.as:String):void; function get errorString():String; } }//package mx.validators
Section 230
//ValidationResult (mx.validators.ValidationResult) package mx.validators { import mx.core.*; public class ValidationResult { public var subField:String; public var errorCode:String; public var isError:Boolean; public var errorMessage:String; mx_internal static const VERSION:String = "3.0.0.0"; public function ValidationResult(isError:Boolean, subField:String="", errorCode:String="", errorMessage:String=""){ super(); this.isError = isError; this.subField = subField; this.errorMessage = errorMessage; this.errorCode = errorCode; } } }//package mx.validators
Section 231
//_activeButtonStyleStyle (_activeButtonStyleStyle) package { import mx.core.*; import mx.styles.*; public class _activeButtonStyleStyle { public static function init(_activeButtonStyleStyle:IFlexModuleFactory):void{ var fbs = _activeButtonStyleStyle; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".activeButtonStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".activeButtonStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ }; }; } } }//package
Section 232
//_activeTabStyleStyle (_activeTabStyleStyle) package { import mx.core.*; import mx.styles.*; public class _activeTabStyleStyle { public static function init(:IFlexModuleFactory):void{ var fbs = ; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".activeTabStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".activeTabStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fontWeight = "bold"; }; }; } } }//package
Section 233
//_alertButtonStyleStyle (_alertButtonStyleStyle) package { import mx.core.*; import mx.styles.*; public class _alertButtonStyleStyle { public static function init(:IFlexModuleFactory):void{ var fbs = ; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".alertButtonStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".alertButtonStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.color = 734012; }; }; } } }//package
Section 234
//_ButtonStyle (_ButtonStyle) package { import mx.core.*; import mx.styles.*; import mx.skins.halo.*; public class _ButtonStyle { public static function init(verticalGap:IFlexModuleFactory):void{ var fbs = verticalGap; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration("Button"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration("Button", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fontWeight = "bold"; this.paddingTop = 2; this.cornerRadius = 4; this.textAlign = "center"; this.verticalGap = 2; this.horizontalGap = 2; this.skin = ButtonSkin; this.paddingLeft = 10; this.paddingBottom = 2; this.paddingRight = 10; }; }; } } }//package
Section 235
//_comboDropdownStyle (_comboDropdownStyle) package { import mx.core.*; import mx.styles.*; public class _comboDropdownStyle { public static function init(leading:IFlexModuleFactory):void{ var fbs = leading; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".comboDropdown"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".comboDropdown", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.shadowDirection = "center"; this.fontWeight = "normal"; this.dropShadowEnabled = true; this.leading = 0; this.backgroundColor = 0xFFFFFF; this.shadowDistance = 1; this.cornerRadius = 0; this.borderThickness = 0; this.paddingLeft = 5; this.paddingRight = 5; }; }; } } }//package
Section 236
//_dataGridStylesStyle (_dataGridStylesStyle) package { import mx.core.*; import mx.styles.*; public class _dataGridStylesStyle { public static function init(:IFlexModuleFactory):void{ var fbs = ; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".dataGridStyles"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".dataGridStyles", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fontWeight = "bold"; }; }; } } }//package
Section 237
//_dateFieldPopupStyle (_dateFieldPopupStyle) package { import mx.core.*; import mx.styles.*; public class _dateFieldPopupStyle { public static function init(_dateFieldPopupStyle.as$3:IFlexModuleFactory):void{ var fbs = _dateFieldPopupStyle.as$3; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".dateFieldPopup"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".dateFieldPopup", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.dropShadowEnabled = true; this.backgroundColor = 0xFFFFFF; this.borderThickness = 0; }; }; } } }//package
Section 238
//_errorTipStyle (_errorTipStyle) package { import mx.core.*; import mx.styles.*; public class _errorTipStyle { public static function init(borderColor:IFlexModuleFactory):void{ var fbs = borderColor; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".errorTip"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".errorTip", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fontWeight = "bold"; this.borderStyle = "errorTipRight"; this.paddingTop = 4; this.borderColor = 13510953; this.color = 0xFFFFFF; this.fontSize = 9; this.shadowColor = 0; this.paddingLeft = 4; this.paddingBottom = 4; this.paddingRight = 4; }; }; } } }//package
Section 239
//_globalStyle (_globalStyle) package { import mx.core.*; import mx.styles.*; import mx.skins.halo.*; public class _globalStyle { public static function init(horizontalGridLines:IFlexModuleFactory):void{ var fbs = horizontalGridLines; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration("global"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration("global", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fillColor = 0xFFFFFF; this.kerning = false; this.iconColor = 0x111111; this.textRollOverColor = 2831164; this.horizontalAlign = "left"; this.shadowCapColor = 14015965; this.backgroundAlpha = 1; this.filled = true; this.textDecoration = "none"; this.roundedBottomCorners = true; this.fontThickness = 0; this.focusBlendMode = "normal"; this.fillColors = [0xFFFFFF, 0xCCCCCC, 0xFFFFFF, 0xEEEEEE]; this.horizontalGap = 8; this.borderCapColor = 9542041; this.buttonColor = 7305079; this.indentation = 17; this.selectionDisabledColor = 0xDDDDDD; this.closeDuration = 250; this.embedFonts = false; this.paddingTop = 0; this.letterSpacing = 0; this.focusAlpha = 0.4; this.bevel = true; this.fontSize = 10; this.shadowColor = 0xEEEEEE; this.borderAlpha = 1; this.paddingLeft = 0; this.fontWeight = "normal"; this.indicatorGap = 14; this.focusSkin = HaloFocusRect; this.dropShadowEnabled = false; this.leading = 2; this.borderSkin = HaloBorder; this.fontSharpness = 0; this.modalTransparencyDuration = 100; this.borderThickness = 1; this.backgroundSize = "auto"; this.borderStyle = "inset"; this.borderColor = 12040892; this.fontAntiAliasType = "advanced"; this.errorColor = 0xFF0000; this.shadowDistance = 2; this.horizontalGridLineColor = 0xF7F7F7; this.stroked = false; this.modalTransparencyColor = 0xDDDDDD; this.cornerRadius = 0; this.verticalAlign = "top"; this.textIndent = 0; this.fillAlphas = [0.6, 0.4, 0.75, 0.65]; this.verticalGridLineColor = 14015965; this.themeColor = 40447; this.version = "3.0.0"; this.shadowDirection = "center"; this.modalTransparency = 0.5; this.repeatInterval = 35; this.openDuration = 250; this.textAlign = "left"; this.fontFamily = "Verdana"; this.textSelectedColor = 2831164; this.paddingBottom = 0; this.strokeWidth = 1; this.fontGridFitType = "pixel"; this.horizontalGridLines = false; this.useRollOver = true; this.verticalGridLines = true; this.repeatDelay = 500; this.fontStyle = "normal"; this.dropShadowColor = 0; this.focusThickness = 2; this.verticalGap = 6; this.disabledColor = 11187123; this.paddingRight = 0; this.focusRoundedCorners = "tl tr bl br"; this.borderSides = "left top right bottom"; this.disabledIconColor = 0x999999; this.modalTransparencyBlur = 3; this.color = 734012; this.selectionDuration = 250; this.highlightAlphas = [0.3, 0]; }; }; } } }//package
Section 240
//_headerDateTextStyle (_headerDateTextStyle) package { import mx.core.*; import mx.styles.*; public class _headerDateTextStyle { public static function init(bold:IFlexModuleFactory):void{ var fbs = bold; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".headerDateText"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".headerDateText", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fontWeight = "bold"; this.textAlign = "center"; }; }; } } }//package
Section 241
//_headerDragProxyStyleStyle (_headerDragProxyStyleStyle) package { import mx.core.*; import mx.styles.*; public class _headerDragProxyStyleStyle { public static function init(:IFlexModuleFactory):void{ var fbs = ; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".headerDragProxyStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".headerDragProxyStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fontWeight = "bold"; }; }; } } }//package
Section 242
//_linkButtonStyleStyle (_linkButtonStyleStyle) package { import mx.core.*; import mx.styles.*; public class _linkButtonStyleStyle { public static function init(http://adobe.com/AS3/2006/builtin:IFlexModuleFactory):void{ var fbs = http://adobe.com/AS3/2006/builtin; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".linkButtonStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".linkButtonStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.paddingTop = 2; this.paddingLeft = 2; this.paddingBottom = 2; this.paddingRight = 2; }; }; } } }//package
Section 243
//_opaquePanelStyle (_opaquePanelStyle) package { import mx.core.*; import mx.styles.*; public class _opaquePanelStyle { public static function init(Object:IFlexModuleFactory):void{ var fbs = Object; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".opaquePanel"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".opaquePanel", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.borderColor = 0xFFFFFF; this.backgroundColor = 0xFFFFFF; this.headerColors = [0xE7E7E7, 0xD9D9D9]; this.footerColors = [0xE7E7E7, 0xC7C7C7]; this.borderAlpha = 1; }; }; } } }//package
Section 244
//_plainStyle (_plainStyle) package { import mx.core.*; import mx.styles.*; public class _plainStyle { public static function init(backgroundImage:IFlexModuleFactory):void{ var fbs = backgroundImage; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".plain"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".plain", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.paddingTop = 0; this.backgroundColor = 0xFFFFFF; this.backgroundImage = ""; this.horizontalAlign = "left"; this.paddingLeft = 0; this.paddingBottom = 0; this.paddingRight = 0; }; }; } } }//package
Section 245
//_popUpMenuStyle (_popUpMenuStyle) package { import mx.core.*; import mx.styles.*; public class _popUpMenuStyle { public static function init(normal:IFlexModuleFactory):void{ var fbs = normal; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".popUpMenu"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".popUpMenu", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fontWeight = "normal"; this.textAlign = "left"; }; }; } } }//package
Section 246
//_richTextEditorTextAreaStyleStyle (_richTextEditorTextAreaStyleStyle) package { import mx.core.*; import mx.styles.*; public class _richTextEditorTextAreaStyleStyle { public static function init(_richTextEditorTextAreaStyleStyle:IFlexModuleFactory):void{ var fbs = _richTextEditorTextAreaStyleStyle; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".richTextEditorTextAreaStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".richTextEditorTextAreaStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ }; }; } } }//package
Section 247
//_swatchPanelTextFieldStyle (_swatchPanelTextFieldStyle) package { import mx.core.*; import mx.styles.*; public class _swatchPanelTextFieldStyle { public static function init(shadowCapColor:IFlexModuleFactory):void{ var fbs = shadowCapColor; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".swatchPanelTextField"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".swatchPanelTextField", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.borderStyle = "inset"; this.borderColor = 14015965; this.highlightColor = 12897484; this.backgroundColor = 0xFFFFFF; this.shadowCapColor = 14015965; this.shadowColor = 14015965; this.paddingLeft = 5; this.buttonColor = 7305079; this.borderCapColor = 9542041; this.paddingRight = 5; }; }; } } }//package
Section 248
//_textAreaHScrollBarStyleStyle (_textAreaHScrollBarStyleStyle) package { import mx.core.*; import mx.styles.*; public class _textAreaHScrollBarStyleStyle { public static function init(_textAreaHScrollBarStyleStyle:IFlexModuleFactory):void{ var fbs = _textAreaHScrollBarStyleStyle; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".textAreaHScrollBarStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".textAreaHScrollBarStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ }; }; } } }//package
Section 249
//_textAreaVScrollBarStyleStyle (_textAreaVScrollBarStyleStyle) package { import mx.core.*; import mx.styles.*; public class _textAreaVScrollBarStyleStyle { public static function init(_textAreaVScrollBarStyleStyle:IFlexModuleFactory):void{ var fbs = _textAreaVScrollBarStyleStyle; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".textAreaVScrollBarStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".textAreaVScrollBarStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ }; }; } } }//package
Section 250
//_todayStyleStyle (_todayStyleStyle) package { import mx.core.*; import mx.styles.*; public class _todayStyleStyle { public static function init(color:IFlexModuleFactory):void{ var fbs = color; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".todayStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".todayStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.color = 0xFFFFFF; this.textAlign = "center"; }; }; } } }//package
Section 251
//_weekDayStyleStyle (_weekDayStyleStyle) package { import mx.core.*; import mx.styles.*; public class _weekDayStyleStyle { public static function init(bold:IFlexModuleFactory):void{ var fbs = bold; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".weekDayStyle"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".weekDayStyle", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fontWeight = "bold"; this.textAlign = "center"; }; }; } } }//package
Section 252
//_windowStatusStyle (_windowStatusStyle) package { import mx.core.*; import mx.styles.*; public class _windowStatusStyle { public static function init(:IFlexModuleFactory):void{ var fbs = ; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".windowStatus"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".windowStatus", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.color = 0x666666; }; }; } } }//package
Section 253
//_windowStylesStyle (_windowStylesStyle) package { import mx.core.*; import mx.styles.*; public class _windowStylesStyle { public static function init(:IFlexModuleFactory):void{ var fbs = ; var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".windowStyles"); if (!style){ style = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration(".windowStyles", style, false); }; if (style.defaultFactory == null){ style.defaultFactory = function ():void{ this.fontWeight = "bold"; }; }; } } }//package
Section 254
//Background (Background) package { import flash.display.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; public class Background { private var m_sprite:Sprite; public function Background(){ var wallBody:b2Body; super(); m_sprite = new Sprite(); m_sprite.graphics.beginFill(0x4F4F4F); var bgWidth:uint = Constants.StageWidth; var bgHeight:uint = Constants.StageHeight; m_sprite.graphics.drawRect(0, 0, bgWidth, bgHeight); var offset:uint; var dim1:uint = 100; var dim2:uint = 25; var top:uint = 40; m_sprite.graphics.beginFill(0); m_sprite.graphics.lineStyle(2, Constants.ColorWall); m_sprite.graphics.moveTo(dim1, dim2); m_sprite.graphics.lineTo((bgWidth - dim1), dim2); m_sprite.graphics.lineTo((bgWidth - dim2), dim1); m_sprite.graphics.lineTo((bgWidth - dim2), (bgHeight - dim1)); m_sprite.graphics.lineTo((bgWidth - dim1), (bgHeight - dim2)); m_sprite.graphics.lineTo(dim1, (bgHeight - dim2)); m_sprite.graphics.lineTo(dim2, (bgHeight - dim1)); m_sprite.graphics.lineTo(dim2, dim1); m_sprite.graphics.endFill(); var world:b2World = Physics.GetWorld(); var wallShapeDef:b2PolygonDef = new b2PolygonDef(); var wallBodyDef:b2BodyDef = new b2BodyDef(); wallBodyDef.position.Set((bgWidth / 2), (dim2 / 2)); wallShapeDef.SetAsBox((bgWidth / 2), (dim2 / 2)); wallBody = world.CreateStaticBody(wallBodyDef); wallBody.CreateShape(wallShapeDef); wallBody.SetMassFromShapes(); wallBodyDef.position.Set((bgWidth / 2), (bgHeight - (dim2 / 2))); wallShapeDef.SetAsBox((bgWidth / 2), (dim2 / 2)); wallBody = world.CreateStaticBody(wallBodyDef); wallBody.CreateShape(wallShapeDef); wallBody.SetMassFromShapes(); wallBodyDef.position.Set((dim2 / 2), (bgHeight / 2)); wallShapeDef.SetAsBox((dim2 / 2), (bgHeight / 2)); wallBody = world.CreateStaticBody(wallBodyDef); wallBody.CreateShape(wallShapeDef); wallBody.SetMassFromShapes(); wallBodyDef.position.Set((bgWidth - (dim2 / 2)), (bgHeight / 2)); wallShapeDef.SetAsBox((dim2 / 2), (bgHeight / 2)); wallBody = world.CreateStaticBody(wallBodyDef); wallBody.CreateShape(wallShapeDef); wallBody.SetMassFromShapes(); var cornerPos:uint = 52; wallBodyDef.position.Set(cornerPos, cornerPos); wallBodyDef.angle = ((-45 * Math.PI) / 180); wallShapeDef.SetAsBox(60, 14); wallBody = world.CreateStaticBody(wallBodyDef); wallBody.CreateShape(wallShapeDef); wallBody.SetMassFromShapes(); wallBodyDef.position.Set((bgWidth - cornerPos), cornerPos); wallBodyDef.angle = ((45 * Math.PI) / 180); wallShapeDef.SetAsBox(60, 14); wallBody = world.CreateStaticBody(wallBodyDef); wallBody.CreateShape(wallShapeDef); wallBody.SetMassFromShapes(); wallBodyDef.position.Set((bgWidth - cornerPos), (bgHeight - cornerPos)); wallBodyDef.angle = ((-45 * Math.PI) / 180); wallShapeDef.SetAsBox(60, 14); wallBody = world.CreateStaticBody(wallBodyDef); wallBody.CreateShape(wallShapeDef); wallBody.SetMassFromShapes(); wallBodyDef.position.Set(cornerPos, (bgHeight - cornerPos)); wallBodyDef.angle = ((45 * Math.PI) / 180); wallShapeDef.SetAsBox(60, 14); wallBody = world.CreateStaticBody(wallBodyDef); wallBody.CreateShape(wallShapeDef); wallBody.SetMassFromShapes(); } public function GetSprite():Sprite{ return (m_sprite); } } }//package
Section 255
//Ball (Ball) package { import flash.display.*; import flash.geom.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; public class Ball extends Entity { public var m_past:Array; public var m_hitKillWall:Boolean;// = true private var frame:uint;// = 0 private var m_stop:Boolean;// = false public var m_sprite:Sprite; public var m_bounce:Boolean;// = false public var m_body:b2Body; public function Ball(){ m_past = new Array(); super(); m_sprite = new Sprite(); var shapeDef:b2CircleDef = new b2CircleDef(); shapeDef.radius = Constants.BallRadius; shapeDef.density = 1; shapeDef.friction = 0; shapeDef.restitution = 1; var bodyDef:b2BodyDef = new b2BodyDef(); bodyDef.position.Set(100, 80); m_body = Physics.GetWorld().CreateDynamicBody(bodyDef); m_body.CreateShape(shapeDef); m_body.SetMassFromShapes(); m_body.m_userData = this; } public function GetSprite():Sprite{ return (m_sprite); } public function HitKillWall():void{ m_hitKillWall = true; Stop(); } public function SetPosition(x:Number, y:Number):void{ m_body.SetXForm(new b2Vec2(x, y), 0); m_sprite.x = m_body.GetPosition().x; m_sprite.y = m_body.GetPosition().y; } override public function Update():Boolean{ var pt:Point; if (m_bounce){ m_bounce = false; SoundPlayer.PlaySound(SoundPlayer.SOUND_BOUNCE); }; frame++; if (m_past.length >= 30){ m_past.pop(); }; var temp:Array = new Array(); temp.push(new Point(m_sprite.x, m_sprite.y)); m_past = temp.concat(m_past); m_sprite.x = m_body.GetPosition().x; m_sprite.y = m_body.GetPosition().y; m_sprite.graphics.clear(); var radius:Number = Constants.BallRadius; var alpha:Number = 0.4; for each (pt in m_past) { radius = (radius * 0.94); alpha = (alpha * 0.95); m_sprite.graphics.beginFill(0xFF00, alpha); m_sprite.graphics.drawCircle((pt.x - m_sprite.x), (pt.y - m_sprite.y), radius); m_sprite.graphics.endFill(); }; m_sprite.graphics.beginFill(0xAA00); m_sprite.graphics.drawCircle(0, 0, Constants.BallRadius); m_sprite.graphics.endFill(); m_sprite.graphics.beginFill(0xFF00); m_sprite.graphics.drawCircle(0, 0, (Constants.BallRadius - 2)); m_sprite.graphics.endFill(); if (m_stop){ m_body.SetLinearVelocity(new b2Vec2(0, 0)); }; return (false); } public function Stop():void{ m_stop = true; } public function Start():void{ m_past = new Array(); m_stop = false; m_hitKillWall = false; } public function SetVelocity(angle:Number, speed:Number):void{ var x:Number = (Math.cos(((angle * 3.141592) / 180)) * speed); var y:Number = (Math.sin(((angle * 3.141592) / 180)) * speed); var velocity:b2Vec2 = new b2Vec2(x, y); m_body.SetLinearVelocity(velocity); } } }//package
Section 256
//Button (Button) package { import flash.events.*; import flash.display.*; import flash.text.*; public class Button extends Sprite { private var m_textfield:TextField; private var m_animFrames:uint;// = 0 private var m_animDir:int;// = 1 private var m_animate:Boolean;// = false private var m_hover:Boolean;// = false public function Button(text:String){ super(); m_textfield = new TextField(); m_textfield.embedFonts = false; m_textfield.antiAliasType = AntiAliasType.ADVANCED; m_textfield.autoSize = TextFieldAutoSize.LEFT; m_textfield.gridFitType = GridFitType.SUBPIXEL; m_textfield.x = 0; m_textfield.y = 0; m_textfield.textColor = 0xFFFFFF; m_textfield.text = text; m_textfield.mouseEnabled = false; m_textfield.selectable = false; m_textfield.setTextFormat(new TextFormat("arial", 14, 0xFFFFFF, true)); addEventListener(MouseEvent.MOUSE_OVER, onEnter); addEventListener(MouseEvent.MOUSE_OUT, onLeave); addEventListener(MouseEvent.CLICK, onClick); addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); addChild(m_textfield); } public function Animate(animate:Boolean):void{ if (m_animate != animate){ m_animate = animate; m_textfield.textColor = 0xFFFFFF; }; } public function onEnterFrame(event:Event):void{ if (((m_animate) && (!(m_hover)))){ if (m_animDir){ m_textfield.textColor = 0xFF0000; } else { m_textfield.textColor = 0xFFFFFF; }; m_animFrames++; if (m_animFrames >= 30){ if (m_animDir){ m_animDir = 0; } else { m_animDir = 1; }; m_animFrames = 0; }; }; } public function onClick(event:MouseEvent):void{ SoundPlayer.PlaySound(SoundPlayer.SOUND_CLICK); } public function onLeave(event:MouseEvent):void{ m_hover = false; m_textfield.textColor = 0xFFFFFF; } public function onEnter(event:MouseEvent):void{ m_hover = true; m_textfield.textColor = Constants.ColorAccent; } } }//package
Section 257
//Constants (Constants) package { public class Constants { public static const GoalRadius:uint = 12; public static const StageWidth:uint = 600; public static const StageHeight:uint = 450; public static const ColorAccent:uint = 0xAA00; public static const ColorHighlight:uint = 0xFCFC00; public static const ColorWall:uint = 0xB0B0B0; public static const BallRadius:uint = 10; public static const ColorUserWall:uint = 0x3CB000; public function Constants(){ super(); } } }//package
Section 258
//ContactListener (ContactListener) package { import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import Box2D.Dynamics.Joints.*; import Box2D.Dynamics.Contacts.*; import Box2D.Collision.*; import Box2D.Common.*; public class ContactListener extends b2ContactListener { public function ContactListener(){ super(); } override public function Add(point:b2ContactPoint):void{ if (point.shape1.GetBody().GetUserData() == Level.m_ball){ Level.m_ball.m_bounce = true; if (point.shape2.GetBody().GetUserData() != null){ point.shape2.GetBody().GetUserData().HitByBall(); }; } else { if (point.shape2.GetBody().GetUserData() == Level.m_ball){ Level.m_ball.m_bounce = true; if (point.shape1.GetBody().GetUserData() != null){ point.shape1.GetBody().GetUserData().HitByBall(); }; }; }; } override public function Remove(point:b2ContactPoint):void{ } override public function Persist(point:b2ContactPoint):void{ } } }//package
Section 259
//DeflectLine (DeflectLine) package { import flash.display.*; import flash.geom.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; public class DeflectLine extends Entity { private var fadeIn:Boolean; private var fadeAlpha:Number; public var ep:Point; private var m_hit:Boolean; private var fadeOut:Boolean; public var m_body:b2Body; public var m_sprite:Sprite; public var sp:Point; private var totalFadeAlpha:Number; public function DeflectLine(){ super(); m_sprite = new Sprite(); fadeAlpha = 0; fadeIn = false; fadeOut = false; m_hit = false; totalFadeAlpha = 1; } public function CreatePhysics():void{ var world:b2World = Physics.GetWorld(); var wallShapeDef:b2PolygonDef = new b2PolygonDef(); var wallBodyDef:b2BodyDef = new b2BodyDef(); var dx:Number = (sp.x - ep.x); var dy:Number = (sp.y - ep.y); var length:Number = Math.sqrt(((dx * dx) + (dy * dy))); wallBodyDef.angle = Math.atan((dy / dx)); wallBodyDef.position.Set(((sp.x + ep.x) / 2), ((sp.y + ep.y) / 2)); wallShapeDef.SetAsBox((length / 2), 3); m_body = world.CreateStaticBody(wallBodyDef); m_body.CreateShape(wallShapeDef); m_body.SetMassFromShapes(); m_body.m_userData = this; fadeIn = true; } public function DestroyPhysics():void{ if (m_body != null){ Physics.GetWorld().DestroyBody(m_body); m_body = null; }; } override public function HitByBall():void{ m_hit = true; } override public function Update():Boolean{ m_sprite.graphics.clear(); if (m_hit){ if (m_body != null){ DestroyPhysics(); }; if (totalFadeAlpha > 0){ totalFadeAlpha = (totalFadeAlpha - 0.1); } else { return (true); }; } else { if (((fadeIn) && ((fadeAlpha < 1)))){ fadeAlpha = (fadeAlpha + 0.1); } else { if (fadeAlpha >= 1){ fadeIn = false; fadeOut = true; }; }; if (((fadeOut) && ((fadeAlpha > 0)))){ fadeAlpha = (fadeAlpha - 0.1); } else { fadeOut = false; }; }; m_sprite.graphics.lineStyle(5, Constants.ColorHighlight, (fadeAlpha * totalFadeAlpha)); m_sprite.graphics.moveTo(sp.x, sp.y); m_sprite.graphics.lineTo(ep.x, ep.y); m_sprite.graphics.lineStyle(2, Constants.ColorUserWall, totalFadeAlpha); m_sprite.graphics.moveTo(sp.x, sp.y); m_sprite.graphics.lineTo(ep.x, ep.y); return (false); } public function GetSprite():Sprite{ return (m_sprite); } } }//package
Section 260
//Dialog (Dialog) package { import flash.display.*; import flash.text.*; public class Dialog { protected var m_result:uint; protected var m_panel:Sprite; protected var m_sprite:Sprite; protected var m_parent:Sprite; protected var m_bg:Sprite; public static const CANCEL:uint = 2; public static const OK:uint = 1; public static const RESUME:uint = 3; public static const RESTART:uint = 4; public function Dialog(parent:Sprite, width:uint, height:uint){ super(); m_parent = parent; m_sprite = new Sprite(); m_bg = new Sprite(); m_bg.x = 0; m_bg.y = 0; m_bg.graphics.beginFill(0, 0.5); m_bg.graphics.drawRect(0, 0, Constants.StageWidth, Constants.StageHeight); m_bg.graphics.endFill(); m_sprite.addChild(m_bg); m_panel = new Sprite(); var curve:uint = 10; m_panel.graphics.lineStyle(2, 0xAA00, 1, false, "normal", "square", "miter", 3); m_panel.graphics.beginFill(0x232323); m_panel.graphics.moveTo(curve, 0); m_panel.graphics.lineTo((width - curve), 0); m_panel.graphics.curveTo(width, 0, width, curve); m_panel.graphics.lineTo(width, (height - curve)); m_panel.graphics.curveTo(width, height, (width - curve), height); m_panel.graphics.lineTo(curve, height); m_panel.graphics.curveTo(0, height, 0, (height - curve)); m_panel.graphics.lineTo(0, curve); m_panel.graphics.curveTo(0, 0, curve, 0); m_panel.graphics.endFill(); m_sprite.addChild(m_panel); m_panel.x = ((Constants.StageWidth / 2) - (width / 2)); m_panel.y = ((Constants.StageHeight / 2) - (height / 2)); } public function Hide():void{ m_parent.removeChild(m_sprite); } public function GetResult():uint{ return (m_result); } public function GetSprite():Sprite{ return (m_sprite); } public function Show():void{ m_parent.addChild(m_sprite); } protected function CreateLabel():TextField{ var textfield:TextField = new TextField(); textfield.embedFonts = false; textfield.antiAliasType = AntiAliasType.ADVANCED; textfield.autoSize = TextFieldAutoSize.CENTER; textfield.gridFitType = GridFitType.SUBPIXEL; textfield.textColor = 0xFFFFFF; textfield.mouseEnabled = false; textfield.selectable = false; return (textfield); } public static function formatTime(time:uint):String{ var nMinute:uint = (time / 60); var nSecond:uint = (time % 60); var sSecond:String = nSecond.toString(); if (nSecond < 10){ sSecond = ("0" + sSecond); }; var sMinute:String = nMinute.toString(); return (((sMinute + ":") + sSecond)); } } }//package
Section 261
//DlgLevelCompleted (DlgLevelCompleted) package { import flash.events.*; import flash.display.*; import flash.text.*; public class DlgLevelCompleted extends Dialog { private var m_btnRetry:Button; private var m_lblLevel:TextField; private var m_lblTotalTimeHdr:TextField; private var m_lblLvlTime:TextField; private var m_alpha:Number;// = 0 private var m_paused:Boolean; private var m_btnContinue:Button; private var m_lblLvlTimeHdrLbl:TextField; private var m_totalTime:uint; private var m_lblTotalTime:TextField; private var m_lvlTime:uint; public function DlgLevelCompleted(sprite:Sprite, level:uint, lvlTime:uint, totalTime:uint, completed:Boolean, paused:Boolean=false){ super(sprite, 200, 180); m_paused = paused; m_lvlTime = lvlTime; m_totalTime = totalTime; m_lblLevel = CreateLabel(); m_lblLevel.x = 100; m_lblLevel.y = 10; m_lblLevel.textColor = 0xFFFFFF; if (completed){ m_lblLevel.text = (("Level " + level) + " Completed"); } else { if (!paused){ m_lblLevel.text = ("Too slow! Failed Level " + level); } else { if (paused){ m_lblLevel.text = "Paused"; }; }; }; m_lblLevel.setTextFormat(new TextFormat("arial", 14)); m_panel.addChild(m_lblLevel); if (!paused){ m_lblLvlTimeHdrLbl = CreateLabel(); m_lblLvlTimeHdrLbl.x = 100; m_lblLvlTimeHdrLbl.y = 40; m_lblLvlTimeHdrLbl.textColor = 0xDDDDDD; m_lblLvlTimeHdrLbl.text = "Level Time"; m_lblLvlTimeHdrLbl.setTextFormat(new TextFormat("arial", 14)); m_panel.addChild(m_lblLvlTimeHdrLbl); m_lblLvlTime = CreateLabel(); m_lblLvlTime.x = 100; m_lblLvlTime.y = 60; if (completed){ m_lblLvlTime.textColor = Constants.ColorAccent; } else { m_lblLvlTime.textColor = 0xFF0000; }; m_lblLvlTime.text = formatTime(m_lvlTime); m_lblLvlTime.setTextFormat(new TextFormat("arial", 18)); m_panel.addChild(m_lblLvlTime); m_lblTotalTimeHdr = CreateLabel(); m_lblTotalTimeHdr.x = 100; m_lblTotalTimeHdr.y = 90; m_lblTotalTimeHdr.textColor = 0xDDDDDD; m_lblTotalTimeHdr.text = "Time Limit"; m_lblTotalTimeHdr.setTextFormat(new TextFormat("arial", 14)); m_panel.addChild(m_lblTotalTimeHdr); m_lblTotalTime = CreateLabel(); m_lblTotalTime.x = 100; m_lblTotalTime.y = 110; m_lblTotalTime.textColor = 0xFFFFFF; m_lblTotalTime.text = formatTime(m_totalTime); m_lblTotalTime.setTextFormat(new TextFormat("arial", 18)); m_panel.addChild(m_lblTotalTime); }; if (((completed) || (paused))){ m_btnRetry = new Button("Retry"); m_btnRetry.x = 35; m_btnRetry.y = 150; m_btnRetry.addEventListener(MouseEvent.CLICK, onRetry); m_panel.addChild(m_btnRetry); m_btnContinue = new Button("Continue"); m_btnContinue.x = 110; m_btnContinue.y = 150; m_btnContinue.addEventListener(MouseEvent.CLICK, onContinue); m_panel.addChild(m_btnContinue); } else { m_btnRetry = new Button("Retry"); m_btnRetry.x = 80; m_btnRetry.y = 150; m_btnRetry.addEventListener(MouseEvent.CLICK, onRetry); m_panel.addChild(m_btnRetry); }; m_sprite.alpha = 0; m_panel.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); } private function onRetry(event:MouseEvent):void{ m_result = Dialog.CANCEL; } private function onContinue(event:MouseEvent):void{ if (!m_paused){ m_result = Dialog.OK; } else { m_result = Dialog.RESUME; }; } private function onEnterFrame(event:Event):void{ if (m_sprite.alpha < 1){ m_sprite.alpha = (m_sprite.alpha + 0.05); }; } public static function formatTime(time:uint):String{ var nMinute:uint = (time / 60); var nSecond:uint = (time % 60); var sSecond:String = nSecond.toString(); if (nSecond < 10){ sSecond = ("0" + sSecond); }; var sMinute:String = nMinute.toString(); return (((sMinute + ":") + sSecond)); } } }//package
Section 262
//DlgWin (DlgWin) package { import flash.events.*; import flash.display.*; import flash.text.*; import flash.net.*; public class DlgWin extends Dialog { private var m_lblMastered:TextField; private var m_lblLvlTimeHdrLbl:TextField; private var m_btnRestart:Button; private var m_btnWebsite:Button; private var m_lblLvlTime:TextField; private var m_lblCongrats:TextField; private var m_lblWebsite:TextField; public function DlgWin(sprite:Sprite, totalTime:uint){ super(sprite, 220, 215); m_lblLvlTimeHdrLbl = CreateLabel(); m_lblLvlTimeHdrLbl.x = 110; m_lblLvlTimeHdrLbl.y = 10; m_lblLvlTimeHdrLbl.textColor = 0xFFFFFF; m_lblLvlTimeHdrLbl.text = " Excellent!\nYou have mastered Deflection."; m_lblLvlTimeHdrLbl.setTextFormat(new TextFormat("arial", 14)); m_panel.addChild(m_lblLvlTimeHdrLbl); m_lblLvlTimeHdrLbl = CreateLabel(); m_lblLvlTimeHdrLbl.x = 110; m_lblLvlTimeHdrLbl.y = 60; m_lblLvlTimeHdrLbl.textColor = 0xFFFFFF; m_lblLvlTimeHdrLbl.text = "Total Game Time"; m_lblLvlTimeHdrLbl.setTextFormat(new TextFormat("arial", 14)); m_panel.addChild(m_lblLvlTimeHdrLbl); m_lblLvlTime = CreateLabel(); m_lblLvlTime.x = 110; m_lblLvlTime.y = 80; m_lblLvlTime.textColor = Constants.ColorAccent; m_lblLvlTime.text = formatTime(totalTime); m_lblLvlTime.setTextFormat(new TextFormat("arial", 18)); m_panel.addChild(m_lblLvlTime); m_lblLvlTime = CreateLabel(); m_lblLvlTime.x = 110; m_lblLvlTime.y = 125; m_lblLvlTime.textColor = 0xFFFFFF; m_lblLvlTime.text = "Find more games at"; m_lblLvlTime.setTextFormat(new TextFormat("arial", 14)); m_panel.addChild(m_lblLvlTime); m_btnWebsite = new Button("www.averagegames.com"); m_btnWebsite.x = 22; m_btnWebsite.y = 140; m_btnWebsite.addEventListener(MouseEvent.CLICK, onClickWebsite, false, 0, true); m_panel.addChild(m_btnWebsite); m_btnRestart = new Button("Retry"); m_btnRestart.x = 30; m_btnRestart.y = 195; m_btnRestart.addEventListener(MouseEvent.CLICK, onClickRetry, false, 0, true); m_panel.addChild(m_btnRestart); m_btnRestart = new Button("Restart Game"); m_btnRestart.x = 110; m_btnRestart.y = 195; m_btnRestart.addEventListener(MouseEvent.CLICK, onClickRestart, false, 0, true); m_panel.addChild(m_btnRestart); } public function onClickWebsite(event:MouseEvent):void{ navigateToURL(new URLRequest("http://www.averagegames.com/")); } public function onClickRestart(event:MouseEvent):void{ m_result = Dialog.RESTART; } public function onClickRetry(event:MouseEvent):void{ m_result = Dialog.CANCEL; } } }//package
Section 263
//en_US$core_properties (en_US$core_properties) package { import mx.resources.*; public class en_US$core_properties extends ResourceBundle { public function en_US$core_properties(){ super("en_US", "core"); } override protected function getContent():Object{ var _local1:Object = {multipleChildSets_ClassAndInstance:"Multiple sets of visual children have been specified for this component (component definition and component instance).", truncationIndicator:"...", notExecuting:"Repeater is not executing.", versionAlreadyRead:"Compatibility version has already been read.", multipleChildSets_ClassAndSubclass:"Multiple sets of visual children have been specified for this component (base component definition and derived component definition).", viewSource:"View Source", badFile:"File does not exist.", stateUndefined:"Undefined state '{0}'.", versionAlreadySet:"Compatibility version has already been set."}; return (_local1); } } }//package
Section 264
//en_US$effects_properties (en_US$effects_properties) package { import mx.resources.*; public class en_US$effects_properties extends ResourceBundle { public function en_US$effects_properties(){ super("en_US", "effects"); } override protected function getContent():Object{ var _local1:Object = {incorrectTrigger:"The Zoom effect can not be triggered by a moveEffect trigger.", incorrectSource:"Source property must be a Class or String."}; return (_local1); } } }//package
Section 265
//en_US$skins_properties (en_US$skins_properties) package { import mx.resources.*; public class en_US$skins_properties extends ResourceBundle { public function en_US$skins_properties(){ super("en_US", "skins"); } override protected function getContent():Object{ var _local1:Object = {notLoaded:"Unable to load '{0}'."}; return (_local1); } } }//package
Section 266
//en_US$styles_properties (en_US$styles_properties) package { import mx.resources.*; public class en_US$styles_properties extends ResourceBundle { public function en_US$styles_properties(){ super("en_US", "styles"); } override protected function getContent():Object{ var _local1:Object = {unableToLoad:"Unable to load style({0}): {1}."}; return (_local1); } } }//package
Section 267
//Entity (Entity) package { public class Entity { public function Entity(){ super(); } public function HitByBall():void{ } public function Update():Boolean{ return (false); } } }//package
Section 268
//Goal (Goal) package { import flash.display.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Collision.Shapes.*; public class Goal extends Entity { public var m_hit:Boolean; private var m_body:b2Body; private var m_sprite:Sprite; public function Goal(){ super(); m_sprite = new Sprite(); var shapeDef:b2CircleDef = new b2CircleDef(); shapeDef.radius = Constants.GoalRadius; shapeDef.density = 1; shapeDef.friction = 0; shapeDef.restitution = 1; var bodyDef:b2BodyDef = new b2BodyDef(); m_body = Physics.GetWorld().CreateStaticBody(bodyDef); m_body.CreateShape(shapeDef); m_body.SetMassFromShapes(); m_body.m_userData = this; m_hit = false; } override public function HitByBall():void{ m_hit = true; } override public function Update():Boolean{ m_sprite.graphics.clear(); if (m_hit){ m_sprite.graphics.lineStyle(1, 0xCECECE); m_sprite.graphics.beginFill(Constants.ColorHighlight); } else { m_sprite.graphics.lineStyle(2, 0xA0A0A0); m_sprite.graphics.beginFill(0xFEFEFE); }; m_sprite.graphics.drawCircle(0, 0, Constants.GoalRadius); m_sprite.graphics.endFill(); return (false); } public function SetPosition(x:Number, y:Number):void{ m_body.SetXForm(new b2Vec2(x, y), 0); m_sprite.x = m_body.GetPosition().x; m_sprite.y = m_body.GetPosition().y; } public function GetSprite():Sprite{ return (m_sprite); } } }//package
Section 269
//IconButton (IconButton) package { import flash.events.*; import flash.display.*; import flash.text.*; public class IconButton extends Sprite { private const m_padding:uint = 3; private var m_x:Sprite; private var m_enabled:Boolean;// = true private var m_tooltip:TextField; private var m_width:uint; private var m_height:uint; public function IconButton(bitmap:Bitmap, tooltip:String){ super(); bitmap.x = 0; bitmap.y = 0; addChild(bitmap); m_width = bitmap.width; m_height = bitmap.height; graphics.clear(); graphics.lineStyle(1, 0); graphics.beginFill(0xFFFFFF); var padding:uint = 3; graphics.drawEllipse(-(m_padding), -(m_padding), (m_width + (m_padding * 2)), (m_height + (m_padding * 2))); graphics.endFill(); m_x = new Sprite(); m_x.graphics.clear(); addChild(m_x); m_tooltip = new TextField(); m_tooltip.embedFonts = false; m_tooltip.antiAliasType = AntiAliasType.ADVANCED; m_tooltip.autoSize = TextFieldAutoSize.CENTER; m_tooltip.gridFitType = GridFitType.SUBPIXEL; m_tooltip.mouseEnabled = false; m_tooltip.selectable = false; m_tooltip.x = ((m_width / 2) - m_padding); m_tooltip.y = m_height; m_tooltip.textColor = 0xFFFFFF; m_tooltip.text = tooltip; m_tooltip.setTextFormat(new TextFormat("arial", 12)); m_tooltip.visible = false; addChild(m_tooltip); addEventListener(MouseEvent.MOUSE_OVER, onEnter); addEventListener(MouseEvent.MOUSE_OUT, onLeave); } public function onEnter(event:MouseEvent):void{ m_tooltip.visible = true; graphics.clear(); graphics.lineStyle(1, Constants.ColorAccent); graphics.beginFill(0xFFFFFF); var padding:uint = 3; graphics.drawEllipse(-(m_padding), -(m_padding), (m_width + (m_padding * 2)), (m_height + (m_padding * 2))); graphics.endFill(); } public function SetEnabled(enabled:Boolean):void{ var m_xpadding:uint; m_enabled = enabled; m_x.graphics.clear(); if (!enabled){ m_x.graphics.lineStyle(4, 0, 0.7); m_xpadding = (m_padding - 1); m_x.graphics.moveTo(-(m_xpadding), -(m_xpadding)); m_x.graphics.lineTo((m_width + m_xpadding), (m_height + m_xpadding)); m_x.graphics.moveTo((m_width + m_xpadding), -(m_xpadding)); m_x.graphics.lineTo(-(m_xpadding), (m_height + m_xpadding)); }; } public function IsEnabled():Boolean{ return (m_enabled); } public function onLeave(event:MouseEvent):void{ m_tooltip.visible = false; graphics.clear(); graphics.lineStyle(1, 0); graphics.beginFill(0xFFFFFF); var padding:uint = 3; graphics.drawEllipse(-(m_padding), -(m_padding), (m_width + (m_padding * 2)), (m_height + (m_padding * 2))); graphics.endFill(); } } }//package
Section 270
//KillWall (KillWall) package { import flash.geom.*; public class KillWall extends Wall { public function KillWall(sp:Point, ep:Point){ super(sp, ep); m_sprite.graphics.clear(); m_sprite.graphics.lineStyle(3, Constants.ColorHighlight); m_sprite.graphics.moveTo(sp.x, sp.y); m_sprite.graphics.lineTo(ep.x, ep.y); } override public function HitByBall():void{ Level.m_ball.HitKillWall(); } } }//package
Section 271
//Level (Level) package { import flash.display.*; import flash.geom.*; public class Level { private var m_ballPos:Point; private var m_goalPos:Point; private var m_sprite:Sprite; private var m_timeLimit:uint; public var m_walls:Array; public static var m_ball:Ball; public static var m_goal:Goal; public static var NumLevels:uint = 12; public function Level(parent:Sprite):void{ super(); m_walls = new Array(); m_sprite = new Sprite(); parent.addChild(m_sprite); m_ball = new Ball(); m_goal = new Goal(); m_sprite.addChild(m_ball.GetSprite()); m_sprite.addChild(m_goal.GetSprite()); } public function IsCompleted():Boolean{ return (m_goal.m_hit); } public function IsFailed():Boolean{ return (m_ball.m_hitKillWall); } public function CreateLevel(lvlNum:uint):void{ var wall:Wall; m_goal.m_hit = false; m_ball.Start(); if (lvlNum == 1){ m_walls.push(new Wall(new Point(300, 120), new Point(150, 225))); m_walls.push(new Wall(new Point(300, 120), new Point(450, 225))); m_goal.SetPosition(300, 225); m_ball.SetPosition(100, 100); m_ball.SetVelocity(90, 100); m_timeLimit = 15; } else { if (lvlNum == 2){ m_walls.push(new Wall(new Point(500, 26), new Point(500, 348))); m_walls.push(new Wall(new Point(500, 348), new Point(103, 348))); m_walls.push(new Wall(new Point(103, 348), new Point(105, 101))); m_walls.push(new Wall(new Point(105, 101), new Point(416, 101))); m_walls.push(new Wall(new Point(416, 101), new Point(416, 263))); m_walls.push(new Wall(new Point(416, 263), new Point(196, 263))); m_walls.push(new Wall(new Point(196, 263), new Point(196, 186))); m_walls.push(new Wall(new Point(196, 186), new Point(340, 186))); m_goal.SetPosition(230, 225); m_ball.SetPosition(537, 111); m_ball.SetVelocity(90, 100); m_timeLimit = 40; } else { if (lvlNum == 3){ m_walls.push(new Wall(new Point(353, 132), new Point(365, 82))); m_walls.push(new Wall(new Point(365, 82), new Point(433, 63))); m_walls.push(new Wall(new Point(433, 63), new Point(498, 116))); m_walls.push(new Wall(new Point(498, 116), new Point(0x0202, 214))); m_walls.push(new Wall(new Point(0x0202, 214), new Point(483, 297))); m_walls.push(new Wall(new Point(483, 297), new Point(432, 343))); m_walls.push(new Wall(new Point(432, 343), new Point(331, 379))); m_walls.push(new Wall(new Point(331, 379), new Point(220, 372))); m_walls.push(new Wall(new Point(220, 372), new Point(156, 338))); m_walls.push(new Wall(new Point(156, 338), new Point(92, 272))); m_walls.push(new Wall(new Point(92, 272), new Point(96, 194))); m_walls.push(new Wall(new Point(353, 132), new Point(388, 183))); m_walls.push(new Wall(new Point(388, 183), new Point(437, 179))); m_goal.SetPosition(407, 119); m_ball.SetPosition(100, 100); m_ball.SetVelocity(45, 120); m_timeLimit = 10; } else { if (lvlNum == 4){ m_walls.push(new Wall(new Point(99, 423), new Point(128, 349))); m_walls.push(new Wall(new Point(128, 349), new Point(311, 287))); m_walls.push(new Wall(new Point(303, 350), new Point(479, 291))); m_walls.push(new Wall(new Point(479, 291), new Point(573, 349))); m_walls.push(new Wall(new Point(302, 350), new Point(282, 424))); m_walls.push(new Wall(new Point(311, 287), new Point(325, 231))); m_walls.push(new Wall(new Point(325, 231), new Point(71, 304))); m_walls.push(new Wall(new Point(71, 304), new Point(25, 348))); m_walls.push(new Wall(new Point(479, 290), new Point(513, 152))); m_walls.push(new Wall(new Point(513, 152), new Point(448, 96))); m_walls.push(new Wall(new Point(448, 96), new Point(100, 26))); m_goal.SetPosition(212, 380); m_ball.SetPosition(100, 100); m_ball.SetVelocity(0, 140); m_timeLimit = 15; } else { if (lvlNum == 5){ m_walls.push(new Wall(new Point(498, 28), new Point(333, 103))); m_walls.push(new Wall(new Point(333, 103), new Point(278, 325))); m_walls.push(new Wall(new Point(278, 325), new Point(115, 325))); m_walls.push(new Wall(new Point(115, 325), new Point(115, 105))); m_walls.push(new Wall(new Point(115, 105), new Point(276, 100))); m_walls.push(new Wall(new Point(276, 100), new Point(247, 246))); m_walls.push(new Wall(new Point(247, 246), new Point(177, 173))); m_walls.push(new Wall(new Point(572, 100), new Point(422, 156))); m_walls.push(new Wall(new Point(422, 156), new Point(356, 423))); m_goal.SetPosition(228, 159); m_ball.SetPosition(506, 73); m_ball.SetVelocity(155, 110); m_timeLimit = 30; } else { if (lvlNum == 6){ m_walls.push(new Wall(new Point(126, 152), new Point(203, 109))); m_walls.push(new Wall(new Point(203, 109), new Point(159, 0xFF))); m_walls.push(new Wall(new Point(159, 0xFF), new Point(125, 154))); m_walls.push(new Wall(new Point(234, 219), new Point(216, 381))); m_walls.push(new Wall(new Point(216, 381), new Point(294, 317))); m_walls.push(new Wall(new Point(294, 317), new Point(234, 218))); m_walls.push(new Wall(new Point(269, 67), new Point(303, 113))); m_walls.push(new Wall(new Point(303, 113), new Point(339, 68))); m_walls.push(new Wall(new Point(339, 68), new Point(269, 66))); m_walls.push(new Wall(new Point((Constants.StageWidth - 126), 152), new Point((Constants.StageWidth - 203), 109))); m_walls.push(new Wall(new Point((Constants.StageWidth - 203), 109), new Point((Constants.StageWidth - 159), 0xFF))); m_walls.push(new Wall(new Point((Constants.StageWidth - 159), 0xFF), new Point((Constants.StageWidth - 125), 154))); m_walls.push(new Wall(new Point((Constants.StageWidth - 234), 219), new Point((Constants.StageWidth - 216), 381))); m_walls.push(new Wall(new Point((Constants.StageWidth - 216), 381), new Point((Constants.StageWidth - 294), 317))); m_walls.push(new Wall(new Point((Constants.StageWidth - 294), 317), new Point((Constants.StageWidth - 234), 218))); m_goal.SetPosition(300, 225); m_ball.SetPosition((Constants.StageWidth / 2), (Constants.StageHeight - 50)); m_ball.SetVelocity(20, 130); m_timeLimit = 15; } else { if (lvlNum == 7){ m_walls.push(new Wall(new Point(91, 189), new Point(86, 279))); m_walls.push(new Wall(new Point(86, 279), new Point(181, 239))); m_walls.push(new Wall(new Point(181, 239), new Point(156, 206))); m_walls.push(new Wall(new Point(240, 154), new Point(271, 181))); m_walls.push(new Wall(new Point(271, 181), new Point(312, 96))); m_walls.push(new Wall(new Point(312, 96), new Point(236, 87))); m_walls.push(new Wall(new Point(218, 278), new Point(233, 348))); m_walls.push(new Wall(new Point(233, 348), new Point(301, 249))); m_walls.push(new Wall(new Point(107, 360), new Point(160, 298))); m_walls.push(new Wall(new Point(160, 298), new Point(162, 392))); m_walls.push(new Wall(new Point(162, 392), new Point(104, 360))); m_walls.push(new Wall(new Point(362, 211), new Point(431, 167))); m_walls.push(new Wall(new Point(431, 167), new Point(380, 286))); m_walls.push(new Wall(new Point(380, 286), new Point(362, 212))); m_walls.push(new Wall(new Point(156, 205), new Point(90, 189))); m_walls.push(new Wall(new Point(239, 154), new Point(237, 88))); m_walls.push(new Wall(new Point(219, 278), new Point(300, 250))); m_walls.push(new Wall(new Point(470, 83), new Point(437, 113))); m_walls.push(new Wall(new Point(437, 113), new Point(506, 111))); m_walls.push(new Wall(new Point(506, 111), new Point(469, 83))); m_walls.push(new Wall(new Point(446, 340), new Point(493, 308))); m_walls.push(new Wall(new Point(493, 308), new Point(501, 367))); m_walls.push(new Wall(new Point(501, 367), new Point(448, 341))); m_goal.SetPosition(490, 220); m_ball.SetPosition(100, 100); m_ball.SetVelocity(45, 140); m_timeLimit = 15; } else { if (lvlNum == 8){ m_walls.push(new Wall(new Point(25, 247), new Point(86, 206))); m_walls.push(new Wall(new Point(86, 206), new Point(186, 233))); m_walls.push(new Wall(new Point(167, 314), new Point(227, 340))); m_walls.push(new Wall(new Point(227, 339), new Point(254, 423))); m_walls.push(new Wall(new Point(228, 340), new Point(332, 172))); m_walls.push(new Wall(new Point(332, 172), new Point(433, 131))); m_goal.SetPosition(165, 375); m_ball.SetPosition(330, 360); m_ball.SetVelocity(310, 140); m_timeLimit = 12; } else { if (lvlNum == 9){ m_walls.push(new Wall(new Point(133, 424), new Point(117, 331))); m_walls.push(new Wall(new Point(117, 331), new Point(152, 296))); m_walls.push(new Wall(new Point(152, 296), new Point(240, 387))); m_walls.push(new Wall(new Point(240, 387), new Point(237, 422))); m_walls.push(new Wall(new Point(281, 352), new Point(204, 261))); m_walls.push(new Wall(new Point(204, 261), new Point((Constants.StageWidth / 2), 221))); m_walls.push(new Wall(new Point(281, 352), new Point(317, 353))); m_walls.push(new Wall(new Point(287, 214), new Point(199, 250))); m_walls.push(new Wall(new Point(199, 250), new Point(159, 220))); m_walls.push(new Wall(new Point(159, 220), new Point(128, 227))); m_walls.push(new Wall(new Point(128, 227), new Point(105, 206))); m_walls.push(new Wall(new Point(105, 206), new Point(173, 194))); m_walls.push(new Wall(new Point(173, 194), new Point(216, 218))); m_walls.push(new Wall(new Point(216, 218), new Point(285, 213))); m_walls.push(new Wall(new Point((Constants.StageWidth - 287), 214), new Point((Constants.StageWidth - 199), 250))); m_walls.push(new Wall(new Point((Constants.StageWidth - 199), 250), new Point((Constants.StageWidth - 159), 220))); m_walls.push(new Wall(new Point((Constants.StageWidth - 159), 220), new Point((Constants.StageWidth - 128), 227))); m_walls.push(new Wall(new Point((Constants.StageWidth - 128), 227), new Point((Constants.StageWidth - 105), 206))); m_walls.push(new Wall(new Point((Constants.StageWidth - 105), 206), new Point((Constants.StageWidth - 173), 194))); m_walls.push(new Wall(new Point((Constants.StageWidth - 173), 194), new Point((Constants.StageWidth - 216), 218))); m_walls.push(new Wall(new Point((Constants.StageWidth - 216), 218), new Point((Constants.StageWidth - 285), 213))); m_walls.push(new Wall(new Point((Constants.StageWidth - 133), 424), new Point((Constants.StageWidth - 117), 331))); m_walls.push(new Wall(new Point((Constants.StageWidth - 117), 331), new Point((Constants.StageWidth - 152), 296))); m_walls.push(new Wall(new Point((Constants.StageWidth - 152), 296), new Point((Constants.StageWidth - 240), 387))); m_walls.push(new Wall(new Point((Constants.StageWidth - 240), 387), new Point((Constants.StageWidth - 237), 422))); m_walls.push(new Wall(new Point((Constants.StageWidth - 281), 352), new Point((Constants.StageWidth - 204), 261))); m_walls.push(new Wall(new Point((Constants.StageWidth - 204), 261), new Point((Constants.StageWidth / 2), 221))); m_goal.SetPosition((Constants.StageWidth / 2), (Constants.StageHeight - 50)); m_ball.SetPosition((Constants.StageWidth / 2), 75); m_ball.SetVelocity(90, 140); m_timeLimit = 15; } else { if (lvlNum == 10){ m_walls.push(new Wall(new Point(499, 27), new Point(303, 205))); m_walls.push(new Wall(new Point(303, 205), new Point(463, 343))); m_walls.push(new Wall(new Point(575, 348), new Point(443, 221))); m_walls.push(new Wall(new Point(443, 221), new Point(575, 99))); m_walls.push(new Wall(new Point(410, 424), new Point(162, 215))); m_walls.push(new Wall(new Point(162, 215), new Point(296, 84))); m_walls.push(new KillWall(new Point(101, 27), new Point(128, 106))); m_walls.push(new KillWall(new Point(128, 106), new Point(25, 100))); m_walls.push(new KillWall(new Point(26, 351), new Point(107, 344))); m_walls.push(new KillWall(new Point(107, 344), new Point(101, 421))); m_goal.SetPosition(222, 383); m_ball.SetPosition(520, 85); m_ball.SetVelocity(138, 140); m_timeLimit = 20; } else { if (lvlNum == 11){ m_walls.push(new Wall(new Point(179, 221), new Point(204, 171))); m_walls.push(new Wall(new Point(204, 171), new Point(312, 149))); m_walls.push(new Wall(new Point(311, 149), new Point(363, 160))); m_walls.push(new KillWall(new Point(363, 160), new Point(347, 207))); m_walls.push(new Wall(new Point(178, 222), new Point(176, 289))); m_walls.push(new Wall(new Point(176, 289), new Point(238, 343))); m_walls.push(new Wall(new Point(238, 343), new Point(294, 341))); m_walls.push(new Wall(new Point(294, 341), new Point(385, 280))); m_walls.push(new KillWall(new Point(385, 280), new Point(397, 236))); m_goal.SetPosition(246, 0xFF); m_ball.SetPosition(150, 360); m_ball.SetVelocity(0, 140); m_timeLimit = 10; } else { if (lvlNum == 12){ m_walls.push(new Wall(new Point(237, 319), new Point(294, 376))); m_walls.push(new Wall(new Point(294, 376), new Point(355, 323))); m_walls.push(new Wall(new Point(355, 323), new Point(339, 127))); m_walls.push(new Wall(new Point(339, 127), new Point(424, 95))); m_walls.push(new Wall(new Point(424, 95), new Point(485, 154))); m_walls.push(new Wall(new Point(235, 318), new Point(262, 26))); m_walls.push(new Wall(new Point(574, 177), new Point(429, 223))); m_walls.push(new Wall(new Point(355, 322), new Point(0x0202, 279))); m_walls.push(new Wall(new Point(293, 376), new Point(165, 376))); m_walls.push(new Wall(new Point(24, 349), new Point(116, 313))); m_walls.push(new Wall(new Point(117, 313), new Point(171, 87))); m_goal.SetPosition(83, 223); m_ball.SetPosition(292, 310); m_ball.SetVelocity(270, 150); m_timeLimit = 20; }; }; }; }; }; }; }; }; }; }; }; }; for each (wall in m_walls) { m_sprite.addChild(wall.GetSprite()); }; } public function Update():void{ m_ball.Update(); m_goal.Update(); if (m_goal.m_hit){ m_ball.Stop(); }; } public function DestroyLevel():void{ var wall:Wall; for each (wall in m_walls) { wall.DestroyPhysics(); m_sprite.removeChild(wall.GetSprite()); }; m_walls.splice(0, m_walls.length); } public function GetTimeLimit():uint{ return (m_timeLimit); } } }//package
Section 272
//Main (Main) package { import flash.display.*; public class Main extends Sprite { private var m_runtime:Runtime; private var m_mainMenu:MainMenu; public function Main(){ super(); } public function Init():void{ SoundPlayer.Init(); Music.Init(); Music.Play(); m_mainMenu = new MainMenu(this); addChild(m_mainMenu); } public function StartGame():void{ m_mainMenu.visible = false; removeChild(m_mainMenu); m_runtime = new Runtime(); addChild(m_runtime); m_runtime.Init(); } } }//package
Section 273
//MainMenu (MainMenu) package { import flash.events.*; import flash.display.*; import flash.net.*; public class MainMenu extends Sprite { private var m_bgImage:Bitmap; private var m_musicWebsite:Sprite; private var m_main:Main; private var m_avgWebsite:Sprite; private var m_bgSprite:Sprite; private static const ResMenuBg:Class = MainMenu_ResMenuBg; public function MainMenu(main:Main){ super(); m_main = main; m_bgImage = new ResMenuBg(); addChild(m_bgImage); m_bgSprite = new Sprite(); m_bgSprite.addEventListener(MouseEvent.CLICK, onClick, false, 0, true); m_bgSprite.addChild(m_bgImage); addChild(m_bgSprite); m_avgWebsite = new Sprite(); m_avgWebsite.x = 0; m_avgWebsite.y = 0; m_avgWebsite.graphics.beginFill(0xFFFFFF, 0); m_avgWebsite.graphics.drawRect(0, 0, 250, 40); m_avgWebsite.graphics.endFill(); m_avgWebsite.addEventListener(MouseEvent.CLICK, onClickWebsite, false, 0, true); addChild(m_avgWebsite); m_musicWebsite = new Sprite(); m_musicWebsite.x = 260; m_musicWebsite.y = 420; m_musicWebsite.graphics.beginFill(0xFFFFFF, 0); m_musicWebsite.graphics.drawRect(0, 0, 390, 30); m_musicWebsite.graphics.endFill(); m_musicWebsite.addEventListener(MouseEvent.CLICK, onClickMusic, false, 0, true); addChild(m_musicWebsite); } private function onClickMusic(event:MouseEvent):void{ navigateToURL(new URLRequest("http://www.rigaudio.com/")); } private function onClick(event:MouseEvent):void{ m_main.StartGame(); } private function onClickWebsite(event:MouseEvent):void{ navigateToURL(new URLRequest("http://www.averagegames.com/")); } } }//package
Section 274
//MainMenu_ResMenuBg (MainMenu_ResMenuBg) package { import mx.core.*; public class MainMenu_ResMenuBg extends BitmapAsset { } }//package
Section 275
//Message (Message) package { import flash.events.*; import flash.display.*; import flash.geom.*; import flash.text.*; public class Message extends Sprite { private var m_bitmap:Bitmap; private var m_textfield:TextField; private var m_message:String; private var m_start:Boolean;// = true private var m_scale:Number;// = 0 private var m_frame:uint;// = 0 public function Message(message:String, x:uint, y:uint){ super(); m_message = message; m_textfield = new TextField(); m_textfield.embedFonts = false; m_textfield.antiAliasType = AntiAliasType.ADVANCED; m_textfield.autoSize = TextFieldAutoSize.CENTER; m_textfield.gridFitType = GridFitType.SUBPIXEL; m_textfield.textColor = 0xFFFFFF; m_textfield.mouseEnabled = false; m_textfield.selectable = false; m_textfield.textColor = 0xDDDDDD; m_textfield.x = 0; m_textfield.x = 0; m_textfield.text = m_message; m_textfield.scaleX = 0; m_textfield.scaleY = 0; m_textfield.setTextFormat(new TextFormat("arial", 20)); var bitmapData:BitmapData = new BitmapData(Constants.StageWidth, 30, true, 0); var matrix:Matrix = new Matrix(); matrix.identity(); matrix.translate((Constants.StageWidth / 2), 0); bitmapData.draw(m_textfield, matrix); m_bitmap = new Bitmap(); m_bitmap.bitmapData = bitmapData; addChild(m_bitmap); m_bitmap.x = (x - (Constants.StageWidth / 2)); m_bitmap.y = 0; scaleX = 0; scaleY = 0; alpha = 0; m_start = true; addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); } public function onEnterFrame(event:Event):void{ y = (y - 1); if ((((scaleX < 1)) && ((m_frame == 0)))){ scaleX = (scaleX + 0.05); scaleY = (scaleY + 0.05); alpha = (alpha + 0.1); } else { if (m_frame < 60){ m_frame++; } else { if (alpha > 0){ alpha = (alpha - 0.03); } else { visible = false; }; }; }; } } }//package
Section 276
//MochiAd (MochiAd) package { import flash.events.*; import flash.display.*; import flash.utils.*; import flash.system.*; import flash.net.*; public class MochiAd { public function MochiAd(){ super(); } public static function getVersion():String{ return ("2.5"); } public static function showClickAwayAd(options:Object):void{ var clip:Object; var mc:MovieClip; var chk:MovieClip; var options = options; var DEFAULTS:Object = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{ }, ad_finished:function ():void{ }, ad_loaded:function (width:Number, height:Number):void{ }, ad_failed:function ():void{ trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software"); }, ad_skipped:function ():void{ }}; options = MochiAd._parseOptions(options, DEFAULTS); clip = options.clip; var ad_timeout:Number = options.ad_timeout; delete options.ad_timeout; if (!MochiAd.load(options)){ options.ad_failed(); options.ad_finished(); return; }; options.ad_started(); mc = clip._mochiad; mc["onUnload"] = function ():void{ MochiAd._cleanup(mc); options.ad_finished(); }; var wh:Array = MochiAd._getRes(options, clip); var w:Number = wh[0]; var h:Number = wh[1]; mc.x = (w * 0.5); mc.y = (h * 0.5); chk = createEmptyMovieClip(mc, "_mochiad_wait", 3); chk.ad_timeout = ad_timeout; chk.started = getTimer(); chk.showing = false; mc.unloadAd = function ():void{ MochiAd.unload(clip); }; mc.adLoaded = options.ad_loaded; mc.adSkipped = options.ad_skipped; mc.rpc = function (callbackID:Number, arg:Object):void{ MochiAd.rpc(clip, callbackID, arg); }; var sendHostProgress:Boolean; mc.regContLC = function (lc_name:String):void{ mc._containerLCName = lc_name; }; chk["onEnterFrame"] = function ():void{ var total:Number; if (!this.parent){ delete this.onEnterFrame; return; }; var ad_clip:Object = this.parent._mochiad_ctr; var elapsed:Number = (getTimer() - this.started); var finished:Boolean; if (!chk.showing){ total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal; if (total > 0){ chk.showing = true; finished = true; chk.started = getTimer(); } else { if (elapsed > chk.ad_timeout){ options.ad_failed(); finished = true; }; }; }; if (this.root == null){ finished = true; }; if (finished){ delete this.onEnterFrame; }; }; doOnEnterFrame(chk); } public static function _isNetworkAvailable():Boolean{ return (!((Security.sandboxType == "localWithFile"))); } public static function _allowDomains(server:String):String{ var hostname:String = server.split("/")[2].split(":")[0]; Security.allowDomain("*"); Security.allowDomain(hostname); Security.allowInsecureDomain("*"); Security.allowInsecureDomain(hostname); return (hostname); } public static function unload(clip:Object):Boolean{ if (((clip.clip) && (clip.clip._mochiad))){ clip = clip.clip; }; if (clip.origFrameRate != undefined){ clip.stage.frameRate = clip.origFrameRate; }; if (!clip._mochiad){ return (false); }; if (clip._mochiad._containerLCName != undefined){ clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"unload"}); }; if (clip._mochiad.onUnload){ clip._mochiad.onUnload(); }; delete clip._mochiad_loaded; delete clip._mochiad; return (true); } public static function showInterLevelAd(options:Object):void{ var clip:Object; var mc:MovieClip; var chk:MovieClip; var options = options; var DEFAULTS:Object = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{ if ((this.clip is MovieClip)){ this.clip.stop(); } else { throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.")); }; }, ad_finished:function ():void{ if ((this.clip is MovieClip)){ this.clip.play(); } else { throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.")); }; }, ad_loaded:function (width:Number, height:Number):void{ }, ad_failed:function ():void{ trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software"); }, ad_skipped:function ():void{ }}; options = MochiAd._parseOptions(options, DEFAULTS); clip = options.clip; var ad_msec:Number = 11000; var ad_timeout:Number = options.ad_timeout; delete options.ad_timeout; var fadeout_time:Number = options.fadeout_time; delete options.fadeout_time; if (!MochiAd.load(options)){ options.ad_failed(); options.ad_finished(); return; }; options.ad_started(); mc = clip._mochiad; mc["onUnload"] = function ():void{ MochiAd._cleanup(mc); options.ad_finished(); }; var wh:Array = MochiAd._getRes(options, clip); var w:Number = wh[0]; var h:Number = wh[1]; mc.x = (w * 0.5); mc.y = (h * 0.5); chk = createEmptyMovieClip(mc, "_mochiad_wait", 3); chk.ad_msec = ad_msec; chk.ad_timeout = ad_timeout; chk.started = getTimer(); chk.showing = false; chk.fadeout_time = fadeout_time; chk.fadeFunction = function ():void{ if (!this.parent){ delete this.onEnterFrame; delete this.fadeFunction; return; }; var p:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time))); if (p > 0){ this.parent.alpha = (p * 0.01); } else { MochiAd.unload(clip); delete this["onEnterFrame"]; }; }; mc.unloadAd = function ():void{ MochiAd.unload(clip); }; mc.adLoaded = options.ad_loaded; mc.adSkipped = options.ad_skipped; mc.adjustProgress = function (msec:Number):void{ var _chk:Object = mc._mochiad_wait; _chk.server_control = true; _chk.showing = true; _chk.started = getTimer(); _chk.ad_msec = (msec - 250); }; mc.rpc = function (callbackID:Number, arg:Object):void{ MochiAd.rpc(clip, callbackID, arg); }; chk["onEnterFrame"] = function ():void{ var total:Number; if (!this.parent){ delete this.onEnterFrame; delete this.fadeFunction; return; }; var ad_clip:Object = this.parent._mochiad_ctr; var elapsed:Number = (getTimer() - this.started); var finished:Boolean; if (!chk.showing){ total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal; if (total > 0){ chk.showing = true; chk.started = getTimer(); MochiAd.adShowing(clip); } else { if (elapsed > chk.ad_timeout){ options.ad_failed(); finished = true; }; }; }; if (elapsed > chk.ad_msec){ finished = true; }; if (finished){ if (this.server_control){ delete this.onEnterFrame; } else { this.fadeout_start = getTimer(); this.onEnterFrame = this.fadeFunction; }; }; }; doOnEnterFrame(chk); } public static function _parseOptions(options:Object, defaults:Object):Object{ var k:String; var pairs:Array; var i:Number; var kv:Array; var optcopy:Object = {}; for (k in defaults) { optcopy[k] = defaults[k]; }; if (options){ for (k in options) { optcopy[k] = options[k]; }; }; if (optcopy.clip == undefined){ throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite.")); }; options = optcopy.clip.loaderInfo.parameters.mochiad_options; if (options){ pairs = options.split("&"); i = 0; while (i < pairs.length) { kv = pairs[i].split("="); optcopy[unescape(kv[0])] = unescape(kv[1]); i++; }; }; if (optcopy.id == "test"){ trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!"); }; return (optcopy); } public static function _cleanup(mc:Object):void{ var k:String; var lc:LocalConnection; var f:Function; var mc = mc; if (("lc" in mc)){ lc = mc.lc; f = function ():void{ lc.client = null; lc.close(); //unresolved jump var _slot1 = e; }; setTimeout(f, 0); }; var idx:Number = DisplayObjectContainer(mc).numChildren; while (idx > 0) { idx = (idx - 1); DisplayObjectContainer(mc).removeChildAt(idx); }; for (k in mc) { delete mc[k]; }; } public static function load(options:Object):MovieClip{ var clip:Object; var k:String; var server:String; var hostname:String; var lc:LocalConnection; var name:String; var loader:Loader; var g:Function; var req:URLRequest; var v:Object; var options = options; var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"}; options = MochiAd._parseOptions(options, DEFAULTS); options.swfv = 9; options.mav = MochiAd.getVersion(); clip = options.clip; if (!MochiAd._isNetworkAvailable()){ return (null); }; if (clip._mochiad_loaded){ return (null); }; //unresolved jump var _slot1 = e; throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic.")); var depth:Number = options.depth; delete options.depth; var mc:MovieClip = createEmptyMovieClip(clip, "_mochiad", depth); var wh:Array = MochiAd._getRes(options, clip); options.res = ((wh[0] + "x") + wh[1]); options.server = (options.server + options.id); delete options.id; clip._mochiad_loaded = true; if (clip.loaderInfo.loaderURL.indexOf("http") == 0){ options.as3_swf = clip.loaderInfo.loaderURL; }; var lv:URLVariables = new URLVariables(); for (k in options) { v = options[k]; if (!(v is Function)){ lv[k] = v; }; }; server = lv.server; delete lv.server; hostname = _allowDomains(server); lc = new LocalConnection(); lc.client = mc; name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_"); lc.allowDomain("*", "localhost"); lc.allowInsecureDomain("*", "localhost"); lc.connect(name); mc.lc = lc; mc.lcName = name; lv.lc = name; lv.st = getTimer(); loader = new Loader(); g = function (ev:Object):void{ ev.target.removeEventListener(ev.type, arguments.callee); MochiAd.unload(clip); }; loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g); req = new URLRequest((server + ".swf")); req.contentType = "application/x-www-form-urlencoded"; req.method = URLRequestMethod.POST; req.data = lv; loader.load(req); mc.addChild(loader); mc._mochiad_ctr = loader; return (mc); } public static function runMethod(base:Object, methodName:String, argsArray:Array):Object{ var nameArray:Array = methodName.split("."); var i:Number = 0; while (i < (nameArray.length - 1)) { if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){ return (undefined); }; base = base[nameArray[i]]; i++; }; if (typeof(base[nameArray[i]]) == "function"){ return (base[nameArray[i]].apply(base, argsArray)); }; return (undefined); } public static function createEmptyMovieClip(parent:Object, name:String, depth:Number):MovieClip{ var mc:MovieClip = new MovieClip(); if (((false) && (depth))){ parent.addChildAt(mc, depth); } else { parent.addChild(mc); }; parent[name] = mc; mc["_name"] = name; return (mc); } public static function _getRes(options:Object, clip:Object):Array{ var xy:Array; var b:Object = clip.getBounds(clip.root); var w:Number = 0; var h:Number = 0; if (typeof(options.res) != "undefined"){ xy = options.res.split("x"); w = parseFloat(xy[0]); h = parseFloat(xy[1]); } else { w = (b.xMax - b.xMin); h = (b.yMax - b.yMin); }; if ((((w == 0)) || ((h == 0)))){ w = clip.stage.stageWidth; h = clip.stage.stageHeight; }; return ([w, h]); } public static function adShowing(mc:Object):void{ mc.origFrameRate = mc.stage.frameRate; mc.stage.frameRate = 30; } public static function getValue(base:Object, objectName:String):Object{ var nameArray:Array = objectName.split("."); var i:Number = 0; while (i < (nameArray.length - 1)) { if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){ return (undefined); }; base = base[nameArray[i]]; i++; }; return (base[nameArray[i]]); } public static function rpc(clip:Object, callbackID:Number, arg:Object):void{ var _local4:Object; var _local5:Object; switch (arg.id){ case "setValue": MochiAd.setValue(clip, arg.objectName, arg.value); break; case "getValue": _local4 = MochiAd.getValue(clip, arg.objectName); clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local4); break; case "runMethod": _local5 = MochiAd.runMethod(clip, arg.method, arg.args); clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local5); break; default: trace(("[mochiads rpc] unknown rpc id: " + arg.id)); }; } public static function setValue(base:Object, objectName:String, value:Object):void{ var nameArray:Array = objectName.split("."); var i:Number = 0; while (i < (nameArray.length - 1)) { if ((((base[nameArray[i]] == undefined)) || ((base[nameArray[i]] == null)))){ return; }; base = base[nameArray[i]]; i++; }; base[nameArray[i]] = value; } public static function showPreGameAd(options:Object):void{ var clip:Object; var mc:MovieClip; var chk:MovieClip; var complete:Boolean; var unloaded:Boolean; var sendHostProgress:Boolean; var r:MovieClip; var options = options; var DEFAULTS:Object = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{ if ((this.clip is MovieClip)){ this.clip.stop(); } else { throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.")); }; }, ad_finished:function ():void{ if ((this.clip is MovieClip)){ this.clip.play(); } else { throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers.")); }; }, ad_loaded:function (width:Number, height:Number):void{ }, ad_failed:function ():void{ trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software"); }, ad_skipped:function ():void{ }, ad_progress:function (percent:Number):void{ }}; options = MochiAd._parseOptions(options, DEFAULTS); if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){ options.ad_started(); setTimeout(options.ad_finished, 100); return; }; clip = options.clip; var ad_msec:Number = 11000; var ad_timeout:Number = options.ad_timeout; delete options.ad_timeout; var fadeout_time:Number = options.fadeout_time; delete options.fadeout_time; if (!MochiAd.load(options)){ options.ad_failed(); options.ad_finished(); return; }; options.ad_started(); mc = clip._mochiad; mc["onUnload"] = function ():void{ MochiAd._cleanup(mc); var fn:Function = function ():void{ options.ad_finished(); }; setTimeout(fn, 100); }; var wh:Array = MochiAd._getRes(options, clip); var w:Number = wh[0]; var h:Number = wh[1]; mc.x = (w * 0.5); mc.y = (h * 0.5); chk = createEmptyMovieClip(mc, "_mochiad_wait", 3); chk.x = (w * -0.5); chk.y = (h * -0.5); var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4); if (options.no_progress_bar){ bar.visible = false; delete options.no_progress_bar; } else { bar.x = 10; bar.y = (h - 20); }; var bar_color:Number = options.color; delete options.color; var bar_background:Number = options.background; delete options.background; var bar_outline:Number = options.outline; delete options.outline; var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1); var backing:Object = backing_mc.graphics; backing.beginFill(bar_background); backing.moveTo(0, 0); backing.lineTo((w - 20), 0); backing.lineTo((w - 20), 10); backing.lineTo(0, 10); backing.lineTo(0, 0); backing.endFill(); var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2); var inside:Object = inside_mc.graphics; inside.beginFill(bar_color); inside.moveTo(0, 0); inside.lineTo((w - 20), 0); inside.lineTo((w - 20), 10); inside.lineTo(0, 10); inside.lineTo(0, 0); inside.endFill(); inside_mc.scaleX = 0; var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3); var outline:Object = outline_mc.graphics; outline.lineStyle(0, bar_outline, 100); outline.moveTo(0, 0); outline.lineTo((w - 20), 0); outline.lineTo((w - 20), 10); outline.lineTo(0, 10); outline.lineTo(0, 0); chk.ad_msec = ad_msec; chk.ad_timeout = ad_timeout; chk.started = getTimer(); chk.showing = false; chk.last_pcnt = 0; chk.fadeout_time = fadeout_time; chk.fadeFunction = function ():void{ var p:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time))); if (p > 0){ this.parent.alpha = (p * 0.01); } else { MochiAd.unload(clip); delete this["onEnterFrame"]; }; }; complete = false; unloaded = false; var f:Function = function (ev:Event):void{ ev.target.removeEventListener(ev.type, arguments.callee); complete = true; if (unloaded){ MochiAd.unload(clip); }; }; clip.loaderInfo.addEventListener(Event.COMPLETE, f); if ((clip.root is MovieClip)){ r = (clip.root as MovieClip); if (r.framesLoaded >= r.totalFrames){ complete = true; }; }; mc.unloadAd = function ():void{ unloaded = true; if (complete){ MochiAd.unload(clip); }; }; mc.adLoaded = options.ad_loaded; mc.adSkipped = options.ad_skipped; mc.adjustProgress = function (msec:Number):void{ var _chk:Object = mc._mochiad_wait; _chk.server_control = true; _chk.showing = true; _chk.started = getTimer(); _chk.ad_msec = msec; }; mc.rpc = function (callbackID:Number, arg:Object):void{ MochiAd.rpc(clip, callbackID, arg); }; mc.rpcTestFn = function (s:String):Object{ trace(("[MOCHIAD rpcTestFn] " + s)); return (s); }; mc.regContLC = function (lc_name:String):void{ mc._containerLCName = lc_name; }; sendHostProgress = false; mc.sendHostLoadProgress = function (lc_name:String):void{ sendHostProgress = true; }; chk["onEnterFrame"] = function ():void{ var total:Number; if (((!(this.parent)) || (!(this.parent.parent)))){ delete this["onEnterFrame"]; return; }; var _clip:Object = this.parent.parent.root; var ad_clip:Object = this.parent._mochiad_ctr; var elapsed:Number = (getTimer() - this.started); var finished:Boolean; var clip_total:Number = _clip.loaderInfo.bytesTotal; var clip_loaded:Number = _clip.loaderInfo.bytesLoaded; if (complete){ clip_loaded = Math.max(1, clip_loaded); clip_total = clip_loaded; }; var clip_pcnt:Number = ((100 * clip_loaded) / clip_total); var ad_pcnt:Number = ((100 * elapsed) / chk.ad_msec); var _inside:Object = this._mochiad_bar._inside; var pcnt:Number = Math.min(100, Math.min(((clip_pcnt) || (0)), ad_pcnt)); pcnt = Math.max(this.last_pcnt, pcnt); this.last_pcnt = pcnt; _inside.scaleX = (pcnt * 0.01); options.ad_progress(pcnt); if (sendHostProgress){ clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:clip_pcnt}); if (clip_pcnt == 100){ sendHostProgress = false; }; }; if (!chk.showing){ total = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal; if (total > 0){ chk.showing = true; chk.started = getTimer(); MochiAd.adShowing(clip); } else { if ((((elapsed > chk.ad_timeout)) && ((clip_pcnt == 100)))){ options.ad_failed(); finished = true; }; }; }; if (elapsed > chk.ad_msec){ finished = true; }; if (((complete) && (finished))){ if (this.server_control){ delete this.onEnterFrame; } else { this.fadeout_start = getTimer(); this.onEnterFrame = chk.fadeFunction; }; }; }; doOnEnterFrame(chk); } public static function showPreloaderAd(options:Object):void{ trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0"); MochiAd.showPreGameAd(options); } public static function showTimedAd(options:Object):void{ trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0"); MochiAd.showInterLevelAd(options); } public static function doOnEnterFrame(mc:MovieClip):void{ var mc = mc; var f:Function = function (ev:Object):void{ if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){ mc.onEnterFrame(); } else { ev.target.removeEventListener(ev.type, arguments.callee); }; }; mc.addEventListener(Event.ENTER_FRAME, f); } } }//package
Section 277
//Music (Music) package { import flash.media.*; public class Music { private static const ResMusic:Class = Music_ResMusic; private static var m_music:Sound; private static var m_soundChannel:SoundChannel; public function Music(){ super(); } public static function Init():void{ m_music = new ResMusic(); } public static function Play():void{ var st:SoundTransform = new SoundTransform(0.5); m_soundChannel = m_music.play(0, 99999, st); } public static function Stop():void{ m_soundChannel.stop(); } } }//package
Section 278
//Music_ResMusic (Music_ResMusic) package { import mx.core.*; public class Music_ResMusic extends SoundAsset { } }//package
Section 279
//MyPreloader (MyPreloader) package { import flash.events.*; import flash.display.*; import flash.utils.*; public dynamic class MyPreloader extends MovieClip { private var m_adFinished:Boolean;// = false private var m_gameLoaded:Boolean;// = false private var m_adStarted:Boolean;// = false private var m_firstEnterFrame:Boolean; private var m_sprite:Sprite; public static var GAME_OPTIONS:Object = {id:"46a148ba9d056b04", res:"600x450"}; public function MyPreloader(){ var k:String; super(); stage.frameRate = 60; stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.stageWidth = Constants.StageWidth; stage.stageHeight = Constants.StageHeight; stop(); m_sprite = new Sprite(); addChild(m_sprite); m_firstEnterFrame = true; addEventListener(Event.ENTER_FRAME, onEnterFrame); var f:Function = function (ev:IOErrorEvent):void{ }; loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f); var opts:Object = {}; for (k in GAME_OPTIONS) { opts[k] = GAME_OPTIONS[k]; }; opts.ad_started = function ():void{ m_adStarted = true; }; opts.ad_finished = function ():void{ m_adFinished = true; initialize(); }; opts.clip = this; MochiAd.showPreGameAd(opts); } private function initialize():void{ var MainClass:Class; var main:Object; if (((m_adFinished) && (m_gameLoaded))){ MainClass = (getDefinitionByName("Main") as Class); if (MainClass == null){ throw (new Error("AbstractPreloader:initialize. There was no class matching that name. Did you remember to override mainClassName?")); }; main = new (MainClass); if (main == null){ throw (new Error("AbstractPreloader:initialize. Main class needs to inherit from Sprite or MovieClip.")); }; addChildAt((main as DisplayObject), 0); main.Init(); }; } private function onEnterFrame(event:Event):void{ if (framesLoaded == totalFrames){ m_gameLoaded = true; removeChild(m_sprite); removeEventListener(Event.ENTER_FRAME, onEnterFrame); nextFrame(); initialize(); }; } } }//package
Section 280
//Physics (Physics) package { import flash.display.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Collision.*; public class Physics { private static var m_world:b2World; public function Physics(){ super(); } public static function GetWorld():b2World{ return (m_world); } public static function Init(dbgSprite:Sprite):void{ var worldAABB:b2AABB = new b2AABB(); worldAABB.lowerBound.Set(-1000, -1000); worldAABB.upperBound.Set(1000, 1000); var gravity:b2Vec2 = new b2Vec2(0, 0); Physics.m_world = new b2World(worldAABB, gravity, false); var dbgDraw:b2DebugDraw = new b2DebugDraw(); dbgDraw.m_sprite = dbgSprite; dbgDraw.m_drawScale = 1; dbgDraw.m_fillAlpha = 0.3; dbgDraw.m_lineThickness = 1; dbgDraw.m_drawFlags = (b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit); m_world.SetDebugDraw(dbgDraw); var contactListener:ContactListener = new ContactListener(); m_world.SetListener(contactListener); } } }//package
Section 281
//Runtime (Runtime) package { import flash.events.*; import flash.display.*; import flash.geom.*; import flash.text.*; public class Runtime extends Sprite { private var m_lastStepTime:Number;// = 0 private var m_dbgSprite:Sprite; private var m_line:DeflectLine; private var m_currLevel:uint;// = 1 private var m_lblCurrTime:TextField; private var m_nPauseTime:Number; private var m_lines:Array; private var m_level:Level; private var m_message:Message;// = null private var StateLineStarted:uint;// = 2 private var m_lvlTime:uint;// = 0 private var m_btnRetry:Button; private var m_state:uint; private var m_background:Background; private var StateNone:uint;// = 1 private var m_soundButton:IconButton; private var m_paused:Boolean;// = false private var m_totalTime:uint;// = 0 private var m_dialog:Dialog;// = null private var m_musicButton:IconButton; private var m_frameNum:uint;// = 0 private var m_lblCurrLevel:TextField; private var m_startTime:Number;// = 0 private static const ResSoundIcon:Class = Runtime_ResSoundIcon; private static const ResMusicIcon:Class = Runtime_ResMusicIcon; public function Runtime(){ m_state = StateNone; super(); } public function mouseMove(e:MouseEvent):void{ if (m_state == StateLineStarted){ m_line.ep.x = e.stageX; m_line.ep.y = e.stageY; }; } public function onMusicClick(event:MouseEvent):void{ var enabled:Boolean = m_musicButton.IsEnabled(); if (enabled){ Music.Stop(); } else { Music.Play(); }; m_musicButton.SetEnabled(!(enabled)); } public function mouseUp(e:MouseEvent):void{ var dx:Number; var dy:Number; var length:Number; if (m_state == StateLineStarted){ dx = (m_line.sp.x - m_line.ep.x); dy = (m_line.sp.y - m_line.ep.y); length = Math.sqrt(((dx * dx) + (dy * dy))); if (length > 5){ m_line.ep = new Point(e.stageX, e.stageY); m_line.CreatePhysics(); m_lines.push(m_line); SoundPlayer.PlaySound(SoundPlayer.SOUND_WALL); } else { removeChild(m_line.GetSprite()); }; m_line = null; m_state = StateNone; }; } public function Init():void{ m_dbgSprite = new Sprite(); Physics.Init(m_dbgSprite); m_background = new Background(); addChild(m_background.GetSprite()); m_lines = new Array(); stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown, false, 0, true); stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp, false, 0, true); stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove, false, 0, true); stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp, false, 0, true); addEventListener(Event.ENTER_FRAME, update, false, 0, true); m_lblCurrTime = new TextField(); m_lblCurrTime.embedFonts = false; m_lblCurrTime.antiAliasType = AntiAliasType.ADVANCED; m_lblCurrTime.autoSize = TextFieldAutoSize.CENTER; m_lblCurrTime.gridFitType = GridFitType.SUBPIXEL; m_lblCurrTime.mouseEnabled = false; m_lblCurrTime.selectable = false; m_lblCurrTime.x = (Constants.StageWidth - 36); m_lblCurrTime.y = 15; m_lblCurrTime.textColor = 0xFFFFFF; m_lblCurrTime.text = "0:00"; m_lblCurrTime.setTextFormat(new TextFormat("arial", 20, 0xFFFFFF, true)); addChild(m_lblCurrTime); m_lblCurrLevel = new TextField(); m_lblCurrLevel.embedFonts = false; m_lblCurrLevel.antiAliasType = AntiAliasType.ADVANCED; m_lblCurrLevel.autoSize = TextFieldAutoSize.CENTER; m_lblCurrLevel.gridFitType = GridFitType.SUBPIXEL; m_lblCurrLevel.mouseEnabled = false; m_lblCurrLevel.selectable = false; m_lblCurrLevel.x = (Constants.StageWidth / 2); m_lblCurrLevel.y = 5; m_lblCurrLevel.textColor = 0xFFFFFF; m_lblCurrLevel.text = ""; addChild(m_lblCurrLevel); m_btnRetry = new Button("Retry"); m_btnRetry.x = (Constants.StageWidth - 52); m_btnRetry.y = 45; m_btnRetry.addEventListener(MouseEvent.CLICK, onRetryClicked, false, 0, true); addChild(m_btnRetry); m_musicButton = new IconButton(new ResMusicIcon(), "music"); m_musicButton.x = 48; m_musicButton.y = 18; addChild(m_musicButton); m_musicButton.addEventListener(MouseEvent.CLICK, onMusicClick, false, 0, true); m_soundButton = new IconButton(new ResSoundIcon(), "sound fx"); m_soundButton.x = 18; m_soundButton.y = 48; addChild(m_soundButton); m_soundButton.addEventListener(MouseEvent.CLICK, onSoundClick, false, 0, true); m_level = new Level(this); startLevel(); } public function onKeyUp(e:KeyboardEvent):void{ if (m_dialog == null){ m_dialog = new DlgLevelCompleted(this, m_currLevel, 0, 0, false, true); m_dialog.Show(); m_nPauseTime = new Date().time; m_paused = true; } else { if ((((e.keyCode == 27)) && (m_paused))){ m_paused = false; m_startTime = (m_startTime + (new Date().time - m_nPauseTime)); m_dialog.Hide(); m_dialog = null; m_lastStepTime = 0; }; }; } public function startLevel():void{ m_level.CreateLevel(m_currLevel); m_startTime = new Date().time; m_lblCurrLevel.text = ("Level " + m_currLevel); m_lblCurrLevel.setTextFormat(new TextFormat("arial", 14, 0xFFFFFF, true)); m_btnRetry.Animate(false); m_btnRetry.Animate(false); } public function update(e:Event):void{ var stepTime:Number; var i:uint; var completed:Boolean; if (m_dialog == null){ m_frameNum++; if ((m_frameNum % 5) == 0){ updateTimerLabel(); }; if (m_lastStepTime == 0){ stepTime = 0.01667; } else { stepTime = ((new Date().time - m_lastStepTime) / 1000); }; Physics.GetWorld().Step(stepTime, 10); m_lastStepTime = new Date().time; i = 0; while (i < m_lines.length) { if (m_lines[i].Update()){ removeChild(m_lines[i].GetSprite()); m_lines.splice(i, 1); } else { i++; }; }; if (m_line != null){ m_line.Update(); }; if (m_level != null){ m_level.Update(); if (m_dialog == null){ if (m_level.IsCompleted()){ endLevel(); completed = (m_lvlTime <= m_level.GetTimeLimit()); if (((completed) && ((m_currLevel == Level.NumLevels)))){ SoundPlayer.PlaySound(SoundPlayer.SOUND_WIN); m_totalTime = (m_totalTime + m_lvlTime); m_dialog = new DlgWin(this, m_totalTime); } else { if (completed){ SoundPlayer.PlaySound(SoundPlayer.SOUND_WIN); } else { SoundPlayer.PlaySound(SoundPlayer.SOUND_LOSE); }; m_dialog = new DlgLevelCompleted(this, m_currLevel, m_lvlTime, m_level.GetTimeLimit(), completed); }; m_dialog.Show(); } else { if (m_level.IsFailed()){ if (m_message == null){ SoundPlayer.PlaySound(SoundPlayer.SOUND_LOSE); m_message = new Message("Sticky Wall!", 0, 0); m_message.x = Level.m_ball.GetSprite().x; m_message.y = Level.m_ball.GetSprite().y; addChild(m_message); }; }; }; }; }; } else { if (m_dialog.GetResult() != 0){ if (m_dialog.GetResult() == Dialog.OK){ m_currLevel++; m_totalTime = (m_totalTime + m_lvlTime); startLevel(); } else { if (m_dialog.GetResult() == Dialog.CANCEL){ endLevel(); startLevel(); } else { if (m_dialog.GetResult() == Dialog.RESTART){ m_totalTime = 0; m_currLevel = 1; startLevel(); } else { m_startTime = (m_startTime + (new Date().time - m_nPauseTime)); m_paused = false; }; }; }; m_dialog.Hide(); m_dialog = null; m_lastStepTime = 0; }; }; } public function calcTime():uint{ var endTime:Number = new Date().time; var elapsedTime:Number = (endTime - m_startTime); return ((elapsedTime / 1000)); } public function onRetryClicked(event:MouseEvent):void{ if (m_dialog == null){ endLevel(); startLevel(); }; } public function mouseDown(e:MouseEvent):void{ if (m_dialog == null){ if ((((((((((((m_state == StateNone)) && ((e.stageX >= 0)))) && ((e.stageX < Constants.StageWidth)))) && ((e.stageY >= 0)))) && ((e.stageY < Constants.StageHeight)))) && (!((((((((e.stageX >= m_btnRetry.x)) && ((e.stageX < (m_btnRetry.x + m_btnRetry.width))))) && ((e.stageY >= m_btnRetry.y)))) && ((e.stageY < (m_btnRetry.y + m_btnRetry.height)))))))){ m_line = new DeflectLine(); m_line.sp = new Point(e.stageX, e.stageY); m_line.ep = new Point(e.stageX, e.stageY); m_state = StateLineStarted; addChild(m_line.GetSprite()); }; }; } public function endLevel():void{ var line:DeflectLine; if (m_line != null){ removeChild(m_line.GetSprite()); m_line = null; }; if (m_message != null){ removeChild(m_message); m_message = null; }; m_state = StateNone; m_level.DestroyLevel(); m_lvlTime = calcTime(); for each (line in m_lines) { removeChild(line.GetSprite()); line.DestroyPhysics(); }; m_lines = new Array(); } public function updateTimerLabel():void{ var color:uint; var currTime:uint = calcTime(); m_lblCurrTime.text = DlgLevelCompleted.formatTime(currTime); if (currTime <= m_level.GetTimeLimit()){ color = 0xFFFFFF; } else { color = 0xFF0000; }; m_lblCurrTime.setTextFormat(new TextFormat("arial", 20, color, true)); } public function onSoundClick(event:MouseEvent):void{ var line:DeflectLine; var enabled:Boolean; trace("Level Data:"); for each (line in m_lines) { trace((((((((("m_walls.push(new Wall(new Point(" + line.sp.x) + ", ") + line.sp.y) + "), new Point(") + line.ep.x) + ", ") + line.ep.y) + ")));")); }; enabled = m_soundButton.IsEnabled(); SoundPlayer.Enable(!(enabled)); m_soundButton.SetEnabled(!(enabled)); } } }//package
Section 282
//Runtime_ResMusicIcon (Runtime_ResMusicIcon) package { import mx.core.*; public class Runtime_ResMusicIcon extends BitmapAsset { } }//package
Section 283
//Runtime_ResSoundIcon (Runtime_ResSoundIcon) package { import mx.core.*; public class Runtime_ResSoundIcon extends BitmapAsset { } }//package
Section 284
//SoundPlayer (SoundPlayer) package { public class SoundPlayer { private static const SoundBounce:Class = SoundPlayer_SoundBounce; private static const SoundWall:Class = SoundPlayer_SoundWall; private static const SoundClick:Class = SoundPlayer_SoundClick; private static const SoundLose:Class = SoundPlayer_SoundLose; private static const SoundWin:Class = SoundPlayer_SoundWin; private static var m_sounds:Array; public static var SOUND_BOUNCE:uint; public static var SOUND_WALL:uint; public static var SOUND_LOSE:uint; public static var SOUND_CLICK:uint; public static var SOUND_WIN:uint; private static var m_enabled:Boolean = true; public function SoundPlayer(){ super(); } public static function PlaySound(soundId:uint):void{ if (m_enabled){ m_sounds[soundId].play(); }; } public static function Enable(enabled:Boolean):void{ m_enabled = enabled; } public static function Init():void{ m_sounds = new Array(); SOUND_WIN = (m_sounds.push(new SoundWin()) - 1); SOUND_LOSE = (m_sounds.push(new SoundLose()) - 1); SOUND_WALL = (m_sounds.push(new SoundWall()) - 1); SOUND_CLICK = (m_sounds.push(new SoundClick()) - 1); SOUND_BOUNCE = (m_sounds.push(new SoundBounce()) - 1); } } }//package
Section 285
//SoundPlayer_SoundBounce (SoundPlayer_SoundBounce) package { import mx.core.*; public class SoundPlayer_SoundBounce extends SoundAsset { } }//package
Section 286
//SoundPlayer_SoundClick (SoundPlayer_SoundClick) package { import mx.core.*; public class SoundPlayer_SoundClick extends SoundAsset { } }//package
Section 287
//SoundPlayer_SoundLose (SoundPlayer_SoundLose) package { import mx.core.*; public class SoundPlayer_SoundLose extends SoundAsset { } }//package
Section 288
//SoundPlayer_SoundWall (SoundPlayer_SoundWall) package { import mx.core.*; public class SoundPlayer_SoundWall extends SoundAsset { } }//package
Section 289
//SoundPlayer_SoundWin (SoundPlayer_SoundWin) package { import mx.core.*; public class SoundPlayer_SoundWin extends SoundAsset { } }//package
Section 290
//Wall (Wall) package { import flash.display.*; import flash.geom.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; public class Wall extends Entity { public var m_body:b2Body; public var m_sprite:Sprite; public var m_ep:Point; public var m_sp:Point; public function Wall(sp:Point, ep:Point){ var wallBodyDef:b2BodyDef; super(); m_sp = sp; m_ep = ep; m_sprite = new Sprite(); m_sprite.graphics.lineStyle(3, Constants.ColorWall); m_sprite.graphics.moveTo(sp.x, sp.y); m_sprite.graphics.lineTo(ep.x, ep.y); var world:b2World = Physics.GetWorld(); var wallShapeDef:b2PolygonDef = new b2PolygonDef(); wallBodyDef = new b2BodyDef(); var dx:Number = (sp.x - ep.x); var dy:Number = (sp.y - ep.y); var length:Number = Math.sqrt(((dx * dx) + (dy * dy))); wallBodyDef.angle = Math.atan((dy / dx)); wallBodyDef.position.Set(((sp.x + ep.x) / 2), ((sp.y + ep.y) / 2)); wallShapeDef.SetAsBox((length / 2), 3); m_body = world.CreateStaticBody(wallBodyDef); m_body.CreateShape(wallShapeDef); m_body.SetMassFromShapes(); m_body.m_userData = this; } public function GetSprite():Sprite{ return (m_sprite); } public function DestroyPhysics():void{ if (m_body != null){ Physics.GetWorld().DestroyBody(m_body); m_body = null; }; } } }//package

Library Items

Symbol 1 Sound {Music_ResMusic} [Music_ResMusic]
Symbol 2 Sound {SoundPlayer_SoundWin} [SoundPlayer_SoundWin]
Symbol 3 Sound {SoundPlayer_SoundWall} [SoundPlayer_SoundWall]
Symbol 4 Sound {SoundPlayer_SoundLose} [SoundPlayer_SoundLose]
Symbol 5 Sound {SoundPlayer_SoundBounce} [SoundPlayer_SoundBounce]
Symbol 6 Sound {SoundPlayer_SoundClick} [SoundPlayer_SoundClick]
Symbol 7 Bitmap {MainMenu_ResMenuBg}
Symbol 8 Bitmap {Runtime_ResSoundIcon}
Symbol 9 Bitmap {Runtime_ResMusicIcon}

Special Tags

FileAttributes (69)Timeline Frame 1Access network only, Metadata present, AS3.
SWFMetaData (77)Timeline Frame 1458 bytes "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'><rdf:Description rdf:about='' xmlns ..."
ScriptLimits (65)Timeline Frame 1MaxRecursionDepth: 1000, ScriptTimeout: 60 seconds
ExportAssets (56)Timeline Frame 2Symbol 1 as "Music_ResMusic"
ExportAssets (56)Timeline Frame 2Symbol 2 as "SoundPlayer_SoundWin"
ExportAssets (56)Timeline Frame 2Symbol 3 as "SoundPlayer_SoundWall"
ExportAssets (56)Timeline Frame 2Symbol 4 as "SoundPlayer_SoundLose"
ExportAssets (56)Timeline Frame 2Symbol 5 as "SoundPlayer_SoundBounce"
ExportAssets (56)Timeline Frame 2Symbol 6 as "SoundPlayer_SoundClick"
EnableDebugger2 (64)Timeline Frame 131 bytes "u.$1$Kq$3PA8bsNbV1bMkVIevWCzz.."
DebugMX1 (63)Timeline Frame 1
SerialNumber (41)Timeline Frame 1

Labels

"MyPreloader"Frame 1
"Main"Frame 2




http://swfchan.com/6/28807/info.shtml
Created: 20/5 -2019 06:05:39 Last modified: 20/5 -2019 06:05:39 Server time: 14/11 -2024 17:41:25