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

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

Uncharted-2.swf

This is the info page for
Flash #118267

(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.Collision.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2CircleShape extends b2Shape { b2internal var m_localPosition:b2Vec2; b2internal var m_radius:Number; public function b2CircleShape(_arg1:b2ShapeDef){ m_localPosition = new b2Vec2(); super(_arg1); var _local2:b2CircleDef = (_arg1 as b2CircleDef); m_type = e_circleShape; m_localPosition.SetV(_local2.localPosition); m_radius = _local2.radius; } override public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{ var _local10:Number; var _local6:b2Mat22 = _arg1.R; var _local7:Number = (_arg1.position.x + ((_local6.col1.x * m_localPosition.x) + (_local6.col2.x * m_localPosition.y))); var _local8:Number = (_arg1.position.y + ((_local6.col1.y * m_localPosition.x) + (_local6.col2.y * m_localPosition.y))); var _local9:Number = (_arg4.p1.x - _local7); _local10 = (_arg4.p1.y - _local8); var _local11:Number = (((_local9 * _local9) + (_local10 * _local10)) - (m_radius * m_radius)); if (_local11 < 0){ _arg2[0] = 0; return (e_startsInsideCollide); }; var _local12:Number = (_arg4.p2.x - _arg4.p1.x); var _local13:Number = (_arg4.p2.y - _arg4.p1.y); var _local14:Number = ((_local9 * _local12) + (_local10 * _local13)); var _local15:Number = ((_local12 * _local12) + (_local13 * _local13)); var _local16:Number = ((_local14 * _local14) - (_local15 * _local11)); if ((((_local16 < 0)) || ((_local15 < Number.MIN_VALUE)))){ return (e_missCollide); }; var _local17:Number = -((_local14 + Math.sqrt(_local16))); if ((((0 <= _local17)) && ((_local17 <= (_arg5 * _local15))))){ _local17 = (_local17 / _local15); _arg2[0] = _local17; _arg3.x = (_local9 + (_local17 * _local12)); _arg3.y = (_local10 + (_local17 * _local13)); _arg3.Normalize(); return (e_hitCollide); }; return (e_missCollide); } public function GetLocalPosition():b2Vec2{ return (m_localPosition); } public function GetRadius():Number{ return (m_radius); } override public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{ var _local4:b2Mat22; _local4 = _arg2.R; var _local5:Number = (_arg2.position.x + ((_local4.col1.x * m_localPosition.x) + (_local4.col2.x * m_localPosition.y))); var _local6:Number = (_arg2.position.y + ((_local4.col1.y * m_localPosition.x) + (_local4.col2.y * m_localPosition.y))); _local4 = _arg3.R; var _local7:Number = (_arg3.position.x + ((_local4.col1.x * m_localPosition.x) + (_local4.col2.x * m_localPosition.y))); var _local8:Number = (_arg3.position.y + ((_local4.col1.y * m_localPosition.x) + (_local4.col2.y * m_localPosition.y))); _arg1.lowerBound.Set((((_local5 < _local7)) ? _local5 : _local7 - m_radius), (((_local6 < _local8)) ? _local6 : _local8 - m_radius)); _arg1.upperBound.Set((((_local5 > _local7)) ? _local5 : _local7 + m_radius), (((_local6 > _local8)) ? _local6 : _local8 + m_radius)); } override public function ComputeMass(_arg1:b2MassData):void{ _arg1.mass = (((m_density * b2Settings.b2_pi) * m_radius) * m_radius); _arg1.center.SetV(m_localPosition); _arg1.I = (_arg1.mass * (((0.5 * m_radius) * m_radius) + ((m_localPosition.x * m_localPosition.x) + (m_localPosition.y * m_localPosition.y)))); } override b2internal function UpdateSweepRadius(_arg1:b2Vec2):void{ var _local2:Number = (m_localPosition.x - _arg1.x); var _local3:Number = (m_localPosition.y - _arg1.y); _local2 = Math.sqrt(((_local2 * _local2) + (_local3 * _local3))); m_sweepRadius = ((_local2 + m_radius) - b2Settings.b2_toiSlop); } override public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{ var _local3:b2Mat22 = _arg2.R; var _local4:Number = (_arg2.position.x + ((_local3.col1.x * m_localPosition.x) + (_local3.col2.x * m_localPosition.y))); var _local5:Number = (_arg2.position.y + ((_local3.col1.y * m_localPosition.x) + (_local3.col2.y * m_localPosition.y))); _arg1.lowerBound.Set((_local4 - m_radius), (_local5 - m_radius)); _arg1.upperBound.Set((_local4 + m_radius), (_local5 + m_radius)); } override public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{ var _local3:b2Mat22 = _arg1.R; var _local4:Number = (_arg1.position.x + ((_local3.col1.x * m_localPosition.x) + (_local3.col2.x * m_localPosition.y))); var _local5:Number = (_arg1.position.y + ((_local3.col1.y * m_localPosition.x) + (_local3.col2.y * m_localPosition.y))); _local4 = (_arg2.x - _local4); _local5 = (_arg2.y - _local5); return ((((_local4 * _local4) + (_local5 * _local5)) <= (m_radius * m_radius))); } } }//package Box2D.Collision.Shapes
Section 3
//b2FilterData (Box2D.Collision.Shapes.b2FilterData) package Box2D.Collision.Shapes { public class b2FilterData { public var maskBits:uint;// = 0xFFFF public var groupIndex:int;// = 0 public var categoryBits:uint;// = 1 public function Copy():b2FilterData{ var _local1:b2FilterData = new b2FilterData(); _local1.categoryBits = categoryBits; _local1.maskBits = maskBits; _local1.groupIndex = groupIndex; return (_local1); } } }//package Box2D.Collision.Shapes
Section 4
//b2MassData (Box2D.Collision.Shapes.b2MassData) package Box2D.Collision.Shapes { import Box2D.Common.Math.*; public class b2MassData { public var mass:Number;// = 0 public var center:b2Vec2; public var I:Number;// = 0 public function b2MassData(){ center = new b2Vec2(0, 0); super(); } } }//package Box2D.Collision.Shapes
Section 5
//b2PolygonDef (Box2D.Collision.Shapes.b2PolygonDef) package Box2D.Collision.Shapes { import Box2D.Common.Math.*; import Box2D.Common.*; public class b2PolygonDef extends b2ShapeDef { public var vertices:Array; public var vertexCount:int; private static var s_mat:b2Mat22 = new b2Mat22(); public function b2PolygonDef(){ vertices = new Array(b2Settings.b2_maxPolygonVertices); super(); type = b2Shape.e_polygonShape; vertexCount = 0; var _local1:int; while (_local1 < b2Settings.b2_maxPolygonVertices) { vertices[_local1] = new b2Vec2(); _local1++; }; } public function SetAsOrientedBox(_arg1:Number, _arg2:Number, _arg3:b2Vec2=null, _arg4:Number=0):void{ var _local5:b2Vec2; var _local6:b2Mat22; var _local7:int; vertexCount = 4; vertices[0].Set(-(_arg1), -(_arg2)); vertices[1].Set(_arg1, -(_arg2)); vertices[2].Set(_arg1, _arg2); vertices[3].Set(-(_arg1), _arg2); if (_arg3){ _local5 = _arg3; _local6 = s_mat; _local6.Set(_arg4); _local7 = 0; while (_local7 < vertexCount) { _arg3 = vertices[_local7]; _arg1 = (_local5.x + ((_local6.col1.x * _arg3.x) + (_local6.col2.x * _arg3.y))); _arg3.y = (_local5.y + ((_local6.col1.y * _arg3.x) + (_local6.col2.y * _arg3.y))); _arg3.x = _arg1; _local7++; }; }; } public function SetAsBox(_arg1:Number, _arg2:Number):void{ vertexCount = 4; vertices[0].Set(-(_arg1), -(_arg2)); vertices[1].Set(_arg1, -(_arg2)); vertices[2].Set(_arg1, _arg2); vertices[3].Set(-(_arg1), _arg2); } } }//package Box2D.Collision.Shapes
Section 6
//b2PolygonShape (Box2D.Collision.Shapes.b2PolygonShape) package Box2D.Collision.Shapes { import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2PolygonShape extends b2Shape { private var m_coreVertices:Array; b2internal var m_vertices:Array; private var s_supportVec:b2Vec2; b2internal var m_centroid:b2Vec2; b2internal var m_normals:Array; private var m_obb:b2OBB; b2internal 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(_arg1:b2ShapeDef){ var _local3:int; var _local6:Number; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17: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(_arg1); m_type = e_polygonShape; var _local2:b2PolygonDef = (_arg1 as b2PolygonDef); m_vertexCount = _local2.vertexCount; var _local4:int = _local3; var _local5:int = _local3; _local3 = 0; while (_local3 < m_vertexCount) { m_vertices[_local3] = _local2.vertices[_local3].Copy(); _local3++; }; _local3 = 0; while (_local3 < m_vertexCount) { _local4 = _local3; _local5 = (((_local3 + 1) < m_vertexCount)) ? (_local3 + 1) : 0; _local6 = (m_vertices[_local5].x - m_vertices[_local4].x); _local7 = (m_vertices[_local5].y - m_vertices[_local4].y); _local8 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7))); m_normals[_local3] = new b2Vec2((_local7 / _local8), (-(_local6) / _local8)); _local3++; }; m_centroid = ComputeCentroid(_local2.vertices, _local2.vertexCount); ComputeOBB(m_obb, m_vertices, m_vertexCount); _local3 = 0; while (_local3 < m_vertexCount) { _local4 = (((_local3 - 1) >= 0)) ? (_local3 - 1) : (m_vertexCount - 1); _local5 = _local3; _local9 = m_normals[_local4].x; _local10 = m_normals[_local4].y; _local11 = m_normals[_local5].x; _local12 = m_normals[_local5].y; _local13 = (m_vertices[_local3].x - m_centroid.x); _local14 = (m_vertices[_local3].y - m_centroid.y); _local15 = (((_local9 * _local13) + (_local10 * _local14)) - b2Settings.b2_toiSlop); _local16 = (((_local11 * _local13) + (_local12 * _local14)) - b2Settings.b2_toiSlop); _local17 = (1 / ((_local9 * _local12) - (_local10 * _local11))); m_coreVertices[_local3] = new b2Vec2(((_local17 * ((_local12 * _local15) - (_local10 * _local16))) + m_centroid.x), ((_local17 * ((_local9 * _local16) - (_local11 * _local15))) + m_centroid.y)); _local3++; }; } override public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{ var _local4:b2AABB = s_sweptAABB1; var _local5:b2AABB = s_sweptAABB2; ComputeAABB(_local4, _arg2); ComputeAABB(_local5, _arg3); _arg1.lowerBound.Set(((_local4.lowerBound.x < _local5.lowerBound.x)) ? _local4.lowerBound.x : _local5.lowerBound.x, ((_local4.lowerBound.y < _local5.lowerBound.y)) ? _local4.lowerBound.y : _local5.lowerBound.y); _arg1.upperBound.Set(((_local4.upperBound.x > _local5.upperBound.x)) ? _local4.upperBound.x : _local5.upperBound.x, ((_local4.upperBound.y > _local5.upperBound.y)) ? _local4.upperBound.y : _local5.upperBound.y); } public function GetVertices():Array{ return (m_vertices); } public function GetCoreVertices():Array{ return (m_coreVertices); } public function GetCentroid():b2Vec2{ return (m_centroid); } public function GetOBB():b2OBB{ return (m_obb); } public function GetFirstVertex(_arg1:b2XForm):b2Vec2{ return (b2Math.b2MulX(_arg1, m_coreVertices[0])); } public function Centroid(_arg1:b2XForm):b2Vec2{ return (b2Math.b2MulX(_arg1, m_centroid)); } override public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{ var _local8:Number; var _local9:Number; var _local10:b2Mat22; var _local11:b2Vec2; var _local20:Number; var _local21:Number; var _local6:Number = 0; var _local7:Number = _arg5; _local8 = (_arg4.p1.x - _arg1.position.x); _local9 = (_arg4.p1.y - _arg1.position.y); _local10 = _arg1.R; var _local12:Number = ((_local8 * _local10.col1.x) + (_local9 * _local10.col1.y)); var _local13:Number = ((_local8 * _local10.col2.x) + (_local9 * _local10.col2.y)); _local8 = (_arg4.p2.x - _arg1.position.x); _local9 = (_arg4.p2.y - _arg1.position.y); _local10 = _arg1.R; var _local14:Number = ((_local8 * _local10.col1.x) + (_local9 * _local10.col1.y)); var _local15:Number = ((_local8 * _local10.col2.x) + (_local9 * _local10.col2.y)); var _local16:Number = (_local14 - _local12); var _local17:Number = (_local15 - _local13); var _local18 = -1; var _local19:int; while (_local19 < m_vertexCount) { _local11 = m_vertices[_local19]; _local8 = (_local11.x - _local12); _local9 = (_local11.y - _local13); _local11 = m_normals[_local19]; _local20 = ((_local11.x * _local8) + (_local11.y * _local9)); _local21 = ((_local11.x * _local16) + (_local11.y * _local17)); if ((((_local21 < 0)) && ((_local20 < (_local6 * _local21))))){ _local6 = (_local20 / _local21); _local18 = _local19; } else { if ((((_local21 > 0)) && ((_local20 < (_local7 * _local21))))){ _local7 = (_local20 / _local21); }; }; if (_local7 < _local6){ return (e_missCollide); }; _local19++; }; if (_local18 >= 0){ _arg2[0] = _local6; _local10 = _arg1.R; _local11 = m_normals[_local18]; _arg3.x = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y)); _arg3.y = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y)); return (e_hitCollide); }; _arg2[0] = 0; return (e_startsInsideCollide); } override public function ComputeMass(_arg1:b2MassData):void{ var _local10:b2Vec2; var _local11:b2Vec2; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:Number; var _local20:Number; var _local21:Number; var _local22:Number; var _local23:Number; var _local24:Number; var _local25:Number; var _local2:Number = 0; var _local3:Number = 0; var _local4:Number = 0; var _local5:Number = 0; var _local6:Number = 0; var _local7:Number = 0; var _local8:Number = (1 / 3); var _local9:int; while (_local9 < m_vertexCount) { _local10 = m_vertices[_local9]; _local11 = (((_local9 + 1) < m_vertexCount)) ? m_vertices[int((_local9 + 1))] : m_vertices[0]; _local12 = (_local10.x - _local6); _local13 = (_local10.y - _local7); _local14 = (_local11.x - _local6); _local15 = (_local11.y - _local7); _local16 = ((_local12 * _local15) - (_local13 * _local14)); _local17 = (0.5 * _local16); _local4 = (_local4 + _local17); _local2 = (_local2 + ((_local17 * _local8) * ((_local6 + _local10.x) + _local11.x))); _local3 = (_local3 + ((_local17 * _local8) * ((_local7 + _local10.y) + _local11.y))); _local18 = _local6; _local19 = _local7; _local20 = _local12; _local21 = _local13; _local22 = _local14; _local23 = _local15; _local24 = ((_local8 * ((0.25 * (((_local20 * _local20) + (_local22 * _local20)) + (_local22 * _local22))) + ((_local18 * _local20) + (_local18 * _local22)))) + ((0.5 * _local18) * _local18)); _local25 = ((_local8 * ((0.25 * (((_local21 * _local21) + (_local23 * _local21)) + (_local23 * _local23))) + ((_local19 * _local21) + (_local19 * _local23)))) + ((0.5 * _local19) * _local19)); _local5 = (_local5 + (_local16 * (_local24 + _local25))); _local9++; }; _arg1.mass = (m_density * _local4); _local2 = (_local2 * (1 / _local4)); _local3 = (_local3 * (1 / _local4)); _arg1.center.Set(_local2, _local3); _arg1.I = (m_density * _local5); } public function GetNormals():Array{ return (m_normals); } public function Support(_arg1:b2XForm, _arg2:Number, _arg3:Number):b2Vec2{ var _local4:b2Vec2; var _local5:b2Mat22; var _local11:Number; _local5 = _arg1.R; var _local6:Number = ((_arg2 * _local5.col1.x) + (_arg3 * _local5.col1.y)); var _local7:Number = ((_arg2 * _local5.col2.x) + (_arg3 * _local5.col2.y)); var _local8:int; _local4 = m_coreVertices[0]; var _local9:Number = ((_local4.x * _local6) + (_local4.y * _local7)); var _local10 = 1; while (_local10 < m_vertexCount) { _local4 = m_coreVertices[_local10]; _local11 = ((_local4.x * _local6) + (_local4.y * _local7)); if (_local11 > _local9){ _local8 = _local10; _local9 = _local11; }; _local10++; }; _local5 = _arg1.R; _local4 = m_coreVertices[_local8]; s_supportVec.x = (_arg1.position.x + ((_local5.col1.x * _local4.x) + (_local5.col2.x * _local4.y))); s_supportVec.y = (_arg1.position.y + ((_local5.col1.y * _local4.x) + (_local5.col2.y * _local4.y))); return (s_supportVec); } public function GetVertexCount():int{ return (m_vertexCount); } override public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{ var _local3:b2Mat22; var _local4:b2Vec2; var _local5:b2Mat22 = s_computeMat; _local3 = _arg2.R; _local4 = m_obb.R.col1; _local5.col1.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)); _local5.col1.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y)); _local4 = m_obb.R.col2; _local5.col2.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)); _local5.col2.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y)); _local5.Abs(); var _local6:b2Mat22 = _local5; _local4 = m_obb.extents; var _local7:Number = ((_local6.col1.x * _local4.x) + (_local6.col2.x * _local4.y)); var _local8:Number = ((_local6.col1.y * _local4.x) + (_local6.col2.y * _local4.y)); _local3 = _arg2.R; _local4 = m_obb.center; var _local9:Number = (_arg2.position.x + ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y))); var _local10:Number = (_arg2.position.y + ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y))); _arg1.lowerBound.Set((_local9 - _local7), (_local10 - _local8)); _arg1.upperBound.Set((_local9 + _local7), (_local10 + _local8)); } override b2internal function UpdateSweepRadius(_arg1:b2Vec2):void{ var _local2:b2Vec2; var _local4:Number; var _local5:Number; m_sweepRadius = 0; var _local3:int; while (_local3 < m_vertexCount) { _local2 = m_coreVertices[_local3]; _local4 = (_local2.x - _arg1.x); _local5 = (_local2.y - _arg1.y); _local4 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5))); if (_local4 > m_sweepRadius){ m_sweepRadius = _local4; }; _local3++; }; } override public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{ var _local3:b2Vec2; var _local10:Number; var _local4:b2Mat22 = _arg1.R; var _local5:Number = (_arg2.x - _arg1.position.x); var _local6:Number = (_arg2.y - _arg1.position.y); var _local7:Number = ((_local5 * _local4.col1.x) + (_local6 * _local4.col1.y)); var _local8:Number = ((_local5 * _local4.col2.x) + (_local6 * _local4.col2.y)); var _local9:int; while (_local9 < m_vertexCount) { _local3 = m_vertices[_local9]; _local5 = (_local7 - _local3.x); _local6 = (_local8 - _local3.y); _local3 = m_normals[_local9]; _local10 = ((_local3.x * _local5) + (_local3.y * _local6)); if (_local10 > 0){ return (false); }; _local9++; }; return (true); } public static function ComputeCentroid(_arg1:Array, _arg2:int):b2Vec2{ var _local3:b2Vec2; var _local7:Number; var _local9:b2Vec2; var _local10:b2Vec2; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; _local3 = new b2Vec2(); var _local4:Number = 0; var _local5:Number = 0; var _local6:Number = 0; _local7 = (1 / 3); var _local8:int; while (_local8 < _arg2) { _local9 = _arg1[_local8]; _local10 = (((_local8 + 1) < _arg2)) ? _arg1[int((_local8 + 1))] : _arg1[0]; _local11 = (_local9.x - _local5); _local12 = (_local9.y - _local6); _local13 = (_local10.x - _local5); _local14 = (_local10.y - _local6); _local15 = ((_local11 * _local14) - (_local12 * _local13)); _local16 = (0.5 * _local15); _local4 = (_local4 + _local16); _local3.x = (_local3.x + ((_local16 * _local7) * ((_local5 + _local9.x) + _local10.x))); _local3.y = (_local3.y + ((_local16 * _local7) * ((_local6 + _local9.y) + _local10.y))); _local8++; }; _local3.x = (_local3.x * (1 / _local4)); _local3.y = (_local3.y * (1 / _local4)); return (_local3); } b2internal static function ComputeOBB(_arg1:b2OBB, _arg2:Array, _arg3:int):void{ var _local4:int; var _local7:b2Vec2; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:int; var _local18:Number; var _local19:Number; var _local20:Number; var _local21:Number; var _local22:Number; var _local23:Number; var _local24:Number; var _local25:b2Mat22; var _local5:Array = new Array((b2Settings.b2_maxPolygonVertices + 1)); _local4 = 0; while (_local4 < _arg3) { _local5[_local4] = _arg2[_local4]; _local4++; }; _local5[_arg3] = _local5[0]; var _local6:Number = Number.MAX_VALUE; _local4 = 1; while (_local4 <= _arg3) { _local7 = _local5[int((_local4 - 1))]; _local8 = (_local5[_local4].x - _local7.x); _local9 = (_local5[_local4].y - _local7.y); _local10 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9))); _local8 = (_local8 / _local10); _local9 = (_local9 / _local10); _local11 = -(_local9); _local12 = _local8; _local13 = Number.MAX_VALUE; _local14 = Number.MAX_VALUE; _local15 = -(Number.MAX_VALUE); _local16 = -(Number.MAX_VALUE); _local17 = 0; while (_local17 < _arg3) { _local19 = (_local5[_local17].x - _local7.x); _local20 = (_local5[_local17].y - _local7.y); _local21 = ((_local8 * _local19) + (_local9 * _local20)); _local22 = ((_local11 * _local19) + (_local12 * _local20)); if (_local21 < _local13){ _local13 = _local21; }; if (_local22 < _local14){ _local14 = _local22; }; if (_local21 > _local15){ _local15 = _local21; }; if (_local22 > _local16){ _local16 = _local22; }; _local17++; }; _local18 = ((_local15 - _local13) * (_local16 - _local14)); if (_local18 < (0.95 * _local6)){ _local6 = _local18; _arg1.R.col1.x = _local8; _arg1.R.col1.y = _local9; _arg1.R.col2.x = _local11; _arg1.R.col2.y = _local12; _local23 = (0.5 * (_local13 + _local15)); _local24 = (0.5 * (_local14 + _local16)); _local25 = _arg1.R; _arg1.center.x = (_local7.x + ((_local25.col1.x * _local23) + (_local25.col2.x * _local24))); _arg1.center.y = (_local7.y + ((_local25.col1.y * _local23) + (_local25.col2.y * _local24))); _arg1.extents.x = (0.5 * (_local15 - _local13)); _arg1.extents.y = (0.5 * (_local16 - _local14)); }; _local4++; }; } } }//package Box2D.Collision.Shapes
Section 7
//b2Shape (Box2D.Collision.Shapes.b2Shape) package Box2D.Collision.Shapes { import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2Shape { b2internal var m_next:b2Shape; b2internal var m_type:int; b2internal var m_sweepRadius:Number; b2internal var m_density:Number; private var m_filter:b2FilterData; b2internal var m_friction:Number; private var m_isSensor:Boolean; b2internal var m_restitution:Number; private var m_userData; private var m_proxyId:uint; b2internal var m_body:b2Body; b2internal static const e_polygonShape:int = 1; public static const e_hitCollide:int = 1; public static const e_missCollide:int = 0; b2internal static const e_unknownShape:int = -1; b2internal static const e_circleShape:int = 0; b2internal static const e_shapeTypeCount:int = 2; public static const e_startsInsideCollide:int = -1; 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(_arg1:b2ShapeDef){ m_userData = _arg1.userData; m_friction = _arg1.friction; m_restitution = _arg1.restitution; m_density = _arg1.density; m_body = null; m_sweepRadius = 0; m_next = null; m_proxyId = b2Pair.b2_nullProxy; m_filter = _arg1.filter.Copy(); m_isSensor = _arg1.isSensor; } public function SetUserData(_arg1):void{ m_userData = _arg1; } public function GetSweepRadius():Number{ return (m_sweepRadius); } public function GetNext():b2Shape{ return (m_next); } public function ComputeSweptAABB(_arg1:b2AABB, _arg2:b2XForm, _arg3:b2XForm):void{ } public function GetType():int{ return (m_type); } public function GetRestitution():Number{ return (m_restitution); } public function GetFriction():Number{ return (m_friction); } public function GetFilterData():b2FilterData{ return (m_filter.Copy()); } public function TestSegment(_arg1:b2XForm, _arg2:Array, _arg3:b2Vec2, _arg4:b2Segment, _arg5:Number):int{ return (e_missCollide); } b2internal function RefilterProxy(_arg1:b2BroadPhase, _arg2:b2XForm):void{ if (m_proxyId == b2Pair.b2_nullProxy){ return; }; _arg1.DestroyProxy(m_proxyId); var _local3:b2AABB = s_resetAABB; ComputeAABB(_local3, _arg2); var _local4:Boolean = _arg1.InRange(_local3); if (_local4){ m_proxyId = _arg1.CreateProxy(_local3, this); } else { m_proxyId = b2Pair.b2_nullProxy; }; } public function SetFilterData(_arg1:b2FilterData):void{ m_filter = _arg1.Copy(); } public function GetUserData(){ return (m_userData); } b2internal function Synchronize(_arg1:b2BroadPhase, _arg2:b2XForm, _arg3:b2XForm):Boolean{ if (m_proxyId == b2Pair.b2_nullProxy){ return (false); }; var _local4:b2AABB = s_syncAABB; ComputeSweptAABB(_local4, _arg2, _arg3); if (_arg1.InRange(_local4)){ _arg1.MoveProxy(m_proxyId, _local4); return (true); }; return (false); } public function ComputeMass(_arg1:b2MassData):void{ } public function IsSensor():Boolean{ return (m_isSensor); } b2internal function DestroyProxy(_arg1:b2BroadPhase):void{ if (m_proxyId != b2Pair.b2_nullProxy){ _arg1.DestroyProxy(m_proxyId); m_proxyId = b2Pair.b2_nullProxy; }; } b2internal function UpdateSweepRadius(_arg1:b2Vec2):void{ } public function ComputeAABB(_arg1:b2AABB, _arg2:b2XForm):void{ } public function GetBody():b2Body{ return (m_body); } b2internal function CreateProxy(_arg1:b2BroadPhase, _arg2:b2XForm):void{ var _local3:b2AABB = s_proxyAABB; ComputeAABB(_local3, _arg2); var _local4:Boolean = _arg1.InRange(_local3); if (_local4){ m_proxyId = _arg1.CreateProxy(_local3, this); } else { m_proxyId = b2Pair.b2_nullProxy; }; } public function TestPoint(_arg1:b2XForm, _arg2:b2Vec2):Boolean{ return (false); } b2internal static function Destroy(_arg1:b2Shape, _arg2):void{ } b2internal static function Create(_arg1:b2ShapeDef, _arg2):b2Shape{ switch (_arg1.type){ case e_circleShape: return (new b2CircleShape(_arg1)); case e_polygonShape: return (new b2PolygonShape(_arg1)); default: return (null); }; } } }//package Box2D.Collision.Shapes
Section 8
//b2ShapeDef (Box2D.Collision.Shapes.b2ShapeDef) package Box2D.Collision.Shapes { import com.kerb.uncharted.game.physics.*; public class b2ShapeDef { public var friction:Number; public var isSensor:Boolean;// = false public var density:Number;// = 0 public var restitution:Number; public var userData;// = null public var filter:b2FilterData; public var type:int; public function b2ShapeDef(){ type = b2Shape.e_unknownShape; friction = Physics.DEFAULT_FRICTION; restitution = Physics.DEFAULT_RESTITUTION; filter = new b2FilterData(); super(); } } }//package Box2D.Collision.Shapes
Section 9
//b2AABB (Box2D.Collision.b2AABB) package Box2D.Collision { import Box2D.Common.Math.*; public class b2AABB { public var upperBound:b2Vec2; public var lowerBound:b2Vec2; public function b2AABB(){ lowerBound = new b2Vec2(); upperBound = new b2Vec2(); super(); } public function IsValid():Boolean{ var _local1:Number = (upperBound.x - lowerBound.x); var _local2:Number = (upperBound.y - lowerBound.y); var _local3:Boolean = (((_local1 >= 0)) && ((_local2 >= 0))); _local3 = ((((_local3) && (lowerBound.IsValid()))) && (upperBound.IsValid())); return (_local3); } } }//package Box2D.Collision
Section 10
//b2Bound (Box2D.Collision.b2Bound) package Box2D.Collision { public class b2Bound { public var value:uint; public var proxyId:uint; public var stabbingCount:uint; public function Swap(_arg1:b2Bound):void{ var _local2:uint = value; var _local3:uint = proxyId; var _local4:uint = stabbingCount; value = _arg1.value; proxyId = _arg1.proxyId; stabbingCount = _arg1.stabbingCount; _arg1.value = _local2; _arg1.proxyId = _local3; _arg1.stabbingCount = _local4; } public function IsLower():Boolean{ return (((value & 1) == 0)); } public function IsUpper():Boolean{ return (((value & 1) == 1)); } } }//package Box2D.Collision
Section 11
//b2BoundValues (Box2D.Collision.b2BoundValues) package Box2D.Collision { public class b2BoundValues { public var lowerValues:Array; public var upperValues:Array; public function b2BoundValues(){ lowerValues = [0, 0]; upperValues = [0, 0]; super(); } } }//package Box2D.Collision
Section 12
//b2BroadPhase (Box2D.Collision.b2BroadPhase) package Box2D.Collision { import Box2D.Common.Math.*; import Box2D.Common.*; public class b2BroadPhase { b2internal var m_bounds:Array; b2internal var m_worldAABB:b2AABB; private var m_querySortKeys:Array; private var m_freeProxy:uint; b2internal var m_quantizationFactor:b2Vec2; b2internal var m_proxyCount:int; b2internal var m_proxyPool:Array; private var m_queryResultCount:int; b2internal var m_pairManager:b2PairManager; private var m_timeStamp:uint; private 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(_arg1:b2AABB, _arg2:b2PairCallback){ var _local3:int; var _local6:b2Proxy; var _local7:int; m_pairManager = new b2PairManager(); m_proxyPool = new Array(b2Settings.b2_maxPairs); m_bounds = new Array((2 * b2Settings.b2_maxProxies)); m_querySortKeys = new Array(b2Settings.b2_maxProxies); m_queryResults = new Array(b2Settings.b2_maxProxies); m_quantizationFactor = new b2Vec2(); super(); m_pairManager.Initialize(this, _arg2); m_worldAABB = _arg1; m_proxyCount = 0; _local3 = 0; while (_local3 < b2Settings.b2_maxProxies) { m_queryResults[_local3] = 0; m_querySortKeys[_local3] = 0; _local3++; }; m_bounds = new Array(2); _local3 = 0; while (_local3 < 2) { m_bounds[_local3] = new Array((2 * b2Settings.b2_maxProxies)); _local7 = 0; while (_local7 < (2 * b2Settings.b2_maxProxies)) { m_bounds[_local3][_local7] = new b2Bound(); _local7++; }; _local3++; }; var _local4:Number = (_arg1.upperBound.x - _arg1.lowerBound.x); var _local5:Number = (_arg1.upperBound.y - _arg1.lowerBound.y); m_quantizationFactor.x = (b2Settings.USHRT_MAX / _local4); m_quantizationFactor.y = (b2Settings.USHRT_MAX / _local5); _local3 = 0; while (_local3 < (b2Settings.b2_maxProxies - 1)) { _local6 = new b2Proxy(); m_proxyPool[_local3] = _local6; _local6.SetNext((_local3 + 1)); _local6.timeStamp = 0; _local6.overlapCount = b2_invalid; _local6.userData = null; _local3++; }; _local6 = new b2Proxy(); m_proxyPool[int((b2Settings.b2_maxProxies - 1))] = _local6; _local6.SetNext(b2Pair.b2_nullProxy); _local6.timeStamp = 0; _local6.overlapCount = b2_invalid; _local6.userData = null; m_freeProxy = 0; m_timeStamp = 1; m_queryResultCount = 0; } public function QueryAABB(_arg1:b2AABB, _arg2, _arg3:int):int{ var _local6:uint; var _local7:uint; var _local12:b2Proxy; var _local4:Array = new Array(); var _local5:Array = new Array(); ComputeBounds(_local4, _local5, _arg1); var _local8:Array = [_local6]; var _local9:Array = [_local7]; Query(_local8, _local9, _local4[0], _local5[0], m_bounds[0], (2 * m_proxyCount), 0); Query(_local8, _local9, _local4[1], _local5[1], m_bounds[1], (2 * m_proxyCount), 1); var _local10:int; var _local11:int; while ((((_local11 < m_queryResultCount)) && ((_local10 < _arg3)))) { _local12 = m_proxyPool[m_queryResults[_local11]]; _arg2[_local11] = _local12.userData; _local11++; _local10++; }; m_queryResultCount = 0; IncrementTimeStamp(); return (_local10); } public function Commit():void{ m_pairManager.Commit(); } public function GetProxy(_arg1:int):b2Proxy{ var _local2:b2Proxy = m_proxyPool[_arg1]; if ((((_arg1 == b2Pair.b2_nullProxy)) || ((_local2.IsValid() == false)))){ return (null); }; return (_local2); } private function IncrementTimeStamp():void{ var _local1:uint; if (m_timeStamp == b2Settings.USHRT_MAX){ _local1 = 0; while (_local1 < b2Settings.b2_maxProxies) { (m_proxyPool[_local1] as b2Proxy).timeStamp = 0; _local1++; }; m_timeStamp = 1; } else { m_timeStamp++; }; } private function Query(_arg1:Array, _arg2:Array, _arg3:uint, _arg4:uint, _arg5:Array, _arg6:uint, _arg7:int):void{ var _local10:b2Bound; var _local12:int; var _local13:int; var _local14:b2Proxy; var _local8:uint = BinarySearch(_arg5, _arg6, _arg3); var _local9:uint = BinarySearch(_arg5, _arg6, _arg4); var _local11:uint = _local8; while (_local11 < _local9) { _local10 = _arg5[_local11]; if (_local10.IsLower()){ IncrementOverlapCount(_local10.proxyId); }; _local11++; }; if (_local8 > 0){ _local12 = (_local8 - 1); _local10 = _arg5[_local12]; _local13 = _local10.stabbingCount; while (_local13) { _local10 = _arg5[_local12]; if (_local10.IsLower()){ _local14 = m_proxyPool[_local10.proxyId]; if (_local8 <= _local14.upperBounds[_arg7]){ IncrementOverlapCount(_local10.proxyId); _local13--; }; }; _local12--; }; }; _arg1[0] = _local8; _arg2[0] = _local9; } private function AddProxyResult(_arg1:uint, _arg2:b2Proxy, _arg3:Number, _arg4:Function):void{ var _local9:Number; var _local10:uint; var _local5:Number = _arg4(_arg2.userData); if (_local5 < 0){ return; }; var _local6:Number = 0; while ((((_local6 < m_queryResultCount)) && ((m_querySortKeys[_local6] < _local5)))) { _local6++; }; var _local7:Number = _local5; var _local8:uint = _arg1; m_queryResultCount = (m_queryResultCount + 1); if (m_queryResultCount > _arg3){ m_queryResultCount = _arg3; }; while (_local6 < m_queryResultCount) { _local9 = m_querySortKeys[_local6]; _local10 = m_queryResults[_local6]; m_querySortKeys[_local6] = _local7; m_queryResults[_local6] = _local8; _local7 = _local9; _local8 = _local10; _local6++; }; } private function TestOverlapValidate(_arg1:b2Proxy, _arg2:b2Proxy):Boolean{ var _local4:Array; var _local5:b2Bound; var _local6:b2Bound; var _local3:int; while (_local3 < 2) { _local4 = m_bounds[_local3]; _local5 = _local4[_arg1.lowerBounds[_local3]]; _local6 = _local4[_arg2.upperBounds[_local3]]; if (_local5.value > _local6.value){ return (false); }; _local5 = _local4[_arg1.upperBounds[_local3]]; _local6 = _local4[_arg2.lowerBounds[_local3]]; if (_local5.value < _local6.value){ return (false); }; _local3++; }; return (true); } private function ComputeBounds(_arg1:Array, _arg2:Array, _arg3:b2AABB):void{ var _local4:Number = _arg3.lowerBound.x; var _local5:Number = _arg3.lowerBound.y; _local4 = b2Math.b2Min(_local4, m_worldAABB.upperBound.x); _local5 = b2Math.b2Min(_local5, m_worldAABB.upperBound.y); _local4 = b2Math.b2Max(_local4, m_worldAABB.lowerBound.x); _local5 = b2Math.b2Max(_local5, m_worldAABB.lowerBound.y); var _local6:Number = _arg3.upperBound.x; var _local7:Number = _arg3.upperBound.y; _local6 = b2Math.b2Min(_local6, m_worldAABB.upperBound.x); _local7 = b2Math.b2Min(_local7, m_worldAABB.upperBound.y); _local6 = b2Math.b2Max(_local6, m_worldAABB.lowerBound.x); _local7 = b2Math.b2Max(_local7, m_worldAABB.lowerBound.y); _arg1[0] = (uint((m_quantizationFactor.x * (_local4 - m_worldAABB.lowerBound.x))) & (b2Settings.USHRT_MAX - 1)); _arg2[0] = ((uint((m_quantizationFactor.x * (_local6 - m_worldAABB.lowerBound.x))) & 0xFFFF) | 1); _arg1[1] = (uint((m_quantizationFactor.y * (_local5 - m_worldAABB.lowerBound.y))) & (b2Settings.USHRT_MAX - 1)); _arg2[1] = ((uint((m_quantizationFactor.y * (_local7 - m_worldAABB.lowerBound.y))) & 0xFFFF) | 1); } public function CreateProxy(_arg1:b2AABB, _arg2):uint{ var _local3:uint; var _local4:b2Proxy; var _local11:Array; var _local12:uint; var _local13:uint; var _local14:Array; var _local15:Array; var _local16:Array; var _local17:int; var _local18:int; var _local19:b2Bound; var _local20:b2Bound; var _local21:b2Bound; var _local22:int; var _local23:b2Proxy; var _local5:uint = m_freeProxy; _local4 = m_proxyPool[_local5]; m_freeProxy = _local4.GetNext(); _local4.overlapCount = 0; _local4.userData = _arg2; var _local6:uint = (2 * m_proxyCount); var _local7:Array = new Array(); var _local8:Array = new Array(); ComputeBounds(_local7, _local8, _arg1); var _local9:int; while (_local9 < 2) { _local11 = m_bounds[_local9]; _local14 = [_local12]; _local15 = [_local13]; Query(_local14, _local15, _local7[_local9], _local8[_local9], _local11, _local6, _local9); _local12 = _local14[0]; _local13 = _local15[0]; _local16 = new Array(); _local18 = (_local6 - _local13); _local17 = 0; while (_local17 < _local18) { _local16[_local17] = new b2Bound(); _local19 = _local16[_local17]; _local20 = _local11[int((_local13 + _local17))]; _local19.value = _local20.value; _local19.proxyId = _local20.proxyId; _local19.stabbingCount = _local20.stabbingCount; _local17++; }; _local18 = _local16.length; _local22 = (_local13 + 2); _local17 = 0; while (_local17 < _local18) { _local20 = _local16[_local17]; _local19 = _local11[int((_local22 + _local17))]; _local19.value = _local20.value; _local19.proxyId = _local20.proxyId; _local19.stabbingCount = _local20.stabbingCount; _local17++; }; _local16 = new Array(); _local18 = (_local13 - _local12); _local17 = 0; while (_local17 < _local18) { _local16[_local17] = new b2Bound(); _local19 = _local16[_local17]; _local20 = _local11[int((_local12 + _local17))]; _local19.value = _local20.value; _local19.proxyId = _local20.proxyId; _local19.stabbingCount = _local20.stabbingCount; _local17++; }; _local18 = _local16.length; _local22 = (_local12 + 1); _local17 = 0; while (_local17 < _local18) { _local20 = _local16[_local17]; _local19 = _local11[int((_local22 + _local17))]; _local19.value = _local20.value; _local19.proxyId = _local20.proxyId; _local19.stabbingCount = _local20.stabbingCount; _local17++; }; _local13++; _local19 = _local11[_local12]; _local20 = _local11[_local13]; _local19.value = _local7[_local9]; _local19.proxyId = _local5; _local20.value = _local8[_local9]; _local20.proxyId = _local5; _local21 = _local11[int((_local12 - 1))]; _local19.stabbingCount = ((_local12 == 0)) ? 0 : _local21.stabbingCount; _local21 = _local11[int((_local13 - 1))]; _local20.stabbingCount = _local21.stabbingCount; _local3 = _local12; while (_local3 < _local13) { _local21 = _local11[_local3]; _local21.stabbingCount++; _local3++; }; _local3 = _local12; while (_local3 < (_local6 + 2)) { _local19 = _local11[_local3]; _local23 = m_proxyPool[_local19.proxyId]; if (_local19.IsLower()){ _local23.lowerBounds[_local9] = _local3; } else { _local23.upperBounds[_local9] = _local3; }; _local3++; }; _local9++; }; m_proxyCount++; var _local10:int; while (_local10 < m_queryResultCount) { m_pairManager.AddBufferedPair(_local5, m_queryResults[_local10]); _local10++; }; m_pairManager.Commit(); m_queryResultCount = 0; IncrementTimeStamp(); return (_local5); } public function DestroyProxy(_arg1:uint):void{ var _local2:b2Bound; var _local3:b2Bound; var _local8:Array; var _local9:uint; var _local10:uint; var _local11:uint; var _local12:uint; var _local13:Array; var _local14:int; var _local15:int; var _local16:int; var _local17:uint; var _local18:int; var _local19:b2Proxy; var _local4:b2Proxy = m_proxyPool[_arg1]; var _local5:int = (2 * m_proxyCount); var _local6:int; while (_local6 < 2) { _local8 = m_bounds[_local6]; _local9 = _local4.lowerBounds[_local6]; _local10 = _local4.upperBounds[_local6]; _local2 = _local8[_local9]; _local11 = _local2.value; _local3 = _local8[_local10]; _local12 = _local3.value; _local13 = new Array(); _local15 = ((_local10 - _local9) - 1); _local14 = 0; while (_local14 < _local15) { _local13[_local14] = new b2Bound(); _local2 = _local13[_local14]; _local3 = _local8[int(((_local9 + 1) + _local14))]; _local2.value = _local3.value; _local2.proxyId = _local3.proxyId; _local2.stabbingCount = _local3.stabbingCount; _local14++; }; _local15 = _local13.length; _local16 = _local9; _local14 = 0; while (_local14 < _local15) { _local3 = _local13[_local14]; _local2 = _local8[int((_local16 + _local14))]; _local2.value = _local3.value; _local2.proxyId = _local3.proxyId; _local2.stabbingCount = _local3.stabbingCount; _local14++; }; _local13 = new Array(); _local15 = ((_local5 - _local10) - 1); _local14 = 0; while (_local14 < _local15) { _local13[_local14] = new b2Bound(); _local2 = _local13[_local14]; _local3 = _local8[int(((_local10 + 1) + _local14))]; _local2.value = _local3.value; _local2.proxyId = _local3.proxyId; _local2.stabbingCount = _local3.stabbingCount; _local14++; }; _local15 = _local13.length; _local16 = (_local10 - 1); _local14 = 0; while (_local14 < _local15) { _local3 = _local13[_local14]; _local2 = _local8[int((_local16 + _local14))]; _local2.value = _local3.value; _local2.proxyId = _local3.proxyId; _local2.stabbingCount = _local3.stabbingCount; _local14++; }; _local15 = (_local5 - 2); _local17 = _local9; while (_local17 < _local15) { _local2 = _local8[_local17]; _local19 = m_proxyPool[_local2.proxyId]; if (_local2.IsLower()){ _local19.lowerBounds[_local6] = _local17; } else { _local19.upperBounds[_local6] = _local17; }; _local17++; }; _local15 = (_local10 - 1); _local18 = _local9; while (_local18 < _local15) { _local2 = _local8[_local18]; _local2.stabbingCount--; _local18++; }; Query([0], [0], _local11, _local12, _local8, (_local5 - 2), _local6); _local6++; }; var _local7:int; while (_local7 < m_queryResultCount) { m_pairManager.RemoveBufferedPair(_arg1, m_queryResults[_local7]); _local7++; }; m_pairManager.Commit(); m_queryResultCount = 0; IncrementTimeStamp(); _local4.userData = null; _local4.overlapCount = b2_invalid; _local4.lowerBounds[0] = b2_invalid; _local4.lowerBounds[1] = b2_invalid; _local4.upperBounds[0] = b2_invalid; _local4.upperBounds[1] = b2_invalid; _local4.SetNext(m_freeProxy); m_freeProxy = _arg1; m_proxyCount--; } public function TestOverlap(_arg1:b2BoundValues, _arg2:b2Proxy):Boolean{ var _local4:Array; var _local5:b2Bound; var _local3:int; while (_local3 < 2) { _local4 = m_bounds[_local3]; _local5 = _local4[_arg2.upperBounds[_local3]]; if (_arg1.lowerValues[_local3] > _local5.value){ return (false); }; _local5 = _local4[_arg2.lowerBounds[_local3]]; if (_arg1.upperValues[_local3] < _local5.value){ return (false); }; _local3++; }; return (true); } public function Validate():void{ var _local1:b2Pair; var _local2:b2Proxy; var _local3:b2Proxy; var _local4:Boolean; var _local6:b2Bound; var _local7:uint; var _local8:uint; var _local9:uint; var _local10:b2Bound; var _local5:int; while (_local5 < 2) { _local6 = m_bounds[_local5]; _local7 = (2 * m_proxyCount); _local8 = 0; _local9 = 0; while (_local9 < _local7) { _local10 = _local6[_local9]; if (_local10.IsLower() == true){ _local8++; } else { _local8--; }; _local9++; }; _local5++; }; } private function IncrementOverlapCount(_arg1:uint):void{ var _local2:b2Proxy = m_proxyPool[_arg1]; if (_local2.timeStamp < m_timeStamp){ _local2.timeStamp = m_timeStamp; _local2.overlapCount = 1; } else { _local2.overlapCount = 2; m_queryResults[m_queryResultCount] = _arg1; m_queryResultCount++; }; } public function InRange(_arg1:b2AABB):Boolean{ var _local2:Number; var _local3:Number; var _local4:Number; var _local5:Number; _local2 = _arg1.lowerBound.x; _local3 = _arg1.lowerBound.y; _local2 = (_local2 - m_worldAABB.upperBound.x); _local3 = (_local3 - m_worldAABB.upperBound.y); _local4 = m_worldAABB.lowerBound.x; _local5 = m_worldAABB.lowerBound.y; _local4 = (_local4 - _arg1.upperBound.x); _local5 = (_local5 - _arg1.upperBound.y); _local2 = b2Math.b2Max(_local2, _local4); _local3 = b2Math.b2Max(_local3, _local5); return ((b2Math.b2Max(_local2, _local3) < 0)); } public function QuerySegment(_arg1:b2Segment, _arg2, _arg3:int, _arg4:Function):int{ var _local15:int; var _local16:int; var _local17:uint; var _local18:b2Proxy; var _local19:uint; var _local20:uint; var _local23:int; var _local24:Number; var _local25:Number; var _local26:Number; var _local27:uint; var _local28:Number; var _local29:Number; var _local5:Number = 1; var _local6:Number = ((_arg1.p2.x - _arg1.p1.x) * m_quantizationFactor.x); var _local7:Number = ((_arg1.p2.y - _arg1.p1.y) * m_quantizationFactor.y); var _local8:int = ((_local6 < -(Number.MIN_VALUE))) ? -1 : ((_local6 > Number.MIN_VALUE)) ? 1 : 0; var _local9:int = ((_local7 < -(Number.MIN_VALUE))) ? -1 : ((_local7 > Number.MIN_VALUE)) ? 1 : 0; var _local10:Number = (m_quantizationFactor.x * (_arg1.p1.x - m_worldAABB.lowerBound.x)); var _local11:Number = (m_quantizationFactor.y * (_arg1.p1.y - m_worldAABB.lowerBound.y)); var _local12:Array = new Array(); var _local13:Array = new Array(); _local12[0] = (uint(_local10) & (b2Settings.USHRT_MAX - 1)); _local12[1] = (uint(_local11) & (b2Settings.USHRT_MAX - 1)); _local13[0] = (_local12[0] + 1); _local13[1] = (_local12[1] + 1); var _local14:Array = new Array(); var _local21:Array = [_local19]; var _local22:Array = [_local20]; Query(_local21, _local22, _local12[0], _local13[0], m_bounds[0], (2 * m_proxyCount), 0); if (_local8 >= 0){ _local15 = (_local22[0] - 1); } else { _local15 = _local21[0]; }; Query(_local21, _local22, _local12[1], _local13[1], m_bounds[1], (2 * m_proxyCount), 1); if (_local9 >= 0){ _local16 = (_local22[0] - 1); } else { _local16 = _local21[0]; }; if (_arg4 != null){ _local24 = 0; while (_local24 < m_queryResultCount) { m_querySortKeys[_local24] = _arg4(m_proxyPool[m_queryResults[_local24]].userData); _local24++; }; _local24 = 0; while (_local24 < (m_queryResultCount - 1)) { _local25 = m_querySortKeys[_local24]; _local26 = m_querySortKeys[(_local24 + 1)]; if (((_local25)<0) ? (_local26 >= 0) : (((_local25 > _local26)) && ((_local26 >= 0)))){ m_querySortKeys[(_local24 + 1)] = _local25; m_querySortKeys[_local24] = _local26; _local27 = m_queryResults[(_local24 + 1)]; m_queryResults[(_local24 + 1)] = m_queryResults[_local24]; m_queryResults[_local24] = _local27; --_local24; if (_local24 == -1){ _local24 = 1; }; } else { _local24++; }; }; while ((((m_queryResultCount > 0)) && ((m_querySortKeys[(m_queryResultCount - 1)] < 0)))) { m_queryResultCount--; }; }; while (true) { _local28 = 0; _local29 = 0; _local15 = (_local15 + ((_local8 >= 0)) ? 1 : -1); if ((((_local15 < 0)) || ((_local15 >= (m_proxyCount * 2))))){ break; }; if (_local8 != 0){ _local28 = ((m_bounds[0][_local15].value - _local10) / _local6); }; _local16 = (_local16 + ((_local9 >= 0)) ? 1 : -1); if ((((_local16 < 0)) || ((_local16 >= (m_proxyCount * 2))))){ break; }; if (_local9 != 0){ _local29 = ((m_bounds[1][_local16].value - _local11) / _local7); }; while (true) { if ((((_local9 == 0)) || (((!((_local8 == 0))) && ((_local28 < _local29)))))){ if (_local28 > _local5){ break; }; if (((_local8 > 0)) ? m_bounds[0][_local15].IsLower() : m_bounds[0][_local15].IsUpper()){ _local17 = m_bounds[0][_local15].proxyId; _local18 = m_proxyPool[_local17]; if (_local9 >= 0){ if ((((_local18.lowerBounds[1] <= (_local16 - 1))) && ((_local18.upperBounds[1] >= _local16)))){ if (_arg4 != null){ AddProxyResult(_local17, _local18, _arg3, _arg4); } else { m_queryResults[m_queryResultCount] = _local17; m_queryResultCount++; }; }; } else { if ((((_local18.lowerBounds[1] <= _local16)) && ((_local18.upperBounds[1] >= (_local16 + 1))))){ if (_arg4 != null){ AddProxyResult(_local17, _local18, _arg3, _arg4); } else { m_queryResults[m_queryResultCount] = _local17; m_queryResultCount++; }; }; }; }; if (((((((!((_arg4 == null))) && ((m_queryResultCount == _arg3)))) && ((m_queryResultCount > 0)))) && ((_local28 > m_querySortKeys[(m_queryResultCount - 1)])))){ break; }; if (_local8 > 0){ _local15++; if (_local15 == (m_proxyCount * 2)){ break; }; } else { --_local15; if (_local15 < 0){ break; }; }; _local28 = ((m_bounds[0][_local15].value - _local10) / _local6); } else { if (_local29 > _local5){ break; }; if (((_local9 > 0)) ? m_bounds[1][_local16].IsLower() : m_bounds[1][_local16].IsUpper()){ _local17 = m_bounds[1][_local16].proxyId; _local18 = m_proxyPool[_local17]; if (_local8 >= 0){ if ((((_local18.lowerBounds[0] <= (_local15 - 1))) && ((_local18.upperBounds[0] >= _local15)))){ if (_arg4 != null){ AddProxyResult(_local17, _local18, _arg3, _arg4); } else { m_queryResults[m_queryResultCount] = _local17; m_queryResultCount++; }; }; } else { if ((((_local18.lowerBounds[0] <= _local15)) && ((_local18.upperBounds[0] >= (_local15 + 1))))){ if (_arg4 != null){ AddProxyResult(_local17, _local18, _arg3, _arg4); } else { m_queryResults[m_queryResultCount] = _local17; m_queryResultCount++; }; }; }; }; if (((((((!((_arg4 == null))) && ((m_queryResultCount == _arg3)))) && ((m_queryResultCount > 0)))) && ((_local29 > m_querySortKeys[(m_queryResultCount - 1)])))){ break; }; if (_local9 > 0){ _local16++; if (_local16 == (m_proxyCount * 2)){ break; }; } else { --_local16; if (_local16 < 0){ break; }; }; _local29 = ((m_bounds[1][_local16].value - _local11) / _local7); }; }; break; }; _local23 = 0; _local24 = 0; while ((((_local24 < m_queryResultCount)) && ((_local23 < _arg3)))) { _local18 = m_proxyPool[m_queryResults[_local24]]; _arg2[_local24] = _local18.userData; _local24++; _local23++; }; m_queryResultCount = 0; IncrementTimeStamp(); return (_local23); } public function MoveProxy(_arg1:uint, _arg2:b2AABB):void{ var _local3:Array; var _local4:int; var _local5:uint; var _local6:uint; var _local7:b2Bound; var _local8:b2Bound; var _local9:b2Bound; var _local10:uint; var _local11:b2Proxy; var _local16:Array; var _local17:uint; var _local18:uint; var _local19:uint; var _local20:uint; var _local21:int; var _local22:int; var _local23:uint; var _local24:b2Proxy; if ((((_arg1 == b2Pair.b2_nullProxy)) || ((b2Settings.b2_maxProxies <= _arg1)))){ return; }; if (_arg2.IsValid() == false){ return; }; var _local12:uint = (2 * m_proxyCount); var _local13:b2Proxy = m_proxyPool[_arg1]; var _local14:b2BoundValues = new b2BoundValues(); ComputeBounds(_local14.lowerValues, _local14.upperValues, _arg2); var _local15:b2BoundValues = new b2BoundValues(); _local5 = 0; while (_local5 < 2) { _local7 = m_bounds[_local5][_local13.lowerBounds[_local5]]; _local15.lowerValues[_local5] = _local7.value; _local7 = m_bounds[_local5][_local13.upperBounds[_local5]]; _local15.upperValues[_local5] = _local7.value; _local5++; }; _local5 = 0; while (_local5 < 2) { _local16 = m_bounds[_local5]; _local17 = _local13.lowerBounds[_local5]; _local18 = _local13.upperBounds[_local5]; _local19 = _local14.lowerValues[_local5]; _local20 = _local14.upperValues[_local5]; _local7 = _local16[_local17]; _local21 = (_local19 - _local7.value); _local7.value = _local19; _local7 = _local16[_local18]; _local22 = (_local20 - _local7.value); _local7.value = _local20; if (_local21 < 0){ _local6 = _local17; while ((((_local6 > 0)) && ((_local19 < (_local16[int((_local6 - 1))] as b2Bound).value)))) { _local7 = _local16[_local6]; _local8 = _local16[int((_local6 - 1))]; _local23 = _local8.proxyId; _local24 = m_proxyPool[_local8.proxyId]; _local8.stabbingCount++; if (_local8.IsUpper() == true){ if (TestOverlap(_local14, _local24)){ m_pairManager.AddBufferedPair(_arg1, _local23); }; _local3 = _local24.upperBounds; _local4 = _local3[_local5]; _local4++; _local3[_local5] = _local4; _local7.stabbingCount++; } else { _local3 = _local24.lowerBounds; _local4 = _local3[_local5]; _local4++; _local3[_local5] = _local4; _local7.stabbingCount--; }; _local3 = _local13.lowerBounds; _local4 = _local3[_local5]; _local4--; _local3[_local5] = _local4; _local7.Swap(_local8); _local6--; }; }; if (_local22 > 0){ _local6 = _local18; while ((((_local6 < (_local12 - 1))) && (((_local16[int((_local6 + 1))] as b2Bound).value <= _local20)))) { _local7 = _local16[_local6]; _local9 = _local16[int((_local6 + 1))]; _local10 = _local9.proxyId; _local11 = m_proxyPool[_local10]; _local9.stabbingCount++; if (_local9.IsLower() == true){ if (TestOverlap(_local14, _local11)){ m_pairManager.AddBufferedPair(_arg1, _local10); }; _local3 = _local11.lowerBounds; _local4 = _local3[_local5]; _local4--; _local3[_local5] = _local4; _local7.stabbingCount++; } else { _local3 = _local11.upperBounds; _local4 = _local3[_local5]; _local4--; _local3[_local5] = _local4; _local7.stabbingCount--; }; _local3 = _local13.upperBounds; _local4 = _local3[_local5]; _local4++; _local3[_local5] = _local4; _local7.Swap(_local9); _local6++; }; }; if (_local21 > 0){ _local6 = _local17; while ((((_local6 < (_local12 - 1))) && (((_local16[int((_local6 + 1))] as b2Bound).value <= _local19)))) { _local7 = _local16[_local6]; _local9 = _local16[int((_local6 + 1))]; _local10 = _local9.proxyId; _local11 = m_proxyPool[_local10]; _local9.stabbingCount--; if (_local9.IsUpper()){ if (TestOverlap(_local15, _local11)){ m_pairManager.RemoveBufferedPair(_arg1, _local10); }; _local3 = _local11.upperBounds; _local4 = _local3[_local5]; _local4--; _local3[_local5] = _local4; _local7.stabbingCount--; } else { _local3 = _local11.lowerBounds; _local4 = _local3[_local5]; _local4--; _local3[_local5] = _local4; _local7.stabbingCount++; }; _local3 = _local13.lowerBounds; _local4 = _local3[_local5]; _local4++; _local3[_local5] = _local4; _local7.Swap(_local9); _local6++; }; }; if (_local22 < 0){ _local6 = _local18; while ((((_local6 > 0)) && ((_local20 < (_local16[int((_local6 - 1))] as b2Bound).value)))) { _local7 = _local16[_local6]; _local8 = _local16[int((_local6 - 1))]; _local23 = _local8.proxyId; _local24 = m_proxyPool[_local23]; _local8.stabbingCount--; if (_local8.IsLower() == true){ if (TestOverlap(_local15, _local24)){ m_pairManager.RemoveBufferedPair(_arg1, _local23); }; _local3 = _local24.lowerBounds; _local4 = _local3[_local5]; _local4++; _local3[_local5] = _local4; _local7.stabbingCount--; } else { _local3 = _local24.upperBounds; _local4 = _local3[_local5]; _local4++; _local3[_local5] = _local4; _local7.stabbingCount++; }; _local3 = _local13.upperBounds; _local4 = _local3[_local5]; _local4--; _local3[_local5] = _local4; _local7.Swap(_local8); _local6--; }; }; _local5++; }; } public static function BinarySearch(_arg1:Array, _arg2:int, _arg3:uint):uint{ var _local6:int; var _local7:b2Bound; var _local4:int; var _local5:int = (_arg2 - 1); while (_local4 <= _local5) { _local6 = ((_local4 + _local5) / 2); _local7 = _arg1[_local6]; if (_local7.value > _arg3){ _local5 = (_local6 - 1); } else { if (_local7.value < _arg3){ _local4 = (_local6 + 1); } else { return (uint(_local6)); }; }; }; return (uint(_local4)); } } }//package Box2D.Collision
Section 13
//b2BufferedPair (Box2D.Collision.b2BufferedPair) package Box2D.Collision { public class b2BufferedPair { public var proxyId1:uint; public var proxyId2:uint; } }//package Box2D.Collision
Section 14
//b2Collision (Box2D.Collision.b2Collision) package Box2D.Collision { import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2Collision { public static const b2_nullFeature:uint = 0xFF; private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2(); public static function EdgeSeparation(_arg1:b2PolygonShape, _arg2:b2XForm, _arg3:int, _arg4:b2PolygonShape, _arg5:b2XForm):Number{ var _local11:b2Mat22; var _local12:b2Vec2; var _local25:Number; var _local6:int = _arg1.m_vertexCount; var _local7:Array = _arg1.m_vertices; var _local8:Array = _arg1.m_normals; var _local9:int = _arg4.m_vertexCount; var _local10:Array = _arg4.m_vertices; _local11 = _arg2.R; _local12 = _local8[_arg3]; var _local13:Number = ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y)); var _local14:Number = ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y)); _local11 = _arg5.R; var _local15:Number = ((_local11.col1.x * _local13) + (_local11.col1.y * _local14)); var _local16:Number = ((_local11.col2.x * _local13) + (_local11.col2.y * _local14)); var _local17:int; var _local18:Number = Number.MAX_VALUE; var _local19:int; while (_local19 < _local9) { _local12 = _local10[_local19]; _local25 = ((_local12.x * _local15) + (_local12.y * _local16)); if (_local25 < _local18){ _local18 = _local25; _local17 = _local19; }; _local19++; }; _local12 = _local7[_arg3]; _local11 = _arg2.R; var _local20:Number = (_arg2.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y))); var _local21:Number = (_arg2.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y))); _local12 = _local10[_local17]; _local11 = _arg5.R; var _local22:Number = (_arg5.position.x + ((_local11.col1.x * _local12.x) + (_local11.col2.x * _local12.y))); var _local23:Number = (_arg5.position.y + ((_local11.col1.y * _local12.x) + (_local11.col2.y * _local12.y))); _local22 = (_local22 - _local20); _local23 = (_local23 - _local21); var _local24:Number = ((_local22 * _local13) + (_local23 * _local14)); return (_local24); } public static function b2TestOverlap(_arg1:b2AABB, _arg2:b2AABB):Boolean{ var _local3:b2Vec2 = _arg2.lowerBound; var _local4:b2Vec2 = _arg1.upperBound; var _local5:Number = (_local3.x - _local4.x); var _local6:Number = (_local3.y - _local4.y); _local3 = _arg1.lowerBound; _local4 = _arg2.upperBound; var _local7:Number = (_local3.x - _local4.x); var _local8:Number = (_local3.y - _local4.y); if ((((_local5 > 0)) || ((_local6 > 0)))){ return (false); }; if ((((_local7 > 0)) || ((_local8 > 0)))){ return (false); }; return (true); } public static function FindIncidentEdge(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:int, _arg5:b2PolygonShape, _arg6:b2XForm):void{ var _local12:b2Mat22; var _local13:b2Vec2; var _local20:ClipVertex; var _local23:Number; var _local7:int = _arg2.m_vertexCount; var _local8:Array = _arg2.m_normals; var _local9:int = _arg5.m_vertexCount; var _local10:Array = _arg5.m_vertices; var _local11:Array = _arg5.m_normals; _local12 = _arg3.R; _local13 = _local8[_arg4]; var _local14:Number = ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y)); var _local15:Number = ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y)); _local12 = _arg6.R; var _local16:Number = ((_local12.col1.x * _local14) + (_local12.col1.y * _local15)); _local15 = ((_local12.col2.x * _local14) + (_local12.col2.y * _local15)); _local14 = _local16; var _local17:int; var _local18:Number = Number.MAX_VALUE; var _local19:int; while (_local19 < _local9) { _local13 = _local11[_local19]; _local23 = ((_local14 * _local13.x) + (_local15 * _local13.y)); if (_local23 < _local18){ _local18 = _local23; _local17 = _local19; }; _local19++; }; var _local21:int = _local17; var _local22:int = (((_local21 + 1) < _local9)) ? (_local21 + 1) : 0; _local20 = _arg1[0]; _local13 = _local10[_local21]; _local12 = _arg6.R; _local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y))); _local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y))); _local20.id.features.referenceEdge = _arg4; _local20.id.features.incidentEdge = _local21; _local20.id.features.incidentVertex = 0; _local20 = _arg1[1]; _local13 = _local10[_local22]; _local12 = _arg6.R; _local20.v.x = (_arg6.position.x + ((_local12.col1.x * _local13.x) + (_local12.col2.x * _local13.y))); _local20.v.y = (_arg6.position.y + ((_local12.col1.y * _local13.x) + (_local12.col2.y * _local13.y))); _local20.id.features.referenceEdge = _arg4; _local20.id.features.incidentEdge = _local22; _local20.id.features.incidentVertex = 1; } public static function b2CollidePolygons(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2PolygonShape, _arg5:b2XForm):void{ var _local6:ClipVertex; var _local13:b2PolygonShape; var _local14:b2PolygonShape; var _local17:int; var _local18:uint; var _local34:int; var _local37:b2Vec2; var _local38:Number; var _local39:b2ManifoldPoint; _arg1.pointCount = 0; var _local7:int; var _local8:Array = [_local7]; var _local9:Number = FindMaxSeparation(_local8, _arg2, _arg3, _arg4, _arg5); _local7 = _local8[0]; if (_local9 > 0){ return; }; var _local10:int; var _local11:Array = [_local10]; var _local12:Number = FindMaxSeparation(_local11, _arg4, _arg5, _arg2, _arg3); _local10 = _local11[0]; if (_local12 > 0){ return; }; var _local15:b2XForm = new b2XForm(); var _local16:b2XForm = new b2XForm(); var _local19:Number = 0.98; var _local20:Number = 0.001; if (_local12 > ((_local19 * _local9) + _local20)){ _local13 = _arg4; _local14 = _arg2; _local15.Set(_arg5); _local16.Set(_arg3); _local17 = _local10; _local18 = 1; } else { _local13 = _arg2; _local14 = _arg4; _local15.Set(_arg3); _local16.Set(_arg5); _local17 = _local7; _local18 = 0; }; var _local21:Array = [new ClipVertex(), new ClipVertex()]; FindIncidentEdge(_local21, _local13, _local15, _local17, _local14, _local16); var _local22:int = _local13.m_vertexCount; var _local23:Array = _local13.m_vertices; var _local24:b2Vec2 = _local23[_local17]; var _local25:b2Vec2 = _local24.Copy(); if ((_local17 + 1) < _local22){ _local24 = _local23[int((_local17 + 1))]; _local37 = _local24.Copy(); } else { _local24 = _local23[0]; _local37 = _local24.Copy(); }; var _local26:b2Vec2 = b2Math.SubtractVV(_local37, _local25); var _local27:b2Vec2 = b2Math.b2MulMV(_local15.R, b2Math.SubtractVV(_local37, _local25)); _local27.Normalize(); var _local28:b2Vec2 = b2Math.b2CrossVF(_local27, 1); _local25 = b2Math.b2MulX(_local15, _local25); _local37 = b2Math.b2MulX(_local15, _local37); var _local29:Number = b2Math.b2Dot(_local28, _local25); var _local30:Number = -(b2Math.b2Dot(_local27, _local25)); var _local31:Number = b2Math.b2Dot(_local27, _local37); var _local32:Array = [new ClipVertex(), new ClipVertex()]; var _local33:Array = [new ClipVertex(), new ClipVertex()]; _local34 = ClipSegmentToLine(_local32, _local21, _local27.Negative(), _local30); if (_local34 < 2){ return; }; _local34 = ClipSegmentToLine(_local33, _local32, _local27, _local31); if (_local34 < 2){ return; }; _arg1.normal = (_local18) ? _local28.Negative() : _local28.Copy(); var _local35:int; var _local36:int; while (_local36 < b2Settings.b2_maxManifoldPoints) { _local6 = _local33[_local36]; _local38 = (((_local28.x * _local6.v.x) + (_local28.y * _local6.v.y)) - _local29); if (_local38 <= 0){ _local39 = _arg1.points[_local35]; _local39.separation = _local38; _local39.localPoint1 = b2Math.b2MulXT(_arg3, _local6.v); _local39.localPoint2 = b2Math.b2MulXT(_arg5, _local6.v); _local39.id.key = _local6.id._key; _local39.id.features.flip = _local18; _local35++; }; _local36++; }; _arg1.pointCount = _local35; } public static function FindMaxSeparation(_arg1:Array, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2PolygonShape, _arg5:b2XForm):Number{ var _local8:b2Vec2; var _local9:b2Mat22; var _local22:int; var _local23:Number; var _local24:int; var _local25:Number; var _local6:int = _arg2.m_vertexCount; var _local7:Array = _arg2.m_normals; _local9 = _arg5.R; _local8 = _arg4.m_centroid; var _local10:Number = (_arg5.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y))); var _local11:Number = (_arg5.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y))); _local9 = _arg3.R; _local8 = _arg2.m_centroid; _local10 = (_local10 - (_arg3.position.x + ((_local9.col1.x * _local8.x) + (_local9.col2.x * _local8.y)))); _local11 = (_local11 - (_arg3.position.y + ((_local9.col1.y * _local8.x) + (_local9.col2.y * _local8.y)))); var _local12:Number = ((_local10 * _arg3.R.col1.x) + (_local11 * _arg3.R.col1.y)); var _local13:Number = ((_local10 * _arg3.R.col2.x) + (_local11 * _arg3.R.col2.y)); var _local14:int; var _local15:Number = -(Number.MAX_VALUE); var _local16:int; while (_local16 < _local6) { _local8 = _local7[_local16]; _local25 = ((_local8.x * _local12) + (_local8.y * _local13)); if (_local25 > _local15){ _local15 = _local25; _local14 = _local16; }; _local16++; }; var _local17:Number = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5); if (_local17 > 0){ return (_local17); }; var _local18:int = (((_local14 - 1) >= 0)) ? (_local14 - 1) : (_local6 - 1); var _local19:Number = EdgeSeparation(_arg2, _arg3, _local18, _arg4, _arg5); if (_local19 > 0){ return (_local19); }; var _local20:int = (((_local14 + 1) < _local6)) ? (_local14 + 1) : 0; var _local21:Number = EdgeSeparation(_arg2, _arg3, _local20, _arg4, _arg5); if (_local21 > 0){ return (_local21); }; if ((((_local19 > _local17)) && ((_local19 > _local21)))){ _local24 = -1; _local22 = _local18; _local23 = _local19; } else { if (_local21 > _local17){ _local24 = 1; _local22 = _local20; _local23 = _local21; } else { _arg1[0] = _local14; return (_local17); }; }; while (true) { if (_local24 == -1){ _local14 = (((_local22 - 1) >= 0)) ? (_local22 - 1) : (_local6 - 1); } else { _local14 = (((_local22 + 1) < _local6)) ? (_local22 + 1) : 0; }; _local17 = EdgeSeparation(_arg2, _arg3, _local14, _arg4, _arg5); if (_local17 > 0){ return (_local17); }; if (_local17 > _local23){ _local22 = _local14; _local23 = _local17; } else { break; }; }; _arg1[0] = _local22; return (_local23); } public static function ClipSegmentToLine(_arg1:Array, _arg2:Array, _arg3:b2Vec2, _arg4:Number):int{ var _local5:ClipVertex; var _local6:int; var _local7:b2Vec2; var _local8:b2Vec2; var _local9:Number; var _local11:Number; var _local12:b2Vec2; var _local13:ClipVertex; _local6 = 0; _local5 = _arg2[0]; _local7 = _local5.v; _local5 = _arg2[1]; _local8 = _local5.v; _local9 = (b2Math.b2Dot(_arg3, _local7) - _arg4); var _local10:Number = (b2Math.b2Dot(_arg3, _local8) - _arg4); if (_local9 <= 0){ var _temp1 = _local6; _local6 = (_local6 + 1); var _local14 = _temp1; _arg1[_local14] = _arg2[0]; }; if (_local10 <= 0){ var _temp2 = _local6; _local6 = (_local6 + 1); _local14 = _temp2; _arg1[_local14] = _arg2[1]; }; if ((_local9 * _local10) < 0){ _local11 = (_local9 / (_local9 - _local10)); _local5 = _arg1[_local6]; _local12 = _local5.v; _local12.x = (_local7.x + (_local11 * (_local8.x - _local7.x))); _local12.y = (_local7.y + (_local11 * (_local8.y - _local7.y))); _local5 = _arg1[_local6]; if (_local9 > 0){ _local13 = _arg2[0]; _local5.id = _local13.id; } else { _local13 = _arg2[1]; _local5.id = _local13.id; }; _local6++; }; return (_local6); } public static function b2CollideCircles(_arg1:b2Manifold, _arg2:b2CircleShape, _arg3:b2XForm, _arg4:b2CircleShape, _arg5:b2XForm):void{ var _local6:b2Mat22; var _local7:b2Vec2; var _local18:Number; var _local24:Number; var _local25:Number; _arg1.pointCount = 0; _local6 = _arg3.R; _local7 = _arg2.m_localPosition; var _local8:Number = (_arg3.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y))); var _local9:Number = (_arg3.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y))); _local6 = _arg5.R; _local7 = _arg4.m_localPosition; var _local10:Number = (_arg5.position.x + ((_local6.col1.x * _local7.x) + (_local6.col2.x * _local7.y))); var _local11:Number = (_arg5.position.y + ((_local6.col1.y * _local7.x) + (_local6.col2.y * _local7.y))); var _local12:Number = (_local10 - _local8); var _local13:Number = (_local11 - _local9); var _local14:Number = ((_local12 * _local12) + (_local13 * _local13)); var _local15:Number = _arg2.m_radius; var _local16:Number = _arg4.m_radius; var _local17:Number = (_local15 + _local16); if (_local14 > (_local17 * _local17)){ return; }; if (_local14 < Number.MIN_VALUE){ _local18 = -(_local17); _arg1.normal.Set(0, 1); } else { _local24 = Math.sqrt(_local14); _local18 = (_local24 - _local17); _local25 = (1 / _local24); _arg1.normal.x = (_local25 * _local12); _arg1.normal.y = (_local25 * _local13); }; _arg1.pointCount = 1; var _local19:b2ManifoldPoint = _arg1.points[0]; _local19.id.key = 0; _local19.separation = _local18; _local8 = (_local8 + (_local15 * _arg1.normal.x)); _local9 = (_local9 + (_local15 * _arg1.normal.y)); _local10 = (_local10 - (_local16 * _arg1.normal.x)); _local11 = (_local11 - (_local16 * _arg1.normal.y)); var _local20:Number = (0.5 * (_local8 + _local10)); var _local21:Number = (0.5 * (_local9 + _local11)); var _local22:Number = (_local20 - _arg3.position.x); var _local23:Number = (_local21 - _arg3.position.y); _local19.localPoint1.x = ((_local22 * _arg3.R.col1.x) + (_local23 * _arg3.R.col1.y)); _local19.localPoint1.y = ((_local22 * _arg3.R.col2.x) + (_local23 * _arg3.R.col2.y)); _local22 = (_local20 - _arg5.position.x); _local23 = (_local21 - _arg5.position.y); _local19.localPoint2.x = ((_local22 * _arg5.R.col1.x) + (_local23 * _arg5.R.col1.y)); _local19.localPoint2.y = ((_local22 * _arg5.R.col2.x) + (_local23 * _arg5.R.col2.y)); } public static function b2CollidePolygonAndCircle(_arg1:b2Manifold, _arg2:b2PolygonShape, _arg3:b2XForm, _arg4:b2CircleShape, _arg5:b2XForm):void{ var _local6:b2ManifoldPoint; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:b2Vec2; var _local12:b2Mat22; var _local17:Number; var _local32:Number; var _local33:Number; var _local34:Number; _arg1.pointCount = 0; _local12 = _arg5.R; _local11 = _arg4.m_localPosition; var _local13:Number = (_arg5.position.x + ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y))); var _local14:Number = (_arg5.position.y + ((_local12.col1.y * _local11.x) + (_local12.col2.y * _local11.y))); _local7 = (_local13 - _arg3.position.x); _local8 = (_local14 - _arg3.position.y); _local12 = _arg3.R; var _local15:Number = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y)); var _local16:Number = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y)); var _local18:int; var _local19:Number = -(Number.MAX_VALUE); var _local20:Number = _arg4.m_radius; var _local21:int = _arg2.m_vertexCount; var _local22:Array = _arg2.m_vertices; var _local23:Array = _arg2.m_normals; var _local24:int; while (_local24 < _local21) { _local11 = _local22[_local24]; _local7 = (_local15 - _local11.x); _local8 = (_local16 - _local11.y); _local11 = _local23[_local24]; _local34 = ((_local11.x * _local7) + (_local11.y * _local8)); if (_local34 > _local20){ return; }; if (_local34 > _local19){ _local19 = _local34; _local18 = _local24; }; _local24++; }; if (_local19 < Number.MIN_VALUE){ _arg1.pointCount = 1; _local11 = _local23[_local18]; _local12 = _arg3.R; _arg1.normal.x = ((_local12.col1.x * _local11.x) + (_local12.col2.x * _local11.y)); _arg1.normal.y = ((_local12.col1.y * _local11.x) + (_local12.col2.y * _local11.y)); _local6 = _arg1.points[0]; _local6.id.features.incidentEdge = _local18; _local6.id.features.incidentVertex = b2_nullFeature; _local6.id.features.referenceEdge = 0; _local6.id.features.flip = 0; _local9 = (_local13 - (_local20 * _arg1.normal.x)); _local10 = (_local14 - (_local20 * _arg1.normal.y)); _local7 = (_local9 - _arg3.position.x); _local8 = (_local10 - _arg3.position.y); _local12 = _arg3.R; _local6.localPoint1.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y)); _local6.localPoint1.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y)); _local7 = (_local9 - _arg5.position.x); _local8 = (_local10 - _arg5.position.y); _local12 = _arg5.R; _local6.localPoint2.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y)); _local6.localPoint2.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y)); _local6.separation = (_local19 - _local20); return; }; var _local25:int = _local18; var _local26:int = (((_local25 + 1) < _local21)) ? (_local25 + 1) : 0; _local11 = _local22[_local25]; var _local27:b2Vec2 = _local22[_local26]; var _local28:Number = (_local27.x - _local11.x); var _local29:Number = (_local27.y - _local11.y); var _local30:Number = Math.sqrt(((_local28 * _local28) + (_local29 * _local29))); _local28 = (_local28 / _local30); _local29 = (_local29 / _local30); _local7 = (_local15 - _local11.x); _local8 = (_local16 - _local11.y); var _local31:Number = ((_local7 * _local28) + (_local8 * _local29)); _local6 = _arg1.points[0]; if (_local31 <= 0){ _local32 = _local11.x; _local33 = _local11.y; _local6.id.features.incidentEdge = b2_nullFeature; _local6.id.features.incidentVertex = _local25; } else { if (_local31 >= _local30){ _local32 = _local27.x; _local33 = _local27.y; _local6.id.features.incidentEdge = b2_nullFeature; _local6.id.features.incidentVertex = _local26; } else { _local32 = ((_local28 * _local31) + _local11.x); _local33 = ((_local29 * _local31) + _local11.y); _local6.id.features.incidentEdge = _local18; _local6.id.features.incidentVertex = b2_nullFeature; }; }; _local7 = (_local15 - _local32); _local8 = (_local16 - _local33); _local17 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8))); _local7 = (_local7 / _local17); _local8 = (_local8 / _local17); if (_local17 > _local20){ return; }; _arg1.pointCount = 1; _local12 = _arg3.R; _arg1.normal.x = ((_local12.col1.x * _local7) + (_local12.col2.x * _local8)); _arg1.normal.y = ((_local12.col1.y * _local7) + (_local12.col2.y * _local8)); _local9 = (_local13 - (_local20 * _arg1.normal.x)); _local10 = (_local14 - (_local20 * _arg1.normal.y)); _local7 = (_local9 - _arg3.position.x); _local8 = (_local10 - _arg3.position.y); _local12 = _arg3.R; _local6.localPoint1.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y)); _local6.localPoint1.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y)); _local7 = (_local9 - _arg5.position.x); _local8 = (_local10 - _arg5.position.y); _local12 = _arg5.R; _local6.localPoint2.x = ((_local7 * _local12.col1.x) + (_local8 * _local12.col1.y)); _local6.localPoint2.y = ((_local7 * _local12.col2.x) + (_local8 * _local12.col2.y)); _local6.separation = (_local17 - _local20); _local6.id.features.referenceEdge = 0; _local6.id.features.flip = 0; } } }//package Box2D.Collision
Section 15
//b2ContactID (Box2D.Collision.b2ContactID) package Box2D.Collision { import Box2D.Common.*; public class b2ContactID { b2internal var _key:uint; public var features:Features; public function b2ContactID(){ features = new Features(); super(); features._m_id = this; } public function Set(_arg1:b2ContactID):void{ key = _arg1._key; } public function Copy():b2ContactID{ var _local1:b2ContactID = new b2ContactID(); _local1.key = key; return (_local1); } public function set key(_arg1:uint):void{ _key = _arg1; features._referenceEdge = (_key & 0xFF); features._incidentEdge = (((_key & 0xFF00) >> 8) & 0xFF); features._incidentVertex = (((_key & 0xFF0000) >> 16) & 0xFF); features._flip = (((_key & 4278190080) >> 24) & 0xFF); } public function get key():uint{ return (_key); } } }//package Box2D.Collision
Section 16
//b2ContactPoint (Box2D.Collision.b2ContactPoint) package Box2D.Collision { import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; public class b2ContactPoint { public var friction:Number; public var separation:Number; public var normal:b2Vec2; public var position:b2Vec2; public var restitution:Number; public var shape1:b2Shape; public var shape2:b2Shape; public var id:b2ContactID; public var velocity:b2Vec2; public function b2ContactPoint(){ position = new b2Vec2(); velocity = new b2Vec2(); normal = new b2Vec2(); id = new b2ContactID(); super(); } } }//package Box2D.Collision
Section 17
//b2Distance (Box2D.Collision.b2Distance) package Box2D.Collision { import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2Distance { private static var s_p2s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()]; private static var s_p1s:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()]; private static var s_points:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2()]; private static var gPoint:b2Point = new b2Point(); public static var g_GJK_Iterations:int = 0; public static function InPoints(_arg1:b2Vec2, _arg2:Array, _arg3:int):Boolean{ var _local6:b2Vec2; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local4:Number = (100 * Number.MIN_VALUE); var _local5:int; while (_local5 < _arg3) { _local6 = _arg2[_local5]; _local7 = Math.abs((_arg1.x - _local6.x)); _local8 = Math.abs((_arg1.y - _local6.y)); _local9 = Math.max(Math.abs(_arg1.x), Math.abs(_local6.x)); _local10 = Math.max(Math.abs(_arg1.y), Math.abs(_local6.y)); if ((((_local7 < (_local4 * (_local9 + 1)))) && ((_local8 < (_local4 * (_local10 + 1)))))){ return (true); }; _local5++; }; return (false); } public static function DistanceGeneric(_arg1:b2Vec2, _arg2:b2Vec2, _arg3, _arg4:b2XForm, _arg5, _arg6:b2XForm):Number{ var _local7:b2Vec2; var _local15:Number; var _local16:Number; var _local17:b2Vec2; var _local18:b2Vec2; var _local19:Number; var _local20:Number; var _local21:Number; var _local22:Number; var _local23:int; var _local8:Array = s_p1s; var _local9:Array = s_p2s; var _local10:Array = s_points; var _local11:int; _arg1.SetV(_arg3.GetFirstVertex(_arg4)); _arg2.SetV(_arg5.GetFirstVertex(_arg6)); var _local12:Number = 0; var _local13 = 20; var _local14:int; while (_local14 < _local13) { _local15 = (_arg2.x - _arg1.x); _local16 = (_arg2.y - _arg1.y); _local17 = _arg3.Support(_arg4, _local15, _local16); _local18 = _arg5.Support(_arg6, -(_local15), -(_local16)); _local12 = ((_local15 * _local15) + (_local16 * _local16)); _local19 = (_local18.x - _local17.x); _local20 = (_local18.y - _local17.y); _local21 = ((_local15 * _local19) + (_local16 * _local20)); if ((_local12 - _local21) <= (0.01 * _local12)){ if (_local11 == 0){ _arg1.SetV(_local17); _arg2.SetV(_local18); }; g_GJK_Iterations = _local14; return (Math.sqrt(_local12)); }; switch (_local11){ case 0: _local7 = _local8[0]; _local7.SetV(_local17); _local7 = _local9[0]; _local7.SetV(_local18); _local7 = _local10[0]; _local7.x = _local19; _local7.y = _local20; _arg1.SetV(_local8[0]); _arg2.SetV(_local9[0]); _local11++; break; case 1: _local7 = _local8[1]; _local7.SetV(_local17); _local7 = _local9[1]; _local7.SetV(_local18); _local7 = _local10[1]; _local7.x = _local19; _local7.y = _local20; _local11 = ProcessTwo(_arg1, _arg2, _local8, _local9, _local10); break; case 2: _local7 = _local8[2]; _local7.SetV(_local17); _local7 = _local9[2]; _local7.SetV(_local18); _local7 = _local10[2]; _local7.x = _local19; _local7.y = _local20; _local11 = ProcessThree(_arg1, _arg2, _local8, _local9, _local10); break; }; if (_local11 == 3){ g_GJK_Iterations = _local14; return (0); }; _local22 = -(Number.MAX_VALUE); _local23 = 0; while (_local23 < _local11) { _local7 = _local10[_local23]; _local22 = b2Math.b2Max(_local22, ((_local7.x * _local7.x) + (_local7.y * _local7.y))); _local23++; }; if ((((_local11 == 3)) || ((_local12 <= ((100 * Number.MIN_VALUE) * _local22))))){ g_GJK_Iterations = _local14; _local15 = (_arg2.x - _arg1.x); _local16 = (_arg2.y - _arg1.y); _local12 = ((_local15 * _local15) + (_local16 * _local16)); return (Math.sqrt(_local12)); }; _local14++; }; g_GJK_Iterations = _local13; return (Math.sqrt(_local12)); } public static function DistanceCC(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2CircleShape, _arg4:b2XForm, _arg5:b2CircleShape, _arg6:b2XForm):Number{ var _local7:b2Mat22; var _local8:b2Vec2; var _local19:Number; var _local20:Number; _local7 = _arg4.R; _local8 = _arg3.m_localPosition; var _local9:Number = (_arg4.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y))); var _local10:Number = (_arg4.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y))); _local7 = _arg6.R; _local8 = _arg5.m_localPosition; var _local11:Number = (_arg6.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y))); var _local12:Number = (_arg6.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y))); var _local13:Number = (_local11 - _local9); var _local14:Number = (_local12 - _local10); var _local15:Number = ((_local13 * _local13) + (_local14 * _local14)); var _local16:Number = (_arg3.m_radius - b2Settings.b2_toiSlop); var _local17:Number = (_arg5.m_radius - b2Settings.b2_toiSlop); var _local18:Number = (_local16 + _local17); if (_local15 > (_local18 * _local18)){ _local19 = Math.sqrt(_local15); _local13 = (_local13 / _local19); _local14 = (_local14 / _local19); _local20 = (_local19 - _local18); _arg1.x = (_local9 + (_local16 * _local13)); _arg1.y = (_local10 + (_local16 * _local14)); _arg2.x = (_local11 - (_local17 * _local13)); _arg2.y = (_local12 - (_local17 * _local14)); return (_local20); }; if (_local15 > (Number.MIN_VALUE * Number.MIN_VALUE)){ _local19 = Math.sqrt(_local15); _local13 = (_local13 / _local19); _local14 = (_local14 / _local19); _arg1.x = (_local9 + (_local16 * _local13)); _arg1.y = (_local10 + (_local16 * _local14)); _arg2.x = _arg1.x; _arg2.y = _arg1.y; return (0); }; _arg1.x = _local9; _arg1.y = _local10; _arg2.x = _arg1.x; _arg2.y = _arg1.y; return (0); } public static function ProcessThree(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:Array, _arg4:Array, _arg5:Array):int{ var _local6:b2Vec2; var _local7:b2Vec2; var _local8:b2Vec2; var _local9:b2Vec2; var _local10:b2Vec2; var _local11:b2Vec2; var _local12:b2Vec2; var _local13:b2Vec2; var _local35:Number; _local6 = _arg5[0]; _local7 = _arg5[1]; _local8 = _arg5[2]; _local9 = _arg3[0]; _local10 = _arg3[1]; _local11 = _arg3[2]; _local12 = _arg4[0]; _local13 = _arg4[1]; var _local14:b2Vec2 = _arg4[2]; var _local15:Number = _local6.x; var _local16:Number = _local6.y; var _local17:Number = _local7.x; var _local18:Number = _local7.y; var _local19:Number = _local8.x; var _local20:Number = _local8.y; var _local21:Number = (_local17 - _local15); var _local22:Number = (_local18 - _local16); var _local23:Number = (_local19 - _local15); var _local24:Number = (_local20 - _local16); var _local25:Number = (_local19 - _local17); var _local26:Number = (_local20 - _local18); var _local27:Number = -(((_local15 * _local21) + (_local16 * _local22))); var _local28:Number = ((_local17 * _local21) + (_local18 * _local22)); var _local29:Number = -(((_local15 * _local23) + (_local16 * _local24))); var _local30:Number = ((_local19 * _local23) + (_local20 * _local24)); var _local31:Number = -(((_local17 * _local25) + (_local18 * _local26))); var _local32:Number = ((_local19 * _local25) + (_local20 * _local26)); if ((((_local30 <= 0)) && ((_local32 <= 0)))){ _arg1.SetV(_local11); _arg2.SetV(_local14); _local9.SetV(_local11); _local12.SetV(_local14); _local6.SetV(_local8); return (1); }; var _local33:Number = ((_local21 * _local24) - (_local22 * _local23)); var _local34:Number = (_local33 * ((_local15 * _local18) - (_local16 * _local17))); var _local36:Number = (_local33 * ((_local17 * _local20) - (_local18 * _local19))); if ((((((((_local36 <= 0)) && ((_local31 >= 0)))) && ((_local32 >= 0)))) && (((_local31 + _local32) > 0)))){ _local35 = (_local31 / (_local31 + _local32)); _arg1.x = (_local10.x + (_local35 * (_local11.x - _local10.x))); _arg1.y = (_local10.y + (_local35 * (_local11.y - _local10.y))); _arg2.x = (_local13.x + (_local35 * (_local14.x - _local13.x))); _arg2.y = (_local13.y + (_local35 * (_local14.y - _local13.y))); _local9.SetV(_local11); _local12.SetV(_local14); _local6.SetV(_local8); return (2); }; var _local37:Number = (_local33 * ((_local19 * _local16) - (_local20 * _local15))); if ((((((((_local37 <= 0)) && ((_local29 >= 0)))) && ((_local30 >= 0)))) && (((_local29 + _local30) > 0)))){ _local35 = (_local29 / (_local29 + _local30)); _arg1.x = (_local9.x + (_local35 * (_local11.x - _local9.x))); _arg1.y = (_local9.y + (_local35 * (_local11.y - _local9.y))); _arg2.x = (_local12.x + (_local35 * (_local14.x - _local12.x))); _arg2.y = (_local12.y + (_local35 * (_local14.y - _local12.y))); _local10.SetV(_local11); _local13.SetV(_local14); _local7.SetV(_local8); return (2); }; var _local38:Number = ((_local36 + _local37) + _local34); _local38 = (1 / _local38); var _local39:Number = (_local36 * _local38); var _local40:Number = (_local37 * _local38); var _local41:Number = ((1 - _local39) - _local40); _arg1.x = (((_local39 * _local9.x) + (_local40 * _local10.x)) + (_local41 * _local11.x)); _arg1.y = (((_local39 * _local9.y) + (_local40 * _local10.y)) + (_local41 * _local11.y)); _arg2.x = (((_local39 * _local12.x) + (_local40 * _local13.x)) + (_local41 * _local14.x)); _arg2.y = (((_local39 * _local12.y) + (_local40 * _local13.y)) + (_local41 * _local14.y)); return (3); } public static function DistancePC(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2PolygonShape, _arg4:b2XForm, _arg5:b2CircleShape, _arg6:b2XForm):Number{ var _local7:b2Mat22; var _local8:b2Vec2; var _local12:Number; var _local13:Number; var _local14:Number; var _local9:b2Point = gPoint; _local8 = _arg5.m_localPosition; _local7 = _arg6.R; _local9.p.x = (_arg6.position.x + ((_local7.col1.x * _local8.x) + (_local7.col2.x * _local8.y))); _local9.p.y = (_arg6.position.y + ((_local7.col1.y * _local8.x) + (_local7.col2.y * _local8.y))); var _local10:Number = DistanceGeneric(_arg1, _arg2, _arg3, _arg4, _local9, b2Math.b2XForm_identity); var _local11:Number = (_arg5.m_radius - b2Settings.b2_toiSlop); if (_local10 > _local11){ _local10 = (_local10 - _local11); _local12 = (_arg2.x - _arg1.x); _local13 = (_arg2.y - _arg1.y); _local14 = Math.sqrt(((_local12 * _local12) + (_local13 * _local13))); _local12 = (_local12 / _local14); _local13 = (_local13 / _local14); _arg2.x = (_arg2.x - (_local11 * _local12)); _arg2.y = (_arg2.y - (_local11 * _local13)); } else { _local10 = 0; _arg2.x = _arg1.x; _arg2.y = _arg1.y; }; return (_local10); } public static function Distance(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Shape, _arg4:b2XForm, _arg5:b2Shape, _arg6:b2XForm):Number{ var _local7:int = _arg3.m_type; var _local8:int = _arg5.m_type; if ((((_local7 == b2Shape.e_circleShape)) && ((_local8 == b2Shape.e_circleShape)))){ return (DistanceCC(_arg1, _arg2, (_arg3 as b2CircleShape), _arg4, (_arg5 as b2CircleShape), _arg6)); }; if ((((_local7 == b2Shape.e_polygonShape)) && ((_local8 == b2Shape.e_circleShape)))){ return (DistancePC(_arg1, _arg2, (_arg3 as b2PolygonShape), _arg4, (_arg5 as b2CircleShape), _arg6)); }; if ((((_local7 == b2Shape.e_circleShape)) && ((_local8 == b2Shape.e_polygonShape)))){ return (DistancePC(_arg2, _arg1, (_arg5 as b2PolygonShape), _arg6, (_arg3 as b2CircleShape), _arg4)); }; if ((((_local7 == b2Shape.e_polygonShape)) && ((_local8 == b2Shape.e_polygonShape)))){ return (DistanceGeneric(_arg1, _arg2, (_arg3 as b2PolygonShape), _arg4, (_arg5 as b2PolygonShape), _arg6)); }; return (0); } public static function ProcessTwo(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:Array, _arg4:Array, _arg5:Array):int{ var _local9:b2Vec2; var _local10:b2Vec2; var _local11:b2Vec2; var _local17:Number; var _local6:b2Vec2 = _arg5[0]; var _local7:b2Vec2 = _arg5[1]; var _local8:b2Vec2 = _arg3[0]; _local9 = _arg3[1]; _local10 = _arg4[0]; _local11 = _arg4[1]; var _local12:Number = -(_local7.x); var _local13:Number = -(_local7.y); var _local14:Number = (_local6.x - _local7.x); var _local15:Number = (_local6.y - _local7.y); var _local16:Number = Math.sqrt(((_local14 * _local14) + (_local15 * _local15))); _local14 = (_local14 / _local16); _local15 = (_local15 / _local16); _local17 = ((_local12 * _local14) + (_local13 * _local15)); if ((((_local17 <= 0)) || ((_local16 < Number.MIN_VALUE)))){ _arg1.SetV(_local9); _arg2.SetV(_local11); _local8.SetV(_local9); _local10.SetV(_local11); _local6.SetV(_local7); return (1); }; _local17 = (_local17 / _local16); _arg1.x = (_local9.x + (_local17 * (_local8.x - _local9.x))); _arg1.y = (_local9.y + (_local17 * (_local8.y - _local9.y))); _arg2.x = (_local11.x + (_local17 * (_local10.x - _local11.x))); _arg2.y = (_local11.y + (_local17 * (_local10.y - _local11.y))); return (2); } } }//package Box2D.Collision
Section 18
//b2Manifold (Box2D.Collision.b2Manifold) package Box2D.Collision { import Box2D.Common.Math.*; import Box2D.Common.*; public class b2Manifold { public var pointCount:int;// = 0 public var normal:b2Vec2; public var points:Array; public function b2Manifold(){ points = new Array(b2Settings.b2_maxManifoldPoints); var _local1:int; while (_local1 < b2Settings.b2_maxManifoldPoints) { points[_local1] = new b2ManifoldPoint(); _local1++; }; normal = new b2Vec2(); } public function Set(_arg1:b2Manifold):void{ pointCount = _arg1.pointCount; var _local2:int; while (_local2 < b2Settings.b2_maxManifoldPoints) { (points[_local2] as b2ManifoldPoint).Set(_arg1.points[_local2]); _local2++; }; normal.SetV(_arg1.normal); } public function Reset():void{ var _local1:int; while (_local1 < b2Settings.b2_maxManifoldPoints) { (points[_local1] as b2ManifoldPoint).Reset(); _local1++; }; normal.SetZero(); pointCount = 0; } } }//package Box2D.Collision
Section 19
//b2ManifoldPoint (Box2D.Collision.b2ManifoldPoint) package Box2D.Collision { import Box2D.Common.Math.*; public class b2ManifoldPoint { public var separation:Number; public var localPoint2:b2Vec2; public var normalImpulse:Number; public var tangentImpulse:Number; public var localPoint1:b2Vec2; public var id:b2ContactID; public function b2ManifoldPoint(){ localPoint1 = new b2Vec2(); localPoint2 = new b2Vec2(); id = new b2ContactID(); super(); } public function Set(_arg1:b2ManifoldPoint):void{ localPoint1.SetV(_arg1.localPoint1); localPoint2.SetV(_arg1.localPoint2); separation = _arg1.separation; normalImpulse = _arg1.normalImpulse; tangentImpulse = _arg1.tangentImpulse; id.key = _arg1.id.key; } public function Reset():void{ localPoint1.SetZero(); localPoint2.SetZero(); separation = 0; normalImpulse = 0; tangentImpulse = 0; id.key = 0; } } }//package Box2D.Collision
Section 20
//b2OBB (Box2D.Collision.b2OBB) package Box2D.Collision { import Box2D.Common.Math.*; public class b2OBB { public var R:b2Mat22; public var center:b2Vec2; public var extents:b2Vec2; public function b2OBB(){ R = new b2Mat22(); center = new b2Vec2(); extents = new b2Vec2(); super(); } } }//package Box2D.Collision
Section 21
//b2Pair (Box2D.Collision.b2Pair) package Box2D.Collision { import Box2D.Common.*; public class b2Pair { public var proxyId1:uint; public var userData;// = null public var proxyId2:uint; public var status:uint; public var next:uint; public static var e_pairFinal:uint = 4; public static var b2_tableMask:int = (b2_tableCapacity - 1); public static var e_pairRemoved:uint = 2; public static var b2_nullPair:uint = b2Settings.USHRT_MAX; public static var e_pairBuffered:uint = 1; public static var b2_nullProxy:uint = b2Settings.USHRT_MAX; public static var b2_tableCapacity:int = b2Settings.b2_maxPairs; public function SetBuffered():void{ status = (status | e_pairBuffered); } public function IsBuffered():Boolean{ return (((status & e_pairBuffered) == e_pairBuffered)); } public function IsFinal():Boolean{ return (((status & e_pairFinal) == e_pairFinal)); } public function ClearRemoved():void{ status = (status & ~(e_pairRemoved)); } public function SetFinal():void{ status = (status | e_pairFinal); } public function IsRemoved():Boolean{ return (((status & e_pairRemoved) == e_pairRemoved)); } public function ClearBuffered():void{ status = (status & ~(e_pairBuffered)); } public function SetRemoved():void{ status = (status | e_pairRemoved); } } }//package Box2D.Collision
Section 22
//b2PairCallback (Box2D.Collision.b2PairCallback) package Box2D.Collision { public class b2PairCallback { public function PairRemoved(_arg1, _arg2, _arg3):void{ } public function PairAdded(_arg1, _arg2){ return (null); } } }//package Box2D.Collision
Section 23
//b2PairManager (Box2D.Collision.b2PairManager) package Box2D.Collision { import Box2D.Common.Math.*; import Box2D.Common.*; public class b2PairManager { b2internal var m_pairCount:int; private var m_pairBuffer:Array; b2internal var m_hashTable:Array; private var m_callback:b2PairCallback; b2internal var m_pairs:Array; private var m_pairBufferCount:int; private var m_broadPhase:b2BroadPhase; private var m_freePair:uint; public function b2PairManager(){ var _local1:uint; super(); m_hashTable = new Array(b2Pair.b2_tableCapacity); _local1 = 0; while (_local1 < b2Pair.b2_tableCapacity) { m_hashTable[_local1] = b2Pair.b2_nullPair; _local1++; }; m_pairs = new Array(b2Settings.b2_maxPairs); _local1 = 0; while (_local1 < b2Settings.b2_maxPairs) { m_pairs[_local1] = new b2Pair(); _local1++; }; m_pairBuffer = new Array(b2Settings.b2_maxPairs); _local1 = 0; while (_local1 < b2Settings.b2_maxPairs) { m_pairBuffer[_local1] = new b2BufferedPair(); _local1++; }; _local1 = 0; while (_local1 < b2Settings.b2_maxPairs) { m_pairs[_local1].proxyId1 = b2Pair.b2_nullProxy; m_pairs[_local1].proxyId2 = b2Pair.b2_nullProxy; m_pairs[_local1].userData = null; m_pairs[_local1].status = 0; m_pairs[_local1].next = (_local1 + 1); _local1++; }; m_pairs[int((b2Settings.b2_maxPairs - 1))].next = b2Pair.b2_nullPair; m_pairCount = 0; m_pairBufferCount = 0; } private function FindHash(_arg1:uint, _arg2:uint, _arg3:uint):b2Pair{ var _local4:b2Pair; var _local5:uint = m_hashTable[_arg3]; _local4 = m_pairs[_local5]; while (((!((_local5 == b2Pair.b2_nullPair))) && ((Equals(_local4, _arg1, _arg2) == false)))) { _local5 = _local4.next; _local4 = m_pairs[_local5]; }; if (_local5 == b2Pair.b2_nullPair){ return (null); }; return (_local4); } private function Find(_arg1:uint, _arg2:uint):b2Pair{ var _local4:uint; if (_arg1 > _arg2){ _local4 = _arg1; _arg1 = _arg2; _arg2 = _local4; }; var _local3:uint = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask); return (FindHash(_arg1, _arg2, _local3)); } private function ValidateBuffer():void{ } public function Commit():void{ var _local1:b2BufferedPair; var _local2:int; var _local5:b2Pair; var _local6:b2Proxy; var _local7:b2Proxy; var _local3:int; var _local4:Array = m_broadPhase.m_proxyPool; _local2 = 0; while (_local2 < m_pairBufferCount) { _local1 = m_pairBuffer[_local2]; _local5 = Find(_local1.proxyId1, _local1.proxyId2); _local5.ClearBuffered(); _local6 = _local4[_local5.proxyId1]; _local7 = _local4[_local5.proxyId2]; if (_local5.IsRemoved()){ if (_local5.IsFinal() == true){ m_callback.PairRemoved(_local6.userData, _local7.userData, _local5.userData); }; _local1 = m_pairBuffer[_local3]; _local1.proxyId1 = _local5.proxyId1; _local1.proxyId2 = _local5.proxyId2; _local3++; } else { if (_local5.IsFinal() == false){ _local5.userData = m_callback.PairAdded(_local6.userData, _local7.userData); _local5.SetFinal(); }; }; _local2++; }; _local2 = 0; while (_local2 < _local3) { _local1 = m_pairBuffer[_local2]; RemovePair(_local1.proxyId1, _local1.proxyId2); _local2++; }; m_pairBufferCount = 0; if (b2BroadPhase.s_validate){ ValidateTable(); }; } public function RemoveBufferedPair(_arg1:int, _arg2:int):void{ var _local3:b2BufferedPair; var _local4:b2Pair = Find(_arg1, _arg2); if (_local4 == null){ return; }; if (_local4.IsBuffered() == false){ _local4.SetBuffered(); _local3 = m_pairBuffer[m_pairBufferCount]; _local3.proxyId1 = _local4.proxyId1; _local3.proxyId2 = _local4.proxyId2; m_pairBufferCount++; }; _local4.SetRemoved(); if (b2BroadPhase.s_validate){ ValidateBuffer(); }; } private function RemovePair(_arg1:uint, _arg2:uint){ var _local3:b2Pair; var _local7:uint; var _local8:uint; var _local9:*; if (_arg1 > _arg2){ _local7 = _arg1; _arg1 = _arg2; _arg2 = _local7; }; var _local4:uint = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask); var _local5:uint = m_hashTable[_local4]; var _local6:b2Pair; while (_local5 != b2Pair.b2_nullPair) { if (Equals(m_pairs[_local5], _arg1, _arg2)){ _local8 = _local5; _local3 = m_pairs[_local5]; if (_local6){ _local6.next = _local3.next; } else { m_hashTable[_local4] = _local3.next; }; _local3 = m_pairs[_local8]; _local9 = _local3.userData; _local3.next = m_freePair; _local3.proxyId1 = b2Pair.b2_nullProxy; _local3.proxyId2 = b2Pair.b2_nullProxy; _local3.userData = null; _local3.status = 0; m_freePair = _local8; m_pairCount--; return (_local9); } else { _local6 = m_pairs[_local5]; _local5 = _local6.next; }; }; return (null); } public function Initialize(_arg1:b2BroadPhase, _arg2:b2PairCallback):void{ m_broadPhase = _arg1; m_callback = _arg2; } public function AddBufferedPair(_arg1:int, _arg2:int):void{ var _local3:b2BufferedPair; var _local4:b2Pair = AddPair(_arg1, _arg2); if (_local4.IsBuffered() == false){ _local4.SetBuffered(); _local3 = m_pairBuffer[m_pairBufferCount]; _local3.proxyId1 = _local4.proxyId1; _local3.proxyId2 = _local4.proxyId2; m_pairBufferCount++; }; _local4.ClearRemoved(); if (b2BroadPhase.s_validate){ ValidateBuffer(); }; } private function AddPair(_arg1:uint, _arg2:uint):b2Pair{ var _local6:uint; if (_arg1 > _arg2){ _local6 = _arg1; _arg1 = _arg2; _arg2 = _local6; }; var _local3:uint = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask); var _local4 = FindHash(_arg1, _arg2, _local3); if (_local4 != null){ return (_local4); }; var _local5:uint = m_freePair; _local4 = m_pairs[_local5]; m_freePair = _local4.next; _local4.proxyId1 = _arg1; _local4.proxyId2 = _arg2; _local4.status = 0; _local4.userData = null; _local4.next = m_hashTable[_local3]; m_hashTable[_local3] = _local5; m_pairCount++; return (_local4); } private function ValidateTable():void{ } public static function EqualsPair(_arg1:b2BufferedPair, _arg2:b2BufferedPair):Boolean{ return ((((_arg1.proxyId1 == _arg2.proxyId1)) && ((_arg1.proxyId2 == _arg2.proxyId2)))); } public static function Hash(_arg1:uint, _arg2:uint):uint{ var _local3:uint = (((_arg2 << 16) & 4294901760) | _arg1); _local3 = (~(_local3) + ((_local3 << 15) & 4294934528)); _local3 = (_local3 ^ ((_local3 >> 12) & 1048575)); _local3 = (_local3 + ((_local3 << 2) & 4294967292)); _local3 = (_local3 ^ ((_local3 >> 4) & 268435455)); _local3 = (_local3 * 2057); _local3 = (_local3 ^ ((_local3 >> 16) & 0xFFFF)); return (_local3); } public static function Equals(_arg1:b2Pair, _arg2:uint, _arg3:uint):Boolean{ return ((((_arg1.proxyId1 == _arg2)) && ((_arg1.proxyId2 == _arg3)))); } } }//package Box2D.Collision
Section 24
//b2Point (Box2D.Collision.b2Point) package Box2D.Collision { import Box2D.Common.Math.*; public class b2Point { public var p:b2Vec2; public function b2Point(){ p = new b2Vec2(); super(); } public function GetFirstVertex(_arg1:b2XForm):b2Vec2{ return (p); } public function Support(_arg1:b2XForm, _arg2:Number, _arg3:Number):b2Vec2{ return (p); } } }//package Box2D.Collision
Section 25
//b2Proxy (Box2D.Collision.b2Proxy) package Box2D.Collision { public class b2Proxy { public var overlapCount:uint; public var userData;// = null public var lowerBounds:Array; public var upperBounds:Array; public var timeStamp:uint; public function b2Proxy(){ lowerBounds = [uint(0), uint(0)]; upperBounds = [uint(0), uint(0)]; super(); } public function GetNext():uint{ return (lowerBounds[0]); } public function IsValid():Boolean{ return (!((overlapCount == b2BroadPhase.b2_invalid))); } public function SetNext(_arg1:uint):void{ lowerBounds[0] = (_arg1 & 0xFFFF); } } }//package Box2D.Collision
Section 26
//b2Segment (Box2D.Collision.b2Segment) package Box2D.Collision { import Box2D.Common.Math.*; import Box2D.Common.*; public class b2Segment { public var p1:b2Vec2; public var p2:b2Vec2; public function b2Segment(){ p1 = new b2Vec2(); p2 = new b2Vec2(); super(); } public function TestSegment(_arg1:Array, _arg2:b2Vec2, _arg3:b2Segment, _arg4:Number):Boolean{ var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local5:b2Vec2 = _arg3.p1; var _local6:Number = (_arg3.p2.x - _local5.x); var _local7:Number = (_arg3.p2.y - _local5.y); var _local8:Number = (p2.x - p1.x); var _local9:Number = (p2.y - p1.y); var _local10:Number = _local9; var _local11:Number = -(_local8); var _local12:Number = (100 * Number.MIN_VALUE); var _local13:Number = -(((_local6 * _local10) + (_local7 * _local11))); if (_local13 > _local12){ _local14 = (_local5.x - p1.x); _local15 = (_local5.y - p1.y); _local16 = ((_local14 * _local10) + (_local15 * _local11)); if ((((0 <= _local16)) && ((_local16 <= (_arg4 * _local13))))){ _local17 = ((-(_local6) * _local15) + (_local7 * _local14)); if (((((-(_local12) * _local13) <= _local17)) && ((_local17 <= (_local13 * (1 + _local12)))))){ _local16 = (_local16 / _local13); _local18 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11))); _local10 = (_local10 / _local18); _local11 = (_local11 / _local18); _arg1[0] = _local16; _arg2.Set(_local10, _local11); return (true); }; }; }; return (false); } public function Extend(_arg1:b2AABB):void{ ExtendForward(_arg1); ExtendBackward(_arg1); } public function ExtendForward(_arg1:b2AABB):void{ var _local4:Number; var _local2:Number = (p2.x - p1.x); var _local3:Number = (p2.y - p1.y); _local4 = Math.min(((_local2 > 0)) ? ((_arg1.upperBound.x - p1.x) / _local2) : ((_local2 < 0)) ? ((_arg1.lowerBound.x - p1.x) / _local2) : Number.POSITIVE_INFINITY, ((_local3 > 0)) ? ((_arg1.upperBound.y - p1.y) / _local3) : ((_local3 < 0)) ? ((_arg1.lowerBound.y - p1.y) / _local3) : Number.POSITIVE_INFINITY); p2.x = (p1.x + (_local2 * _local4)); p2.y = (p1.y + (_local3 * _local4)); } public function ExtendBackward(_arg1:b2AABB):void{ var _local4:Number; var _local2:Number = (-(p2.x) + p1.x); var _local3:Number = (-(p2.y) + p1.y); _local4 = Math.min(((_local2 > 0)) ? ((_arg1.upperBound.x - p2.x) / _local2) : ((_local2 < 0)) ? ((_arg1.lowerBound.x - p2.x) / _local2) : Number.POSITIVE_INFINITY, ((_local3 > 0)) ? ((_arg1.upperBound.y - p2.y) / _local3) : ((_local3 < 0)) ? ((_arg1.lowerBound.y - p2.y) / _local3) : Number.POSITIVE_INFINITY); p1.x = (p2.x + (_local2 * _local4)); p1.y = (p2.y + (_local3 * _local4)); } } }//package Box2D.Collision
Section 27
//b2TimeOfImpact (Box2D.Collision.b2TimeOfImpact) package Box2D.Collision { import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2TimeOfImpact { public static var s_xf1:b2XForm = new b2XForm(); public static var s_xf2:b2XForm = new b2XForm(); public static var s_p1:b2Vec2 = new b2Vec2(); public static var s_p2:b2Vec2 = new b2Vec2(); public static function TimeOfImpact(_arg1:b2Shape, _arg2:b2Sweep, _arg3:b2Shape, _arg4:b2Sweep):Number{ var _local5:Number; var _local6:Number; var _local25:Number; var _local26:b2XForm; var _local27:b2XForm; var _local28:Number; var _local29:Number; var _local30:Number; var _local31:Number; var _local7:Number = _arg1.m_sweepRadius; var _local8:Number = _arg3.m_sweepRadius; var _local9:Number = _arg2.t0; var _local10:Number = (_arg2.c.x - _arg2.c0.x); var _local11:Number = (_arg2.c.y - _arg2.c0.y); var _local12:Number = (_arg4.c.x - _arg4.c0.x); var _local13:Number = (_arg4.c.y - _arg4.c0.y); var _local14:Number = (_arg2.a - _arg2.a0); var _local15:Number = (_arg4.a - _arg4.a0); var _local16:Number = 0; var _local17:b2Vec2 = s_p1; var _local18:b2Vec2 = s_p2; var _local19 = 20; var _local20:int; var _local21:Number = 0; var _local22:Number = 0; var _local23:Number = 0; var _local24:Number = 0; while (true) { _local25 = (((1 - _local16) * _local9) + _local16); _local26 = s_xf1; _local27 = s_xf2; _arg2.GetXForm(_local26, _local25); _arg4.GetXForm(_local27, _local25); _local23 = b2Distance.Distance(_local17, _local18, _arg1, _local26, _arg3, _local27); if (_local20 == 0){ if (_local23 > (2 * b2Settings.b2_toiSlop)){ _local24 = (1.5 * b2Settings.b2_toiSlop); } else { _local5 = (0.05 * b2Settings.b2_toiSlop); _local6 = (_local23 - (0.5 * b2Settings.b2_toiSlop)); _local24 = ((_local5 > _local6)) ? _local5 : _local6; }; }; if (((((_local23 - _local24) < (0.05 * b2Settings.b2_toiSlop))) || ((_local20 == _local19)))){ break; }; _local21 = (_local18.x - _local17.x); _local22 = (_local18.y - _local17.y); _local28 = Math.sqrt(((_local21 * _local21) + (_local22 * _local22))); _local21 = (_local21 / _local28); _local22 = (_local22 / _local28); _local29 = ((((_local21 * (_local10 - _local12)) + (_local22 * (_local11 - _local13))) + (((_local14 < 0)) ? -(_local14) : _local14 * _local7)) + (((_local15 < 0)) ? -(_local15) : _local15 * _local8)); if (_local29 == 0){ _local16 = 1; break; }; _local30 = ((_local23 - _local24) / _local29); _local31 = (_local16 + _local30); if ((((_local31 < 0)) || ((1 < _local31)))){ _local16 = 1; break; }; if (_local31 < ((1 + (100 * Number.MIN_VALUE)) * _local16)){ break; }; _local16 = _local31; _local20++; }; return (_local16); } } }//package Box2D.Collision
Section 28
//ClipVertex (Box2D.Collision.ClipVertex) package Box2D.Collision { import Box2D.Common.Math.*; public class ClipVertex { public var id:b2ContactID; public var v:b2Vec2; public function ClipVertex(){ v = new b2Vec2(); id = new b2ContactID(); super(); } } }//package Box2D.Collision
Section 29
//Features (Box2D.Collision.Features) package Box2D.Collision { import Box2D.Common.*; public class Features { b2internal var _referenceEdge:int; b2internal var _incidentEdge:int; b2internal var _flip:int; b2internal var _incidentVertex:int; b2internal var _m_id:b2ContactID; public function get referenceEdge():int{ return (_referenceEdge); } public function set incidentVertex(_arg1:int):void{ _incidentVertex = _arg1; _m_id._key = ((_m_id._key & 4278255615) | ((_incidentVertex << 16) & 0xFF0000)); } public function get flip():int{ return (_flip); } public function get incidentEdge():int{ return (_incidentEdge); } public function set referenceEdge(_arg1:int):void{ _referenceEdge = _arg1; _m_id._key = ((_m_id._key & 4294967040) | (_referenceEdge & 0xFF)); } public function get incidentVertex():int{ return (_incidentVertex); } public function set flip(_arg1:int):void{ _flip = _arg1; _m_id._key = ((_m_id._key & 0xFFFFFF) | ((_flip << 24) & 4278190080)); } public function set incidentEdge(_arg1:int):void{ _incidentEdge = _arg1; _m_id._key = ((_m_id._key & 4294902015) | ((_incidentEdge << 8) & 0xFF00)); } } }//package Box2D.Collision
Section 30
//b2Mat22 (Box2D.Common.Math.b2Mat22) package Box2D.Common.Math { public class b2Mat22 { public var col1:b2Vec2; public var col2:b2Vec2; public function b2Mat22(_arg1:Number=0, _arg2:b2Vec2=null, _arg3:b2Vec2=null){ var _local4:Number; var _local5:Number; col1 = new b2Vec2(); col2 = new b2Vec2(); super(); if (((!((_arg2 == null))) && (!((_arg3 == null))))){ col1.SetV(_arg2); col2.SetV(_arg3); } else { _local4 = Math.cos(_arg1); _local5 = Math.sin(_arg1); col1.x = _local4; col2.x = -(_local5); col1.y = _local5; col2.y = _local4; }; } public function SetIdentity():void{ col1.x = 1; col2.x = 0; col1.y = 0; col2.y = 1; } public function SetVV(_arg1:b2Vec2, _arg2:b2Vec2):void{ col1.SetV(_arg1); col2.SetV(_arg2); } public function Set(_arg1:Number):void{ var _local2:Number; _local2 = Math.cos(_arg1); var _local3:Number = Math.sin(_arg1); col1.x = _local2; col2.x = -(_local3); col1.y = _local3; col2.y = _local2; } public function SetZero():void{ col1.x = 0; col2.x = 0; col1.y = 0; col2.y = 0; } public function SetM(_arg1:b2Mat22):void{ col1.SetV(_arg1.col1); col2.SetV(_arg1.col2); } public function AddM(_arg1:b2Mat22):void{ col1.x = (col1.x + _arg1.col1.x); col1.y = (col1.y + _arg1.col1.y); col2.x = (col2.x + _arg1.col2.x); col2.y = (col2.y + _arg1.col2.y); } public function Abs():void{ col1.Abs(); col2.Abs(); } public function Copy():b2Mat22{ return (new b2Mat22(0, col1, col2)); } public function GetInverse(_arg1:b2Mat22):b2Mat22{ var _local2:Number; var _local4:Number; var _local6:Number; _local2 = col1.x; var _local3:Number = col2.x; _local4 = col1.y; var _local5:Number = col2.y; _local6 = ((_local2 * _local5) - (_local3 * _local4)); _local6 = (1 / _local6); _arg1.col1.x = (_local6 * _local5); _arg1.col2.x = (-(_local6) * _local3); _arg1.col1.y = (-(_local6) * _local4); _arg1.col2.y = (_local6 * _local2); return (_arg1); } public function GetAngle():Number{ return (Math.atan2(col1.y, col1.x)); } public function Solve(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{ var _local4:Number = col1.x; var _local5:Number = col2.x; var _local6:Number = col1.y; var _local7:Number = col2.y; var _local8:Number = ((_local4 * _local7) - (_local5 * _local6)); _local8 = (1 / _local8); _arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3))); _arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2))); return (_arg1); } } }//package Box2D.Common.Math
Section 31
//b2Mat33 (Box2D.Common.Math.b2Mat33) package Box2D.Common.Math { public class b2Mat33 { public var col1:b2Vec3; public var col2:b2Vec3; public var col3:b2Vec3; public function b2Mat33(_arg1:b2Vec3=null, _arg2:b2Vec3=null, _arg3:b2Vec3=null){ col1 = new b2Vec3(); col2 = new b2Vec3(); col3 = new b2Vec3(); super(); if (((((!(_arg1)) && (!(_arg2)))) && (!(_arg3)))){ col1.SetZero(); col2.SetZero(); col3.SetZero(); } else { col1.SetV(_arg1); col2.SetV(_arg2); col3.SetV(_arg3); }; } public function SetIdentity():void{ col1.x = 1; col2.x = 0; col3.x = 0; col1.y = 0; col2.y = 1; col3.y = 0; col1.z = 0; col2.z = 0; col3.z = 1; } public function Solve22(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{ var _local4:Number; _local4 = col1.x; var _local5:Number = col2.x; var _local6:Number = col1.y; var _local7:Number = col2.y; var _local8:Number = ((_local4 * _local7) - (_local5 * _local6)); _local8 = (1 / _local8); _arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3))); _arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2))); return (_arg1); } public function SetZero():void{ col1.x = 0; col2.x = 0; col3.x = 0; col1.y = 0; col2.y = 0; col3.y = 0; col1.z = 0; col2.z = 0; col3.z = 0; } public function SetM(_arg1:b2Mat33):void{ col1.SetV(_arg1.col1); col2.SetV(_arg1.col2); col3.SetV(_arg1.col3); } public function AddM(_arg1:b2Mat33):void{ col1.x = (col1.x + _arg1.col1.x); col1.y = (col1.y + _arg1.col1.y); col1.z = (col1.z + _arg1.col1.z); col2.x = (col2.x + _arg1.col2.x); col2.y = (col2.y + _arg1.col2.y); col2.z = (col2.z + _arg1.col2.z); col3.x = (col3.x + _arg1.col3.x); col3.y = (col3.y + _arg1.col3.y); col3.z = (col3.z + _arg1.col3.z); } public function SetVVV(_arg1:b2Vec3, _arg2:b2Vec3, _arg3:b2Vec3):void{ col1.SetV(_arg1); col2.SetV(_arg2); col3.SetV(_arg3); } public function Copy():b2Mat33{ return (new b2Mat33(col1, col2, col3)); } public function Solve33(_arg1:b2Vec3, _arg2:Number, _arg3:Number, _arg4:Number):b2Vec3{ var _local5:Number = col1.x; var _local6:Number = col1.y; var _local7:Number = col1.z; var _local8:Number = col2.x; var _local9:Number = col2.y; var _local10:Number = col2.z; var _local11:Number = col3.x; var _local12:Number = col3.y; var _local13:Number = col3.z; var _local14:Number = (((_local5 * ((_local9 * _local13) - (_local10 * _local12))) + (_local6 * ((_local10 * _local11) - (_local8 * _local13)))) + (_local7 * ((_local8 * _local12) - (_local9 * _local11)))); _local14 = (1 / _local14); _arg1.x = (_local14 * (((_arg2 * ((_local9 * _local13) - (_local10 * _local12))) + (_arg3 * ((_local10 * _local11) - (_local8 * _local13)))) + (_arg4 * ((_local8 * _local12) - (_local9 * _local11))))); _arg1.y = (_local14 * (((_local5 * ((_arg3 * _local13) - (_arg4 * _local12))) + (_local6 * ((_arg4 * _local11) - (_arg2 * _local13)))) + (_local7 * ((_arg2 * _local12) - (_arg3 * _local11))))); _arg1.z = (_local14 * (((_local5 * ((_local9 * _arg4) - (_local10 * _arg3))) + (_local6 * ((_local10 * _arg2) - (_local8 * _arg4)))) + (_local7 * ((_local8 * _arg3) - (_local9 * _arg2))))); return (_arg1); } } }//package Box2D.Common.Math
Section 32
//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 static function b2CrossVF(_arg1:b2Vec2, _arg2:Number):b2Vec2{ var _local3:b2Vec2 = new b2Vec2((_arg2 * _arg1.y), (-(_arg2) * _arg1.x)); return (_local3); } public static function AddVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2 = new b2Vec2((_arg1.x + _arg2.x), (_arg1.y + _arg2.y)); return (_local3); } public static function b2IsValid(_arg1:Number):Boolean{ return (isFinite(_arg1)); } public static function b2MinV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2 = new b2Vec2(b2Min(_arg1.x, _arg2.x), b2Min(_arg1.y, _arg2.y)); return (_local3); } public static function b2MulX(_arg1:b2XForm, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2; _local3 = b2MulMV(_arg1.R, _arg2); _local3.x = (_local3.x + _arg1.position.x); _local3.y = (_local3.y + _arg1.position.y); return (_local3); } public static function b2DistanceSquared(_arg1:b2Vec2, _arg2:b2Vec2):Number{ var _local3:Number = (_arg1.x - _arg2.x); var _local4:Number = (_arg1.y - _arg2.y); return (((_local3 * _local3) + (_local4 * _local4))); } public static function b2Swap(_arg1:Array, _arg2:Array):void{ var _local3:* = _arg1[0]; _arg1[0] = _arg2[0]; _arg2[0] = _local3; } public static function b2AbsM(_arg1:b2Mat22):b2Mat22{ var _local2:b2Mat22 = new b2Mat22(0, b2AbsV(_arg1.col1), b2AbsV(_arg1.col2)); return (_local2); } public static function SubtractVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2 = new b2Vec2((_arg1.x - _arg2.x), (_arg1.y - _arg2.y)); return (_local3); } public static function b2MulXT(_arg1:b2XForm, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2; var _local4:Number; _local3 = SubtractVV(_arg2, _arg1.position); _local4 = ((_local3.x * _arg1.R.col1.x) + (_local3.y * _arg1.R.col1.y)); _local3.y = ((_local3.x * _arg1.R.col2.x) + (_local3.y * _arg1.R.col2.y)); _local3.x = _local4; return (_local3); } public static function b2Abs(_arg1:Number):Number{ return (((_arg1 > 0)) ? _arg1 : -(_arg1)); } public static function b2Clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{ return (b2Max(_arg2, b2Min(_arg1, _arg3))); } public static function b2AbsV(_arg1:b2Vec2):b2Vec2{ var _local2:b2Vec2 = new b2Vec2(b2Abs(_arg1.x), b2Abs(_arg1.y)); return (_local2); } public static function MulFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2 = new b2Vec2((_arg1 * _arg2.x), (_arg1 * _arg2.y)); return (_local3); } public static function b2CrossVV(_arg1:b2Vec2, _arg2:b2Vec2):Number{ return (((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x))); } public static function b2Dot(_arg1:b2Vec2, _arg2:b2Vec2):Number{ return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y))); } public static function b2CrossFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2 = new b2Vec2((-(_arg1) * _arg2.y), (_arg1 * _arg2.x)); return (_local3); } public static function AddMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{ var _local3:b2Mat22 = new b2Mat22(0, AddVV(_arg1.col1, _arg2.col1), AddVV(_arg1.col2, _arg2.col2)); return (_local3); } public static function b2Distance(_arg1:b2Vec2, _arg2:b2Vec2):Number{ var _local3:Number = (_arg1.x - _arg2.x); var _local4:Number = (_arg1.y - _arg2.y); return (Math.sqrt(((_local3 * _local3) + (_local4 * _local4)))); } public static function b2MulTMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{ var _local3:b2Vec2 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col1), b2Dot(_arg1.col2, _arg2.col1)); var _local4:b2Vec2 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col2), b2Dot(_arg1.col2, _arg2.col2)); var _local5:b2Mat22 = new b2Mat22(0, _local3, _local4); return (_local5); } public static function b2MaxV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2 = new b2Vec2(b2Max(_arg1.x, _arg2.x), b2Max(_arg1.y, _arg2.y)); return (_local3); } public static function b2IsPowerOfTwo(_arg1:uint):Boolean{ var _local2:Boolean = (((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0))); return (_local2); } public static function b2ClampV(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):b2Vec2{ return (b2MaxV(_arg2, b2MinV(_arg1, _arg3))); } public static function b2RandomRange(_arg1:Number, _arg2:Number):Number{ var _local3:Number = Math.random(); _local3 = (((_arg2 - _arg1) * _local3) + _arg1); return (_local3); } public static function b2MulTMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2 = new b2Vec2(b2Dot(_arg2, _arg1.col1), b2Dot(_arg2, _arg1.col2)); return (_local3); } public static function b2Min(_arg1:Number, _arg2:Number):Number{ return (((_arg1 < _arg2)) ? _arg1 : _arg2); } public static function b2Random():Number{ return (((Math.random() * 2) - 1)); } public static function b2MulMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{ var _local3:b2Mat22 = new b2Mat22(0, b2MulMV(_arg1, _arg2.col1), b2MulMV(_arg1, _arg2.col2)); return (_local3); } public static function b2NextPowerOfTwo(_arg1:uint):uint{ _arg1 = (_arg1 | ((_arg1 >> 1) & 2147483647)); _arg1 = (_arg1 | ((_arg1 >> 2) & 1073741823)); _arg1 = (_arg1 | ((_arg1 >> 4) & 268435455)); _arg1 = (_arg1 | ((_arg1 >> 8) & 0xFFFFFF)); _arg1 = (_arg1 | ((_arg1 >> 16) & 0xFFFF)); return ((_arg1 + 1)); } public static function b2Max(_arg1:Number, _arg2:Number):Number{ return (((_arg1 > _arg2)) ? _arg1 : _arg2); } public static function b2MulMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{ var _local3:b2Vec2 = new b2Vec2(((_arg1.col1.x * _arg2.x) + (_arg1.col2.x * _arg2.y)), ((_arg1.col1.y * _arg2.x) + (_arg1.col2.y * _arg2.y))); return (_local3); } } }//package Box2D.Common.Math
Section 33
//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(_arg1:Number):void{ var _local2:Number; if ((((t0 < _arg1)) && (((1 - t0) > Number.MIN_VALUE)))){ _local2 = ((_arg1 - t0) / (1 - t0)); c0.x = (((1 - _local2) * c0.x) + (_local2 * c.x)); c0.y = (((1 - _local2) * c0.y) + (_local2 * c.y)); a0 = (((1 - _local2) * a0) + (_local2 * a)); t0 = _arg1; }; } public function GetXForm(_arg1:b2XForm, _arg2:Number):void{ var _local4:Number; var _local5:Number; if ((1 - t0) > Number.MIN_VALUE){ _local4 = ((_arg2 - t0) / (1 - t0)); _arg1.position.x = (((1 - _local4) * c0.x) + (_local4 * c.x)); _arg1.position.y = (((1 - _local4) * c0.y) + (_local4 * c.y)); _local5 = (((1 - _local4) * a0) + (_local4 * a)); _arg1.R.Set(_local5); } else { _arg1.position.SetV(c); _arg1.R.Set(a); }; var _local3:b2Mat22 = _arg1.R; _arg1.position.x = (_arg1.position.x - ((_local3.col1.x * localCenter.x) + (_local3.col2.x * localCenter.y))); _arg1.position.y = (_arg1.position.y - ((_local3.col1.y * localCenter.x) + (_local3.col2.y * localCenter.y))); } } }//package Box2D.Common.Math
Section 34
//b2Vec2 (Box2D.Common.Math.b2Vec2) package Box2D.Common.Math { public class b2Vec2 { public var y:Number; public var x:Number; public function b2Vec2(_arg1:Number=0, _arg2:Number=0):void{ x = _arg1; y = _arg2; } public function Add(_arg1:b2Vec2):void{ x = (x + _arg1.x); y = (y + _arg1.y); } public function Set(_arg1:Number=0, _arg2:Number=0):void{ x = _arg1; y = _arg2; } public function Multiply(_arg1:Number):void{ x = (x * _arg1); y = (y * _arg1); } public function Length():Number{ return (Math.sqrt(((x * x) + (y * y)))); } public function LengthSquared():Number{ return (((x * x) + (y * y))); } public function MulM(_arg1:b2Mat22):void{ var _local2:Number = x; x = ((_arg1.col1.x * _local2) + (_arg1.col2.x * y)); y = ((_arg1.col1.y * _local2) + (_arg1.col2.y * y)); } public function SetZero():void{ x = 0; y = 0; } public function MinV(_arg1:b2Vec2):void{ x = ((x < _arg1.x)) ? x : _arg1.x; y = ((y < _arg1.y)) ? y : _arg1.y; } public function toString():String{ return (((("x:" + x) + ", y:") + y)); } public function Normalize():Number{ var _local1:Number = Math.sqrt(((x * x) + (y * y))); if (_local1 < Number.MIN_VALUE){ return (0); }; var _local2:Number = (1 / _local1); x = (x * _local2); y = (y * _local2); return (_local1); } public function CrossVF(_arg1:Number):void{ var _local2:Number = x; x = (_arg1 * y); y = (-(_arg1) * _local2); } public function MaxV(_arg1:b2Vec2):void{ x = ((x > _arg1.x)) ? x : _arg1.x; y = ((y > _arg1.y)) ? y : _arg1.y; } public function SetV(_arg1:b2Vec2):void{ x = _arg1.x; y = _arg1.y; } public function Negative():b2Vec2{ return (new b2Vec2(-(x), -(y))); } public function CrossFV(_arg1:Number):void{ var _local2:Number = x; x = (-(_arg1) * y); y = (_arg1 * _local2); } public function Abs():void{ if (x < 0){ x = -(x); }; if (y < 0){ y = -(y); }; } public function Subtract(_arg1:b2Vec2):void{ x = (x - _arg1.x); y = (y - _arg1.y); } public function Copy():b2Vec2{ return (new b2Vec2(x, y)); } public function MulTM(_arg1:b2Mat22):void{ var _local2:Number = b2Math.b2Dot(this, _arg1.col1); y = b2Math.b2Dot(this, _arg1.col2); x = _local2; } public function IsValid():Boolean{ return (((b2Math.b2IsValid(x)) && (b2Math.b2IsValid(y)))); } public static function Make(_arg1:Number, _arg2:Number):b2Vec2{ return (new b2Vec2(_arg1, _arg2)); } } }//package Box2D.Common.Math
Section 35
//b2Vec3 (Box2D.Common.Math.b2Vec3) package Box2D.Common.Math { public class b2Vec3 { public var x:Number; public var y:Number; public var z:Number; public function b2Vec3(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){ this.x = _arg1; this.y = _arg2; this.z = _arg3; } public function Add(_arg1:b2Vec3):void{ x = (x + _arg1.x); y = (y + _arg1.y); z = (z + _arg1.z); } public function Set(_arg1:Number, _arg2:Number, _arg3:Number):void{ this.x = _arg1; this.y = _arg2; this.z = _arg3; } public function Multiply(_arg1:Number):void{ x = (x * _arg1); y = (y * _arg1); z = (z * _arg1); } public function SetZero():void{ x = (y = (z = 0)); } public function SetV(_arg1:b2Vec3):void{ x = _arg1.x; y = _arg1.y; z = _arg1.z; } public function Negative():b2Vec3{ return (new b2Vec3(-(x), -(y), -(z))); } public function Subtract(_arg1:b2Vec3):void{ x = (x - _arg1.x); y = (y - _arg1.y); z = (z - _arg1.z); } public function Copy():b2Vec3{ return (new b2Vec3(x, y, z)); } } }//package Box2D.Common.Math
Section 36
//b2XForm (Box2D.Common.Math.b2XForm) package Box2D.Common.Math { public class b2XForm { public var position:b2Vec2; public var R:b2Mat22; public function b2XForm(_arg1:b2Vec2=null, _arg2:b2Mat22=null):void{ position = new b2Vec2(); R = new b2Mat22(); super(); if (_arg1){ position.SetV(_arg1); R.SetM(_arg2); }; } public function Initialize(_arg1:b2Vec2, _arg2:b2Mat22):void{ position.SetV(_arg1); R.SetM(_arg2); } public function Set(_arg1:b2XForm):void{ position.SetV(_arg1.position); R.SetM(_arg1.R); } public function SetIdentity():void{ position.SetZero(); R.SetIdentity(); } } }//package Box2D.Common.Math
Section 37
//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(_arg1:Number, _arg2:Number, _arg3:Number){ _r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1))); _g = uint((0xFF * b2Math.b2Clamp(_arg2, 0, 1))); _b = uint((0xFF * b2Math.b2Clamp(_arg3, 0, 1))); } public function Set(_arg1:Number, _arg2:Number, _arg3:Number):void{ _r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1))); _g = uint((0xFF * b2Math.b2Clamp(_arg2, 0, 1))); _b = uint((0xFF * b2Math.b2Clamp(_arg3, 0, 1))); } public function set b(_arg1:Number):void{ _b = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1))); } public function get color():uint{ return ((((_r << 16) | (_g << 8)) | _b)); } public function set r(_arg1:Number):void{ _r = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1))); } public function set g(_arg1:Number):void{ _g = uint((0xFF * b2Math.b2Clamp(_arg1, 0, 1))); } } }//package Box2D.Common
Section 38
//b2internal (Box2D.Common.b2internal) package Box2D.Common { public namespace b2internal = "http://www.box2d.org/ns/b2internal"; }//package Box2D.Common
Section 39
//b2Settings (Box2D.Common.b2Settings) package Box2D.Common { import Box2D.Common.Math.*; public class b2Settings { public static const b2_maxLinearVelocity:Number = 200; 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_maxLinearVelocitySquared:Number = 40000; public static const b2_maxPolygonVertices:int = 8; public static const b2_maxTOIJointsPerIsland:int = 32; 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_maxManifoldPoints:int = 2; public static const b2_maxAngularVelocity:Number = 250; public static const b2_maxAngularCorrection:Number = 0.139626340159546; public static const b2_maxAngularVelocitySquared:Number = 62500; public static const b2_timeToSleep:Number = 0.5; public static const USHRT_MAX:int = 0xFFFF; public static const b2_velocityThreshold:Number = 1; public static const VERSION:String = "2.0.2"; public static const b2_toiSlop:Number = 0.04; public static const b2_maxLinearCorrection:Number = 0.2; public static function b2Assert(_arg1:Boolean):void{ var _local2:b2Vec2; if (!_arg1){ _local2.x++; }; } } }//package Box2D.Common
Section 40
//b2CircleContact (Box2D.Dynamics.Contacts.b2CircleContact) package Box2D.Dynamics.Contacts { import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2CircleContact extends b2Contact { private var m_manifolds:Array; private var m_manifold:b2Manifold; private var m0:b2Manifold; private static const s_evalCP:b2ContactPoint = new b2ContactPoint(); public function b2CircleContact(_arg1:b2Shape, _arg2:b2Shape){ m_manifolds = [new b2Manifold()]; m0 = new b2Manifold(); super(_arg1, _arg2); m_manifold = m_manifolds[0]; m_manifold.pointCount = 0; var _local3:b2ManifoldPoint = m_manifold.points[0]; _local3.normalImpulse = 0; _local3.tangentImpulse = 0; } override b2internal function Evaluate(_arg1:b2ContactListener):void{ var _local2:b2Vec2; var _local3:b2Vec2; var _local4:b2ManifoldPoint; var _local8:b2ManifoldPoint; var _local5:b2Body = m_shape1.m_body; var _local6:b2Body = m_shape2.m_body; m0.Set(m_manifold); b2Collision.b2CollideCircles(m_manifold, (m_shape1 as b2CircleShape), _local5.m_xf, (m_shape2 as b2CircleShape), _local6.m_xf); var _local7:b2ContactPoint = s_evalCP; _local7.shape1 = m_shape1; _local7.shape2 = m_shape2; _local7.friction = m_friction; _local7.restitution = m_restitution; if (m_manifold.pointCount > 0){ m_manifoldCount = 1; _local8 = m_manifold.points[0]; if (m0.pointCount == 0){ _local8.normalImpulse = 0; _local8.tangentImpulse = 0; if (_arg1){ _local7.position = _local5.GetWorldPoint(_local8.localPoint1); _local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1); _local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2); _local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y)); _local7.normal.SetV(m_manifold.normal); _local7.separation = _local8.separation; _local7.id.key = _local8.id._key; _arg1.Add(_local7, this); }; } else { _local4 = m0.points[0]; _local8.normalImpulse = _local4.normalImpulse; _local8.tangentImpulse = _local4.tangentImpulse; if (_arg1){ _local7.position = _local5.GetWorldPoint(_local8.localPoint1); _local2 = _local5.GetLinearVelocityFromLocalPoint(_local8.localPoint1); _local3 = _local6.GetLinearVelocityFromLocalPoint(_local8.localPoint2); _local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y)); _local7.normal.SetV(m_manifold.normal); _local7.separation = _local8.separation; _local7.id.key = _local8.id._key; _arg1.Persist(_local7, this); }; }; } else { m_manifoldCount = 0; if ((((m0.pointCount > 0)) && (_arg1))){ _local4 = m0.points[0]; _local7.position = _local5.GetWorldPoint(_local4.localPoint1); _local2 = _local5.GetLinearVelocityFromLocalPoint(_local4.localPoint1); _local3 = _local6.GetLinearVelocityFromLocalPoint(_local4.localPoint2); _local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y)); _local7.normal.SetV(m0.normal); _local7.separation = _local4.separation; _local7.id.key = _local4.id._key; _arg1.Remove(_local7, this); }; }; } override public function GetManifolds():Array{ return (m_manifolds); } public static function Destroy(_arg1:b2Contact, _arg2):void{ } public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{ return (new b2CircleContact(_arg1, _arg2)); } } }//package Box2D.Dynamics.Contacts
Section 41
//b2Contact (Box2D.Dynamics.Contacts.b2Contact) package Box2D.Dynamics.Contacts { import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2Contact { b2internal var m_shape1:b2Shape; b2internal var m_shape2:b2Shape; b2internal var m_prev:b2Contact; b2internal var m_toi:Number; b2internal var m_next:b2Contact; b2internal var m_friction:Number; b2internal var m_manifoldCount:int; b2internal var m_node1:b2ContactEdge; b2internal var m_node2:b2ContactEdge; b2internal var m_restitution:Number; b2internal var m_flags:uint; b2internal static var e_toiFlag:uint = 8; b2internal static var e_nonSolidFlag:uint = 1; b2internal static var e_slowFlag:uint = 2; b2internal static var e_islandFlag:uint = 4; b2internal static var s_registers:Array; b2internal static var s_initialized:Boolean = false; public function b2Contact(_arg1:b2Shape=null, _arg2:b2Shape=null){ m_node1 = new b2ContactEdge(); m_node2 = new b2ContactEdge(); super(); m_flags = 0; if (((!(_arg1)) || (!(_arg2)))){ m_shape1 = null; m_shape2 = null; return; }; if (((_arg1.IsSensor()) || (_arg2.IsSensor()))){ m_flags = (m_flags | e_nonSolidFlag); }; m_shape1 = _arg1; m_shape2 = _arg2; 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); } b2internal function Update(_arg1:b2ContactListener):void{ var _local2:int = m_manifoldCount; Evaluate(_arg1); var _local3:int = m_manifoldCount; var _local4:b2Body = m_shape1.m_body; var _local5:b2Body = m_shape2.m_body; if ((((_local3 == 0)) && ((_local2 > 0)))){ _local4.WakeUp(); _local5.WakeUp(); }; if (((((((_local4.IsStatic()) || (_local4.IsBullet()))) || (_local5.IsStatic()))) || (_local5.IsBullet()))){ m_flags = (m_flags & ~(e_slowFlag)); } else { m_flags = (m_flags | e_slowFlag); }; } b2internal function Evaluate(_arg1:b2ContactListener):void{ } b2internal static function InitializeRegisters():void{ var _local2:int; s_registers = new Array(b2Shape.e_shapeTypeCount); var _local1:int; while (_local1 < b2Shape.e_shapeTypeCount) { s_registers[_local1] = new Array(b2Shape.e_shapeTypeCount); _local2 = 0; while (_local2 < b2Shape.e_shapeTypeCount) { s_registers[_local1][_local2] = new b2ContactRegister(); _local2++; }; _local1++; }; 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); } b2internal static function Destroy(_arg1:b2Contact, _arg2):void{ if (_arg1.m_manifoldCount > 0){ _arg1.m_shape1.m_body.WakeUp(); _arg1.m_shape2.m_body.WakeUp(); }; var _local3:int = _arg1.m_shape1.m_type; var _local4:int = _arg1.m_shape2.m_type; var _local5:b2ContactRegister = s_registers[_local3][_local4]; var _local6:Function = _local5.destroyFcn; _local6(_arg1, _arg2); } b2internal static function AddType(_arg1:Function, _arg2:Function, _arg3:int, _arg4:int):void{ s_registers[_arg3][_arg4].createFcn = _arg1; s_registers[_arg3][_arg4].destroyFcn = _arg2; s_registers[_arg3][_arg4].primary = true; if (_arg3 != _arg4){ s_registers[_arg4][_arg3].createFcn = _arg1; s_registers[_arg4][_arg3].destroyFcn = _arg2; s_registers[_arg4][_arg3].primary = false; }; } b2internal static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{ var _local8:b2Contact; var _local9:int; var _local10:b2Manifold; if (s_initialized == false){ InitializeRegisters(); s_initialized = true; }; var _local4:int = _arg1.m_type; var _local5:int = _arg2.m_type; var _local6:b2ContactRegister = s_registers[_local4][_local5]; var _local7:Function = _local6.createFcn; if (_local7 != null){ if (_local6.primary){ return (_local7(_arg1, _arg2, _arg3)); }; _local8 = _local7(_arg2, _arg1, _arg3); _local9 = 0; while (_local9 < _local8.m_manifoldCount) { _local10 = _local8.GetManifolds()[_local9]; _local8.GetManifolds()[_local9].normal = _local10.normal.Negative(); _local9++; }; return (_local8); //unresolved jump }; return (null); } } }//package Box2D.Dynamics.Contacts
Section 42
//b2ContactConstraint (Box2D.Dynamics.Contacts.b2ContactConstraint) package Box2D.Dynamics.Contacts { import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2ContactConstraint { public var points:Array; public var normal:b2Vec2; public var restitution:Number; public var K:b2Mat22; public var body1:b2Body; public var manifold:b2Manifold; public var body2:b2Body; public var friction:Number; public var normalMass:b2Mat22; public var pointCount:int; public function b2ContactConstraint(){ normal = new b2Vec2(); normalMass = new b2Mat22(); K = new b2Mat22(); super(); points = new Array(b2Settings.b2_maxManifoldPoints); var _local1:int; while (_local1 < b2Settings.b2_maxManifoldPoints) { points[_local1] = new b2ContactConstraintPoint(); _local1++; }; } } }//package Box2D.Dynamics.Contacts
Section 43
//b2ContactConstraintPoint (Box2D.Dynamics.Contacts.b2ContactConstraintPoint) package Box2D.Dynamics.Contacts { import Box2D.Common.Math.*; public class b2ContactConstraintPoint { public var r2:b2Vec2; public var separation:Number; public var normalImpulse:Number; public var tangentImpulse:Number; public var localAnchor1:b2Vec2; public var localAnchor2:b2Vec2; public var equalizedMass:Number; public var tangentMass:Number; public var normalMass:Number; public var velocityBias:Number; public var r1:b2Vec2; public function b2ContactConstraintPoint(){ localAnchor1 = new b2Vec2(); localAnchor2 = new b2Vec2(); r1 = new b2Vec2(); r2 = new b2Vec2(); super(); } } }//package Box2D.Dynamics.Contacts
Section 44
//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; } }//package Box2D.Dynamics.Contacts
Section 45
//b2ContactRegister (Box2D.Dynamics.Contacts.b2ContactRegister) package Box2D.Dynamics.Contacts { public class b2ContactRegister { public var primary:Boolean; public var createFcn:Function; public var destroyFcn:Function; } }//package Box2D.Dynamics.Contacts
Section 46
//b2ContactResult (Box2D.Dynamics.Contacts.b2ContactResult) package Box2D.Dynamics.Contacts { import Box2D.Collision.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; public class b2ContactResult { public var position:b2Vec2; public var shape1:b2Shape; public var shape2:b2Shape; public var normalImpulse:Number; public var normal:b2Vec2; public var tangentImpulse:Number; public var id:b2ContactID; public function b2ContactResult(){ position = new b2Vec2(); normal = new b2Vec2(); id = new b2ContactID(); super(); } } }//package Box2D.Dynamics.Contacts
Section 47
//b2ContactSolver (Box2D.Dynamics.Contacts.b2ContactSolver) package Box2D.Dynamics.Contacts { import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2ContactSolver { private var m_constraintCount:int; b2internal var m_constraints:Array; private var m_allocator; private var m_step:b2TimeStep; public function b2ContactSolver(_arg1:b2TimeStep, _arg2:Array, _arg3:int, _arg4){ var _local5:b2Contact; var _local6:int; var _local7:b2Vec2; var _local8:b2Mat22; var _local10:b2Body; var _local11:b2Body; var _local12:int; var _local13:Array; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:Number; var _local20:Number; var _local21:Number; var _local22:int; var _local23:b2Manifold; var _local24:Number; var _local25:Number; var _local26:b2ContactConstraint; var _local27:uint; var _local28:b2ManifoldPoint; var _local29:b2ContactConstraintPoint; var _local30:Number; var _local31:Number; var _local32:Number; var _local33:Number; var _local34:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local38:Number; var _local39:Number; var _local40:Number; var _local41:Number; var _local42:Number; var _local43:Number; var _local44:Number; var _local45:Number; var _local46:b2ContactConstraintPoint; var _local47:b2ContactConstraintPoint; var _local48:Number; var _local49:Number; var _local50:Number; var _local51:Number; var _local52:Number; var _local53:Number; var _local54:Number; var _local55:Number; var _local56:Number; var _local57:Number; var _local58:Number; var _local59:Number; m_step = new b2TimeStep(); m_constraints = new Array(); super(); m_step.dt = _arg1.dt; m_step.inv_dt = _arg1.inv_dt; m_step.positionIterations = _arg1.positionIterations; m_step.velocityIterations = _arg1.velocityIterations; m_allocator = _arg4; m_constraintCount = 0; _local6 = 0; while (_local6 < _arg3) { _local5 = _arg2[_local6]; m_constraintCount = (m_constraintCount + _local5.m_manifoldCount); _local6++; }; _local6 = 0; while (_local6 < m_constraintCount) { m_constraints[_local6] = new b2ContactConstraint(); _local6++; }; var _local9:int; _local6 = 0; while (_local6 < _arg3) { _local5 = _arg2[_local6]; _local10 = _local5.m_shape1.m_body; _local11 = _local5.m_shape2.m_body; _local12 = _local5.m_manifoldCount; _local13 = _local5.GetManifolds(); _local14 = _local5.m_friction; _local15 = _local5.m_restitution; _local16 = _local10.m_linearVelocity.x; _local17 = _local10.m_linearVelocity.y; _local18 = _local11.m_linearVelocity.x; _local19 = _local11.m_linearVelocity.y; _local20 = _local10.m_angularVelocity; _local21 = _local11.m_angularVelocity; _local22 = 0; while (_local22 < _local12) { _local23 = _local13[_local22]; _local24 = _local23.normal.x; _local25 = _local23.normal.y; _local26 = m_constraints[_local9]; _local26.body1 = _local10; _local26.body2 = _local11; _local26.manifold = _local23; _local26.normal.x = _local24; _local26.normal.y = _local25; _local26.pointCount = _local23.pointCount; _local26.friction = _local14; _local26.restitution = _local15; _local27 = 0; while (_local27 < _local26.pointCount) { _local28 = _local23.points[_local27]; _local29 = _local26.points[_local27]; _local29.normalImpulse = _local28.normalImpulse; _local29.tangentImpulse = _local28.tangentImpulse; _local29.separation = _local28.separation; _local29.localAnchor1.SetV(_local28.localPoint1); _local29.localAnchor2.SetV(_local28.localPoint2); _local8 = _local10.m_xf.R; _local32 = (_local28.localPoint1.x - _local10.m_sweep.localCenter.x); _local33 = (_local28.localPoint1.y - _local10.m_sweep.localCenter.y); _local30 = ((_local8.col1.x * _local32) + (_local8.col2.x * _local33)); _local33 = ((_local8.col1.y * _local32) + (_local8.col2.y * _local33)); _local32 = _local30; _local29.r1.Set(_local32, _local33); _local8 = _local11.m_xf.R; _local34 = (_local28.localPoint2.x - _local11.m_sweep.localCenter.x); _local35 = (_local28.localPoint2.y - _local11.m_sweep.localCenter.y); _local30 = ((_local8.col1.x * _local34) + (_local8.col2.x * _local35)); _local35 = ((_local8.col1.y * _local34) + (_local8.col2.y * _local35)); _local34 = _local30; _local29.r2.Set(_local34, _local35); _local36 = ((_local32 * _local25) - (_local33 * _local24)); _local37 = ((_local34 * _local25) - (_local35 * _local24)); _local36 = (_local36 * _local36); _local37 = (_local37 * _local37); _local38 = (((_local10.m_invMass + _local11.m_invMass) + (_local10.m_invI * _local36)) + (_local11.m_invI * _local37)); _local29.normalMass = (1 / _local38); _local39 = ((_local10.m_mass * _local10.m_invMass) + (_local11.m_mass * _local11.m_invMass)); _local39 = (_local39 + (((_local10.m_mass * _local10.m_invI) * _local36) + ((_local11.m_mass * _local11.m_invI) * _local37))); _local29.equalizedMass = (1 / _local39); _local40 = _local25; _local41 = -(_local24); _local42 = ((_local32 * _local41) - (_local33 * _local40)); _local43 = ((_local34 * _local41) - (_local35 * _local40)); _local42 = (_local42 * _local42); _local43 = (_local43 * _local43); _local44 = (((_local10.m_invMass + _local11.m_invMass) + (_local10.m_invI * _local42)) + (_local11.m_invI * _local43)); _local29.tangentMass = (1 / _local44); _local29.velocityBias = 0; if (_local29.separation > 0){ _local29.velocityBias = (-60 * _local29.separation); } else { _local30 = (((_local18 + (-(_local21) * _local35)) - _local16) - (-(_local20) * _local33)); _local31 = (((_local19 + (_local21 * _local34)) - _local17) - (_local20 * _local32)); _local45 = ((_local26.normal.x * _local30) + (_local26.normal.y * _local31)); if (_local45 < -(b2Settings.b2_velocityThreshold)){ _local29.velocityBias = (_local29.velocityBias + (-(_local26.restitution) * _local45)); }; }; _local27++; }; if (_local26.pointCount == 2){ _local46 = _local26.points[0]; _local47 = _local26.points[1]; _local48 = _local10.m_invMass; _local49 = _local10.m_invI; _local50 = _local11.m_invMass; _local51 = _local11.m_invI; _local52 = ((_local46.r1.x * _local25) - (_local46.r1.y * _local24)); _local53 = ((_local46.r2.x * _local25) - (_local46.r2.y * _local24)); _local54 = ((_local47.r1.x * _local25) - (_local47.r1.y * _local24)); _local55 = ((_local47.r2.x * _local25) - (_local47.r2.y * _local24)); _local56 = (((_local48 + _local50) + ((_local49 * _local52) * _local52)) + ((_local51 * _local53) * _local53)); _local57 = (((_local48 + _local50) + ((_local49 * _local54) * _local54)) + ((_local51 * _local55) * _local55)); _local58 = (((_local48 + _local50) + ((_local49 * _local52) * _local54)) + ((_local51 * _local53) * _local55)); _local59 = 100; if ((_local56 * _local56) < (_local59 * ((_local56 * _local57) - (_local58 * _local58)))){ _local26.K.col1.Set(_local56, _local58); _local26.K.col2.Set(_local58, _local57); _local26.K.GetInverse(_local26.normalMass); } else { _local26.pointCount = 1; }; }; _local9++; _local22++; }; _local6++; }; } public function InitVelocityConstraints(_arg1:b2TimeStep):void{ var _local2:b2Vec2; var _local3:b2Vec2; var _local4:b2Mat22; var _local6:b2ContactConstraint; var _local7:b2Body; var _local8:b2Body; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:int; var _local19:int; var _local20:b2ContactConstraintPoint; var _local21:Number; var _local22:Number; var _local23:b2ContactConstraintPoint; var _local5:int; while (_local5 < m_constraintCount) { _local6 = m_constraints[_local5]; _local7 = _local6.body1; _local8 = _local6.body2; _local9 = _local7.m_invMass; _local10 = _local7.m_invI; _local11 = _local8.m_invMass; _local12 = _local8.m_invI; _local13 = _local6.normal.x; _local14 = _local6.normal.y; _local15 = _local14; _local16 = -(_local13); if (_arg1.warmStarting){ _local19 = _local6.pointCount; _local18 = 0; while (_local18 < _local19) { _local20 = _local6.points[_local18]; _local6.points[_local18].normalImpulse = (_local20.normalImpulse * _arg1.dtRatio); _local20.tangentImpulse = (_local20.tangentImpulse * _arg1.dtRatio); _local21 = ((_local20.normalImpulse * _local13) + (_local20.tangentImpulse * _local15)); _local22 = ((_local20.normalImpulse * _local14) + (_local20.tangentImpulse * _local16)); _local7.m_angularVelocity = (_local7.m_angularVelocity - (_local10 * ((_local20.r1.x * _local22) - (_local20.r1.y * _local21)))); _local7.m_linearVelocity.x = (_local7.m_linearVelocity.x - (_local9 * _local21)); _local7.m_linearVelocity.y = (_local7.m_linearVelocity.y - (_local9 * _local22)); _local8.m_angularVelocity = (_local8.m_angularVelocity + (_local12 * ((_local20.r2.x * _local22) - (_local20.r2.y * _local21)))); _local8.m_linearVelocity.x = (_local8.m_linearVelocity.x + (_local11 * _local21)); _local8.m_linearVelocity.y = (_local8.m_linearVelocity.y + (_local11 * _local22)); _local18++; }; } else { _local19 = _local6.pointCount; _local18 = 0; while (_local18 < _local19) { _local23 = _local6.points[_local18]; _local23.normalImpulse = 0; _local23.tangentImpulse = 0; _local18++; }; }; _local5++; }; } public function SolvePositionConstraints(_arg1:Number):Boolean{ var _local3:b2Mat22; var _local4:b2Vec2; var _local6:b2ContactConstraint; var _local7:b2Body; var _local8:b2Body; var _local9:b2Vec2; var _local10:Number; var _local11:b2Vec2; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:int; var _local20:int; var _local21:b2ContactConstraintPoint; var _local22:Number; var _local23:Number; var _local24:Number; var _local25:Number; var _local26:Number; var _local27:Number; var _local28:Number; var _local29:Number; var _local30:Number; var _local31:Number; var _local32:Number; var _local33:Number; var _local34:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local2:Number = 0; var _local5:int; while (_local5 < m_constraintCount) { _local6 = m_constraints[_local5]; _local7 = _local6.body1; _local8 = _local6.body2; _local9 = _local7.m_sweep.c; _local10 = _local7.m_sweep.a; _local11 = _local8.m_sweep.c; _local12 = _local8.m_sweep.a; _local13 = (_local7.m_mass * _local7.m_invMass); _local14 = (_local7.m_mass * _local7.m_invI); _local15 = (_local8.m_mass * _local8.m_invMass); _local16 = (_local8.m_mass * _local8.m_invI); _local17 = _local6.normal.x; _local18 = _local6.normal.y; _local19 = _local6.pointCount; _local20 = 0; while (_local20 < _local19) { _local21 = _local6.points[_local20]; _local3 = _local7.m_xf.R; _local4 = _local7.m_sweep.localCenter; _local22 = (_local21.localAnchor1.x - _local4.x); _local23 = (_local21.localAnchor1.y - _local4.y); _local26 = ((_local3.col1.x * _local22) + (_local3.col2.x * _local23)); _local23 = ((_local3.col1.y * _local22) + (_local3.col2.y * _local23)); _local22 = _local26; _local3 = _local8.m_xf.R; _local4 = _local8.m_sweep.localCenter; _local24 = (_local21.localAnchor2.x - _local4.x); _local25 = (_local21.localAnchor2.y - _local4.y); _local26 = ((_local3.col1.x * _local24) + (_local3.col2.x * _local25)); _local25 = ((_local3.col1.y * _local24) + (_local3.col2.y * _local25)); _local24 = _local26; _local27 = (_local9.x + _local22); _local28 = (_local9.y + _local23); _local29 = (_local11.x + _local24); _local30 = (_local11.y + _local25); _local31 = (_local29 - _local27); _local32 = (_local30 - _local28); _local33 = (((_local31 * _local17) + (_local32 * _local18)) + _local21.separation); _local2 = b2Math.b2Min(_local2, _local33); _local34 = (_arg1 * b2Math.b2Clamp((_local33 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0)); _local35 = (-(_local21.equalizedMass) * _local34); _local36 = (_local35 * _local17); _local37 = (_local35 * _local18); _local9.x = (_local9.x - (_local13 * _local36)); _local9.y = (_local9.y - (_local13 * _local37)); _local10 = (_local10 - (_local14 * ((_local22 * _local37) - (_local23 * _local36)))); _local7.m_sweep.a = _local10; _local7.SynchronizeTransform(); _local11.x = (_local11.x + (_local15 * _local36)); _local11.y = (_local11.y + (_local15 * _local37)); _local12 = (_local12 + (_local16 * ((_local24 * _local37) - (_local25 * _local36)))); _local8.m_sweep.a = _local12; _local8.SynchronizeTransform(); _local20++; }; _local5++; }; return ((_local2 >= (-1.5 * b2Settings.b2_linearSlop))); } public function SolveVelocityConstraints():void{ var _local1:int; var _local2:b2ContactConstraintPoint; var _local3:Number; var _local4:Number; var _local5:Number; var _local6:Number; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:Number; var _local20:Number; var _local21:Number; var _local22:Number; var _local23:b2Mat22; var _local24:b2Vec2; var _local26:b2ContactConstraint; var _local27:b2Body; var _local28:b2Body; var _local29:Number; var _local30:Number; var _local31:b2Vec2; var _local32:b2Vec2; var _local33:Number; var _local34:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local38:Number; var _local39:Number; var _local40:Number; var _local41:Number; var _local42:Number; var _local43:int; var _local44:Number; var _local45:b2ContactConstraintPoint; var _local46:b2ContactConstraintPoint; var _local47:Number; var _local48:Number; var _local49:Number; var _local50:Number; var _local51:Number; var _local52:Number; var _local53:Number; var _local54:Number; var _local55:Number; var _local56:Number; var _local57:Number; var _local58:Number; var _local59:Number; var _local25:int; while (_local25 < m_constraintCount) { _local26 = m_constraints[_local25]; _local27 = _local26.body1; _local28 = _local26.body2; _local29 = _local27.m_angularVelocity; _local30 = _local28.m_angularVelocity; _local31 = _local27.m_linearVelocity; _local32 = _local28.m_linearVelocity; _local33 = _local27.m_invMass; _local34 = _local27.m_invI; _local35 = _local28.m_invMass; _local36 = _local28.m_invI; _local37 = _local26.normal.x; _local38 = _local26.normal.y; _local39 = _local38; _local40 = -(_local37); _local41 = _local26.friction; _local43 = _local26.pointCount; if (_local26.pointCount == 1){ _local2 = _local26.points[0]; _local7 = (((_local32.x + (-(_local30) * _local2.r2.y)) - _local31.x) - (-(_local29) * _local2.r1.y)); _local8 = (((_local32.y + (_local30 * _local2.r2.x)) - _local31.y) - (_local29 * _local2.r1.x)); _local9 = ((_local7 * _local37) + (_local8 * _local38)); _local11 = (-(_local2.normalMass) * (_local9 - _local2.velocityBias)); _local10 = ((_local7 * _local39) + (_local8 * _local40)); _local12 = (_local2.tangentMass * -(_local10)); _local13 = b2Math.b2Max((_local2.normalImpulse + _local11), 0); _local11 = (_local13 - _local2.normalImpulse); _local44 = (_local41 * _local2.normalImpulse); _local14 = b2Math.b2Clamp((_local2.tangentImpulse + _local12), -(_local44), _local44); _local12 = (_local14 - _local2.tangentImpulse); _local15 = ((_local11 * _local37) + (_local12 * _local39)); _local16 = ((_local11 * _local38) + (_local12 * _local40)); _local31.x = (_local31.x - (_local33 * _local15)); _local31.y = (_local31.y - (_local33 * _local16)); _local29 = (_local29 - (_local34 * ((_local2.r1.x * _local16) - (_local2.r1.y * _local15)))); _local32.x = (_local32.x + (_local35 * _local15)); _local32.y = (_local32.y + (_local35 * _local16)); _local30 = (_local30 + (_local36 * ((_local2.r2.x * _local16) - (_local2.r2.y * _local15)))); _local2.normalImpulse = _local13; _local2.tangentImpulse = _local14; } else { _local45 = _local26.points[0]; _local46 = _local26.points[1]; _local47 = _local45.normalImpulse; _local48 = _local46.normalImpulse; _local49 = (((_local32.x - (_local30 * _local45.r2.y)) - _local31.x) + (_local29 * _local45.r1.y)); _local50 = (((_local32.y + (_local30 * _local45.r2.x)) - _local31.y) - (_local29 * _local45.r1.x)); _local51 = (((_local32.x - (_local30 * _local46.r2.y)) - _local31.x) + (_local29 * _local46.r1.y)); _local52 = (((_local32.y + (_local30 * _local46.r2.x)) - _local31.y) - (_local29 * _local46.r1.x)); _local53 = ((_local49 * _local37) + (_local50 * _local38)); _local54 = ((_local51 * _local37) + (_local52 * _local38)); _local55 = (_local53 - _local45.velocityBias); _local56 = (_local54 - _local46.velocityBias); _local23 = _local26.K; _local55 = (_local55 - ((_local23.col1.x * _local47) + (_local23.col2.x * _local48))); _local56 = (_local56 - ((_local23.col1.y * _local47) + (_local23.col2.y * _local48))); _local57 = 0.001; while (true) { _local23 = _local26.normalMass; _local58 = -(((_local23.col1.x * _local55) + (_local23.col2.x * _local56))); _local59 = -(((_local23.col1.y * _local55) + (_local23.col2.y * _local56))); if ((((_local58 >= 0)) && ((_local59 >= 0)))){ _local17 = (_local58 - _local47); _local18 = (_local59 - _local48); _local19 = (_local17 * _local37); _local20 = (_local17 * _local38); _local21 = (_local18 * _local37); _local22 = (_local18 * _local38); _local31.x = (_local31.x - (_local33 * (_local19 + _local21))); _local31.y = (_local31.y - (_local33 * (_local20 + _local22))); _local29 = (_local29 - (_local34 * ((((_local45.r1.x * _local20) - (_local45.r1.y * _local19)) + (_local46.r1.x * _local22)) - (_local46.r1.y * _local21)))); _local32.x = (_local32.x + (_local35 * (_local19 + _local21))); _local32.y = (_local32.y + (_local35 * (_local20 + _local22))); _local30 = (_local30 + (_local36 * ((((_local45.r2.x * _local20) - (_local45.r2.y * _local19)) + (_local46.r2.x * _local22)) - (_local46.r2.y * _local21)))); _local45.normalImpulse = _local58; _local46.normalImpulse = _local59; break; }; _local58 = (-(_local45.normalMass) * _local55); _local59 = 0; _local53 = 0; _local54 = ((_local26.K.col1.y * _local58) + _local56); if ((((_local58 >= 0)) && ((_local54 >= 0)))){ _local17 = (_local58 - _local47); _local18 = (_local59 - _local48); _local19 = (_local17 * _local37); _local20 = (_local17 * _local38); _local21 = (_local18 * _local37); _local22 = (_local18 * _local38); _local31.x = (_local31.x - (_local33 * (_local19 + _local21))); _local31.y = (_local31.y - (_local33 * (_local20 + _local22))); _local29 = (_local29 - (_local34 * ((((_local45.r1.x * _local20) - (_local45.r1.y * _local19)) + (_local46.r1.x * _local22)) - (_local46.r1.y * _local21)))); _local32.x = (_local32.x + (_local35 * (_local19 + _local21))); _local32.y = (_local32.y + (_local35 * (_local20 + _local22))); _local30 = (_local30 + (_local36 * ((((_local45.r2.x * _local20) - (_local45.r2.y * _local19)) + (_local46.r2.x * _local22)) - (_local46.r2.y * _local21)))); _local45.normalImpulse = _local58; _local46.normalImpulse = _local59; break; }; _local58 = 0; _local59 = (-(_local46.normalMass) * _local56); _local53 = ((_local26.K.col2.x * _local59) + _local55); _local54 = 0; if ((((_local59 >= 0)) && ((_local53 >= 0)))){ _local17 = (_local58 - _local47); _local18 = (_local59 - _local48); _local19 = (_local17 * _local37); _local20 = (_local17 * _local38); _local21 = (_local18 * _local37); _local22 = (_local18 * _local38); _local31.x = (_local31.x - (_local33 * (_local19 + _local21))); _local31.y = (_local31.y - (_local33 * (_local20 + _local22))); _local29 = (_local29 - (_local34 * ((((_local45.r1.x * _local20) - (_local45.r1.y * _local19)) + (_local46.r1.x * _local22)) - (_local46.r1.y * _local21)))); _local32.x = (_local32.x + (_local35 * (_local19 + _local21))); _local32.y = (_local32.y + (_local35 * (_local20 + _local22))); _local30 = (_local30 + (_local36 * ((((_local45.r2.x * _local20) - (_local45.r2.y * _local19)) + (_local46.r2.x * _local22)) - (_local46.r2.y * _local21)))); _local45.normalImpulse = _local58; _local46.normalImpulse = _local59; break; }; _local58 = 0; _local59 = 0; _local53 = _local55; _local54 = _local56; if ((((_local53 >= 0)) && ((_local54 >= 0)))){ _local17 = (_local58 - _local47); _local18 = (_local59 - _local48); _local19 = (_local17 * _local37); _local20 = (_local17 * _local38); _local21 = (_local18 * _local37); _local22 = (_local18 * _local38); _local31.x = (_local31.x - (_local33 * (_local19 + _local21))); _local31.y = (_local31.y - (_local33 * (_local20 + _local22))); _local29 = (_local29 - (_local34 * ((((_local45.r1.x * _local20) - (_local45.r1.y * _local19)) + (_local46.r1.x * _local22)) - (_local46.r1.y * _local21)))); _local32.x = (_local32.x + (_local35 * (_local19 + _local21))); _local32.y = (_local32.y + (_local35 * (_local20 + _local22))); _local30 = (_local30 + (_local36 * ((((_local45.r2.x * _local20) - (_local45.r2.y * _local19)) + (_local46.r2.x * _local22)) - (_local46.r2.y * _local21)))); _local45.normalImpulse = _local58; _local46.normalImpulse = _local59; break; }; break; }; _local1 = 0; while (_local1 < _local26.pointCount) { _local2 = _local26.points[_local1]; _local7 = (((_local32.x - (_local30 * _local2.r2.y)) - _local31.x) + (_local29 * _local2.r1.y)); _local8 = (((_local32.y + (_local30 * _local2.r2.x)) - _local31.y) - (_local29 * _local2.r1.x)); _local10 = ((_local7 * _local39) + (_local8 * _local40)); _local12 = (_local2.tangentMass * -(_local10)); _local44 = (_local41 * _local2.normalImpulse); _local14 = b2Math.b2Clamp((_local2.tangentImpulse + _local12), -(_local44), _local44); _local12 = (_local14 - _local2.tangentImpulse); _local15 = (_local12 * _local39); _local16 = (_local12 * _local40); _local31.x = (_local31.x - (_local33 * _local15)); _local31.y = (_local31.y - (_local33 * _local16)); _local29 = (_local29 - (_local34 * ((_local2.r1.x * _local16) - (_local2.r1.y * _local15)))); _local32.x = (_local32.x + (_local35 * _local15)); _local32.y = (_local32.y + (_local35 * _local16)); _local30 = (_local30 + (_local36 * ((_local2.r2.x * _local16) - (_local2.r2.y * _local15)))); _local2.tangentImpulse = _local14; _local1++; }; }; _local27.m_angularVelocity = _local29; _local28.m_angularVelocity = _local30; _local25++; }; } public function FinalizeVelocityConstraints():void{ var _local2:b2ContactConstraint; var _local3:b2Manifold; var _local4:int; var _local5:b2ManifoldPoint; var _local6:b2ContactConstraintPoint; var _local1:int; while (_local1 < m_constraintCount) { _local2 = m_constraints[_local1]; _local3 = _local2.manifold; _local4 = 0; while (_local4 < _local2.pointCount) { _local5 = _local3.points[_local4]; _local6 = _local2.points[_local4]; _local5.normalImpulse = _local6.normalImpulse; _local5.tangentImpulse = _local6.tangentImpulse; _local4++; }; _local1++; }; } } }//package Box2D.Dynamics.Contacts
Section 48
//b2NullContact (Box2D.Dynamics.Contacts.b2NullContact) package Box2D.Dynamics.Contacts { import Box2D.Dynamics.*; import Box2D.Common.*; public class b2NullContact extends b2Contact { override b2internal function Evaluate(_arg1:b2ContactListener):void{ } override public function GetManifolds():Array{ return (null); } } }//package Box2D.Dynamics.Contacts
Section 49
//b2PolyAndCircleContact (Box2D.Dynamics.Contacts.b2PolyAndCircleContact) package Box2D.Dynamics.Contacts { import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2PolyAndCircleContact extends b2Contact { private var m_manifolds:Array; private var m_manifold:b2Manifold; private var m0:b2Manifold; private static const s_evalCP:b2ContactPoint = new b2ContactPoint(); public function b2PolyAndCircleContact(_arg1:b2Shape, _arg2:b2Shape){ m_manifolds = [new b2Manifold()]; m0 = new b2Manifold(); super(_arg1, _arg2); 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; } override b2internal function Evaluate(_arg1:b2ContactListener):void{ var _local2:int; var _local3:b2Vec2; var _local4:b2Vec2; var _local5:b2ManifoldPoint; var _local10:b2ManifoldPoint; var _local11:Boolean; var _local12:uint; var _local13:int; var _local6:b2Body = m_shape1.m_body; var _local7:b2Body = m_shape2.m_body; m0.Set(m_manifold); b2Collision.b2CollidePolygonAndCircle(m_manifold, (m_shape1 as b2PolygonShape), _local6.m_xf, (m_shape2 as b2CircleShape), _local7.m_xf); var _local8:Array = [false, false]; var _local9:b2ContactPoint = s_evalCP; _local9.shape1 = m_shape1; _local9.shape2 = m_shape2; _local9.friction = m_friction; _local9.restitution = m_restitution; if (m_manifold.pointCount > 0){ _local2 = 0; while (_local2 < m_manifold.pointCount) { _local10 = m_manifold.points[_local2]; _local10.normalImpulse = 0; _local10.tangentImpulse = 0; _local11 = false; _local12 = _local10.id._key; _local13 = 0; while (_local13 < m0.pointCount) { if (_local8[_local13] == true){ } else { _local5 = m0.points[_local13]; if (_local5.id._key == _local12){ _local8[_local13] = true; _local10.normalImpulse = _local5.normalImpulse; _local10.tangentImpulse = _local5.tangentImpulse; _local11 = true; if (_arg1 != null){ _local9.position = _local6.GetWorldPoint(_local10.localPoint1); _local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1); _local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2); _local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y)); _local9.normal.SetV(m_manifold.normal); _local9.separation = _local10.separation; _local9.id.key = _local12; _arg1.Persist(_local9, this); }; break; }; }; _local13++; }; if ((((_local11 == false)) && (!((_arg1 == null))))){ _local9.position = _local6.GetWorldPoint(_local10.localPoint1); _local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint1); _local4 = _local7.GetLinearVelocityFromLocalPoint(_local10.localPoint2); _local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y)); _local9.normal.SetV(m_manifold.normal); _local9.separation = _local10.separation; _local9.id.key = _local12; _arg1.Add(_local9, this); }; _local2++; }; m_manifoldCount = 1; } else { m_manifoldCount = 0; }; if (_arg1 == null){ return; }; _local2 = 0; while (_local2 < m0.pointCount) { if (_local8[_local2]){ } else { _local5 = m0.points[_local2]; _local9.position = _local6.GetWorldPoint(_local5.localPoint1); _local3 = _local6.GetLinearVelocityFromLocalPoint(_local5.localPoint1); _local4 = _local7.GetLinearVelocityFromLocalPoint(_local5.localPoint2); _local9.velocity.Set((_local4.x - _local3.x), (_local4.y - _local3.y)); _local9.normal.SetV(m0.normal); _local9.separation = _local5.separation; _local9.id.key = _local5.id._key; _arg1.Remove(_local9, this); }; _local2++; }; } override public function GetManifolds():Array{ return (m_manifolds); } public static function Destroy(_arg1:b2Contact, _arg2):void{ } public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{ return (new b2PolyAndCircleContact(_arg1, _arg2)); } } }//package Box2D.Dynamics.Contacts
Section 50
//b2PolygonContact (Box2D.Dynamics.Contacts.b2PolygonContact) package Box2D.Dynamics.Contacts { import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2PolygonContact extends b2Contact { private var m_manifolds:Array; private var m0:b2Manifold; private var m_manifold:b2Manifold; private static const s_evalCP:b2ContactPoint = new b2ContactPoint(); public function b2PolygonContact(_arg1:b2Shape, _arg2:b2Shape):void{ m0 = new b2Manifold(); m_manifolds = [new b2Manifold()]; super(_arg1, _arg2); m_manifold = m_manifolds[0]; m_manifold.pointCount = 0; } override b2internal function Evaluate(_arg1:b2ContactListener):void{ var _local2:b2Vec2; var _local3:b2Vec2; var _local4:b2ManifoldPoint; var _local7:b2ContactPoint; var _local8:int; var _local10:b2ManifoldPoint; var _local11:Boolean; var _local12:uint; var _local13:int; var _local5:b2Body = m_shape1.m_body; var _local6:b2Body = m_shape2.m_body; m0.Set(m_manifold); b2Collision.b2CollidePolygons(m_manifold, (m_shape1 as b2PolygonShape), _local5.m_xf, (m_shape2 as b2PolygonShape), _local6.m_xf); var _local9:Array = [false, false]; _local7 = s_evalCP; _local7.shape1 = m_shape1; _local7.shape2 = m_shape2; _local7.friction = m_friction; _local7.restitution = m_restitution; if (m_manifold.pointCount > 0){ _local8 = 0; while (_local8 < m_manifold.pointCount) { _local10 = m_manifold.points[_local8]; _local10.normalImpulse = 0; _local10.tangentImpulse = 0; _local11 = false; _local12 = _local10.id._key; _local13 = 0; while (_local13 < m0.pointCount) { if (_local9[_local13] == true){ } else { _local4 = m0.points[_local13]; if (_local4.id._key == _local12){ _local9[_local13] = true; _local10.normalImpulse = _local4.normalImpulse; _local10.tangentImpulse = _local4.tangentImpulse; _local11 = true; if (_arg1 != null){ _local7.position = _local5.GetWorldPoint(_local10.localPoint1); _local2 = _local5.GetLinearVelocityFromLocalPoint(_local10.localPoint1); _local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint2); _local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y)); _local7.normal.SetV(m_manifold.normal); _local7.separation = _local10.separation; _local7.id.key = _local12; _arg1.Persist(_local7, this); }; break; }; }; _local13++; }; if ((((_local11 == false)) && (!((_arg1 == null))))){ _local7.position = _local5.GetWorldPoint(_local10.localPoint1); _local2 = _local5.GetLinearVelocityFromLocalPoint(_local10.localPoint1); _local3 = _local6.GetLinearVelocityFromLocalPoint(_local10.localPoint2); _local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y)); _local7.normal.SetV(m_manifold.normal); _local7.separation = _local10.separation; _local7.id.key = _local12; _arg1.Add(_local7, this); }; _local8++; }; m_manifoldCount = 1; } else { m_manifoldCount = 0; }; if (_arg1 == null){ return; }; _local8 = 0; while (_local8 < m0.pointCount) { if (_local9[_local8]){ } else { _local4 = m0.points[_local8]; _local7.position = _local5.GetWorldPoint(_local4.localPoint1); _local2 = _local5.GetLinearVelocityFromLocalPoint(_local4.localPoint1); _local3 = _local6.GetLinearVelocityFromLocalPoint(_local4.localPoint2); _local7.velocity.Set((_local3.x - _local2.x), (_local3.y - _local2.y)); _local7.normal.SetV(m0.normal); _local7.separation = _local4.separation; _local7.id.key = _local4.id._key; _arg1.Remove(_local7, this); }; _local8++; }; } override public function GetManifolds():Array{ return (m_manifolds); } public static function Destroy(_arg1:b2Contact, _arg2):void{ } public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{ return (new b2PolygonContact(_arg1, _arg2)); } } }//package Box2D.Dynamics.Contacts
Section 51
//b2DistanceJoint (Box2D.Dynamics.Joints.b2DistanceJoint) package Box2D.Dynamics.Joints { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2DistanceJoint extends b2Joint { private var m_localAnchor1:b2Vec2; private var m_localAnchor2:b2Vec2; private var m_bias:Number; private var m_gamma:Number; private var m_u:b2Vec2; private var m_mass:Number; private var m_impulse:Number; private var m_dampingRatio:Number; private var m_frequencyHz:Number; private var m_length:Number; public function b2DistanceJoint(_arg1:b2DistanceJointDef){ var _local2:b2Mat22; var _local3:Number; var _local4:Number; m_localAnchor1 = new b2Vec2(); m_localAnchor2 = new b2Vec2(); m_u = new b2Vec2(); super(_arg1); m_localAnchor1.SetV(_arg1.localAnchor1); m_localAnchor2.SetV(_arg1.localAnchor2); m_length = _arg1.length; m_frequencyHz = _arg1.frequencyHz; m_dampingRatio = _arg1.dampingRatio; m_impulse = 0; m_gamma = 0; m_bias = 0; } override public function GetAnchor1():b2Vec2{ return (m_body1.GetWorldPoint(m_localAnchor1)); } override public function GetAnchor2():b2Vec2{ return (m_body2.GetWorldPoint(m_localAnchor2)); } override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{ var _local2:b2Mat22; var _local3:Number; var _local4:b2Body; var _local5:b2Body; var _local6:Number; var _local7:Number; var _local8:Number; var _local9:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:Number; _local4 = m_body1; _local5 = m_body2; _local2 = _local4.m_xf.R; _local6 = (m_localAnchor1.x - _local4.m_sweep.localCenter.x); _local7 = (m_localAnchor1.y - _local4.m_sweep.localCenter.y); _local3 = ((_local2.col1.x * _local6) + (_local2.col2.x * _local7)); _local7 = ((_local2.col1.y * _local6) + (_local2.col2.y * _local7)); _local6 = _local3; _local2 = _local5.m_xf.R; _local8 = (m_localAnchor2.x - _local5.m_sweep.localCenter.x); _local9 = (m_localAnchor2.y - _local5.m_sweep.localCenter.y); _local3 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9)); _local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9)); _local8 = _local3; m_u.x = (((_local5.m_sweep.c.x + _local8) - _local4.m_sweep.c.x) - _local6); m_u.y = (((_local5.m_sweep.c.y + _local9) - _local4.m_sweep.c.y) - _local7); var _local10:Number = Math.sqrt(((m_u.x * m_u.x) + (m_u.y * m_u.y))); if (_local10 > b2Settings.b2_linearSlop){ m_u.Multiply((1 / _local10)); } else { m_u.SetZero(); }; var _local11:Number = ((_local6 * m_u.y) - (_local7 * m_u.x)); var _local12:Number = ((_local8 * m_u.y) - (_local9 * m_u.x)); var _local13:Number = (((_local4.m_invMass + ((_local4.m_invI * _local11) * _local11)) + _local5.m_invMass) + ((_local5.m_invI * _local12) * _local12)); m_mass = (1 / _local13); if (m_frequencyHz > 0){ _local14 = (_local10 - m_length); _local15 = ((2 * Math.PI) * m_frequencyHz); _local16 = (((2 * m_mass) * m_dampingRatio) * _local15); _local17 = ((m_mass * _local15) * _local15); m_gamma = (1 / (_arg1.dt * (_local16 + (_arg1.dt * _local17)))); m_bias = (((_local14 * _arg1.dt) * _local17) * m_gamma); m_mass = (1 / (_local13 + m_gamma)); }; if (_arg1.warmStarting){ m_impulse = (m_impulse * _arg1.dtRatio); _local18 = (m_impulse * m_u.x); _local19 = (m_impulse * m_u.y); _local4.m_linearVelocity.x = (_local4.m_linearVelocity.x - (_local4.m_invMass * _local18)); _local4.m_linearVelocity.y = (_local4.m_linearVelocity.y - (_local4.m_invMass * _local19)); _local4.m_angularVelocity = (_local4.m_angularVelocity - (_local4.m_invI * ((_local6 * _local19) - (_local7 * _local18)))); _local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + (_local5.m_invMass * _local18)); _local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + (_local5.m_invMass * _local19)); _local5.m_angularVelocity = (_local5.m_angularVelocity + (_local5.m_invI * ((_local8 * _local19) - (_local9 * _local18)))); } else { m_impulse = 0; }; } override public function GetReactionTorque(_arg1:Number):Number{ return (0); } override public function GetReactionForce(_arg1:Number):b2Vec2{ return (new b2Vec2(((_arg1 * m_impulse) * m_u.x), ((_arg1 * m_impulse) * m_u.y))); } override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{ var _local2:b2Mat22; if (m_frequencyHz > 0){ return (true); }; var _local3:b2Body = m_body1; var _local4:b2Body = m_body2; _local2 = _local3.m_xf.R; var _local5:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x); var _local6:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y); var _local7:Number = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6)); _local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6)); _local5 = _local7; _local2 = _local4.m_xf.R; var _local8:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x); var _local9:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y); _local7 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9)); _local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9)); _local8 = _local7; var _local10:Number = (((_local4.m_sweep.c.x + _local8) - _local3.m_sweep.c.x) - _local5); var _local11:Number = (((_local4.m_sweep.c.y + _local9) - _local3.m_sweep.c.y) - _local6); var _local12:Number = Math.sqrt(((_local10 * _local10) + (_local11 * _local11))); _local10 = (_local10 / _local12); _local11 = (_local11 / _local12); var _local13:Number = (_local12 - m_length); _local13 = b2Math.b2Clamp(_local13, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); var _local14:Number = (-(m_mass) * _local13); m_u.Set(_local10, _local11); var _local15:Number = (_local14 * m_u.x); var _local16:Number = (_local14 * m_u.y); _local3.m_sweep.c.x = (_local3.m_sweep.c.x - (_local3.m_invMass * _local15)); _local3.m_sweep.c.y = (_local3.m_sweep.c.y - (_local3.m_invMass * _local16)); _local3.m_sweep.a = (_local3.m_sweep.a - (_local3.m_invI * ((_local5 * _local16) - (_local6 * _local15)))); _local4.m_sweep.c.x = (_local4.m_sweep.c.x + (_local4.m_invMass * _local15)); _local4.m_sweep.c.y = (_local4.m_sweep.c.y + (_local4.m_invMass * _local16)); _local4.m_sweep.a = (_local4.m_sweep.a + (_local4.m_invI * ((_local8 * _local16) - (_local9 * _local15)))); _local3.SynchronizeTransform(); _local4.SynchronizeTransform(); return ((b2Math.b2Abs(_local13) < b2Settings.b2_linearSlop)); } override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{ var _local2:b2Mat22; var _local3:b2Body = m_body1; var _local4:b2Body = m_body2; _local2 = _local3.m_xf.R; var _local5:Number = (m_localAnchor1.x - _local3.m_sweep.localCenter.x); var _local6:Number = (m_localAnchor1.y - _local3.m_sweep.localCenter.y); var _local7:Number = ((_local2.col1.x * _local5) + (_local2.col2.x * _local6)); _local6 = ((_local2.col1.y * _local5) + (_local2.col2.y * _local6)); _local5 = _local7; _local2 = _local4.m_xf.R; var _local8:Number = (m_localAnchor2.x - _local4.m_sweep.localCenter.x); var _local9:Number = (m_localAnchor2.y - _local4.m_sweep.localCenter.y); _local7 = ((_local2.col1.x * _local8) + (_local2.col2.x * _local9)); _local9 = ((_local2.col1.y * _local8) + (_local2.col2.y * _local9)); _local8 = _local7; var _local10:Number = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local6)); var _local11:Number = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local5)); var _local12:Number = (_local4.m_linearVelocity.x + (-(_local4.m_angularVelocity) * _local9)); var _local13:Number = (_local4.m_linearVelocity.y + (_local4.m_angularVelocity * _local8)); var _local14:Number = ((m_u.x * (_local12 - _local10)) + (m_u.y * (_local13 - _local11))); var _local15:Number = (-(m_mass) * ((_local14 + m_bias) + (m_gamma * m_impulse))); m_impulse = (m_impulse + _local15); var _local16:Number = (_local15 * m_u.x); var _local17:Number = (_local15 * m_u.y); _local3.m_linearVelocity.x = (_local3.m_linearVelocity.x - (_local3.m_invMass * _local16)); _local3.m_linearVelocity.y = (_local3.m_linearVelocity.y - (_local3.m_invMass * _local17)); _local3.m_angularVelocity = (_local3.m_angularVelocity - (_local3.m_invI * ((_local5 * _local17) - (_local6 * _local16)))); _local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + (_local4.m_invMass * _local16)); _local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + (_local4.m_invMass * _local17)); _local4.m_angularVelocity = (_local4.m_angularVelocity + (_local4.m_invI * ((_local8 * _local17) - (_local9 * _local16)))); } } }//package Box2D.Dynamics.Joints
Section 52
//b2DistanceJointDef (Box2D.Dynamics.Joints.b2DistanceJointDef) package Box2D.Dynamics.Joints { import Box2D.Dynamics.*; import Box2D.Common.Math.*; public class b2DistanceJointDef extends b2JointDef { public var localAnchor1:b2Vec2; public var length:Number; public var dampingRatio:Number; public var localAnchor2:b2Vec2; public var frequencyHz:Number; public function b2DistanceJointDef(){ localAnchor1 = new b2Vec2(); localAnchor2 = new b2Vec2(); super(); type = b2Joint.e_distanceJoint; length = 1; frequencyHz = 0; dampingRatio = 0; } public function Initialize(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{ body1 = _arg1; body2 = _arg2; localAnchor1.SetV(body1.GetLocalPoint(_arg3)); localAnchor2.SetV(body2.GetLocalPoint(_arg4)); var _local5:Number = (_arg4.x - _arg3.x); var _local6:Number = (_arg4.y - _arg3.y); length = Math.sqrt(((_local5 * _local5) + (_local6 * _local6))); frequencyHz = 0; dampingRatio = 0; } } }//package Box2D.Dynamics.Joints
Section 53
//b2GearJoint (Box2D.Dynamics.Joints.b2GearJoint) package Box2D.Dynamics.Joints { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2GearJoint extends b2Joint { private var m_ground2:b2Body; private var m_groundAnchor1:b2Vec2; private var m_groundAnchor2:b2Vec2; private var m_localAnchor1:b2Vec2; private var m_localAnchor2:b2Vec2; private var m_ratio:Number; private var m_revolute2:b2RevoluteJoint; private var m_mass:Number; private var m_impulse:Number; private var m_prismatic2:b2PrismaticJoint; private var m_ground1:b2Body; private var m_revolute1:b2RevoluteJoint; private var m_prismatic1:b2PrismaticJoint; private var m_constant:Number; private var m_J:b2Jacobian; public function b2GearJoint(_arg1:b2GearJointDef){ var _local4:Number; var _local5:Number; m_groundAnchor1 = new b2Vec2(); m_groundAnchor2 = new b2Vec2(); m_localAnchor1 = new b2Vec2(); m_localAnchor2 = new b2Vec2(); m_J = new b2Jacobian(); super(_arg1); var _local2:int = _arg1.joint1.m_type; var _local3:int = _arg1.joint2.m_type; m_revolute1 = null; m_prismatic1 = null; m_revolute2 = null; m_prismatic2 = null; m_ground1 = _arg1.joint1.m_body1; m_body1 = _arg1.joint1.m_body2; if (_local2 == b2Joint.e_revoluteJoint){ m_revolute1 = (_arg1.joint1 as b2RevoluteJoint); m_groundAnchor1.SetV(m_revolute1.m_localAnchor1); m_localAnchor1.SetV(m_revolute1.m_localAnchor2); _local4 = m_revolute1.GetJointAngle(); } else { m_prismatic1 = (_arg1.joint1 as b2PrismaticJoint); m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1); m_localAnchor1.SetV(m_prismatic1.m_localAnchor2); _local4 = m_prismatic1.GetJointTranslation(); }; m_ground2 = _arg1.joint2.m_body1; m_body2 = _arg1.joint2.m_body2; if (_local3 == b2Joint.e_revoluteJoint){ m_revolute2 = (_arg1.joint2 as b2RevoluteJoint); m_groundAnchor2.SetV(m_revolute2.m_localAnchor1); m_localAnchor2.SetV(m_revolute2.m_localAnchor2); _local5 = m_revolute2.GetJointAngle(); } else { m_prismatic2 = (_arg1.joint2 as b2PrismaticJoint); m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1); m_localAnchor2.SetV(m_prismatic2.m_localAnchor2); _local5 = m_prismatic2.GetJointTranslation(); }; m_ratio = _arg1.ratio; m_constant = (_local4 + (m_ratio * _local5)); m_impulse = 0; } override public function GetAnchor1():b2Vec2{ return (m_body1.GetWorldPoint(m_localAnchor1)); } override public function GetAnchor2():b2Vec2{ return (m_body2.GetWorldPoint(m_localAnchor2)); } override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{ var _local6:Number; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:b2Mat22; var _local11:b2Vec2; var _local12:Number; var _local13:Number; var _local2:b2Body = m_ground1; var _local3:b2Body = m_ground2; var _local4:b2Body = m_body1; var _local5:b2Body = m_body2; var _local14:Number = 0; m_J.SetZero(); if (m_revolute1){ m_J.angular1 = -1; _local14 = (_local14 + _local4.m_invI); } else { _local10 = _local2.m_xf.R; _local11 = m_prismatic1.m_localXAxis1; _local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y)); _local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y)); _local10 = _local4.m_xf.R; _local8 = (m_localAnchor1.x - _local4.m_sweep.localCenter.x); _local9 = (m_localAnchor1.y - _local4.m_sweep.localCenter.y); _local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9)); _local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9)); _local8 = _local13; _local12 = ((_local8 * _local7) - (_local9 * _local6)); m_J.linear1.Set(-(_local6), -(_local7)); m_J.angular1 = -(_local12); _local14 = (_local14 + (_local4.m_invMass + ((_local4.m_invI * _local12) * _local12))); }; if (m_revolute2){ m_J.angular2 = -(m_ratio); _local14 = (_local14 + ((m_ratio * m_ratio) * _local5.m_invI)); } else { _local10 = _local3.m_xf.R; _local11 = m_prismatic2.m_localXAxis1; _local6 = ((_local10.col1.x * _local11.x) + (_local10.col2.x * _local11.y)); _local7 = ((_local10.col1.y * _local11.x) + (_local10.col2.y * _local11.y)); _local10 = _local5.m_xf.R; _local8 = (m_localAnchor2.x - _local5.m_sweep.localCenter.x); _local9 = (m_localAnchor2.y - _local5.m_sweep.localCenter.y); _local13 = ((_local10.col1.x * _local8) + (_local10.col2.x * _local9)); _local9 = ((_local10.col1.y * _local8) + (_local10.col2.y * _local9)); _local8 = _local13; _local12 = ((_local8 * _local7) - (_local9 * _local6)); m_J.linear2.Set((-(m_ratio) * _local6), (-(m_ratio) * _local7)); m_J.angular2 = (-(m_ratio) * _local12); _local14 = (_local14 + ((m_ratio * m_ratio) * (_local5.m_invMass + ((_local5.m_invI * _local12) * _local12)))); }; m_mass = (1 / _local14); if (_arg1.warmStarting){ _local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + ((_local4.m_invMass * m_impulse) * m_J.linear1.x)); _local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + ((_local4.m_invMass * m_impulse) * m_J.linear1.y)); _local4.m_angularVelocity = (_local4.m_angularVelocity + ((_local4.m_invI * m_impulse) * m_J.angular1)); _local5.m_linearVelocity.x = (_local5.m_linearVelocity.x + ((_local5.m_invMass * m_impulse) * m_J.linear2.x)); _local5.m_linearVelocity.y = (_local5.m_linearVelocity.y + ((_local5.m_invMass * m_impulse) * m_J.linear2.y)); _local5.m_angularVelocity = (_local5.m_angularVelocity + ((_local5.m_invI * m_impulse) * m_J.angular2)); } else { m_impulse = 0; }; } override public function GetReactionTorque(_arg1:Number):Number{ var _local2:b2Mat22 = m_body2.m_xf.R; var _local3:Number = (m_localAnchor1.x - m_body2.m_sweep.localCenter.x); var _local4:Number = (m_localAnchor1.y - m_body2.m_sweep.localCenter.y); var _local5:Number = ((_local2.col1.x * _local3) + (_local2.col2.x * _local4)); _local4 = ((_local2.col1.y * _local3) + (_local2.col2.y * _local4)); _local3 = _local5; var _local6:Number = (m_impulse * m_J.linear2.x); var _local7:Number = (m_impulse * m_J.linear2.y); return ((_arg1 * (((m_impulse * m_J.angular2) - (_local3 * _local7)) + (_local4 * _local6)))); } override public function GetReactionForce(_arg1:Number):b2Vec2{ return (new b2Vec2(((_arg1 * m_impulse) * m_J.linear2.x), ((_arg1 * m_impulse) * m_J.linear2.y))); } override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{ var _local5:Number; var _local6:Number; var _local2:Number = 0; var _local3:b2Body = m_body1; var _local4:b2Body = m_body2; if (m_revolute1){ _local5 = m_revolute1.GetJointAngle(); } else { _local5 = m_prismatic1.GetJointTranslation(); }; if (m_revolute2){ _local6 = m_revolute2.GetJointAngle(); } else { _local6 = m_prismatic2.GetJointTranslation(); }; var _local7:Number = (m_constant - (_local5 + (m_ratio * _local6))); var _local8:Number = (-(m_mass) * _local7); _local3.m_sweep.c.x = (_local3.m_sweep.c.x + ((_local3.m_invMass * _local8) * m_J.linear1.x)); _local3.m_sweep.c.y = (_local3.m_sweep.c.y + ((_local3.m_invMass * _local8) * m_J.linear1.y)); _local3.m_sweep.a = (_local3.m_sweep.a + ((_local3.m_invI * _local8) * m_J.angular1)); _local4.m_sweep.c.x = (_local4.m_sweep.c.x + ((_local4.m_invMass * _local8) * m_J.linear2.x)); _local4.m_sweep.c.y = (_local4.m_sweep.c.y + ((_local4.m_invMass * _local8) * m_J.linear2.y)); _local4.m_sweep.a = (_local4.m_sweep.a + ((_local4.m_invI * _local8) * m_J.angular2)); _local3.SynchronizeTransform(); _local4.SynchronizeTransform(); return ((_local2 < b2Settings.b2_linearSlop)); } public function GetRatio():Number{ return (m_ratio); } override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{ var _local2:b2Body = m_body1; var _local3:b2Body = m_body2; var _local4:Number = m_J.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity); var _local5:Number = (-(m_mass) * _local4); m_impulse = (m_impulse + _local5); _local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local2.m_invMass * _local5) * m_J.linear1.x)); _local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local2.m_invMass * _local5) * m_J.linear1.y)); _local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local2.m_invI * _local5) * m_J.angular1)); _local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local3.m_invMass * _local5) * m_J.linear2.x)); _local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local3.m_invMass * _local5) * m_J.linear2.y)); _local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _local5) * m_J.angular2)); } } }//package Box2D.Dynamics.Joints
Section 54
//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(){ type = b2Joint.e_gearJoint; joint1 = null; joint2 = null; ratio = 1; } } }//package Box2D.Dynamics.Joints
Section 55
//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(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):void{ linear1.SetV(_arg1); angular1 = _arg2; linear2.SetV(_arg3); angular2 = _arg4; } public function SetZero():void{ linear1.SetZero(); angular1 = 0; linear2.SetZero(); angular2 = 0; } public function Compute(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):Number{ return ((((((linear1.x * _arg1.x) + (linear1.y * _arg1.y)) + (angular1 * _arg2)) + ((linear2.x * _arg3.x) + (linear2.y * _arg3.y))) + (angular2 * _arg4))); } } }//package Box2D.Dynamics.Joints
Section 56
//b2Joint (Box2D.Dynamics.Joints.b2Joint) package Box2D.Dynamics.Joints { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2Joint { b2internal var m_islandFlag:Boolean; b2internal var m_collideConnected:Boolean; b2internal var m_prev:b2Joint; b2internal var m_type:int; b2internal var m_next:b2Joint; b2internal var m_node1:b2JointEdge; b2internal var m_node2:b2JointEdge; b2internal var m_localCenter1:b2Vec2; b2internal var m_localCenter2:b2Vec2; b2internal var m_invMass1:Number; b2internal var m_invI2:Number; b2internal var m_invMass2:Number; private var m_userData; b2internal var m_body1:b2Body; b2internal var m_body2:b2Body; b2internal var m_invI1:Number; b2internal static const e_unknownJoint:int = 0; b2internal static const e_inactiveLimit:int = 0; b2internal static const e_atUpperLimit:int = 2; b2internal static const e_atLowerLimit:int = 1; b2internal static const e_gearJoint:int = 6; b2internal static const e_revoluteJoint:int = 1; b2internal static const e_equalLimits:int = 3; b2internal static const e_distanceJoint:int = 3; b2internal static const e_pulleyJoint:int = 4; b2internal static const e_prismaticJoint:int = 2; b2internal static const e_mouseJoint:int = 5; public function b2Joint(_arg1:b2JointDef){ m_node1 = new b2JointEdge(); m_node2 = new b2JointEdge(); m_localCenter1 = new b2Vec2(); m_localCenter2 = new b2Vec2(); super(); m_type = _arg1.type; m_prev = null; m_next = null; m_body1 = _arg1.body1; m_body2 = _arg1.body2; m_collideConnected = _arg1.collideConnected; m_islandFlag = false; m_userData = _arg1.userData; } public function GetBody2():b2Body{ return (m_body2); } b2internal function ComputeXForm(_arg1:b2XForm, _arg2:b2Vec2, _arg3:b2Vec2, _arg4:Number):void{ _arg1.R.Set(_arg4); _arg1.position.SetV(b2Math.SubtractVV(_arg2, b2Math.b2MulMV(_arg1.R, _arg3))); } 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); } b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{ } public function GetReactionTorque(_arg1:Number):Number{ return (0); } public function GetUserData(){ return (m_userData); } public function GetReactionForce(_arg1:Number):b2Vec2{ return (null); } b2internal function SolvePositionConstraints(_arg1:Number):Boolean{ return (false); } public function SetUserData(_arg1):void{ m_userData = _arg1; } public function GetBody1():b2Body{ return (m_body1); } b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{ } b2internal static function Destroy(_arg1:b2Joint, _arg2):void{ } b2internal static function Create(_arg1:b2JointDef, _arg2):b2Joint{ var _local3:b2Joint; switch (_arg1.type){ case e_distanceJoint: _local3 = new b2DistanceJoint((_arg1 as b2DistanceJointDef)); break; case e_mouseJoint: _local3 = new b2MouseJoint((_arg1 as b2MouseJointDef)); break; case e_prismaticJoint: _local3 = new b2PrismaticJoint((_arg1 as b2PrismaticJointDef)); break; case e_revoluteJoint: _local3 = new b2RevoluteJoint((_arg1 as b2RevoluteJointDef)); break; case e_pulleyJoint: _local3 = new b2PulleyJoint((_arg1 as b2PulleyJointDef)); break; case e_gearJoint: _local3 = new b2GearJoint((_arg1 as b2GearJointDef)); break; default: break; }; return (_local3); } } }//package Box2D.Dynamics.Joints
Section 57
//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(){ type = b2Joint.e_unknownJoint; userData = null; body1 = null; body2 = null; collideConnected = false; } } }//package Box2D.Dynamics.Joints
Section 58
//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; } }//package Box2D.Dynamics.Joints
Section 59
//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; private var m_beta:Number; private var m_mass:b2Mat22; private var K2:b2Mat22; private var m_target:b2Vec2; private var m_gamma:Number; private var m_impulse:b2Vec2; private var m_C:b2Vec2; private var m_localAnchor:b2Vec2; private var m_maxForce:Number; private var m_dampingRatio:Number; private var m_frequencyHz:Number; public function b2MouseJoint(_arg1:b2MouseJointDef){ var _local3:Number; K = new b2Mat22(); K1 = new b2Mat22(); K2 = new b2Mat22(); m_localAnchor = new b2Vec2(); m_target = new b2Vec2(); m_impulse = new b2Vec2(); m_mass = new b2Mat22(); m_C = new b2Vec2(); super(_arg1); m_target.SetV(_arg1.target); var _local2:Number = (m_target.x - m_body2.m_xf.position.x); _local3 = (m_target.y - m_body2.m_xf.position.y); var _local4:b2Mat22 = m_body2.m_xf.R; m_localAnchor.x = ((_local2 * _local4.col1.x) + (_local3 * _local4.col1.y)); m_localAnchor.y = ((_local2 * _local4.col2.x) + (_local3 * _local4.col2.y)); m_maxForce = _arg1.maxForce; m_impulse.SetZero(); m_frequencyHz = _arg1.frequencyHz; m_dampingRatio = _arg1.dampingRatio; m_beta = 0; m_gamma = 0; } public function SetTarget(_arg1:b2Vec2):void{ if (m_body2.IsSleeping()){ m_body2.WakeUp(); }; m_target = _arg1; } override public function GetAnchor2():b2Vec2{ return (m_body2.GetWorldPoint(m_localAnchor)); } override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{ var _local2:b2Body; var _local7:b2Mat22; var _local8:Number; var _local9:Number; _local2 = m_body2; var _local3:Number = _local2.GetMass(); var _local4:Number = ((2 * Math.PI) * m_frequencyHz); var _local5:Number = (((2 * _local3) * m_dampingRatio) * _local4); var _local6:Number = ((_local3 * _local4) * _local4); m_gamma = (1 / (_arg1.dt * (_local5 + (_arg1.dt * _local6)))); m_beta = ((_arg1.dt * _local6) * m_gamma); _local7 = _local2.m_xf.R; _local8 = (m_localAnchor.x - _local2.m_sweep.localCenter.x); _local9 = (m_localAnchor.y - _local2.m_sweep.localCenter.y); var _local10:Number = ((_local7.col1.x * _local8) + (_local7.col2.x * _local9)); _local9 = ((_local7.col1.y * _local8) + (_local7.col2.y * _local9)); _local8 = _local10; var _local11:Number = _local2.m_invMass; var _local12:Number = _local2.m_invI; K1.col1.x = _local11; K1.col2.x = 0; K1.col1.y = 0; K1.col2.y = _local11; K2.col1.x = ((_local12 * _local9) * _local9); K2.col2.x = ((-(_local12) * _local8) * _local9); K2.col1.y = ((-(_local12) * _local8) * _local9); K2.col2.y = ((_local12 * _local8) * _local8); K.SetM(K1); K.AddM(K2); K.col1.x = (K.col1.x + m_gamma); K.col2.y = (K.col2.y + m_gamma); K.GetInverse(m_mass); m_C.x = ((_local2.m_sweep.c.x + _local8) - m_target.x); m_C.y = ((_local2.m_sweep.c.y + _local9) - m_target.y); _local2.m_angularVelocity = (_local2.m_angularVelocity * 0.98); m_impulse.x = (m_impulse.x * _arg1.dtRatio); m_impulse.y = (m_impulse.y * _arg1.dtRatio); _local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local11 * m_impulse.x)); _local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local11 * m_impulse.y)); _local2.m_angularVelocity = (_local2.m_angularVelocity + (_local12 * ((_local8 * m_impulse.y) - (_local9 * m_impulse.x)))); } override public function GetAnchor1():b2Vec2{ return (m_target); } override public function GetReactionTorque(_arg1:Number):Number{ return (0); } override public function GetReactionForce(_arg1:Number):b2Vec2{ return (new b2Vec2((_arg1 * m_impulse.x), (_arg1 * m_impulse.y))); } override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{ return (true); } override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{ var _local3:b2Mat22; var _local4:Number; var _local5:Number; var _local2:b2Body = m_body2; _local3 = _local2.m_xf.R; var _local6:Number = (m_localAnchor.x - _local2.m_sweep.localCenter.x); var _local7:Number = (m_localAnchor.y - _local2.m_sweep.localCenter.y); _local4 = ((_local3.col1.x * _local6) + (_local3.col2.x * _local7)); _local7 = ((_local3.col1.y * _local6) + (_local3.col2.y * _local7)); _local6 = _local4; var _local8:Number = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local7)); var _local9:Number = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local6)); _local3 = m_mass; _local4 = ((_local8 + (m_beta * m_C.x)) + (m_gamma * m_impulse.x)); _local5 = ((_local9 + (m_beta * m_C.y)) + (m_gamma * m_impulse.y)); var _local10:Number = -(((_local3.col1.x * _local4) + (_local3.col2.x * _local5))); var _local11:Number = -(((_local3.col1.y * _local4) + (_local3.col2.y * _local5))); var _local12:Number = m_impulse.x; var _local13:Number = m_impulse.y; m_impulse.x = (m_impulse.x + _local10); m_impulse.y = (m_impulse.y + _local11); var _local14:Number = (_arg1.dt * m_maxForce); if (m_impulse.LengthSquared() > (_local14 * _local14)){ m_impulse.Multiply((_local14 / m_impulse.Length())); }; _local10 = (m_impulse.x - _local12); _local11 = (m_impulse.y - _local13); _local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local10)); _local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local11)); _local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local6 * _local11) - (_local7 * _local10)))); } } }//package Box2D.Dynamics.Joints
Section 60
//b2MouseJointDef (Box2D.Dynamics.Joints.b2MouseJointDef) package Box2D.Dynamics.Joints { import Box2D.Common.Math.*; public class b2MouseJointDef extends b2JointDef { 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; } } }//package Box2D.Dynamics.Joints
Section 61
//b2PrismaticJoint (Box2D.Dynamics.Joints.b2PrismaticJoint) package Box2D.Dynamics.Joints { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2PrismaticJoint extends b2Joint { private var m_a1:Number; private var m_a2:Number; private var m_perp:b2Vec2; private var m_lowerTranslation:Number; b2internal var m_localXAxis1:b2Vec2; private var m_refAngle:Number; private var m_impulse:b2Vec3; private var m_enableLimit:Boolean; private var m_maxMotorForce:Number; private var m_localYAxis1:b2Vec2; private var m_s2:Number; private var m_axis:b2Vec2; private var m_motorMass:Number; private var m_s1:Number; private var m_upperTranslation:Number; b2internal var m_localAnchor1:b2Vec2; b2internal var m_localAnchor2:b2Vec2; private var m_limitState:int; private var m_motorImpulse:Number; private var m_motorSpeed:Number; private var m_enableMotor:Boolean; private var m_K:b2Mat33; public function b2PrismaticJoint(_arg1:b2PrismaticJointDef){ var _local2:b2Mat22; var _local3:Number; var _local4:Number; m_localAnchor1 = new b2Vec2(); m_localAnchor2 = new b2Vec2(); m_localXAxis1 = new b2Vec2(); m_localYAxis1 = new b2Vec2(); m_axis = new b2Vec2(); m_perp = new b2Vec2(); m_K = new b2Mat33(); m_impulse = new b2Vec3(); super(_arg1); m_localAnchor1.SetV(_arg1.localAnchor1); m_localAnchor2.SetV(_arg1.localAnchor2); m_localXAxis1.SetV(_arg1.localAxis1); m_localYAxis1.x = -(m_localXAxis1.y); m_localYAxis1.y = m_localXAxis1.x; m_refAngle = _arg1.referenceAngle; m_impulse.SetZero(); m_motorMass = 0; m_motorImpulse = 0; m_lowerTranslation = _arg1.lowerTranslation; m_upperTranslation = _arg1.upperTranslation; m_maxMotorForce = _arg1.maxMotorForce; m_motorSpeed = _arg1.motorSpeed; m_enableLimit = _arg1.enableLimit; m_enableMotor = _arg1.enableMotor; m_axis.SetZero(); m_perp.SetZero(); } override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{ var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:b2Vec3; var _local20:b2Vec3; var _local21:Number; var _local22:Number; var _local23:b2Vec2; var _local24:b2Vec2; var _local2:b2Body = m_body1; var _local3:b2Body = m_body2; var _local4:b2Vec2 = _local2.m_linearVelocity; var _local5:Number = _local2.m_angularVelocity; var _local6:b2Vec2 = _local3.m_linearVelocity; var _local7:Number = _local3.m_angularVelocity; if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){ _local14 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5)); _local15 = (m_motorMass * (m_motorSpeed - _local14)); _local16 = m_motorImpulse; _local17 = (_arg1.dt * m_maxMotorForce); m_motorImpulse = b2Math.b2Clamp((m_motorImpulse + _local15), -(_local17), _local17); _local15 = (m_motorImpulse - _local16); _local8 = (_local15 * m_axis.x); _local9 = (_local15 * m_axis.y); _local10 = (_local15 * m_a1); _local11 = (_local15 * m_a2); _local4.x = (_local4.x - (m_invMass1 * _local8)); _local4.y = (_local4.y - (m_invMass1 * _local9)); _local5 = (_local5 - (m_invI1 * _local10)); _local6.x = (_local6.x + (m_invMass2 * _local8)); _local6.y = (_local6.y + (m_invMass2 * _local9)); _local7 = (_local7 + (m_invI2 * _local11)); }; var _local12:Number = ((((m_perp.x * (_local6.x - _local4.x)) + (m_perp.y * (_local6.y - _local4.y))) + (m_s2 * _local7)) - (m_s1 * _local5)); var _local13:Number = (_local7 - _local5); if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){ _local18 = ((((m_axis.x * (_local6.x - _local4.x)) + (m_axis.y * (_local6.y - _local4.y))) + (m_a2 * _local7)) - (m_a1 * _local5)); _local19 = m_impulse.Copy(); _local20 = m_K.Solve33(new b2Vec3(), -(_local12), -(_local13), -(_local18)); m_impulse.Add(_local20); if (m_limitState == e_atLowerLimit){ m_impulse.z = b2Math.b2Max(m_impulse.z, 0); } else { if (m_limitState == e_atUpperLimit){ m_impulse.z = b2Math.b2Min(m_impulse.z, 0); }; }; _local21 = (-(_local12) - ((m_impulse.z - _local19.z) * m_K.col3.x)); _local22 = (-(_local13) - ((m_impulse.z - _local19.z) * m_K.col3.y)); _local23 = m_K.Solve22(new b2Vec2(), _local21, _local22); m_K.Solve22(new b2Vec2(), _local21, _local22).x = (_local23.x + _local19.x); _local23.y = (_local23.y + _local19.y); m_impulse.x = _local23.x; m_impulse.y = _local23.y; _local20.x = (m_impulse.x - _local19.x); _local20.y = (m_impulse.y - _local19.y); _local20.z = (m_impulse.z - _local19.z); _local8 = ((_local20.x * m_perp.x) + (_local20.z * m_axis.x)); _local9 = ((_local20.x * m_perp.y) + (_local20.z * m_axis.y)); _local10 = (((_local20.x * m_s1) + _local20.y) + (_local20.z * m_a1)); _local11 = (((_local20.x * m_s2) + _local20.y) + (_local20.z * m_a2)); _local4.x = (_local4.x - (m_invMass1 * _local8)); _local4.y = (_local4.y - (m_invMass1 * _local9)); _local5 = (_local5 - (m_invI1 * _local10)); _local6.x = (_local6.x + (m_invMass2 * _local8)); _local6.y = (_local6.y + (m_invMass2 * _local9)); _local7 = (_local7 + (m_invI2 * _local11)); } else { _local24 = m_K.Solve22(new b2Vec2(), -(_local12), -(_local13)); m_impulse.x = (m_impulse.x + _local24.x); m_impulse.y = (m_impulse.y + _local24.y); _local8 = (_local24.x * m_perp.x); _local9 = (_local24.x * m_perp.y); _local10 = ((_local24.x * m_s1) + _local24.y); _local11 = ((_local24.x * m_s2) + _local24.y); _local4.x = (_local4.x - (m_invMass1 * _local8)); _local4.y = (_local4.y - (m_invMass1 * _local9)); _local5 = (_local5 - (m_invI1 * _local10)); _local6.x = (_local6.x + (m_invMass2 * _local8)); _local6.y = (_local6.y + (m_invMass2 * _local9)); _local7 = (_local7 + (m_invI2 * _local11)); }; _local2.m_linearVelocity.SetV(_local4); _local2.m_angularVelocity = _local5; _local3.m_linearVelocity.SetV(_local6); _local3.m_angularVelocity = _local7; } 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(_arg1:Boolean):void{ m_enableMotor = _arg1; } public function GetJointTranslation():Number{ var _local3:b2Mat22; var _local1:b2Body = m_body1; var _local2:b2Body = m_body2; var _local4:b2Vec2 = _local1.GetWorldPoint(m_localAnchor1); var _local5:b2Vec2 = _local2.GetWorldPoint(m_localAnchor2); var _local6:Number = (_local5.x - _local4.x); var _local7:Number = (_local5.y - _local4.y); var _local8:b2Vec2 = _local1.GetWorldVector(m_localXAxis1); var _local9:Number = ((_local8.x * _local6) + (_local8.y * _local7)); return (_local9); } public function GetMotorSpeed():Number{ return (m_motorSpeed); } override public function GetReactionForce(_arg1:Number):b2Vec2{ return (new b2Vec2((_arg1 * ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.z) * m_axis.x))), (_arg1 * ((m_impulse.x * m_perp.y) + ((m_motorImpulse + m_impulse.z) * m_axis.y))))); } override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{ var _local2:Number; var _local3:Number; var _local10:b2Mat22; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local35:Number; var _local36:Number; var _local37:Number; var _local38:Number; var _local39:b2Vec2; var _local4:b2Body = m_body1; var _local5:b2Body = m_body2; var _local6:b2Vec2 = _local4.m_sweep.c; var _local7:Number = _local4.m_sweep.a; var _local8:b2Vec2 = _local5.m_sweep.c; var _local9:Number = _local5.m_sweep.a; var _local16:Number = 0; var _local17:Number = 0; var _local18:Boolean; var _local19:Number = 0; var _local20:b2Mat22 = new b2Mat22(_local7); var _local21:b2Mat22 = new b2Mat22(_local9); _local10 = _local20; var _local22:Number = (m_localAnchor1.x - m_localCenter1.x); var _local23:Number = (m_localAnchor1.y - m_localCenter1.y); _local11 = ((_local10.col1.x * _local22) + (_local10.col2.x * _local23)); _local23 = ((_local10.col1.y * _local22) + (_local10.col2.y * _local23)); _local22 = _local11; _local10 = _local21; var _local24:Number = (m_localAnchor2.x - m_localCenter2.x); var _local25:Number = (m_localAnchor2.y - m_localCenter2.y); _local11 = ((_local10.col1.x * _local24) + (_local10.col2.x * _local25)); _local25 = ((_local10.col1.y * _local24) + (_local10.col2.y * _local25)); _local24 = _local11; var _local26:Number = (((_local8.x + _local24) - _local6.x) - _local22); var _local27:Number = (((_local8.y + _local25) - _local6.y) - _local23); if (m_enableLimit){ m_axis = b2Math.b2MulMV(_local20, m_localXAxis1); m_a1 = (((_local26 + _local22) * m_axis.y) - ((_local27 + _local23) * m_axis.x)); m_a2 = ((_local24 * m_axis.y) - (_local25 * m_axis.x)); _local35 = ((m_axis.x * _local26) + (m_axis.y * _local27)); if (b2Math.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){ _local19 = b2Math.b2Clamp(_local35, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); _local16 = b2Math.b2Abs(_local35); _local18 = true; } else { if (_local35 <= m_lowerTranslation){ _local19 = b2Math.b2Clamp(((_local35 - m_lowerTranslation) + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0); _local16 = (m_lowerTranslation - _local35); _local18 = true; } else { if (_local35 >= m_upperTranslation){ _local19 = b2Math.b2Clamp(((_local35 - m_upperTranslation) + b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection); _local16 = (_local35 - m_upperTranslation); _local18 = true; }; }; }; }; m_perp = b2Math.b2MulMV(_local20, m_localYAxis1); m_s1 = (((_local26 + _local22) * m_perp.y) - ((_local27 + _local23) * m_perp.x)); m_s2 = ((_local24 * m_perp.y) - (_local25 * m_perp.x)); var _local28:b2Vec3 = new b2Vec3(); var _local29:Number = ((m_perp.x * _local26) + (m_perp.y * _local27)); var _local30:Number = ((_local9 - _local7) - m_refAngle); _local16 = b2Math.b2Max(_local16, b2Math.b2Abs(_local29)); _local17 = b2Math.b2Abs(_local30); if (_local18){ _local12 = m_invMass1; _local13 = m_invMass2; _local14 = m_invI1; _local15 = m_invI2; m_K.col1.x = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2)); m_K.col1.y = ((_local14 * m_s1) + (_local15 * m_s2)); m_K.col1.z = (((_local14 * m_s1) * m_a1) + ((_local15 * m_s2) * m_a2)); m_K.col2.x = m_K.col1.y; m_K.col2.y = (_local14 + _local15); m_K.col2.z = ((_local14 * m_a1) + (_local15 * m_a2)); m_K.col3.x = m_K.col1.z; m_K.col3.y = m_K.col2.z; m_K.col3.z = (((_local12 + _local13) + ((_local14 * m_a1) * m_a1)) + ((_local15 * m_a2) * m_a2)); m_K.Solve33(_local28, -(_local29), -(_local30), -(_local19)); } else { _local12 = m_invMass1; _local13 = m_invMass2; _local14 = m_invI1; _local15 = m_invI2; _local36 = (((_local12 + _local13) + ((_local14 * m_s1) * m_s1)) + ((_local15 * m_s2) * m_s2)); _local37 = ((_local14 * m_s1) + (_local15 * m_s2)); _local38 = (_local14 + _local15); m_K.col1.Set(_local36, _local37, 0); m_K.col2.Set(_local37, _local38, 0); _local39 = m_K.Solve22(new b2Vec2(), -(_local29), -(_local30)); _local28.x = _local39.x; _local28.y = _local39.y; _local28.z = 0; }; var _local31:Number = ((_local28.x * m_perp.x) + (_local28.z * m_axis.x)); var _local32:Number = ((_local28.x * m_perp.y) + (_local28.z * m_axis.y)); var _local33:Number = (((_local28.x * m_s1) + _local28.y) + (_local28.z * m_a1)); var _local34:Number = (((_local28.x * m_s2) + _local28.y) + (_local28.z * m_a2)); _local6.x = (_local6.x - (m_invMass1 * _local31)); _local6.y = (_local6.y - (m_invMass1 * _local32)); _local7 = (_local7 - (m_invI1 * _local33)); _local8.x = (_local8.x + (m_invMass2 * _local31)); _local8.y = (_local8.y + (m_invMass2 * _local32)); _local9 = (_local9 + (m_invI2 * _local34)); _local4.m_sweep.a = _local7; _local5.m_sweep.a = _local9; _local4.SynchronizeTransform(); _local5.SynchronizeTransform(); return ((((_local16 <= b2Settings.b2_linearSlop)) && ((_local17 <= b2Settings.b2_angularSlop)))); } public function SetMotorSpeed(_arg1:Number):void{ m_motorSpeed = _arg1; } public function GetJointSpeed():Number{ var _local3:b2Mat22; var _local1:b2Body = m_body1; var _local2:b2Body = m_body2; _local3 = _local1.m_xf.R; var _local4:Number = (m_localAnchor1.x - _local1.m_sweep.localCenter.x); var _local5:Number = (m_localAnchor1.y - _local1.m_sweep.localCenter.y); var _local6:Number = ((_local3.col1.x * _local4) + (_local3.col2.x * _local5)); _local5 = ((_local3.col1.y * _local4) + (_local3.col2.y * _local5)); _local4 = _local6; _local3 = _local2.m_xf.R; var _local7:Number = (m_localAnchor2.x - _local2.m_sweep.localCenter.x); var _local8:Number = (m_localAnchor2.y - _local2.m_sweep.localCenter.y); _local6 = ((_local3.col1.x * _local7) + (_local3.col2.x * _local8)); _local8 = ((_local3.col1.y * _local7) + (_local3.col2.y * _local8)); _local7 = _local6; var _local9:Number = (_local1.m_sweep.c.x + _local4); var _local10:Number = (_local1.m_sweep.c.y + _local5); var _local11:Number = (_local2.m_sweep.c.x + _local7); var _local12:Number = (_local2.m_sweep.c.y + _local8); var _local13:Number = (_local11 - _local9); var _local14:Number = (_local12 - _local10); var _local15:b2Vec2 = _local1.GetWorldVector(m_localXAxis1); var _local16:b2Vec2 = _local1.m_linearVelocity; var _local17:b2Vec2 = _local2.m_linearVelocity; var _local18:Number = _local1.m_angularVelocity; var _local19:Number = _local2.m_angularVelocity; var _local20:Number = (((_local13 * (-(_local18) * _local15.y)) + (_local14 * (_local18 * _local15.x))) + ((_local15.x * (((_local17.x + (-(_local19) * _local8)) - _local16.x) - (-(_local18) * _local5))) + (_local15.y * (((_local17.y + (_local19 * _local7)) - _local16.y) - (_local18 * _local4))))); return (_local20); } override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{ var _local4:b2Mat22; var _local5:Number; var _local18:Number; var _local19:Number; var _local20:Number; var _local21:Number; var _local22:Number; var _local2:b2Body = m_body1; var _local3:b2Body = m_body2; m_localCenter1.SetV(_local2.GetLocalCenter()); m_localCenter2.SetV(_local3.GetLocalCenter()); var _local6:b2XForm = _local2.GetXForm(); var _local7:b2XForm = _local3.GetXForm(); _local4 = _local2.m_xf.R; var _local8:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x); var _local9:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y); _local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9)); _local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9)); _local8 = _local5; _local4 = _local3.m_xf.R; var _local10:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x); var _local11:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y); _local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11)); _local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11)); _local10 = _local5; var _local12:Number = (((_local3.m_sweep.c.x + _local10) - _local2.m_sweep.c.x) - _local8); var _local13:Number = (((_local3.m_sweep.c.y + _local11) - _local2.m_sweep.c.y) - _local9); m_invMass1 = _local2.m_invMass; m_invMass2 = _local3.m_invMass; m_invI1 = _local2.m_invI; m_invI2 = _local3.m_invI; m_axis.SetV(b2Math.b2MulMV(_local6.R, m_localXAxis1)); m_a1 = (((_local12 + _local8) * m_axis.y) - ((_local13 + _local9) * m_axis.x)); m_a2 = ((_local10 * m_axis.y) - (_local11 * m_axis.x)); m_motorMass = (((m_invMass1 + m_invMass2) + ((m_invI1 * m_a1) * m_a1)) + ((m_invI2 * m_a2) * m_a2)); m_motorMass = (1 / m_motorMass); m_perp.SetV(b2Math.b2MulMV(_local6.R, m_localYAxis1)); m_s1 = (((_local12 + _local8) * m_perp.y) - ((_local13 + _local9) * m_perp.x)); m_s2 = ((_local10 * m_perp.y) - (_local11 * m_perp.x)); var _local14:Number = m_invMass1; var _local15:Number = m_invMass2; var _local16:Number = m_invI1; var _local17:Number = m_invI2; m_K.col1.x = (((_local14 + _local15) + ((_local16 * m_s1) * m_s1)) + ((_local17 * m_s2) * m_s2)); m_K.col1.y = ((_local16 * m_s1) + (_local17 * m_s2)); m_K.col1.z = (((_local16 * m_s1) * m_a1) + ((_local17 * m_s2) * m_a2)); m_K.col2.x = m_K.col1.y; m_K.col2.y = (_local16 + _local17); m_K.col2.z = ((_local16 * m_a1) + (_local17 * m_a2)); m_K.col3.x = m_K.col1.z; m_K.col3.y = m_K.col2.z; m_K.col3.z = (((_local14 + _local15) + ((_local16 * m_a1) * m_a1)) + ((_local17 * m_a2) * m_a2)); if (m_enableLimit){ _local18 = ((m_axis.x * _local12) + (m_axis.y * _local13)); if (b2Math.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){ m_limitState = e_equalLimits; } else { if (_local18 <= m_lowerTranslation){ if (m_limitState != e_atLowerLimit){ m_limitState = e_atLowerLimit; m_impulse.z = 0; }; } else { if (_local18 >= m_upperTranslation){ if (m_limitState != e_atUpperLimit){ m_limitState = e_atUpperLimit; m_impulse.z = 0; }; } else { m_limitState = e_inactiveLimit; m_impulse.z = 0; }; }; }; }; if (m_enableMotor == false){ m_motorImpulse = 0; }; if (_arg1.warmStarting){ m_impulse.x = (m_impulse.x * _arg1.dtRatio); m_impulse.y = (m_impulse.y * _arg1.dtRatio); m_motorImpulse = (m_motorImpulse * _arg1.dtRatio); _local19 = ((m_impulse.x * m_perp.x) + ((m_motorImpulse + m_impulse.z) * m_axis.x)); _local20 = ((m_impulse.y * m_perp.y) + ((m_motorImpulse + m_impulse.z) * m_axis.y)); _local21 = (((m_impulse.x * m_s1) + m_impulse.y) + ((m_motorImpulse + m_impulse.z) * m_a1)); _local22 = (((m_impulse.x * m_s2) + m_impulse.y) + ((m_motorImpulse + m_impulse.z) * m_a2)); _local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (m_invMass1 * _local19)); _local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (m_invMass1 * _local20)); _local2.m_angularVelocity = (_local2.m_angularVelocity - (m_invI1 * _local21)); _local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (m_invMass2 * _local19)); _local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (m_invMass2 * _local20)); _local3.m_angularVelocity = (_local3.m_angularVelocity + (m_invI2 * _local22)); } else { m_impulse.SetZero(); m_motorImpulse = 0; }; } public function GetMotorForce():Number{ return (m_motorImpulse); } public function EnableLimit(_arg1:Boolean):void{ m_enableLimit = _arg1; } public function SetMaxMotorForce(_arg1:Number):void{ m_maxMotorForce = _arg1; } override public function GetReactionTorque(_arg1:Number):Number{ return ((_arg1 * m_impulse.y)); } public function IsLimitEnabled():Boolean{ return (m_enableLimit); } public function IsMotorEnabled():Boolean{ return (m_enableMotor); } public function SetLimits(_arg1:Number, _arg2:Number):void{ m_lowerTranslation = _arg1; m_upperTranslation = _arg2; } } }//package Box2D.Dynamics.Joints
Section 62
//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(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2):void{ body1 = _arg1; body2 = _arg2; localAnchor1 = body1.GetLocalPoint(_arg3); localAnchor2 = body2.GetLocalPoint(_arg3); localAxis1 = body1.GetLocalVector(_arg4); referenceAngle = (body2.GetAngle() - body1.GetAngle()); } } }//package Box2D.Dynamics.Joints
Section 63
//b2PulleyJoint (Box2D.Dynamics.Joints.b2PulleyJoint) package Box2D.Dynamics.Joints { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2PulleyJoint extends b2Joint { private var m_limitState1:int; private var m_limitState2:int; private var m_ground:b2Body; private var m_maxLength2:Number; private var m_maxLength1:Number; private var m_impulse:Number; private var m_constant:Number; private var m_state:int; private var m_ratio:Number; private var m_groundAnchor1:b2Vec2; private var m_groundAnchor2:b2Vec2; private var m_localAnchor1:b2Vec2; private var m_localAnchor2:b2Vec2; private var m_limitMass1:Number; private var m_limitMass2:Number; private var m_pulleyMass:Number; private var m_limitImpulse1:Number; private var m_limitImpulse2:Number; private var m_u1:b2Vec2; private var m_u2:b2Vec2; b2internal static const b2_minPulleyLength:Number = 2; public function b2PulleyJoint(_arg1:b2PulleyJointDef){ var _local2:b2Mat22; var _local3:Number; var _local4: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(_arg1); m_ground = m_body1.m_world.m_groundBody; m_groundAnchor1.x = (_arg1.groundAnchor1.x - m_ground.m_xf.position.x); m_groundAnchor1.y = (_arg1.groundAnchor1.y - m_ground.m_xf.position.y); m_groundAnchor2.x = (_arg1.groundAnchor2.x - m_ground.m_xf.position.x); m_groundAnchor2.y = (_arg1.groundAnchor2.y - m_ground.m_xf.position.y); m_localAnchor1.SetV(_arg1.localAnchor1); m_localAnchor2.SetV(_arg1.localAnchor2); m_ratio = _arg1.ratio; m_constant = (_arg1.length1 + (m_ratio * _arg1.length2)); m_maxLength1 = b2Math.b2Min(_arg1.maxLength1, (m_constant - (m_ratio * b2_minPulleyLength))); m_maxLength2 = b2Math.b2Min(_arg1.maxLength2, ((m_constant - b2_minPulleyLength) / m_ratio)); m_impulse = 0; m_limitImpulse1 = 0; m_limitImpulse2 = 0; } public function GetGroundAnchor2():b2Vec2{ var _local1:b2Vec2 = m_ground.m_xf.position.Copy(); _local1.Add(m_groundAnchor2); return (_local1); } 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(_arg1:Number):b2Vec2{ return (new b2Vec2(((_arg1 * m_impulse) * m_u2.x), ((_arg1 * m_impulse) * m_u2.y))); } override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{ var _local4:b2Mat22; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:Number; var _local20:Number; var _local21:Number; var _local22:Number; var _local23:Number; var _local2:b2Body = m_body1; var _local3:b2Body = m_body2; var _local5:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x); var _local6:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y); var _local7:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x); var _local8:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y); var _local24:Number = 0; if (m_state == e_atUpperLimit){ _local4 = _local2.m_xf.R; _local9 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x); _local10 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y); _local23 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10)); _local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10)); _local9 = _local23; _local4 = _local3.m_xf.R; _local11 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x); _local12 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y); _local23 = ((_local4.col1.x * _local11) + (_local4.col2.x * _local12)); _local12 = ((_local4.col1.y * _local11) + (_local4.col2.y * _local12)); _local11 = _local23; _local13 = (_local2.m_sweep.c.x + _local9); _local14 = (_local2.m_sweep.c.y + _local10); _local15 = (_local3.m_sweep.c.x + _local11); _local16 = (_local3.m_sweep.c.y + _local12); m_u1.Set((_local13 - _local5), (_local14 - _local6)); m_u2.Set((_local15 - _local7), (_local16 - _local8)); _local17 = m_u1.Length(); _local18 = m_u2.Length(); if (_local17 > b2Settings.b2_linearSlop){ m_u1.Multiply((1 / _local17)); } else { m_u1.SetZero(); }; if (_local18 > b2Settings.b2_linearSlop){ m_u2.Multiply((1 / _local18)); } else { m_u2.SetZero(); }; _local19 = ((m_constant - _local17) - (m_ratio * _local18)); _local24 = b2Math.b2Max(_local24, -(_local19)); _local19 = b2Math.b2Clamp((_local19 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0); _local20 = (-(m_pulleyMass) * _local19); _local13 = (-(_local20) * m_u1.x); _local14 = (-(_local20) * m_u1.y); _local15 = ((-(m_ratio) * _local20) * m_u2.x); _local16 = ((-(m_ratio) * _local20) * m_u2.y); _local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local13)); _local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local14)); _local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local9 * _local14) - (_local10 * _local13)))); _local3.m_sweep.c.x = (_local3.m_sweep.c.x + (_local3.m_invMass * _local15)); _local3.m_sweep.c.y = (_local3.m_sweep.c.y + (_local3.m_invMass * _local16)); _local3.m_sweep.a = (_local3.m_sweep.a + (_local3.m_invI * ((_local11 * _local16) - (_local12 * _local15)))); _local2.SynchronizeTransform(); _local3.SynchronizeTransform(); }; if (m_limitState1 == e_atUpperLimit){ _local4 = _local2.m_xf.R; _local9 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x); _local10 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y); _local23 = ((_local4.col1.x * _local9) + (_local4.col2.x * _local10)); _local10 = ((_local4.col1.y * _local9) + (_local4.col2.y * _local10)); _local9 = _local23; _local13 = (_local2.m_sweep.c.x + _local9); _local14 = (_local2.m_sweep.c.y + _local10); m_u1.Set((_local13 - _local5), (_local14 - _local6)); _local17 = m_u1.Length(); if (_local17 > b2Settings.b2_linearSlop){ m_u1.x = (m_u1.x * (1 / _local17)); m_u1.y = (m_u1.y * (1 / _local17)); } else { m_u1.SetZero(); }; _local19 = (m_maxLength1 - _local17); _local24 = b2Math.b2Max(_local24, -(_local19)); _local19 = b2Math.b2Clamp((_local19 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0); _local20 = (-(m_limitMass1) * _local19); _local13 = (-(_local20) * m_u1.x); _local14 = (-(_local20) * m_u1.y); _local2.m_sweep.c.x = (_local2.m_sweep.c.x + (_local2.m_invMass * _local13)); _local2.m_sweep.c.y = (_local2.m_sweep.c.y + (_local2.m_invMass * _local14)); _local2.m_sweep.a = (_local2.m_sweep.a + (_local2.m_invI * ((_local9 * _local14) - (_local10 * _local13)))); _local2.SynchronizeTransform(); }; if (m_limitState2 == e_atUpperLimit){ _local4 = _local3.m_xf.R; _local11 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x); _local12 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y); _local23 = ((_local4.col1.x * _local11) + (_local4.col2.x * _local12)); _local12 = ((_local4.col1.y * _local11) + (_local4.col2.y * _local12)); _local11 = _local23; _local15 = (_local3.m_sweep.c.x + _local11); _local16 = (_local3.m_sweep.c.y + _local12); m_u2.Set((_local15 - _local7), (_local16 - _local8)); _local18 = m_u2.Length(); if (_local18 > b2Settings.b2_linearSlop){ m_u2.x = (m_u2.x * (1 / _local18)); m_u2.y = (m_u2.y * (1 / _local18)); } else { m_u2.SetZero(); }; _local19 = (m_maxLength2 - _local18); _local24 = b2Math.b2Max(_local24, -(_local19)); _local19 = b2Math.b2Clamp((_local19 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0); _local20 = (-(m_limitMass2) * _local19); _local15 = (-(_local20) * m_u2.x); _local16 = (-(_local20) * m_u2.y); _local3.m_sweep.c.x = (_local3.m_sweep.c.x + (_local3.m_invMass * _local15)); _local3.m_sweep.c.y = (_local3.m_sweep.c.y + (_local3.m_invMass * _local16)); _local3.m_sweep.a = (_local3.m_sweep.a + (_local3.m_invI * ((_local11 * _local16) - (_local12 * _local15)))); _local3.SynchronizeTransform(); }; return ((_local24 < b2Settings.b2_linearSlop)); } override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{ var _local2:b2Body; var _local4:b2Mat22; var _local23:Number; var _local24:Number; var _local25:Number; var _local26:Number; _local2 = m_body1; var _local3:b2Body = m_body2; _local4 = _local2.m_xf.R; var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x); var _local6:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y); var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6)); _local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6)); _local5 = _local7; _local4 = _local3.m_xf.R; var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x); var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y); _local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9)); _local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9)); _local8 = _local7; var _local10:Number = (_local2.m_sweep.c.x + _local5); var _local11:Number = (_local2.m_sweep.c.y + _local6); var _local12:Number = (_local3.m_sweep.c.x + _local8); var _local13:Number = (_local3.m_sweep.c.y + _local9); var _local14:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x); var _local15:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y); var _local16:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x); var _local17:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y); m_u1.Set((_local10 - _local14), (_local11 - _local15)); m_u2.Set((_local12 - _local16), (_local13 - _local17)); var _local18:Number = m_u1.Length(); var _local19:Number = m_u2.Length(); if (_local18 > b2Settings.b2_linearSlop){ m_u1.Multiply((1 / _local18)); } else { m_u1.SetZero(); }; if (_local19 > b2Settings.b2_linearSlop){ m_u2.Multiply((1 / _local19)); } else { m_u2.SetZero(); }; var _local20:Number = ((m_constant - _local18) - (m_ratio * _local19)); if (_local20 > 0){ m_state = e_inactiveLimit; m_impulse = 0; } else { m_state = e_atUpperLimit; }; if (_local18 < m_maxLength1){ m_limitState1 = e_inactiveLimit; m_limitImpulse1 = 0; } else { m_limitState1 = e_atUpperLimit; }; if (_local19 < m_maxLength2){ m_limitState2 = e_inactiveLimit; m_limitImpulse2 = 0; } else { m_limitState2 = e_atUpperLimit; }; var _local21:Number = ((_local5 * m_u1.y) - (_local6 * m_u1.x)); var _local22:Number = ((_local8 * m_u2.y) - (_local9 * m_u2.x)); m_limitMass1 = (_local2.m_invMass + ((_local2.m_invI * _local21) * _local21)); m_limitMass2 = (_local3.m_invMass + ((_local3.m_invI * _local22) * _local22)); 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 (_arg1.warmStarting){ m_impulse = (m_impulse * _arg1.dtRatio); m_limitImpulse1 = (m_limitImpulse1 * _arg1.dtRatio); m_limitImpulse2 = (m_limitImpulse2 * _arg1.dtRatio); _local23 = ((-(m_impulse) - m_limitImpulse1) * m_u1.x); _local24 = ((-(m_impulse) - m_limitImpulse1) * m_u1.y); _local25 = (((-(m_ratio) * m_impulse) - m_limitImpulse2) * m_u2.x); _local26 = (((-(m_ratio) * m_impulse) - m_limitImpulse2) * m_u2.y); _local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local23)); _local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local24)); _local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local24) - (_local6 * _local23)))); _local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local25)); _local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local26)); _local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local26) - (_local9 * _local25)))); } else { m_impulse = 0; m_limitImpulse1 = 0; m_limitImpulse2 = 0; }; } override public function GetReactionTorque(_arg1:Number):Number{ return (0); } public function GetRatio():Number{ return (m_ratio); } public function GetLength2():Number{ var _local1:b2Vec2 = m_body2.GetWorldPoint(m_localAnchor2); var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor2.x); var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor2.y); var _local4:Number = (_local1.x - _local2); var _local5:Number = (_local1.y - _local3); return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5)))); } override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{ var _local4:b2Mat22; var _local10:Number; var _local11:Number; var _local12:Number; var _local13:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local17:Number; var _local18:Number; var _local19:Number; var _local20:Number; var _local2:b2Body = m_body1; var _local3:b2Body = m_body2; _local4 = _local2.m_xf.R; var _local5:Number = (m_localAnchor1.x - _local2.m_sweep.localCenter.x); var _local6:Number = (m_localAnchor1.y - _local2.m_sweep.localCenter.y); var _local7:Number = ((_local4.col1.x * _local5) + (_local4.col2.x * _local6)); _local6 = ((_local4.col1.y * _local5) + (_local4.col2.y * _local6)); _local5 = _local7; _local4 = _local3.m_xf.R; var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x); var _local9:Number = (m_localAnchor2.y - _local3.m_sweep.localCenter.y); _local7 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9)); _local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9)); _local8 = _local7; if (m_state == e_atUpperLimit){ _local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6)); _local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5)); _local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9)); _local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8)); _local18 = (-(((m_u1.x * _local10) + (m_u1.y * _local11))) - (m_ratio * ((m_u2.x * _local12) + (m_u2.y * _local13)))); _local19 = (m_pulleyMass * -(_local18)); _local20 = m_impulse; m_impulse = b2Math.b2Max(0, (m_impulse + _local19)); _local19 = (m_impulse - _local20); _local14 = (-(_local19) * m_u1.x); _local15 = (-(_local19) * m_u1.y); _local16 = ((-(m_ratio) * _local19) * m_u2.x); _local17 = ((-(m_ratio) * _local19) * m_u2.y); _local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14)); _local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15)); _local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14)))); _local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16)); _local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17)); _local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16)))); }; if (m_limitState1 == e_atUpperLimit){ _local10 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6)); _local11 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5)); _local18 = -(((m_u1.x * _local10) + (m_u1.y * _local11))); _local19 = (-(m_limitMass1) * _local18); _local20 = m_limitImpulse1; m_limitImpulse1 = b2Math.b2Max(0, (m_limitImpulse1 + _local19)); _local19 = (m_limitImpulse1 - _local20); _local14 = (-(_local19) * m_u1.x); _local15 = (-(_local19) * m_u1.y); _local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local14)); _local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local15)); _local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local15) - (_local6 * _local14)))); }; if (m_limitState2 == e_atUpperLimit){ _local12 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local9)); _local13 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local8)); _local18 = -(((m_u2.x * _local12) + (m_u2.y * _local13))); _local19 = (-(m_limitMass2) * _local18); _local20 = m_limitImpulse2; m_limitImpulse2 = b2Math.b2Max(0, (m_limitImpulse2 + _local19)); _local19 = (m_limitImpulse2 - _local20); _local16 = (-(_local19) * m_u2.x); _local17 = (-(_local19) * m_u2.y); _local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local16)); _local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local17)); _local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local8 * _local17) - (_local9 * _local16)))); }; } public function GetLength1():Number{ var _local1:b2Vec2 = m_body1.GetWorldPoint(m_localAnchor1); var _local2:Number = (m_ground.m_xf.position.x + m_groundAnchor1.x); var _local3:Number = (m_ground.m_xf.position.y + m_groundAnchor1.y); var _local4:Number = (_local1.x - _local2); var _local5:Number = (_local1.y - _local3); return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5)))); } public function GetGroundAnchor1():b2Vec2{ var _local1:b2Vec2 = m_ground.m_xf.position.Copy(); _local1.Add(m_groundAnchor1); return (_local1); } } }//package Box2D.Dynamics.Joints
Section 64
//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(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2, _arg4:b2Vec2, _arg5:b2Vec2, _arg6:b2Vec2, _arg7:Number):void{ body1 = _arg1; body2 = _arg2; groundAnchor1.SetV(_arg3); groundAnchor2.SetV(_arg4); localAnchor1 = body1.GetLocalPoint(_arg5); localAnchor2 = body2.GetLocalPoint(_arg6); var _local8:Number = (_arg5.x - _arg3.x); var _local9:Number = (_arg5.y - _arg3.y); length1 = Math.sqrt(((_local8 * _local8) + (_local9 * _local9))); var _local10:Number = (_arg6.x - _arg4.x); var _local11:Number = (_arg6.y - _arg4.y); length2 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11))); ratio = _arg7; var _local12:Number = (length1 + (ratio * length2)); maxLength1 = (_local12 - (ratio * b2PulleyJoint.b2_minPulleyLength)); maxLength2 = ((_local12 - b2PulleyJoint.b2_minPulleyLength) / ratio); } } }//package Box2D.Dynamics.Joints
Section 65
//b2RevoluteJoint (Box2D.Dynamics.Joints.b2RevoluteJoint) package Box2D.Dynamics.Joints { import Box2D.Dynamics.*; import Box2D.Common.Math.*; import Box2D.Common.*; public class b2RevoluteJoint extends b2Joint { private var m_mass:b2Mat33; private var m_impulse:b2Vec3; private var m_enableLimit:Boolean; private var m_limitState:int; private var m_motorMass:Number; b2internal var m_localAnchor1:b2Vec2; b2internal var m_localAnchor2:b2Vec2; private var K1:b2Mat22; private var K2:b2Mat22; private var K3:b2Mat22; private var K:b2Mat22; private var m_motorImpulse:Number; private var m_enableMotor:Boolean; private var m_referenceAngle:Number; private var m_upperAngle:Number; private var m_motorSpeed:Number; private var m_lowerAngle:Number; private var m_maxMotorTorque:Number; private static var tImpulse:b2Vec2 = new b2Vec2(); public function b2RevoluteJoint(_arg1:b2RevoluteJointDef){ K = new b2Mat22(); K1 = new b2Mat22(); K2 = new b2Mat22(); K3 = new b2Mat22(); m_localAnchor1 = new b2Vec2(); m_localAnchor2 = new b2Vec2(); m_impulse = new b2Vec3(); m_mass = new b2Mat33(); super(_arg1); m_localAnchor1.SetV(_arg1.localAnchor1); m_localAnchor2.SetV(_arg1.localAnchor2); m_referenceAngle = _arg1.referenceAngle; m_impulse.SetZero(); m_motorImpulse = 0; m_lowerAngle = _arg1.lowerAngle; m_upperAngle = _arg1.upperAngle; m_maxMotorTorque = _arg1.maxMotorTorque; m_motorSpeed = _arg1.motorSpeed; m_enableLimit = _arg1.enableLimit; m_enableMotor = _arg1.enableMotor; } override b2internal function SolveVelocityConstraints(_arg1:b2TimeStep):void{ var _local4:b2Mat22; var _local5:Number; var _local6:Number; var _local7:b2Vec2; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local20:Number; var _local21:Number; var _local22:Number; var _local23:Number; var _local24:Number; var _local25:Number; var _local26:Number; var _local27:b2Vec3; var _local28:Number; var _local29:Number; var _local30:b2Vec2; var _local2:b2Body = m_body1; var _local3:b2Body = m_body2; var _local12:b2Vec2 = _local2.m_linearVelocity; var _local13:Number = _local2.m_angularVelocity; var _local14:b2Vec2 = _local3.m_linearVelocity; var _local15:Number = _local3.m_angularVelocity; var _local16:Number = _local2.m_invMass; var _local17:Number = _local3.m_invMass; var _local18:Number = _local2.m_invI; var _local19:Number = _local3.m_invI; if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){ _local20 = ((_local15 - _local13) - m_motorSpeed); _local21 = (m_motorMass * -(_local20)); _local22 = m_motorImpulse; _local23 = (_arg1.dt * m_maxMotorTorque); m_motorImpulse = b2Math.b2Clamp((m_motorImpulse + _local21), -(_local23), _local23); _local21 = (m_motorImpulse - _local22); _local13 = (_local13 - (_local18 * _local21)); _local15 = (_local15 + (_local19 * _local21)); }; if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){ _local4 = _local2.m_xf.R; _local8 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x); _local9 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y); _local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9)); _local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9)); _local8 = _local5; _local4 = _local3.m_xf.R; _local10 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x); _local11 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y); _local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11)); _local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11)); _local10 = _local5; _local24 = (((_local14.x + (-(_local15) * _local11)) - _local12.x) - (-(_local13) * _local9)); _local25 = (((_local14.y + (_local15 * _local10)) - _local12.y) - (_local13 * _local8)); _local26 = (_local15 - _local13); _local27 = m_mass.Solve33(new b2Vec3(), -(_local24), -(_local25), -(_local26)); if (m_limitState == e_equalLimits){ m_impulse.Add(_local27); } else { if (m_limitState == e_atLowerLimit){ _local6 = (m_impulse.z + _local27.z); if (_local6 < 0){ _local7 = m_mass.Solve22(new b2Vec2(), -(_local24), -(_local25)); _local27.x = _local7.x; _local27.y = _local7.y; _local27.z = -(m_impulse.z); m_impulse.x = (m_impulse.x + _local7.x); m_impulse.y = (m_impulse.y + _local7.y); m_impulse.z = 0; }; } else { if (m_limitState == e_atUpperLimit){ _local6 = (m_impulse.z + _local27.z); if (_local6 > 0){ _local7 = m_mass.Solve22(new b2Vec2(), -(_local24), -(_local25)); _local27.x = _local7.x; _local27.y = _local7.y; _local27.z = -(m_impulse.z); m_impulse.x = (m_impulse.x + _local7.x); m_impulse.y = (m_impulse.y + _local7.y); m_impulse.z = 0; }; }; }; }; _local12.x = (_local12.x - (_local16 * _local27.x)); _local12.y = (_local12.y - (_local16 * _local27.y)); _local13 = (_local13 - (_local18 * (((_local8 * _local27.y) - (_local9 * _local27.x)) + _local27.z))); _local14.x = (_local14.x + (_local17 * _local27.x)); _local14.y = (_local14.y + (_local17 * _local27.y)); _local15 = (_local15 + (_local19 * (((_local10 * _local27.y) - (_local11 * _local27.x)) + _local27.z))); } else { _local4 = _local2.m_xf.R; _local8 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x); _local9 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y); _local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9)); _local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9)); _local8 = _local5; _local4 = _local3.m_xf.R; _local10 = (m_localAnchor2.x - _local3.m_sweep.localCenter.x); _local11 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y); _local5 = ((_local4.col1.x * _local10) + (_local4.col2.x * _local11)); _local11 = ((_local4.col1.y * _local10) + (_local4.col2.y * _local11)); _local10 = _local5; _local28 = (((_local14.x + (-(_local15) * _local11)) - _local12.x) - (-(_local13) * _local9)); _local29 = (((_local14.y + (_local15 * _local10)) - _local12.y) - (_local13 * _local8)); _local30 = m_mass.Solve22(new b2Vec2(), -(_local28), -(_local29)); m_impulse.x = (m_impulse.x + _local30.x); m_impulse.y = (m_impulse.y + _local30.y); _local12.x = (_local12.x - (_local16 * _local30.x)); _local12.y = (_local12.y - (_local16 * _local30.y)); _local13 = (_local13 - (_local18 * ((_local8 * _local30.y) - (_local9 * _local30.x)))); _local14.x = (_local14.x + (_local17 * _local30.x)); _local14.y = (_local14.y + (_local17 * _local30.y)); _local15 = (_local15 + (_local19 * ((_local10 * _local30.y) - (_local11 * _local30.x)))); }; _local2.m_linearVelocity.SetV(_local12); _local2.m_angularVelocity = _local13; _local3.m_linearVelocity.SetV(_local14); _local3.m_angularVelocity = _local15; } 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(_arg1:Boolean):void{ m_enableMotor = _arg1; } public function GetMotorSpeed():Number{ return (m_motorSpeed); } override public function GetReactionForce(_arg1:Number):b2Vec2{ return (new b2Vec2((_arg1 * m_impulse.x), (_arg1 * m_impulse.y))); } override b2internal function SolvePositionConstraints(_arg1:Number):Boolean{ var _local2:Number; var _local3:Number; var _local4:b2Mat22; var _local9:Number; var _local10:Number; var _local11:Number; var _local25:Number; var _local26:Number; var _local27:Number; var _local28:Number; var _local29:Number; var _local30:Number; var _local31:Number; var _local5:b2Body = m_body1; var _local6:b2Body = m_body2; var _local7:Number = 0; var _local8:Number = 0; if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){ _local25 = ((_local6.m_sweep.a - _local5.m_sweep.a) - m_referenceAngle); _local26 = 0; if (m_limitState == e_equalLimits){ _local3 = b2Math.b2Clamp(_local25, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection); _local26 = (-(m_motorMass) * _local3); _local7 = b2Math.b2Abs(_local3); } else { if (m_limitState == e_atLowerLimit){ _local3 = (_local25 - m_lowerAngle); _local7 = -(_local3); _local3 = b2Math.b2Clamp((_local3 + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0); _local26 = (-(m_motorMass) * _local3); } else { if (m_limitState == e_atUpperLimit){ _local3 = (_local25 - m_upperAngle); _local7 = _local3; _local3 = b2Math.b2Clamp((_local3 - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection); _local26 = (-(m_motorMass) * _local3); }; }; }; _local5.m_sweep.a = (_local5.m_sweep.a - (_local5.m_invI * _local26)); _local6.m_sweep.a = (_local6.m_sweep.a + (_local6.m_invI * _local26)); _local5.SynchronizeTransform(); _local6.SynchronizeTransform(); }; _local4 = _local5.m_xf.R; var _local12:Number = (m_localAnchor1.x - _local5.m_sweep.localCenter.x); var _local13:Number = (m_localAnchor1.y - _local5.m_sweep.localCenter.y); _local9 = ((_local4.col1.x * _local12) + (_local4.col2.x * _local13)); _local13 = ((_local4.col1.y * _local12) + (_local4.col2.y * _local13)); _local12 = _local9; _local4 = _local6.m_xf.R; var _local14:Number = (m_localAnchor2.x - _local6.m_sweep.localCenter.x); var _local15:Number = (m_localAnchor2.y - _local6.m_sweep.localCenter.y); _local9 = ((_local4.col1.x * _local14) + (_local4.col2.x * _local15)); _local15 = ((_local4.col1.y * _local14) + (_local4.col2.y * _local15)); _local14 = _local9; var _local16:Number = (((_local6.m_sweep.c.x + _local14) - _local5.m_sweep.c.x) - _local12); var _local17:Number = (((_local6.m_sweep.c.y + _local15) - _local5.m_sweep.c.y) - _local13); var _local18:Number = ((_local16 * _local16) + (_local17 * _local17)); var _local19:Number = Math.sqrt(_local18); _local8 = _local19; var _local20:Number = _local5.m_invMass; var _local21:Number = _local6.m_invMass; var _local22:Number = _local5.m_invI; var _local23:Number = _local6.m_invI; var _local24:Number = (10 * b2Settings.b2_linearSlop); if (_local18 > (_local24 * _local24)){ _local27 = (_local16 / _local19); _local28 = (_local17 / _local19); _local29 = (_local20 + _local21); _local30 = (1 / _local29); _local10 = (_local30 * -(_local16)); _local11 = (_local30 * -(_local17)); _local31 = 0.5; _local5.m_sweep.c.x = (_local5.m_sweep.c.x - ((_local31 * _local20) * _local10)); _local5.m_sweep.c.y = (_local5.m_sweep.c.y - ((_local31 * _local20) * _local11)); _local6.m_sweep.c.x = (_local6.m_sweep.c.x + ((_local31 * _local21) * _local10)); _local6.m_sweep.c.y = (_local6.m_sweep.c.y + ((_local31 * _local21) * _local11)); _local16 = (((_local6.m_sweep.c.x + _local14) - _local5.m_sweep.c.x) - _local12); _local17 = (((_local6.m_sweep.c.y + _local15) - _local5.m_sweep.c.y) - _local13); }; K1.col1.x = (_local20 + _local21); K1.col2.x = 0; K1.col1.y = 0; K1.col2.y = (_local20 + _local21); K2.col1.x = ((_local22 * _local13) * _local13); K2.col2.x = ((-(_local22) * _local12) * _local13); K2.col1.y = ((-(_local22) * _local12) * _local13); K2.col2.y = ((_local22 * _local12) * _local12); K3.col1.x = ((_local23 * _local15) * _local15); K3.col2.x = ((-(_local23) * _local14) * _local15); K3.col1.y = ((-(_local23) * _local14) * _local15); K3.col2.y = ((_local23 * _local14) * _local14); K.SetM(K1); K.AddM(K2); K.AddM(K3); K.Solve(tImpulse, -(_local16), -(_local17)); _local10 = tImpulse.x; _local11 = tImpulse.y; _local5.m_sweep.c.x = (_local5.m_sweep.c.x - (_local5.m_invMass * _local10)); _local5.m_sweep.c.y = (_local5.m_sweep.c.y - (_local5.m_invMass * _local11)); _local5.m_sweep.a = (_local5.m_sweep.a - (_local5.m_invI * ((_local12 * _local11) - (_local13 * _local10)))); _local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_local6.m_invMass * _local10)); _local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_local6.m_invMass * _local11)); _local6.m_sweep.a = (_local6.m_sweep.a + (_local6.m_invI * ((_local14 * _local11) - (_local15 * _local10)))); _local5.SynchronizeTransform(); _local6.SynchronizeTransform(); return ((((_local8 <= b2Settings.b2_linearSlop)) && ((_local7 <= b2Settings.b2_angularSlop)))); } public function SetMotorSpeed(_arg1:Number):void{ m_body1.WakeUp(); m_body2.WakeUp(); m_motorSpeed = _arg1; } public function GetJointSpeed():Number{ return ((m_body2.m_angularVelocity - m_body1.m_angularVelocity)); } public function SetMaxMotorTorque(_arg1:Number):void{ m_maxMotorTorque = _arg1; } public function GetJointAngle():Number{ return (((m_body2.m_sweep.a - m_body1.m_sweep.a) - m_referenceAngle)); } public function GetMotorTorque():Number{ return (m_maxMotorTorque); } override b2internal function InitVelocityConstraints(_arg1:b2TimeStep):void{ var _local3:b2Body; var _local4:b2Mat22; var _local5:Number; var _local6:Number; var _local7:Number; var _local9:Number; var _local14:Number; var _local15:Number; var _local16:Number; var _local2:b2Body = m_body1; _local3 = m_body2; _local4 = _local2.m_xf.R; _local6 = (m_localAnchor1.x - _local2.m_sweep.localCenter.x); _local7 = (m_localAnchor1.y - _local2.m_sweep.localCenter.y); _local5 = ((_local4.col1.x * _local6) + (_local4.col2.x * _local7)); _local7 = ((_local4.col1.y * _local6) + (_local4.col2.y * _local7)); _local6 = _local5; _local4 = _local3.m_xf.R; var _local8:Number = (m_localAnchor2.x - _local3.m_sweep.localCenter.x); _local9 = (m_localAnchor2.y - _local3.m_sweep.localCenter.y); _local5 = ((_local4.col1.x * _local8) + (_local4.col2.x * _local9)); _local9 = ((_local4.col1.y * _local8) + (_local4.col2.y * _local9)); _local8 = _local5; var _local10:Number = _local2.m_invMass; var _local11:Number = _local3.m_invMass; var _local12:Number = _local2.m_invI; var _local13:Number = _local3.m_invI; m_mass.col1.x = (((_local10 + _local11) + ((_local7 * _local7) * _local12)) + ((_local9 * _local9) * _local13)); m_mass.col2.x = (((-(_local7) * _local6) * _local12) - ((_local9 * _local8) * _local13)); m_mass.col3.x = ((-(_local7) * _local12) - (_local9 * _local13)); m_mass.col1.y = m_mass.col2.x; m_mass.col2.y = (((_local10 + _local11) + ((_local6 * _local6) * _local12)) + ((_local8 * _local8) * _local13)); m_mass.col3.y = ((_local6 * _local12) + (_local8 * _local13)); m_mass.col1.z = m_mass.col3.x; m_mass.col2.z = m_mass.col3.y; m_mass.col3.z = (_local12 + _local13); m_motorMass = (1 / (_local12 + _local13)); if (m_enableMotor == false){ m_motorImpulse = 0; }; if (m_enableLimit){ _local14 = ((_local3.m_sweep.a - _local2.m_sweep.a) - m_referenceAngle); if (b2Math.b2Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){ m_limitState = e_equalLimits; } else { if (_local14 <= m_lowerAngle){ if (m_limitState != e_atLowerLimit){ m_impulse.z = 0; }; m_limitState = e_atLowerLimit; } else { if (_local14 >= m_upperAngle){ if (m_limitState != e_atUpperLimit){ m_impulse.z = 0; }; m_limitState = e_atUpperLimit; } else { m_limitState = e_inactiveLimit; m_impulse.z = 0; }; }; }; }; if (_arg1.warmStarting){ m_impulse.x = (m_impulse.x * _arg1.dtRatio); m_impulse.y = (m_impulse.y * _arg1.dtRatio); m_motorImpulse = (m_motorImpulse * _arg1.dtRatio); _local15 = m_impulse.x; _local16 = m_impulse.y; _local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (_local10 * _local15)); _local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (_local10 * _local16)); _local2.m_angularVelocity = (_local2.m_angularVelocity - (_local12 * ((((_local6 * _local16) - (_local7 * _local15)) + m_motorImpulse) + m_impulse.z))); _local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local11 * _local15)); _local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local11 * _local16)); _local3.m_angularVelocity = (_local3.m_angularVelocity + (_local13 * ((((_local8 * _local16) - (_local9 * _local15)) + m_motorImpulse) + m_impulse.z))); } else { m_impulse.SetZero(); m_motorImpulse = 0; }; } public function EnableLimit(_arg1:Boolean):void{ m_enableLimit = _arg1; } override public function GetReactionTorque(_arg1:Number):Number{ return ((_arg1 * m_impulse.z)); } public function IsLimitEnabled():Boolean{ return (m_enableLimit); } public function IsMotorEnabled():Boolean{ m_body1.WakeUp(); m_body2.WakeUp(); return (m_enableMotor); } public function SetLimits(_arg1:Number, _arg2:Number):void{ m_lowerAngle = _arg1; m_upperAngle = _arg2; } } }//package Box2D.Dynamics.Joints
Section 66
//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(_arg1:b2Body, _arg2:b2Body, _arg3:b2Vec2):void{ body1 = _arg1; body2 = _arg2; localAnchor1 = body1.GetLocalPoint(_arg3); localAnchor2 = body2.GetLocalPoint(_arg3); referenceAngle = (body2.GetAngle() - body1.GetAngle()); } } }//package Box2D.Dynamics.Joints
Section 67
//b2Body (Box2D.Dynamics.b2Body) package Box2D.Dynamics { import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Dynamics.Joints.*; import Box2D.Common.*; import Box2D.Dynamics.Contacts.*; public class b2Body { b2internal var m_next:b2Body; b2internal var m_contactList:b2ContactEdge; b2internal var m_angularVelocity:Number; b2internal var m_xf:b2XForm; b2internal var m_shapeList:b2Shape; b2internal var m_force:b2Vec2; b2internal var m_sweep:b2Sweep; b2internal var m_mass:Number; b2internal var m_torque:Number; private var m_userData; b2internal var m_flags:uint; b2internal var m_world:b2World; b2internal var m_prev:b2Body; b2internal var m_invMass:Number; private var m_type:int; b2internal var m_linearDamping:Number; b2internal var m_angularDamping:Number; b2internal var m_invI:Number; b2internal var m_shapeCount:int; b2internal var m_linearVelocity:b2Vec2; b2internal var m_islandIndex:int; b2internal var m_jointList:b2JointEdge; b2internal var m_sleepTime:Number; b2internal var m_I:Number; b2internal static var e_fixedRotationFlag:uint = 64; b2internal static var e_frozenFlag:uint = 2; b2internal static var e_maxTypes:uint = 3; b2internal static var e_sleepFlag:uint = 8; private static var s_massData:b2MassData = new b2MassData(); b2internal static var e_bulletFlag:uint = 32; b2internal static var e_staticType:uint = 1; b2internal static var e_islandFlag:uint = 4; b2internal static var e_allowSleepFlag:uint = 16; private static var s_xf1:b2XForm = new b2XForm(); b2internal static var e_dynamicType:uint = 2; public function b2Body(_arg1:b2BodyDef, _arg2:b2World){ m_xf = new b2XForm(); m_sweep = new b2Sweep(); m_linearVelocity = new b2Vec2(); m_force = new b2Vec2(); super(); m_flags = 0; if (_arg1.isBullet){ m_flags = (m_flags | e_bulletFlag); }; if (_arg1.fixedRotation){ m_flags = (m_flags | e_fixedRotationFlag); }; if (_arg1.allowSleep){ m_flags = (m_flags | e_allowSleepFlag); }; if (_arg1.isSleeping){ m_flags = (m_flags | e_sleepFlag); }; m_world = _arg2; m_xf.position.SetV(_arg1.position); m_xf.R.Set(_arg1.angle); m_sweep.localCenter.SetV(_arg1.massData.center); m_sweep.t0 = 1; m_sweep.a0 = (m_sweep.a = _arg1.angle); var _local3:b2Mat22 = m_xf.R; var _local4:b2Vec2 = m_sweep.localCenter; m_sweep.c.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)); m_sweep.c.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.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 = _arg1.linearDamping; m_angularDamping = _arg1.angularDamping; m_force.Set(0, 0); m_torque = 0; m_linearVelocity.SetZero(); m_angularVelocity = 0; m_sleepTime = 0; m_invMass = 0; m_I = 0; m_invI = 0; m_mass = _arg1.massData.mass; if (m_mass > 0){ m_invMass = (1 / m_mass); }; if ((m_flags & b2Body.e_fixedRotationFlag) == 0){ m_I = _arg1.massData.I; }; if (m_I > 0){ m_invI = (1 / m_I); }; if ((((m_invMass == 0)) && ((m_invI == 0)))){ m_type = e_staticType; } else { m_type = e_dynamicType; }; m_userData = _arg1.userData; m_shapeList = null; m_shapeCount = 0; } public function GetLinearVelocityFromWorldPoint(_arg1:b2Vec2):b2Vec2{ return (new b2Vec2((m_linearVelocity.x - (m_angularVelocity * (_arg1.y - m_sweep.c.y))), (m_linearVelocity.y + (m_angularVelocity * (_arg1.x - m_sweep.c.x))))); } public function SetLinearVelocity(_arg1:b2Vec2):void{ m_linearVelocity.SetV(_arg1); } public function WakeUp():void{ m_flags = (m_flags & ~(e_sleepFlag)); m_sleepTime = 0; } public function ApplyTorque(_arg1:Number):void{ if (IsSleeping()){ WakeUp(); }; m_torque = (m_torque + _arg1); } public function GetLocalCenter():b2Vec2{ return (m_sweep.localCenter); } public function GetLinearVelocity():b2Vec2{ return (m_linearVelocity); } public function IsFrozen():Boolean{ return (((m_flags & e_frozenFlag) == e_frozenFlag)); } public function IsDynamic():Boolean{ return ((m_type == e_dynamicType)); } b2internal function SynchronizeTransform():void{ m_xf.R.Set(m_sweep.a); var _local1:b2Mat22 = m_xf.R; var _local2:b2Vec2 = m_sweep.localCenter; m_xf.position.x = (m_sweep.c.x - ((_local1.col1.x * _local2.x) + (_local1.col2.x * _local2.y))); m_xf.position.y = (m_sweep.c.y - ((_local1.col1.y * _local2.x) + (_local1.col2.y * _local2.y))); } public function GetInertia():Number{ return (m_I); } public function IsSleeping():Boolean{ return (((m_flags & e_sleepFlag) == e_sleepFlag)); } public function SetMassFromShapes():void{ var _local1:b2Shape; if (m_world.m_lock == true){ return; }; m_mass = 0; m_invMass = 0; m_I = 0; m_invI = 0; var _local2:Number = 0; var _local3:Number = 0; var _local4:b2MassData = s_massData; _local1 = m_shapeList; while (_local1) { _local1.ComputeMass(_local4); m_mass = (m_mass + _local4.mass); _local2 = (_local2 + (_local4.mass * _local4.center.x)); _local3 = (_local3 + (_local4.mass * _local4.center.y)); m_I = (m_I + _local4.I); _local1 = _local1.m_next; }; if (m_mass > 0){ m_invMass = (1 / m_mass); _local2 = (_local2 * m_invMass); _local3 = (_local3 * m_invMass); }; if ((((m_I > 0)) && (((m_flags & e_fixedRotationFlag) == 0)))){ m_I = (m_I - (m_mass * ((_local2 * _local2) + (_local3 * _local3)))); m_invI = (1 / m_I); } else { m_I = 0; m_invI = 0; }; m_sweep.localCenter.Set(_local2, _local3); var _local5:b2Mat22 = m_xf.R; var _local6:b2Vec2 = m_sweep.localCenter; m_sweep.c.x = ((_local5.col1.x * _local6.x) + (_local5.col2.x * _local6.y)); m_sweep.c.y = ((_local5.col1.y * _local6.x) + (_local5.col2.y * _local6.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); _local1 = m_shapeList; while (_local1) { _local1.UpdateSweepRadius(m_sweep.localCenter); _local1 = _local1.m_next; }; var _local7:int = m_type; if ((((m_invMass == 0)) && ((m_invI == 0)))){ m_type = e_staticType; } else { m_type = e_dynamicType; }; if (_local7 != m_type){ _local1 = m_shapeList; while (_local1) { _local1.RefilterProxy(m_world.m_broadPhase, m_xf); _local1 = _local1.m_next; }; }; } public function PutToSleep():void{ m_flags = (m_flags | e_sleepFlag); m_sleepTime = 0; m_linearVelocity.SetZero(); m_angularVelocity = 0; m_force.SetZero(); m_torque = 0; } public function GetJointList():b2JointEdge{ return (m_jointList); } public function SetXForm(_arg1:b2Vec2, _arg2:Number):Boolean{ var _local3:b2Shape; var _local7:Boolean; if (m_world.m_lock == true){ return (true); }; if (IsFrozen()){ return (false); }; m_xf.R.Set(_arg2); m_xf.position.SetV(_arg1); var _local4:b2Mat22 = m_xf.R; var _local5:b2Vec2 = m_sweep.localCenter; m_sweep.c.x = ((_local4.col1.x * _local5.x) + (_local4.col2.x * _local5.y)); m_sweep.c.y = ((_local4.col1.y * _local5.x) + (_local4.col2.y * _local5.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 = _arg2); var _local6:Boolean; _local3 = m_shapeList; while (_local3) { _local7 = _local3.Synchronize(m_world.m_broadPhase, m_xf, m_xf); if (_local7 == false){ _local6 = true; break; }; _local3 = _local3.m_next; }; if (_local6 == true){ m_flags = (m_flags | e_frozenFlag); m_linearVelocity.SetZero(); m_angularVelocity = 0; _local3 = m_shapeList; while (_local3) { _local3.DestroyProxy(m_world.m_broadPhase); _local3 = _local3.m_next; }; return (false); }; m_world.m_broadPhase.Commit(); return (true); } public function GetLocalPoint(_arg1:b2Vec2):b2Vec2{ return (b2Math.b2MulXT(m_xf, _arg1)); } public function ApplyForce(_arg1:b2Vec2, _arg2:b2Vec2):void{ if (IsSleeping()){ WakeUp(); }; m_force.x = (m_force.x + _arg1.x); m_force.y = (m_force.y + _arg1.y); m_torque = (m_torque + (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x))); } b2internal function SynchronizeShapes():Boolean{ var _local4:b2Shape; var _local1:b2XForm = s_xf1; _local1.R.Set(m_sweep.a0); var _local2:b2Mat22 = _local1.R; var _local3:b2Vec2 = m_sweep.localCenter; _local1.position.x = (m_sweep.c0.x - ((_local2.col1.x * _local3.x) + (_local2.col2.x * _local3.y))); _local1.position.y = (m_sweep.c0.y - ((_local2.col1.y * _local3.x) + (_local2.col2.y * _local3.y))); var _local5:Boolean; _local4 = m_shapeList; while (_local4) { _local5 = _local4.Synchronize(m_world.m_broadPhase, _local1, m_xf); if (_local5 == false){ break; }; _local4 = _local4.m_next; }; if (_local5 == false){ m_flags = (m_flags | e_frozenFlag); m_linearVelocity.SetZero(); m_angularVelocity = 0; _local4 = m_shapeList; while (_local4) { _local4.DestroyProxy(m_world.m_broadPhase); _local4 = _local4.m_next; }; return (false); }; return (true); } public function GetAngle():Number{ return (m_sweep.a); } public function GetXForm():b2XForm{ return (m_xf); } public function GetLinearVelocityFromLocalPoint(_arg1:b2Vec2):b2Vec2{ var _local2:b2Mat22 = m_xf.R; var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y))); _local3.x = (_local3.x + m_xf.position.x); _local3.y = (_local3.y + m_xf.position.y); return (new b2Vec2((m_linearVelocity.x - (m_angularVelocity * (_local3.y - m_sweep.c.y))), (m_linearVelocity.y + (m_angularVelocity * (_local3.x - m_sweep.c.x))))); } public function GetNext():b2Body{ return (m_next); } public function GetMass():Number{ return (m_mass); } public function ApplyImpulse(_arg1:b2Vec2, _arg2:b2Vec2):void{ if (IsSleeping()){ WakeUp(); }; m_linearVelocity.x = (m_linearVelocity.x + (m_invMass * _arg1.x)); m_linearVelocity.y = (m_linearVelocity.y + (m_invMass * _arg1.y)); m_angularVelocity = (m_angularVelocity + (m_invI * (((_arg2.x - m_sweep.c.x) * _arg1.y) - ((_arg2.y - m_sweep.c.y) * _arg1.x)))); } public function GetAngularVelocity():Number{ return (m_angularVelocity); } public function SetAngularVelocity(_arg1:Number):void{ m_angularVelocity = _arg1; } public function SetMass(_arg1:b2MassData):void{ var _local2:b2Shape; if (m_world.m_lock == true){ return; }; m_invMass = 0; m_I = 0; m_invI = 0; m_mass = _arg1.mass; if (m_mass > 0){ m_invMass = (1 / m_mass); }; if ((m_flags & b2Body.e_fixedRotationFlag) == 0){ m_I = _arg1.I; }; if (m_I > 0){ m_invI = (1 / m_I); }; m_sweep.localCenter.SetV(_arg1.center); var _local3:b2Mat22 = m_xf.R; var _local4:b2Vec2 = m_sweep.localCenter; m_sweep.c.x = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y)); m_sweep.c.y = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.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); _local2 = m_shapeList; while (_local2) { _local2.UpdateSweepRadius(m_sweep.localCenter); _local2 = _local2.m_next; }; var _local5:int = m_type; if ((((m_invMass == 0)) && ((m_invI == 0)))){ m_type = e_staticType; } else { m_type = e_dynamicType; }; if (_local5 != m_type){ _local2 = m_shapeList; while (_local2) { _local2.RefilterProxy(m_world.m_broadPhase, m_xf); _local2 = _local2.m_next; }; }; } public function IsStatic():Boolean{ return ((m_type == e_staticType)); } public function GetWorldVector(_arg1:b2Vec2):b2Vec2{ return (b2Math.b2MulMV(m_xf.R, _arg1)); } public function GetShapeList():b2Shape{ return (m_shapeList); } b2internal function Advance(_arg1:Number):void{ m_sweep.Advance(_arg1); m_sweep.c.SetV(m_sweep.c0); m_sweep.a = m_sweep.a0; SynchronizeTransform(); } public function SetBullet(_arg1:Boolean):void{ if (_arg1){ m_flags = (m_flags | e_bulletFlag); } else { m_flags = (m_flags & ~(e_bulletFlag)); }; } public function CreateShape(_arg1:b2ShapeDef):b2Shape{ if (m_world.m_lock == true){ return (null); }; var _local2:b2Shape = b2Shape.Create(_arg1, m_world.m_blockAllocator); _local2.m_next = m_shapeList; m_shapeList = _local2; m_shapeCount++; _local2.m_body = this; _local2.CreateProxy(m_world.m_broadPhase, m_xf); _local2.UpdateSweepRadius(m_sweep.localCenter); return (_local2); } b2internal function IsConnected(_arg1:b2Body):Boolean{ var _local2:b2JointEdge = m_jointList; while (_local2) { if (_local2.other == _arg1){ return ((_local2.joint.m_collideConnected == false)); }; _local2 = _local2.next; }; return (false); } public function DestroyShape(_arg1:b2Shape):void{ if (m_world.m_lock == true){ return; }; _arg1.DestroyProxy(m_world.m_broadPhase); var _local2:b2Shape = m_shapeList; var _local3:b2Shape; var _local4:Boolean; while (_local2 != null) { if (_local2 == _arg1){ if (_local3){ _local3.m_next = _arg1.m_next; } else { m_shapeList = _arg1.m_next; }; _local4 = true; break; }; _local3 = _local2; _local2 = _local2.m_next; }; _arg1.m_body = null; _arg1.m_next = null; m_shapeCount--; b2Shape.Destroy(_arg1, 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(_arg1:Boolean):void{ if (_arg1){ m_flags = (m_flags | e_allowSleepFlag); } else { m_flags = (m_flags & ~(e_allowSleepFlag)); WakeUp(); }; } public function SetUserData(_arg1):void{ m_userData = _arg1; } public function GetLocalVector(_arg1:b2Vec2):b2Vec2{ return (b2Math.b2MulTMV(m_xf.R, _arg1)); } public function GetWorldPoint(_arg1:b2Vec2):b2Vec2{ var _local2:b2Mat22 = m_xf.R; var _local3:b2Vec2 = new b2Vec2(((_local2.col1.x * _arg1.x) + (_local2.col2.x * _arg1.y)), ((_local2.col1.y * _arg1.x) + (_local2.col2.y * _arg1.y))); _local3.x = (_local3.x + m_xf.position.x); _local3.y = (_local3.y + m_xf.position.y); return (_local3); } public function GetWorld():b2World{ return (m_world); } public function GetPosition():b2Vec2{ return (m_xf.position); } } }//package Box2D.Dynamics
Section 68
//b2BodyDef (Box2D.Dynamics.b2BodyDef) package Box2D.Dynamics { import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; public class b2BodyDef { public var angularDamping:Number; public var angle:Number; public var isSleeping:Boolean; public var position:b2Vec2; public var isBullet:Boolean; public var allowSleep:Boolean; public var userData; public var fixedRotation:Boolean; public var linearDamping:Number; public var massData:b2MassData; public function b2BodyDef(){ massData = new b2MassData(); position = new b2Vec2(); super(); massData.center.SetZero(); massData.mass = 0; massData.I = 0; userData = null; position.Set(0, 0); angle = 0; linearDamping = 0; angularDamping = 0; allowSleep = true; isSleeping = false; fixedRotation = false; isBullet = false; } } }//package Box2D.Dynamics
Section 69
//b2BoundaryListener (Box2D.Dynamics.b2BoundaryListener) package Box2D.Dynamics { public class b2BoundaryListener { public function Violation(_arg1:b2Body):void{ } } }//package Box2D.Dynamics
Section 70
//b2ContactFilter (Box2D.Dynamics.b2ContactFilter) package Box2D.Dynamics { import Box2D.Collision.Shapes.*; import Box2D.Common.*; public class b2ContactFilter { b2internal static var b2_defaultFilter:b2ContactFilter = new (b2ContactFilter); ; public function ShouldCollide(_arg1:b2Shape, _arg2:b2Shape):Boolean{ var _local3:b2FilterData = _arg1.GetFilterData(); var _local4:b2FilterData = _arg2.GetFilterData(); if ((((_local3.groupIndex == _local4.groupIndex)) && (!((_local3.groupIndex == 0))))){ return ((_local3.groupIndex > 0)); }; var _local5:Boolean = ((!(((_local3.maskBits & _local4.categoryBits) == 0))) && (!(((_local3.categoryBits & _local4.maskBits) == 0)))); return (_local5); } public function RayCollide(_arg1, _arg2:b2Shape):Boolean{ if (!_arg1){ return (true); }; return (ShouldCollide((_arg1 as b2Shape), _arg2)); } } }//package Box2D.Dynamics
Section 71
//b2ContactListener (Box2D.Dynamics.b2ContactListener) package Box2D.Dynamics { import Box2D.Collision.*; import Box2D.Dynamics.Contacts.*; public class b2ContactListener { public function Add(_arg1:b2ContactPoint, _arg2:b2Contact):void{ } public function Remove(_arg1:b2ContactPoint, _arg2:b2Contact):void{ } public function Persist(_arg1:b2ContactPoint, _arg2:b2Contact):void{ } public function Result(_arg1:b2ContactResult, _arg2:b2Contact):void{ } } }//package Box2D.Dynamics
Section 72
//b2ContactManager (Box2D.Dynamics.b2ContactManager) package Box2D.Dynamics { import Box2D.Collision.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Common.*; import Box2D.Dynamics.Contacts.*; public class b2ContactManager extends b2PairCallback { b2internal var m_world:b2World; private var m_destroyImmediate:Boolean; private var m_nullContact:b2NullContact; private static const s_evalCP:b2ContactPoint = new b2ContactPoint(); public function b2ContactManager(){ m_nullContact = new b2NullContact(); super(); m_world = null; m_destroyImmediate = false; } override public function PairRemoved(_arg1, _arg2, _arg3):void{ if (_arg3 == null){ return; }; var _local4:b2Contact = (_arg3 as b2Contact); if (_local4 == m_nullContact){ return; }; Destroy(_local4); } public function Destroy(_arg1:b2Contact):void{ var _local7:b2Body; var _local8:b2Body; var _local9:Array; var _local10:b2ContactPoint; var _local11:int; var _local12:b2Manifold; var _local13:int; var _local14:b2ManifoldPoint; var _local15:b2Vec2; var _local16:b2Vec2; var _local2:b2Shape = _arg1.m_shape1; var _local3:b2Shape = _arg1.m_shape2; var _local4:int = _arg1.m_manifoldCount; if ((((_local4 > 0)) && (m_world.m_contactListener))){ _local7 = _local2.m_body; _local8 = _local3.m_body; _local9 = _arg1.GetManifolds(); _local10 = s_evalCP; _local10.shape1 = _arg1.m_shape1; _local10.shape2 = _arg1.m_shape2; _local10.friction = _arg1.m_friction; _local10.restitution = _arg1.m_restitution; _local11 = 0; while (_local11 < _local4) { _local12 = _local9[_local11]; _local10.normal.SetV(_local12.normal); _local13 = 0; while (_local13 < _local12.pointCount) { _local14 = _local12.points[_local13]; _local10.position = _local7.GetWorldPoint(_local14.localPoint1); _local15 = _local7.GetLinearVelocityFromLocalPoint(_local14.localPoint1); _local16 = _local8.GetLinearVelocityFromLocalPoint(_local14.localPoint2); _local10.velocity.Set((_local16.x - _local15.x), (_local16.y - _local15.y)); _local10.separation = _local14.separation; _local10.id.key = _local14.id._key; m_world.m_contactListener.Remove(_local10, _arg1); _local13++; }; _local11++; }; }; if (_arg1.m_prev){ _arg1.m_prev.m_next = _arg1.m_next; }; if (_arg1.m_next){ _arg1.m_next.m_prev = _arg1.m_prev; }; if (_arg1 == m_world.m_contactList){ m_world.m_contactList = _arg1.m_next; }; var _local5:b2Body = _local2.m_body; var _local6:b2Body = _local3.m_body; if (_arg1.m_node1.prev){ _arg1.m_node1.prev.next = _arg1.m_node1.next; }; if (_arg1.m_node1.next){ _arg1.m_node1.next.prev = _arg1.m_node1.prev; }; if (_arg1.m_node1 == _local5.m_contactList){ _local5.m_contactList = _arg1.m_node1.next; }; if (_arg1.m_node2.prev){ _arg1.m_node2.prev.next = _arg1.m_node2.next; }; if (_arg1.m_node2.next){ _arg1.m_node2.next.prev = _arg1.m_node2.prev; }; if (_arg1.m_node2 == _local6.m_contactList){ _local6.m_contactList = _arg1.m_node2.next; }; b2Contact.Destroy(_arg1, m_world.m_blockAllocator); m_world.m_contactCount--; } override public function PairAdded(_arg1, _arg2){ var _local3:b2Shape = (_arg1 as b2Shape); var _local4:b2Shape = (_arg2 as b2Shape); var _local5:b2Body = _local3.m_body; var _local6:b2Body = _local4.m_body; if (((_local5.IsStatic()) && (_local6.IsStatic()))){ return (m_nullContact); }; if (_local3.m_body == _local4.m_body){ return (m_nullContact); }; if (_local6.IsConnected(_local5)){ return (m_nullContact); }; if (((!((m_world.m_contactFilter == null))) && ((m_world.m_contactFilter.ShouldCollide(_local3, _local4) == false)))){ return (m_nullContact); }; var _local7:b2Contact = b2Contact.Create(_local3, _local4, m_world.m_blockAllocator); if (_local7 == null){ return (m_nullContact); }; _local3 = _local7.m_shape1; _local4 = _local7.m_shape2; _local5 = _local3.m_body; _local6 = _local4.m_body; _local7.m_prev = null; _local7.m_next = m_world.m_contactList; if (m_world.m_contactList != null){ m_world.m_contactList.m_prev = _local7; }; m_world.m_contactList = _local7; _local7.m_node1.contact = _local7; _local7.m_node1.other = _local6; _local7.m_node1.prev = null; _local7.m_node1.next = _local5.m_contactList; if (_local5.m_contactList != null){ _local5.m_contactList.prev = _local7.m_node1; }; _local5.m_contactList = _local7.m_node1; _local7.m_node2.contact = _local7; _local7.m_node2.other = _local5; _local7.m_node2.prev = null; _local7.m_node2.next = _local6.m_contactList; if (_local6.m_contactList != null){ _local6.m_contactList.prev = _local7.m_node2; }; _local6.m_contactList = _local7.m_node2; m_world.m_contactCount++; return (_local7); } public function Collide():void{ var _local2:b2Body; var _local3:b2Body; var _local1:b2Contact = m_world.m_contactList; while (_local1) { _local2 = _local1.m_shape1.m_body; _local3 = _local1.m_shape2.m_body; if (((_local2.IsSleeping()) && (_local3.IsSleeping()))){ } else { _local1.Update(m_world.m_contactListener); }; _local1 = _local1.m_next; }; } } }//package Box2D.Dynamics
Section 73
//b2DebugDraw (Box2D.Dynamics.b2DebugDraw) package Box2D.Dynamics { import flash.display.*; import Box2D.Collision.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Common.*; import Box2D.Dynamics.Contacts.*; public class b2DebugDraw { private var m_xformScale:Number;// = 1 private var m_fillAlpha:Number;// = 1 private var m_alpha:Number;// = 1 private var m_lineThickness:Number;// = 1 private var m_drawFlags:uint; b2internal var m_sprite:Sprite; private var m_drawScale:Number;// = 1 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(){ m_drawFlags = 0; } public function SetDrawScale(_arg1:Number):void{ m_drawScale = _arg1; } public function GetFillAlpha():Number{ return (m_fillAlpha); } public function GetAlpha():Number{ return (m_alpha); } public function GetLineThickness():Number{ return (m_lineThickness); } public function GetDrawScale():Number{ return (m_drawScale); } public function DrawSolidPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{ m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha); m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale)); m_sprite.graphics.beginFill(_arg3.color, m_fillAlpha); var _local4 = 1; while (_local4 < _arg2) { m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale)); _local4++; }; m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale)); m_sprite.graphics.endFill(); } public function DrawCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Color):void{ m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha); m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale)); } public function DrawSolidCircle(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:b2Color):void{ m_sprite.graphics.lineStyle(m_lineThickness, _arg4.color, m_alpha); m_sprite.graphics.moveTo(0, 0); m_sprite.graphics.beginFill(_arg4.color, m_fillAlpha); m_sprite.graphics.drawCircle((_arg1.x * m_drawScale), (_arg1.y * m_drawScale), (_arg2 * m_drawScale)); m_sprite.graphics.endFill(); m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale)); m_sprite.graphics.lineTo(((_arg1.x + (_arg3.x * _arg2)) * m_drawScale), ((_arg1.y + (_arg3.y * _arg2)) * m_drawScale)); } public function DrawXForm(_arg1:b2XForm):void{ m_sprite.graphics.lineStyle(m_lineThickness, 0xFF0000, m_alpha); m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale)); m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col1.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col1.y)) * m_drawScale)); m_sprite.graphics.lineStyle(m_lineThickness, 0xFF00, m_alpha); m_sprite.graphics.moveTo((_arg1.position.x * m_drawScale), (_arg1.position.y * m_drawScale)); m_sprite.graphics.lineTo(((_arg1.position.x + (m_xformScale * _arg1.R.col2.x)) * m_drawScale), ((_arg1.position.y + (m_xformScale * _arg1.R.col2.y)) * m_drawScale)); } public function ClearFlags(_arg1:uint):void{ m_drawFlags = (m_drawFlags & ~(_arg1)); } public function GetSprite():Sprite{ return (m_sprite); } public function GetXFormScale():Number{ return (m_xformScale); } public function SetFlags(_arg1:uint):void{ m_drawFlags = _arg1; } public function SetSprite(_arg1:Sprite):void{ m_sprite = _arg1; } public function AppendFlags(_arg1:uint):void{ m_drawFlags = (m_drawFlags | _arg1); } public function DrawSegment(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Color):void{ m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha); m_sprite.graphics.moveTo((_arg1.x * m_drawScale), (_arg1.y * m_drawScale)); m_sprite.graphics.lineTo((_arg2.x * m_drawScale), (_arg2.y * m_drawScale)); } public function SetXFormScale(_arg1:Number):void{ m_xformScale = _arg1; } public function GetFlags():uint{ return (m_drawFlags); } public function DrawPolygon(_arg1:Array, _arg2:int, _arg3:b2Color):void{ m_sprite.graphics.lineStyle(m_lineThickness, _arg3.color, m_alpha); m_sprite.graphics.moveTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale)); var _local4 = 1; while (_local4 < _arg2) { m_sprite.graphics.lineTo((_arg1[_local4].x * m_drawScale), (_arg1[_local4].y * m_drawScale)); _local4++; }; m_sprite.graphics.lineTo((_arg1[0].x * m_drawScale), (_arg1[0].y * m_drawScale)); } public function SetFillAlpha(_arg1:Number):void{ m_fillAlpha = _arg1; } public function SetAlpha(_arg1:Number):void{ m_alpha = _arg1; } public function SetLineThickness(_arg1:Number):void{ m_lineThickness = _arg1; } } }//package Box2D.Dynamics
Section 74
//b2DestructionListener (Box2D.Dynamics.b2DestructionListener) package Box2D.Dynamics { import Box2D.Collision.Shapes.*; import Box2D.Dynamics.Joints.*; public class b2DestructionListener { public function SayGoodbyeShape(_arg1:b2Shape):void{ } public function SayGoodbyeJoint(_arg1:b2Joint):void{ } } }//package Box2D.Dynamics
Section 75
//b2Island (Box2D.Dynamics.b2Island) package Box2D.Dynamics { import Box2D.Collision.*; import Box2D.Common.Math.*; import Box2D.Dynamics.Joints.*; import Box2D.Common.*; import Box2D.Dynamics.Contacts.*; public class b2Island { private var m_listener:b2ContactListener; private var m_bodyCapacity:int; b2internal var m_bodies:Array; b2internal var m_joints:Array; b2internal var m_jointCapacity:int; b2internal var m_contactCount:int; b2internal var m_contacts:Array; b2internal var m_contactCapacity:int; b2internal var m_jointCount:int; private var m_allocator; b2internal var m_bodyCount:int; private static var s_reportCR:b2ContactResult = new b2ContactResult(); public function b2Island(_arg1:int, _arg2:int, _arg3:int, _arg4, _arg5:b2ContactListener){ var _local6:int; super(); m_bodyCapacity = _arg1; m_contactCapacity = _arg2; m_jointCapacity = _arg3; m_bodyCount = 0; m_contactCount = 0; m_jointCount = 0; m_allocator = _arg4; m_listener = _arg5; m_bodies = new Array(_arg1); _local6 = 0; while (_local6 < _arg1) { m_bodies[_local6] = null; _local6++; }; m_contacts = new Array(_arg2); _local6 = 0; while (_local6 < _arg2) { m_contacts[_local6] = null; _local6++; }; m_joints = new Array(_arg3); _local6 = 0; while (_local6 < _arg3) { m_joints[_local6] = null; _local6++; }; } public function AddBody(_arg1:b2Body):void{ _arg1.m_islandIndex = m_bodyCount; var _local2 = m_bodyCount++; m_bodies[_local2] = _arg1; } public function AddJoint(_arg1:b2Joint):void{ var _local2 = m_jointCount++; m_joints[_local2] = _arg1; } public function Report(_arg1:Array):void{ var _local2:b2Mat22; var _local3:b2Vec2; var _local5:b2Contact; var _local6:b2ContactConstraint; var _local7:b2ContactResult; var _local8:b2Body; var _local9:int; var _local10:Array; var _local11:int; var _local12:b2Manifold; var _local13:int; var _local14:b2ManifoldPoint; var _local15:b2ContactConstraintPoint; if (m_listener == null){ return; }; var _local4:int; while (_local4 < m_contactCount) { _local5 = m_contacts[_local4]; _local6 = _arg1[_local4]; _local7 = s_reportCR; _local7.shape1 = _local5.m_shape1; _local7.shape2 = _local5.m_shape2; _local8 = _local7.shape1.m_body; _local9 = _local5.m_manifoldCount; _local10 = _local5.GetManifolds(); _local11 = 0; while (_local11 < _local9) { _local12 = _local10[_local11]; _local7.normal.SetV(_local12.normal); _local13 = 0; while (_local13 < _local12.pointCount) { _local14 = _local12.points[_local13]; _local15 = _local6.points[_local13]; _local7.position = _local8.GetWorldPoint(_local14.localPoint1); _local7.normalImpulse = _local15.normalImpulse; _local7.tangentImpulse = _local15.tangentImpulse; _local7.id.key = _local14.id.key; m_listener.Result(_local7, _local5); _local13++; }; _local11++; }; _local4++; }; } public function AddContact(_arg1:b2Contact):void{ var _local2 = m_contactCount++; m_contacts[_local2] = _arg1; } public function Solve(_arg1:b2TimeStep, _arg2:b2Vec2, _arg3:Boolean):void{ var _local4:int; var _local5:int; var _local6:b2Body; var _local7:b2Joint; var _local9:Boolean; var _local10:Boolean; var _local11:Boolean; var _local12:Number; var _local13:Number; var _local14:Number; _local4 = 0; while (_local4 < m_bodyCount) { _local6 = m_bodies[_local4]; if (_local6.IsStatic()){ } else { _local6.m_linearVelocity.x = (_local6.m_linearVelocity.x + (_arg1.dt * (_arg2.x + (_local6.m_invMass * _local6.m_force.x)))); _local6.m_linearVelocity.y = (_local6.m_linearVelocity.y + (_arg1.dt * (_arg2.y + (_local6.m_invMass * _local6.m_force.y)))); _local6.m_angularVelocity = (_local6.m_angularVelocity + ((_arg1.dt * _local6.m_invI) * _local6.m_torque)); _local6.m_force.SetZero(); _local6.m_torque = 0; _local6.m_linearVelocity.Multiply(b2Math.b2Clamp((1 - (_arg1.dt * _local6.m_linearDamping)), 0, 1)); _local6.m_angularVelocity = (_local6.m_angularVelocity * b2Math.b2Clamp((1 - (_arg1.dt * _local6.m_angularDamping)), 0, 1)); if (_local6.m_linearVelocity.LengthSquared() > b2Settings.b2_maxLinearVelocitySquared){ _local6.m_linearVelocity.Normalize(); _local6.m_linearVelocity.x = (_local6.m_linearVelocity.x * b2Settings.b2_maxLinearVelocity); _local6.m_linearVelocity.y = (_local6.m_linearVelocity.y * b2Settings.b2_maxLinearVelocity); }; if ((_local6.m_angularVelocity * _local6.m_angularVelocity) > b2Settings.b2_maxAngularVelocitySquared){ if (_local6.m_angularVelocity < 0){ _local6.m_angularVelocity = -(b2Settings.b2_maxAngularVelocity); } else { _local6.m_angularVelocity = b2Settings.b2_maxAngularVelocity; }; }; }; _local4++; }; var _local8:b2ContactSolver = new b2ContactSolver(_arg1, m_contacts, m_contactCount, m_allocator); _local8.InitVelocityConstraints(_arg1); _local4 = 0; while (_local4 < m_jointCount) { _local7 = m_joints[_local4]; _local7.InitVelocityConstraints(_arg1); _local4++; }; _local4 = 0; while (_local4 < _arg1.velocityIterations) { _local5 = 0; while (_local5 < m_jointCount) { _local7 = m_joints[_local5]; _local7.SolveVelocityConstraints(_arg1); _local5++; }; _local8.SolveVelocityConstraints(); _local4++; }; _local8.FinalizeVelocityConstraints(); _local4 = 0; while (_local4 < m_bodyCount) { _local6 = m_bodies[_local4]; if (_local6.IsStatic()){ } else { _local6.m_sweep.c0.SetV(_local6.m_sweep.c); _local6.m_sweep.a0 = _local6.m_sweep.a; _local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_arg1.dt * _local6.m_linearVelocity.x)); _local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_arg1.dt * _local6.m_linearVelocity.y)); _local6.m_sweep.a = (_local6.m_sweep.a + (_arg1.dt * _local6.m_angularVelocity)); _local6.SynchronizeTransform(); }; _local4++; }; _local4 = 0; while (_local4 < _arg1.positionIterations) { _local9 = _local8.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); _local10 = true; _local5 = 0; while (_local5 < m_jointCount) { _local7 = m_joints[_local5]; _local11 = _local7.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); _local10 = ((_local10) && (_local11)); _local5++; }; if (((_local9) && (_local10))){ break; }; _local4++; }; Report(_local8.m_constraints); if (_arg3){ _local12 = Number.MAX_VALUE; _local13 = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance); _local14 = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance); _local4 = 0; while (_local4 < m_bodyCount) { _local6 = m_bodies[_local4]; if (_local6.m_invMass == 0){ } else { if ((_local6.m_flags & b2Body.e_allowSleepFlag) == 0){ _local6.m_sleepTime = 0; _local12 = 0; }; if (((((((_local6.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((_local6.m_angularVelocity * _local6.m_angularVelocity) > _local14)))) || ((b2Math.b2Dot(_local6.m_linearVelocity, _local6.m_linearVelocity) > _local13)))){ _local6.m_sleepTime = 0; _local12 = 0; } else { _local6.m_sleepTime = (_local6.m_sleepTime + _arg1.dt); _local12 = b2Math.b2Min(_local12, _local6.m_sleepTime); }; }; _local4++; }; if (_local12 >= b2Settings.b2_timeToSleep){ _local4 = 0; while (_local4 < m_bodyCount) { _local6 = m_bodies[_local4]; m_bodies[_local4].m_flags = (_local6.m_flags | b2Body.e_sleepFlag); _local6.m_linearVelocity.SetZero(); _local6.m_angularVelocity = 0; _local4++; }; }; }; } public function Clear():void{ m_bodyCount = 0; m_contactCount = 0; m_jointCount = 0; } public function SolveTOI(_arg1:b2TimeStep):void{ var _local2:int; var _local3:int; var _local6:b2Body; var _local7:Boolean; var _local4:b2ContactSolver = new b2ContactSolver(_arg1, m_contacts, m_contactCount, m_allocator); _local2 = 0; while (_local2 < _arg1.velocityIterations) { _local4.SolveVelocityConstraints(); _local2++; }; _local2 = 0; while (_local2 < m_bodyCount) { _local6 = m_bodies[_local2]; if (_local6.IsStatic()){ } else { _local6.m_sweep.c0.SetV(_local6.m_sweep.c); _local6.m_sweep.a0 = _local6.m_sweep.a; _local6.m_sweep.c.x = (_local6.m_sweep.c.x + (_arg1.dt * _local6.m_linearVelocity.x)); _local6.m_sweep.c.y = (_local6.m_sweep.c.y + (_arg1.dt * _local6.m_linearVelocity.y)); _local6.m_sweep.a = (_local6.m_sweep.a + (_arg1.dt * _local6.m_angularVelocity)); _local6.SynchronizeTransform(); }; _local2++; }; var _local5:Number = 0.75; _local2 = 0; while (_local2 < _arg1.positionIterations) { _local7 = _local4.SolvePositionConstraints(_local5); if (_local7){ break; }; _local2++; }; Report(_local4.m_constraints); } } }//package Box2D.Dynamics
Section 76
//b2TimeStep (Box2D.Dynamics.b2TimeStep) package Box2D.Dynamics { public class b2TimeStep { public var warmStarting:Boolean; public var inv_dt:Number; public var dt:Number; public var velocityIterations:int; public var dtRatio:Number; public var positionIterations:int; } }//package Box2D.Dynamics
Section 77
//b2World (Box2D.Dynamics.b2World) package Box2D.Dynamics { import Box2D.Collision.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Dynamics.Joints.*; import Box2D.Common.*; import Box2D.Dynamics.Contacts.*; public class b2World { private var m_inv_dt0:Number; private var m_boundaryListener:b2BoundaryListener; b2internal var m_contactList:b2Contact; b2internal var m_blockAllocator; b2internal var m_contactListener:b2ContactListener; b2internal var m_raycastSegment:b2Segment; b2internal var m_broadPhase:b2BroadPhase; private var m_destructionListener:b2DestructionListener; private var m_jointCount:int; b2internal var m_lock:Boolean; private var m_bodyCount:int; b2internal var m_raycastUserData; private var m_allowSleep:Boolean; b2internal var m_groundBody:b2Body; b2internal var m_contactCount:int; b2internal var m_raycastNormal:b2Vec2; b2internal var m_contactFilter:b2ContactFilter; b2internal var m_bodyList:b2Body; private var m_debugDraw:b2DebugDraw; b2internal var m_stackAllocator; private var m_jointList:b2Joint; private var m_gravity:b2Vec2; private var m_contactManager:b2ContactManager; private static var s_xf:b2XForm = new b2XForm(); private static var s_jointColor:b2Color = new b2Color(0.5, 0.8, 0.8); private static var m_continuousPhysics:Boolean; private static var m_warmStarting:Boolean; private static var s_coreColor:b2Color = new b2Color(0.9, 0.6, 0.6); public function b2World(_arg1:b2AABB, _arg2:b2Vec2, _arg3:Boolean){ m_raycastNormal = new b2Vec2(); 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_warmStarting = true; m_continuousPhysics = true; m_allowSleep = _arg3; m_gravity = _arg2; m_lock = false; m_inv_dt0 = 0; m_contactManager.m_world = this; m_broadPhase = new b2BroadPhase(_arg1, m_contactManager); var _local4:b2BodyDef = new b2BodyDef(); m_groundBody = CreateBody(_local4); } b2internal function DrawJoint(_arg1:b2Joint):void{ var _local11:b2PulleyJoint; var _local12:b2Vec2; var _local13:b2Vec2; var _local2:b2Body = _arg1.m_body1; var _local3:b2Body = _arg1.m_body2; var _local4:b2XForm = _local2.m_xf; var _local5:b2XForm = _local3.m_xf; var _local6:b2Vec2 = _local4.position; var _local7:b2Vec2 = _local5.position; var _local8:b2Vec2 = _arg1.GetAnchor1(); var _local9:b2Vec2 = _arg1.GetAnchor2(); var _local10:b2Color = s_jointColor; switch (_arg1.m_type){ case b2Joint.e_distanceJoint: m_debugDraw.DrawSegment(_local8, _local9, _local10); break; case b2Joint.e_pulleyJoint: _local11 = (_arg1 as b2PulleyJoint); _local12 = _local11.GetGroundAnchor1(); _local13 = _local11.GetGroundAnchor2(); m_debugDraw.DrawSegment(_local12, _local8, _local10); m_debugDraw.DrawSegment(_local13, _local9, _local10); m_debugDraw.DrawSegment(_local12, _local13, _local10); break; case b2Joint.e_mouseJoint: m_debugDraw.DrawSegment(_local8, _local9, _local10); break; default: if (_local2 != m_groundBody){ m_debugDraw.DrawSegment(_local6, _local8, _local10); }; m_debugDraw.DrawSegment(_local8, _local9, _local10); if (_local3 != m_groundBody){ m_debugDraw.DrawSegment(_local7, _local9, _local10); }; }; } public function Refilter(_arg1:b2Shape):void{ _arg1.RefilterProxy(m_broadPhase, _arg1.m_body.m_xf); } public function SetDebugDraw(_arg1:b2DebugDraw):void{ m_debugDraw = _arg1; } public function SetContinuousPhysics(_arg1:Boolean):void{ m_continuousPhysics = _arg1; } public function GetProxyCount():int{ return (m_broadPhase.m_proxyCount); } b2internal function DrawDebugData():void{ var _local2:int; var _local3:b2Body; var _local4:b2Shape; var _local5:b2Joint; var _local6:b2BroadPhase; var _local11:b2XForm; var _local15:Boolean; var _local16:uint; var _local17:b2Pair; var _local18:b2Proxy; var _local19:b2Proxy; var _local20:b2Vec2; var _local21:b2Vec2; var _local22:b2Proxy; var _local23:b2PolygonShape; var _local24:b2OBB; var _local25:b2Vec2; var _local26:b2Mat22; var _local27:b2Vec2; var _local28:Number; if (m_debugDraw == null){ return; }; m_debugDraw.m_sprite.graphics.clear(); var _local1:uint = m_debugDraw.GetFlags(); var _local7:b2Vec2 = new b2Vec2(); var _local8:b2Vec2 = new b2Vec2(); var _local9:b2Vec2 = new b2Vec2(); var _local10:b2Color = new b2Color(0, 0, 0); var _local12:b2AABB = new b2AABB(); var _local13:b2AABB = new b2AABB(); var _local14:Array = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()]; if ((_local1 & b2DebugDraw.e_shapeBit)){ _local15 = ((_local1 & b2DebugDraw.e_coreShapeBit) == b2DebugDraw.e_coreShapeBit); _local3 = m_bodyList; while (_local3) { _local11 = _local3.m_xf; _local4 = _local3.GetShapeList(); while (_local4) { if (_local3.IsStatic()){ DrawShape(_local4, _local11, new b2Color(0.5, 0.9, 0.5), _local15); } else { if (_local3.IsSleeping()){ DrawShape(_local4, _local11, new b2Color(0.5, 0.5, 0.9), _local15); } else { DrawShape(_local4, _local11, new b2Color(0.9, 0.9, 0.9), _local15); }; }; _local4 = _local4.m_next; }; _local3 = _local3.m_next; }; }; if ((_local1 & b2DebugDraw.e_jointBit)){ _local5 = m_jointList; while (_local5) { DrawJoint(_local5); _local5 = _local5.m_next; }; }; if ((_local1 & b2DebugDraw.e_pairBit)){ _local6 = m_broadPhase; _local7.Set((1 / _local6.m_quantizationFactor.x), (1 / _local6.m_quantizationFactor.y)); _local10.Set(0.9, 0.9, 0.3); _local2 = 0; while (_local2 < b2Pair.b2_tableCapacity) { _local16 = _local6.m_pairManager.m_hashTable[_local2]; while (_local16 != b2Pair.b2_nullPair) { _local17 = _local6.m_pairManager.m_pairs[_local16]; _local18 = _local6.m_proxyPool[_local17.proxyId1]; _local19 = _local6.m_proxyPool[_local17.proxyId2]; _local12.lowerBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local18.lowerBounds[0]].value)); _local12.lowerBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local18.lowerBounds[1]].value)); _local12.upperBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local18.upperBounds[0]].value)); _local12.upperBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local18.upperBounds[1]].value)); _local13.lowerBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local19.lowerBounds[0]].value)); _local13.lowerBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local19.lowerBounds[1]].value)); _local13.upperBound.x = (_local6.m_worldAABB.lowerBound.x + (_local7.x * _local6.m_bounds[0][_local19.upperBounds[0]].value)); _local13.upperBound.y = (_local6.m_worldAABB.lowerBound.y + (_local7.y * _local6.m_bounds[1][_local19.upperBounds[1]].value)); _local8.x = (0.5 * (_local12.lowerBound.x + _local12.upperBound.x)); _local8.y = (0.5 * (_local12.lowerBound.y + _local12.upperBound.y)); _local9.x = (0.5 * (_local13.lowerBound.x + _local13.upperBound.x)); _local9.y = (0.5 * (_local13.lowerBound.y + _local13.upperBound.y)); m_debugDraw.DrawSegment(_local8, _local9, _local10); _local16 = _local17.next; }; _local2++; }; }; if ((_local1 & b2DebugDraw.e_aabbBit)){ _local6 = m_broadPhase; _local20 = _local6.m_worldAABB.lowerBound; _local21 = _local6.m_worldAABB.upperBound; _local7.Set((1 / _local6.m_quantizationFactor.x), (1 / _local6.m_quantizationFactor.y)); _local10.Set(0.9, 0.3, 0.9); _local2 = 0; while (_local2 < b2Settings.b2_maxProxies) { _local22 = _local6.m_proxyPool[_local2]; if (_local22.IsValid() == false){ } else { _local12.lowerBound.x = (_local20.x + (_local7.x * _local6.m_bounds[0][_local22.lowerBounds[0]].value)); _local12.lowerBound.y = (_local20.y + (_local7.y * _local6.m_bounds[1][_local22.lowerBounds[1]].value)); _local12.upperBound.x = (_local20.x + (_local7.x * _local6.m_bounds[0][_local22.upperBounds[0]].value)); _local12.upperBound.y = (_local20.y + (_local7.y * _local6.m_bounds[1][_local22.upperBounds[1]].value)); _local14[0].Set(_local12.lowerBound.x, _local12.lowerBound.y); _local14[1].Set(_local12.upperBound.x, _local12.lowerBound.y); _local14[2].Set(_local12.upperBound.x, _local12.upperBound.y); _local14[3].Set(_local12.lowerBound.x, _local12.upperBound.y); m_debugDraw.DrawPolygon(_local14, 4, _local10); }; _local2++; }; _local14[0].Set(_local20.x, _local20.y); _local14[1].Set(_local21.x, _local20.y); _local14[2].Set(_local21.x, _local21.y); _local14[3].Set(_local20.x, _local21.y); m_debugDraw.DrawPolygon(_local14, 4, new b2Color(0.3, 0.9, 0.9)); }; if ((_local1 & b2DebugDraw.e_obbBit)){ _local10.Set(0.5, 0.3, 0.5); _local3 = m_bodyList; while (_local3) { _local11 = _local3.m_xf; _local4 = _local3.GetShapeList(); while (_local4) { if (_local4.m_type != b2Shape.e_polygonShape){ } else { _local23 = (_local4 as b2PolygonShape); _local24 = _local23.GetOBB(); _local25 = _local24.extents; _local14[0].Set(-(_local25.x), -(_local25.y)); _local14[1].Set(_local25.x, -(_local25.y)); _local14[2].Set(_local25.x, _local25.y); _local14[3].Set(-(_local25.x), _local25.y); _local2 = 0; while (_local2 < 4) { _local26 = _local24.R; _local27 = _local14[_local2]; _local28 = (_local24.center.x + ((_local26.col1.x * _local27.x) + (_local26.col2.x * _local27.y))); _local14[_local2].y = (_local24.center.y + ((_local26.col1.y * _local27.x) + (_local26.col2.y * _local27.y))); _local14[_local2].x = _local28; _local26 = _local11.R; _local28 = (_local11.position.x + ((_local26.col1.x * _local27.x) + (_local26.col2.x * _local27.y))); _local14[_local2].y = (_local11.position.y + ((_local26.col1.y * _local27.x) + (_local26.col2.y * _local27.y))); _local14[_local2].x = _local28; _local2++; }; m_debugDraw.DrawPolygon(_local14, 4, _local10); }; _local4 = _local4.m_next; }; _local3 = _local3.m_next; }; }; if ((_local1 & b2DebugDraw.e_centerOfMassBit)){ _local3 = m_bodyList; while (_local3) { _local11 = s_xf; _local11.R = _local3.m_xf.R; _local11.position = _local3.GetWorldCenter(); m_debugDraw.DrawXForm(_local11); _local3 = _local3.m_next; }; }; } public function DestroyBody(_arg1:b2Body):void{ var _local4:b2JointEdge; var _local5:b2Shape; if (m_lock == true){ return; }; var _local2:b2JointEdge = _arg1.m_jointList; while (_local2) { _local4 = _local2; _local2 = _local2.next; if (m_destructionListener){ m_destructionListener.SayGoodbyeJoint(_local4.joint); }; DestroyJoint(_local4.joint); }; var _local3:b2Shape = _arg1.m_shapeList; while (_local3) { _local5 = _local3; _local3 = _local3.m_next; if (m_destructionListener){ m_destructionListener.SayGoodbyeShape(_local5); }; _local5.DestroyProxy(m_broadPhase); b2Shape.Destroy(_local5, m_blockAllocator); }; if (_arg1.m_prev){ _arg1.m_prev.m_next = _arg1.m_next; }; if (_arg1.m_next){ _arg1.m_next.m_prev = _arg1.m_prev; }; if (_arg1 == m_bodyList){ m_bodyList = _arg1.m_next; }; m_bodyCount--; } b2internal function DrawShape(_arg1:b2Shape, _arg2:b2XForm, _arg3:b2Color, _arg4:Boolean):void{ var _local6:b2CircleShape; var _local7:b2Vec2; var _local8:Number; var _local9:b2Vec2; var _local10:int; var _local11:b2PolygonShape; var _local12:int; var _local13:Array; var _local14:Array; var _local15:Array; var _local5:b2Color = s_coreColor; switch (_arg1.m_type){ case b2Shape.e_circleShape: _local6 = (_arg1 as b2CircleShape); _local7 = b2Math.b2MulX(_arg2, _local6.m_localPosition); _local8 = _local6.m_radius; _local9 = _arg2.R.col1; m_debugDraw.DrawSolidCircle(_local7, _local8, _local9, _arg3); if (_arg4){ m_debugDraw.DrawCircle(_local7, (_local8 - b2Settings.b2_toiSlop), _local5); }; break; case b2Shape.e_polygonShape: _local11 = (_arg1 as b2PolygonShape); _local12 = _local11.GetVertexCount(); _local13 = _local11.GetVertices(); _local14 = new Array(b2Settings.b2_maxPolygonVertices); _local10 = 0; while (_local10 < _local12) { _local14[_local10] = b2Math.b2MulX(_arg2, _local13[_local10]); _local10++; }; m_debugDraw.DrawSolidPolygon(_local14, _local12, _arg3); if (_arg4){ _local15 = _local11.GetCoreVertices(); _local10 = 0; while (_local10 < _local12) { _local14[_local10] = b2Math.b2MulX(_arg2, _local15[_local10]); _local10++; }; m_debugDraw.DrawPolygon(_local14, _local12, _local5); }; break; }; } public function GetGroundBody():b2Body{ return (m_groundBody); } public function SetContactFilter(_arg1:b2ContactFilter):void{ m_contactFilter = _arg1; } b2internal function Solve(_arg1:b2TimeStep):void{ var _local2:b2Body; var _local9:int; var _local10:int; var _local11:b2Body; var _local12:b2ContactEdge; var _local13:b2JointEdge; var _local14:Boolean; var _local3:b2Island = new b2Island(m_bodyCount, m_contactCount, m_jointCount, m_stackAllocator, m_contactListener); _local2 = m_bodyList; while (_local2) { _local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag)); _local2 = _local2.m_next; }; var _local4:b2Contact = m_contactList; while (_local4) { _local4.m_flags = (_local4.m_flags & ~(b2Contact.e_islandFlag)); _local4 = _local4.m_next; }; var _local5:b2Joint = m_jointList; while (_local5) { _local5.m_islandFlag = false; _local5 = _local5.m_next; }; var _local6:int = m_bodyCount; var _local7:Array = new Array(_local6); var _local8:b2Body = m_bodyList; while (_local8) { if ((_local8.m_flags & ((b2Body.e_islandFlag | b2Body.e_sleepFlag) | b2Body.e_frozenFlag))){ } else { if (_local8.IsStatic()){ } else { _local3.Clear(); _local9 = 0; var _temp1 = _local9; _local9 = (_local9 + 1); var _local15 = _temp1; _local7[_local15] = _local8; _local8.m_flags = (_local8.m_flags | b2Body.e_islandFlag); while (_local9 > 0) { --_local9; _local2 = _local7[_local9]; _local3.AddBody(_local2); _local2.m_flags = (_local2.m_flags & ~(b2Body.e_sleepFlag)); if (_local2.IsStatic()){ } else { _local12 = _local2.m_contactList; while (_local12) { if ((_local12.contact.m_flags & (b2Contact.e_islandFlag | b2Contact.e_nonSolidFlag))){ } else { if (_local12.contact.m_manifoldCount == 0){ } else { _local3.AddContact(_local12.contact); _local12.contact.m_flags = (_local12.contact.m_flags | b2Contact.e_islandFlag); _local11 = _local12.other; if ((_local11.m_flags & b2Body.e_islandFlag)){ } else { var _temp2 = _local9; _local9 = (_local9 + 1); var _local16 = _temp2; _local7[_local16] = _local11; _local11.m_flags = (_local11.m_flags | b2Body.e_islandFlag); }; }; }; _local12 = _local12.next; }; _local13 = _local2.m_jointList; while (_local13) { if (_local13.joint.m_islandFlag == true){ } else { _local3.AddJoint(_local13.joint); _local13.joint.m_islandFlag = true; _local11 = _local13.other; if ((_local11.m_flags & b2Body.e_islandFlag)){ } else { var _temp3 = _local9; _local9 = (_local9 + 1); _local16 = _temp3; _local7[_local16] = _local11; _local11.m_flags = (_local11.m_flags | b2Body.e_islandFlag); }; }; _local13 = _local13.next; }; }; }; _local3.Solve(_arg1, m_gravity, m_allowSleep); _local10 = 0; while (_local10 < _local3.m_bodyCount) { _local2 = _local3.m_bodies[_local10]; if (_local2.IsStatic()){ _local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag)); }; _local10++; }; }; }; _local8 = _local8.m_next; }; _local2 = m_bodyList; while (_local2) { if ((_local2.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){ } else { if (_local2.IsStatic()){ } else { _local14 = _local2.SynchronizeShapes(); if ((((_local14 == false)) && (!((m_boundaryListener == null))))){ m_boundaryListener.Violation(_local2); }; }; }; _local2 = _local2.m_next; }; m_broadPhase.Commit(); } public function Query(_arg1:b2AABB, _arg2:Array, _arg3:int):int{ var _local4:Array = new Array(_arg3); var _local5:int = m_broadPhase.QueryAABB(_arg1, _local4, _arg3); var _local6:int; while (_local6 < _local5) { _arg2[_local6] = _local4[_local6]; _local6++; }; return (_local5); } public function GetContactCount():int{ return (m_contactCount); } b2internal function SolveTOI(_arg1:b2TimeStep):void{ var _local2:b2Body; var _local3:b2Shape; var _local4:b2Shape; var _local5:b2Body; var _local6:b2Body; var _local7:b2ContactEdge; var _local8:b2Joint; var _local12:b2Contact; var _local13:b2Contact; var _local14:Number; var _local15:b2Body; var _local16:int; var _local17:int; var _local18:b2TimeStep; var _local19:int; var _local20:Number; var _local21:Number; var _local22:b2Body; var _local23:Boolean; var _local9:b2Island = new b2Island(m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, b2Settings.b2_maxTOIJointsPerIsland, m_stackAllocator, m_contactListener); var _local10:int = m_bodyCount; var _local11:Array = new Array(_local10); _local2 = m_bodyList; while (_local2) { _local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag)); _local2.m_sweep.t0 = 0; _local2 = _local2.m_next; }; _local12 = m_contactList; while (_local12) { _local12.m_flags = (_local12.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag))); _local12 = _local12.m_next; }; while (true) { _local13 = null; _local14 = 1; _local12 = m_contactList; for (;_local12;(_local12 = _local12.m_next)) { if ((_local12.m_flags & (b2Contact.e_slowFlag | b2Contact.e_nonSolidFlag))){ } else { _local20 = 1; if ((_local12.m_flags & b2Contact.e_toiFlag)){ _local20 = _local12.m_toi; } else { _local3 = _local12.m_shape1; _local4 = _local12.m_shape2; _local5 = _local3.m_body; _local6 = _local4.m_body; if (((((_local5.IsStatic()) || (_local5.IsSleeping()))) && (((_local6.IsStatic()) || (_local6.IsSleeping()))))){ continue; }; _local21 = _local5.m_sweep.t0; if (_local5.m_sweep.t0 < _local6.m_sweep.t0){ _local21 = _local6.m_sweep.t0; _local5.m_sweep.Advance(_local21); } else { if (_local6.m_sweep.t0 < _local5.m_sweep.t0){ _local21 = _local5.m_sweep.t0; _local6.m_sweep.Advance(_local21); }; }; _local20 = b2TimeOfImpact.TimeOfImpact(_local12.m_shape1, _local5.m_sweep, _local12.m_shape2, _local6.m_sweep); if ((((_local20 > 0)) && ((_local20 < 1)))){ _local20 = (((1 - _local20) * _local21) + _local20); if (_local20 > 1){ _local20 = 1; }; }; _local12.m_toi = _local20; _local12.m_flags = (_local12.m_flags | b2Contact.e_toiFlag); }; if ((((Number.MIN_VALUE < _local20)) && ((_local20 < _local14)))){ _local13 = _local12; _local14 = _local20; }; }; }; if ((((_local13 == null)) || (((1 - (100 * Number.MIN_VALUE)) < _local14)))){ break; }; _local3 = _local13.m_shape1; _local4 = _local13.m_shape2; _local5 = _local3.m_body; _local6 = _local4.m_body; _local5.Advance(_local14); _local6.Advance(_local14); _local13.Update(m_contactListener); _local13.m_flags = (_local13.m_flags & ~(b2Contact.e_toiFlag)); if (_local13.m_manifoldCount == 0){ } else { _local15 = _local5; if (_local15.IsStatic()){ _local15 = _local6; }; _local9.Clear(); _local16 = 0; _local17 = 0; var _temp1 = _local17; _local17 = (_local17 + 1); _local11[(_local16 + _temp1)] = _local15; _local15.m_flags = (_local15.m_flags | b2Body.e_islandFlag); while (_local17 > 0) { var _temp2 = _local16; _local16 = (_local16 + 1); _local2 = _local11[_temp2]; _local17--; _local9.AddBody(_local2); _local2.m_flags = (_local2.m_flags & ~(b2Body.e_sleepFlag)); if (_local2.IsStatic()){ } else { _local7 = _local2.m_contactList; while (_local7) { if (_local9.m_contactCount == _local9.m_contactCapacity){ } else { if ((_local7.contact.m_flags & ((b2Contact.e_islandFlag | b2Contact.e_slowFlag) | b2Contact.e_nonSolidFlag))){ } else { if (_local7.contact.m_manifoldCount == 0){ } else { _local9.AddContact(_local7.contact); _local7.contact.m_flags = (_local7.contact.m_flags | b2Contact.e_islandFlag); _local22 = _local7.other; if ((_local22.m_flags & b2Body.e_islandFlag)){ } else { if (_local22.IsStatic() == false){ _local22.Advance(_local14); _local22.WakeUp(); }; var _temp3 = _local17; _local17 = (_local17 + 1); _local11[(_local16 + _temp3)] = _local22; _local22.m_flags = (_local22.m_flags | b2Body.e_islandFlag); }; }; }; }; _local7 = _local7.next; }; }; }; _local18 = new b2TimeStep(); _local18.warmStarting = false; _local18.dt = ((1 - _local14) * _arg1.dt); _local18.inv_dt = (1 / _local18.dt); _local18.velocityIterations = _arg1.velocityIterations; _local18.positionIterations = _arg1.positionIterations; _local9.SolveTOI(_local18); _local19 = 0; while (_local19 < _local9.m_bodyCount) { _local2 = _local9.m_bodies[_local19]; _local2.m_flags = (_local2.m_flags & ~(b2Body.e_islandFlag)); if ((_local2.m_flags & (b2Body.e_sleepFlag | b2Body.e_frozenFlag))){ } else { if (_local2.IsStatic()){ } else { _local23 = _local2.SynchronizeShapes(); if ((((_local23 == false)) && (!((m_boundaryListener == null))))){ m_boundaryListener.Violation(_local2); }; _local7 = _local2.m_contactList; while (_local7) { _local7.contact.m_flags = (_local7.contact.m_flags & ~(b2Contact.e_toiFlag)); _local7 = _local7.next; }; }; }; _local19++; }; _local19 = 0; while (_local19 < _local9.m_contactCount) { _local12 = _local9.m_contacts[_local19]; _local9.m_contacts[_local19].m_flags = (_local12.m_flags & ~((b2Contact.e_toiFlag | b2Contact.e_islandFlag))); _local19++; }; _local19 = 0; while (_local19 < _local9.m_jointCount) { _local8 = _local9.m_joints[_local19]; _local8.m_islandFlag = false; _local19++; }; m_broadPhase.Commit(); }; }; } public function GetJointList():b2Joint{ return (m_jointList); } public function Validate():void{ m_broadPhase.Validate(); } public function SetGravity(_arg1:b2Vec2):void{ m_gravity = _arg1; } public function GetPairCount():int{ return (m_broadPhase.m_pairManager.m_pairCount); } public function GetBodyList():b2Body{ return (m_bodyList); } public function SetWarmStarting(_arg1:Boolean):void{ m_warmStarting = _arg1; } public function Raycast(_arg1:b2Segment, _arg2:Array, _arg3:int, _arg4:Boolean, _arg5):int{ var _local7:int; var _local6:Array = new Array(_arg3); m_raycastSegment = _arg1; m_raycastUserData = _arg5; if (_arg4){ _local7 = m_broadPhase.QuerySegment(_arg1, _local6, _arg3, RaycastSortKey); } else { _local7 = m_broadPhase.QuerySegment(_arg1, _local6, _arg3, RaycastSortKey2); }; var _local8:int; while (_local8 < _local7) { _arg2[_local8] = _local6[_local8]; _local8++; }; return (_local7); } public function CreateJoint(_arg1:b2JointDef):b2Joint{ var _local3:b2Body; var _local4:b2Shape; var _local2:b2Joint = b2Joint.Create(_arg1, m_blockAllocator); _local2.m_prev = null; _local2.m_next = m_jointList; if (m_jointList){ m_jointList.m_prev = _local2; }; m_jointList = _local2; m_jointCount++; _local2.m_node1.joint = _local2; _local2.m_node1.other = _local2.m_body2; _local2.m_node1.prev = null; _local2.m_node1.next = _local2.m_body1.m_jointList; if (_local2.m_body1.m_jointList){ _local2.m_body1.m_jointList.prev = _local2.m_node1; }; _local2.m_body1.m_jointList = _local2.m_node1; _local2.m_node2.joint = _local2; _local2.m_node2.other = _local2.m_body1; _local2.m_node2.prev = null; _local2.m_node2.next = _local2.m_body2.m_jointList; if (_local2.m_body2.m_jointList){ _local2.m_body2.m_jointList.prev = _local2.m_node2; }; _local2.m_body2.m_jointList = _local2.m_node2; if (_arg1.collideConnected == false){ _local3 = ((_arg1.body1.m_shapeCount < _arg1.body2.m_shapeCount)) ? _arg1.body1 : _arg1.body2; _local4 = _local3.m_shapeList; while (_local4) { _local4.RefilterProxy(m_broadPhase, _local3.m_xf); _local4 = _local4.m_next; }; }; return (_local2); } public function DestroyJoint(_arg1:b2Joint):void{ var _local5:b2Body; var _local6:b2Shape; var _local2:Boolean = _arg1.m_collideConnected; if (_arg1.m_prev){ _arg1.m_prev.m_next = _arg1.m_next; }; if (_arg1.m_next){ _arg1.m_next.m_prev = _arg1.m_prev; }; if (_arg1 == m_jointList){ m_jointList = _arg1.m_next; }; var _local3:b2Body = _arg1.m_body1; var _local4:b2Body = _arg1.m_body2; _local3.WakeUp(); _local4.WakeUp(); if (_arg1.m_node1.prev){ _arg1.m_node1.prev.next = _arg1.m_node1.next; }; if (_arg1.m_node1.next){ _arg1.m_node1.next.prev = _arg1.m_node1.prev; }; if (_arg1.m_node1 == _local3.m_jointList){ _local3.m_jointList = _arg1.m_node1.next; }; _arg1.m_node1.prev = null; _arg1.m_node1.next = null; if (_arg1.m_node2.prev){ _arg1.m_node2.prev.next = _arg1.m_node2.next; }; if (_arg1.m_node2.next){ _arg1.m_node2.next.prev = _arg1.m_node2.prev; }; if (_arg1.m_node2 == _local4.m_jointList){ _local4.m_jointList = _arg1.m_node2.next; }; _arg1.m_node2.prev = null; _arg1.m_node2.next = null; b2Joint.Destroy(_arg1, m_blockAllocator); m_jointCount--; if (_local2 == false){ _local5 = ((_local3.m_shapeCount < _local4.m_shapeCount)) ? _local3 : _local4; _local6 = _local5.m_shapeList; while (_local6) { _local6.RefilterProxy(m_broadPhase, _local5.m_xf); _local6 = _local6.m_next; }; }; } public function SetContactListener(_arg1:b2ContactListener):void{ m_contactListener = _arg1; } b2internal function RaycastSortKey(_arg1:b2Shape):Number{ if (((m_contactFilter) && (!(m_contactFilter.RayCollide(m_raycastUserData, _arg1))))){ return (-1); }; var _local2:b2Body = _arg1.GetBody(); var _local3:b2XForm = _local2.GetXForm(); var _local4:Array = [0]; if (_arg1.TestSegment(_local3, _local4, m_raycastNormal, m_raycastSegment, 1) == b2Shape.e_missCollide){ return (-1); }; return (_local4[0]); } b2internal function RaycastSortKey2(_arg1:b2Shape):Number{ if (((m_contactFilter) && (!(m_contactFilter.RayCollide(m_raycastUserData, _arg1))))){ return (-1); }; var _local2:b2Body = _arg1.GetBody(); var _local3:b2XForm = _local2.GetXForm(); var _local4:Array = [0]; if (_arg1.TestSegment(_local3, _local4, m_raycastNormal, m_raycastSegment, 1) != b2Shape.e_hitCollide){ return (-1); }; return (_local4[0]); } public function RaycastOne(_arg1:b2Segment, _arg2:Array, _arg3:b2Vec2, _arg4:Boolean, _arg5):b2Shape{ var _local6:Array = new Array(1); var _local7:Number = Raycast(_arg1, _local6, 1, _arg4, _arg5); if (_local7 == 0){ return (null); }; var _local8:b2Shape = _local6[0]; var _local9:b2XForm = _local8.GetBody().GetXForm(); _local8.TestSegment(_local9, _arg2, _arg3, _arg1, 1); return (_local8); } public function CreateBody(_arg1:b2BodyDef):b2Body{ if (m_lock == true){ return (null); }; var _local2:b2Body = new b2Body(_arg1, this); _local2.m_prev = null; _local2.m_next = m_bodyList; if (m_bodyList){ m_bodyList.m_prev = _local2; }; m_bodyList = _local2; m_bodyCount++; return (_local2); } public function SetBoundaryListener(_arg1:b2BoundaryListener):void{ m_boundaryListener = _arg1; } public function SetDestructionListener(_arg1:b2DestructionListener):void{ m_destructionListener = _arg1; } public function Step(_arg1:Number, _arg2:int, _arg3:int):void{ m_lock = true; var _local4:b2TimeStep = new b2TimeStep(); _local4.dt = _arg1; _local4.velocityIterations = _arg2; _local4.positionIterations = _arg3; if (_arg1 > 0){ _local4.inv_dt = (1 / _arg1); } else { _local4.inv_dt = 0; }; _local4.dtRatio = (m_inv_dt0 * _arg1); _local4.warmStarting = m_warmStarting; m_contactManager.Collide(); if (_local4.dt > 0){ Solve(_local4); }; if (((m_continuousPhysics) && ((_local4.dt > 0)))){ SolveTOI(_local4); }; DrawDebugData(); m_inv_dt0 = _local4.inv_dt; m_lock = false; } public function GetGravity():b2Vec2{ return (m_gravity); } public function GetBodyCount():int{ return (m_bodyCount); } public function InRange(_arg1:b2AABB):Boolean{ return (m_broadPhase.InRange(_arg1)); } public function GetJointCount():int{ return (m_jointCount); } } }//package Box2D.Dynamics
Section 78
//b2XML (com.boristhebrave.Box2DWith.b2XML) package com.boristhebrave.Box2DWith { import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.props.*; import com.kerb.uncharted.game.characters.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import Box2D.Dynamics.Joints.*; public class b2XML { public static function loadBool(_arg1:XMLList, _arg2:Boolean=false):Boolean{ var attribute = _arg1; var defacto = _arg2; try { if (attribute.length()){ return ((attribute.toString() == "true")); }; } catch(error:Error) { }; return (defacto); } public static function loadShapeDef(_arg1:XML, _arg2:b2ShapeDef=null):b2ShapeDef{ var _local3:b2CircleDef; var _local4:b2PolygonDef; var _local5:XMLList; var _local6:b2PolygonDef; var _local7:Number; var _local8:Number; var _local9:Number; var _local10:Number; var _local11:Number; var _local12:int; switch (_arg1.localName()){ case "circle": _local3 = new b2CircleDef(); assignShapeDefFromXML(_arg1, _local3, _arg2); _local3.radius = loadFloat(_arg1.@radius, 0); _local3.localPosition.x = loadFloat(_arg1.@x, 0); _local3.localPosition.y = loadFloat(_arg1.@y, 0); _local3.localPosition = loadVec2(_arg1.@localPosition, _local3.localPosition); return (_local3); case "polygon": _local4 = new b2PolygonDef(); assignShapeDefFromXML(_arg1, _local4, _arg2); _local5 = _arg1.vertex; if (_local5.length() == 0){ _local5 = _arg1.vertex; }; _local4.vertexCount = _local5.length(); _local12 = 0; while (_local12 < _local5.length()) { _local4.vertices[_local12].x = parseFloat(_local5[_local12].@x); _local4.vertices[_local12].y = parseFloat(_local5[_local12].@y); _local12++; }; return (_local4); case "box": _local6 = new b2PolygonDef(); assignShapeDefFromXML(_arg1, _local6, _arg2); _local7 = parseFloat(_arg1.@width); _local8 = parseFloat(_arg1.@height); _local9 = loadFloat(_arg1.@x, 0); _local10 = loadFloat(_arg1.@y, 0); _local11 = loadFloat(_arg1.@angle, 0); if (!_arg1.@angle.length()){ if (((_arg1.@left.length()) && (_arg1.@right.length()))){ _local9 = ((parseFloat(_arg1.@right) + parseFloat(_arg1.@left)) / 2); _local7 = (parseFloat(_arg1.@right) - parseFloat(_arg1.@left)); }; if (((_arg1.@left.length()) && (_arg1.@width.length()))){ _local9 = (parseFloat(_arg1.@left) + (_local7 / 2)); }; if (((_arg1.@right.length()) && (_arg1.@width.length()))){ _local9 = (parseFloat(_arg1.@right) - (_local7 / 2)); }; if (((_arg1.@top.length()) && (_arg1.@bottom.length()))){ _local10 = ((parseFloat(_arg1.@bottom) + parseFloat(_arg1.@top)) / 2); _local8 = (parseFloat(_arg1.@bottom) - parseFloat(_arg1.@top)); }; if (((_arg1.@top.length()) && (_arg1.@height.length()))){ _local10 = (parseFloat(_arg1.@top) + (_local8 / 2)); }; if (((_arg1.@bottom.length()) && (_arg1.@height.length()))){ _local10 = (parseFloat(_arg1.@bottom) - (_local8 / 2)); }; }; _local6.SetAsOrientedBox((_local7 / 2), (_local8 / 2), new b2Vec2(_local9, _local10), _local11); return (_local6); }; return (null); } private static function assignJointDefFromXML(_arg1:XML, _arg2:b2JointDef, _arg3:b2Body, _arg4:b2Body, _arg5:b2JointDef=null):void{ if (_arg5){ _arg2.userData = _arg5.userData; _arg2.body1 = _arg5.body1; _arg2.body2 = _arg5.body2; _arg2.collideConnected = _arg5.collideConnected; if ((((_arg5 is b2GearJointDef)) && ((_arg2 is b2GearJointDef)))){ (_arg2 as b2GearJointDef).joint1 = (_arg5 as b2GearJointDef).joint1; (_arg2 as b2GearJointDef).joint2 = (_arg5 as b2GearJointDef).joint2; }; }; _arg2.body1 = _arg3; _arg2.body2 = _arg4; var _local6:b2Vec2 = loadVec2(_arg1.attribute("local-anchor1")); var _local7:b2Vec2 = loadVec2(_arg1.attribute("local-anchor2")); var _local8:b2Vec2 = loadVec2(_arg1.attribute("world-anchor1")); var _local9:b2Vec2 = loadVec2(_arg1.attribute("world-anchor2")); var _local10:b2Vec2 = loadVec2(_arg1.attribute("world-anchor")); if (_local10){ _local9 = _local10; _local8 = _local9; }; if (_local8){ _local6 = _arg2.body1.GetLocalPoint(_local8); }; if (_local9){ _local7 = _arg2.body2.GetLocalPoint(_local9); }; if (!_local6){ _local6 = new b2Vec2(); }; if (!_local7){ _local7 = new b2Vec2(); }; if ((_arg2 is b2DistanceJointDef)){ (_arg2 as b2DistanceJointDef).localAnchor1 = _local6; (_arg2 as b2DistanceJointDef).localAnchor2 = _local7; }; if ((_arg2 is b2PrismaticJointDef)){ (_arg2 as b2PrismaticJointDef).localAnchor1 = _local6; (_arg2 as b2PrismaticJointDef).localAnchor2 = _local7; }; if ((_arg2 is b2RevoluteJointDef)){ (_arg2 as b2RevoluteJointDef).localAnchor1 = _local6; (_arg2 as b2RevoluteJointDef).localAnchor2 = _local7; }; if ((_arg2 is b2PulleyJointDef)){ (_arg2 as b2PulleyJointDef).localAnchor1 = _local6; (_arg2 as b2PulleyJointDef).localAnchor2 = _local7; }; if (_arg1.@collideConnected.length()){ _arg2.collideConnected = (_arg1.@collideConnected == "true"); }; } public static function loadVec2(_arg1:XMLList, _arg2:b2Vec2=null):b2Vec2{ var a:Array; var attribute = _arg1; var defacto = _arg2; try { a = String(attribute).split(/\s+/); return (b2Vec2.Make.apply(null, a)); } catch(error:Error) { }; return (defacto); } public static function loadFloat(_arg1:XMLList, _arg2:Number):Number{ var attribute = _arg1; var defacto = _arg2; try { if (attribute.length()){ return (parseFloat(attribute)); }; } catch(error:Error) { }; return (defacto); } public static function loadBody(_arg1:XML, _arg2:b2World, _arg3:b2BodyDef=null, _arg4:b2ShapeDef=null):b2Body{ var _local5:b2ShapeDef; var _local10:XML; var _local6:b2BodyDef = loadBodyDef(_arg1, _arg3); if (!_local6){ return (null); }; if (_local6.userData == "terrain"){ _local5 = loadShapeDef(_arg1.children()[0], _arg4); if (_local5){ Terrain.getInstance().addBody(_local6, _local5); return (null); }; }; var _local7:Boolean; var _local8:Boolean; var _local9:b2Body = _arg2.CreateBody(_local6); for each (_local10 in _arg1.*) { _local5 = loadShapeDef(_local10, _arg4); if (_local5){ _local9.CreateShape(_local5); }; _local7 = ((_local7) || (_local5.isSensor)); _local8 = ((_local8) || (_local5.density)); }; if (!_arg1.@mass.length()){ _local9.SetMassFromShapes(); }; if (_local6.userData == "avatar"){ Terrain.getInstance().registerMoveableBody(new Avatar(_local9, _local6, _local5)); } else { if ((_local6.userData is String)){ if (_local6.userData.indexOf("enemy1") != -1){ Terrain.getInstance().registerMoveableBody(new Enemy1(_local9, _local6, _local5)); } else { if (_local6.userData.indexOf("enemy2") != -1){ Terrain.getInstance().registerMoveableBody(new Enemy2(_local9, _local6, _local5)); } else { if (_local6.userData.indexOf("enemy3") != -1){ Terrain.getInstance().registerMoveableBody(new Enemy3(_local9, _local6, _local5)); } else { if (_local6.userData == "barrel"){ Terrain.getInstance().registerMoveableBody(new Barrel(_local9)); } else { if (_local6.userData.indexOf("treasure") != -1){ Terrain.getInstance().registerProp(new Treasure(_local9)); } else { if (_local6.userData.indexOf("crumblingBlock") != -1){ Terrain.getInstance().registerProp(new CrumblingBlock(_local9)); } else { if (_local6.userData.indexOf("crumblingBridge") != -1){ Terrain.getInstance().registerProp(new CrumblingBridge(_local9)); } else { if (_local6.userData.indexOf("beam") != -1){ Terrain.getInstance().registerMoveableBody(new Beam(_local9)); } else { if (_local6.userData == "cutSceneFloor"){ Terrain.getInstance().registerMoveableBody(new MoveableBody(_local9)); } else { if (_local6.userData == "cutSceneWall"){ Terrain.getInstance().registerMoveableBody(new MoveableBody(_local9)); }; }; }; }; }; }; }; }; }; }; } else { if (((_local8) && (!(_local7)))){ Terrain.getInstance().registerMoveableBody(new MoveableBody(_local9)); }; }; }; return (_local9); } public static function loadInt(_arg1:XMLList, _arg2:int):int{ var attribute = _arg1; var defacto = _arg2; try { if (attribute.length()){ return (parseInt(attribute)); }; } catch(error:Error) { }; return (defacto); } private static function assignShapeDefFromXML(_arg1:XML, _arg2:b2ShapeDef, _arg3:b2ShapeDef=null):void{ var _local4:String; if (_arg3){ _arg2.density = _arg3.density; _arg2.filter = _arg3.filter.Copy(); _arg2.friction = _arg3.friction; _arg2.isSensor = _arg3.isSensor; _arg2.restitution = _arg3.restitution; _arg2.userData = _arg3.userData; }; if (_arg1.@density.length()){ _local4 = _arg1.@density.toString().toLowerCase(); switch (_local4){ case "": case "default": break; default: _arg2.density = parseFloat(_arg1.@density); }; }; _arg2.restitution = loadFloat(_arg1.@restitution, _arg2.restitution); _arg2.friction = loadFloat(_arg1.@friction, _arg2.friction); _arg2.isSensor = loadBool(_arg1.@isSensor, _arg2.isSensor); if (_arg1.@userData.length()){ _arg2.userData = _arg1.@userData; }; _arg2.filter.categoryBits = loadInt(_arg1.@categoryBits, _arg2.filter.categoryBits); _arg2.filter.maskBits = loadInt(_arg1.@maskBits, _arg2.filter.maskBits); _arg2.filter.groupIndex = loadInt(_arg1.@groupIndex, _arg2.filter.groupIndex); } public static function loadWorld(_arg1:XML, _arg2:b2World, _arg3:b2BodyDef=null, _arg4:b2ShapeDef=null, _arg5:b2JointDef=null):Function{ var idMapping:Object; var element:XML; var body:b2Body; var jd:b2JointDef; var joint:b2Joint; var xml = _arg1; var world = _arg2; var bodyDef = _arg3; var shapeDef = _arg4; var jointDef = _arg5; idMapping = {}; var resolver:Function = function (_arg1:String){ return (idMapping[_arg1]); }; for each (element in xml.*) { if (element.localName() == "body"){ body = loadBody(element, world, bodyDef, shapeDef); if (element.@id.length()){ idMapping[String(element.@id)] = body; }; } else { jd = loadJointDef(element, resolver, jointDef); joint = world.CreateJoint(jd); if (element.@id.length()){ idMapping[String(element.@id)] = joint; }; }; }; return (resolver); } public static function loadBodyDef(_arg1:XML, _arg2:b2BodyDef=null):b2BodyDef{ var _local3:b2BodyDef = new b2BodyDef(); if (_arg2){ _local3.allowSleep = _arg2.allowSleep; _local3.angle = _arg2.angle; _local3.angularDamping = _arg2.angularDamping; _local3.fixedRotation = _arg2.fixedRotation; _local3.isBullet = _arg2.isBullet; _local3.isSleeping = _arg2.isSleeping; _local3.linearDamping = _arg2.linearDamping; _local3.massData.center = _arg2.massData.center.Copy(); _local3.massData.I = _arg2.massData.I; _local3.massData.mass = _arg2.massData.mass; _local3.position = _arg2.position.Copy(); _local3.userData = _arg2.userData; }; _local3.allowSleep = loadBool(_arg1.@allowSleep, _local3.allowSleep); _local3.angle = loadFloat(_arg1.@angle, _local3.angle); _local3.angularDamping = loadFloat(_arg1.@angularDamping, _local3.angularDamping); _local3.fixedRotation = loadBool(_arg1.@fixedRotation, _local3.fixedRotation); _local3.isBullet = loadBool(_arg1.@isBullet, _local3.isBullet); _local3.isSleeping = loadBool(_arg1.@isSleeping, _local3.isSleeping); _local3.linearDamping = loadFloat(_arg1.@linearDamping, _local3.linearDamping); _local3.massData.center = loadVec2(_arg1.@center, _local3.massData.center); _local3.massData.I = loadFloat(_arg1.@I, _local3.massData.I); _local3.massData.mass = loadFloat(_arg1.@mass, _local3.massData.mass); _local3.position.x = loadFloat(_arg1.@x, _local3.position.x); _local3.position.y = loadFloat(_arg1.@y, _local3.position.y); _local3.position = loadVec2(_arg1.@position, _local3.position); if (_arg1.@userData.length()){ _local3.userData = String(_arg1.@userData); }; return (_local3); } public static function loadJointDef(_arg1:XML, _arg2:Function, _arg3:b2JointDef=null):b2JointDef{ var _local4:b2Body; var _local5:b2Body; var _local6:b2GearJointDef; var _local7:b2PrismaticJointDef; var _local8:b2Vec2; var _local9:b2Vec2; var _local10:b2RevoluteJointDef; var _local11:b2DistanceJointDef; var _local12:b2PulleyJointDef; var _local13:b2Vec2; var _local14:b2MouseJointDef; if (((_arg3) && (_arg3.body1))){ _local4 = _arg3.body1; }; if (((_arg3) && (_arg3.body2))){ _local5 = _arg3.body2; }; if (_arg1.@body1.length()){ _local4 = _arg2(String(_arg1.@body1)); }; if (_arg1.@body2.length()){ _local5 = _arg2(String(_arg1.@body2)); }; switch (_arg1.localName()){ case "gear": _local6 = new b2GearJointDef(); assignJointDefFromXML(_arg1, _local6, _local4, _local5, _arg3); _local6.collideConnected = true; _local6.ratio = loadFloat(_arg1.@ratio, 1); _local6.joint1 = _arg2(String(_arg1.@joint1)); _local6.joint2 = _arg2(String(_arg1.@joint2)); return (_local6); case "prismatic": _local7 = new b2PrismaticJointDef(); assignJointDefFromXML(_arg1, _local7, _local4, _local5, _arg3); _local7.motorSpeed = loadFloat(_arg1.@motorSpeed, _local7.motorSpeed); _local7.maxMotorForce = loadFloat(_arg1.@maxMotorForce, Number.POSITIVE_INFINITY); _local7.enableMotor = loadBool(_arg1.@enableMotor, ((_arg1.@motorSpeed.length()) || (_arg1.@maxMotorForce.length()))); _local7.lowerTranslation = loadFloat(_arg1.@lower, Number.NEGATIVE_INFINITY); _local7.upperTranslation = loadFloat(_arg1.@upper, Number.POSITIVE_INFINITY); _local7.enableLimit = loadBool(_arg1.@enableLimit, ((_arg1.@lower.length()) || (_arg1.@upper.length()))); _local7.referenceAngle = loadFloat(_arg1.@referenceAngle, (_local5.GetAngle() - _local4.GetAngle())); _local8 = loadVec2(_arg1.attribute("world-axis")); _local9 = loadVec2(_arg1.attribute("local-axis1")); if (_local8){ _local9 = _local4.GetLocalVector(_local8); }; _local9.Normalize(); _local7.localAxis1 = _local9; return (_local7); case "revolute": _local10 = new b2RevoluteJointDef(); assignJointDefFromXML(_arg1, _local10, _local4, _local5, _arg3); _local10.motorSpeed = loadFloat(_arg1.@motorSpeed, _local10.motorSpeed); _local10.maxMotorTorque = loadFloat(_arg1.@maxMotorTorque, Number.POSITIVE_INFINITY); _local10.enableMotor = loadBool(_arg1.@enableMotor, ((_arg1.@motorSpeed.lenght) || (_arg1.@maxMotorTorque.length()))); _local10.lowerAngle = loadFloat(_arg1.@lower, Number.NEGATIVE_INFINITY); _local10.upperAngle = loadFloat(_arg1.@upper, Number.POSITIVE_INFINITY); _local10.enableLimit = loadBool(_arg1.@enableLimit, ((_arg1.@lower.length()) || (_arg1.@upper.length()))); _local10.referenceAngle = loadFloat(_arg1.@referenceAngle, (_local5.GetAngle() - _local4.GetAngle())); return (_local10); case "distance": _local11 = new b2DistanceJointDef(); assignJointDefFromXML(_arg1, _local11, _local4, _local5, _arg3); _local11.dampingRatio = loadFloat(_arg1.@dampingRatio, _local11.dampingRatio); _local11.frequencyHz = loadFloat(_arg1.@frequencyHz, _local11.frequencyHz); if (_arg1.@length.length()){ _local11.length = loadFloat(_arg1.@length.length(), 0); } else { _local11.length = b2Math.SubtractVV(_local4.GetWorldPoint(_local11.localAnchor1), _local5.GetWorldPoint(_local11.localAnchor2)).Length(); }; return (_local11); case "pulley": _local12 = new b2PulleyJointDef(); assignJointDefFromXML(_arg1, _local12, _local4, _local5, _arg3); _local12.ratio = loadFloat(_arg1.@ratio, 1); _local12.maxLength1 = loadFloat(_arg1.@maxLength1, _local12.maxLength1); _local12.maxLength2 = loadFloat(_arg1.@maxLength2, _local12.maxLength2); _local12.groundAnchor1 = loadVec2(_arg1.attribute("world-ground1"), _local12.groundAnchor1); _local12.groundAnchor2 = loadVec2(_arg1.attribute("world-ground2"), _local12.groundAnchor2); _local13 = loadVec2(_arg1.attribute("world-ground")); if (_local13){ _local12.groundAnchor1 = _local13.Copy(); _local12.groundAnchor2 = _local13.Copy(); }; if (_arg1.@length1.length()){ _local12.length1 = loadFloat(_arg1.@length1, _local12.length1); } else { _local12.length1 = b2Math.SubtractVV(_local4.GetWorldPoint(_local12.localAnchor1), _local12.groundAnchor1).Length(); }; if (_arg1.@length2.length()){ _local12.length2 = loadFloat(_arg1.@length2, _local12.length2); } else { _local12.length2 = b2Math.SubtractVV(_local5.GetWorldPoint(_local12.localAnchor2), _local12.groundAnchor2).Length(); }; return (_local12); case "mouse": _local14 = new b2MouseJointDef(); assignJointDefFromXML(_arg1, _local14, _local4, _local5, _arg3); _local14.dampingRatio = loadFloat(_arg1.@dampingRatio, _local14.dampingRatio); _local14.frequencyHz = loadFloat(_arg1.@frequencyHz, _local14.frequencyHz); _local14.maxForce = loadFloat(_arg1.@maxForce, _local14.maxForce); _local14.target = loadVec2(_arg1.@target, _local14.target); return (_local14); }; return (null); } } }//package com.boristhebrave.Box2DWith
Section 79
//KeyboardNavigator (com.kerb.game.KeyboardNavigator) package com.kerb.game { import flash.events.*; import flash.display.*; import flash.utils.*; import flash.ui.*; public class KeyboardNavigator { private var stage:Stage; private var tabIndexes:Array; private var keyListenerSet:Boolean; private var controllableItems:Dictionary; private var defaultAction:Function; public function KeyboardNavigator(_arg1:Stage){ this.stage = _arg1; init(); } public function addInteractiveObject(_arg1:InteractiveObject, _arg2:Function, _arg3:int=-1):void{ controllableItems[_arg1] = _arg2; if (_arg3 > -1){ tabIndexes[_arg3] = _arg1; _arg1.tabEnabled = true; }; _arg1.tabIndex = _arg3; active = true; } protected function onKeyDown(_arg1:KeyboardEvent):void{ var _local2:Function; var _local3:int; var _local4:InteractiveObject; if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){ _local2 = controllableItems[stage.focus]; if (_local2 == null){ defaultAction(); } else { _local2(); }; } else { _local3 = -1; _local4 = null; if ((((stage.focus is InteractiveObject)) && (!((stage.focus == stage))))){ _local3 = (stage.focus as InteractiveObject).tabIndex; }; if (_local3 == -1){ } else { if (_arg1.keyCode == Keyboard.LEFT){ _local4 = getNextLowestTabIndex(_local3); if (_local4 == null){ _local4 = getHighestTabIndex(); }; } else { if (_arg1.keyCode == Keyboard.RIGHT){ _local4 = getNextHighestTabIndex(_local3); if (_local4 == null){ _local4 = getLowestTabIndex(); }; }; }; }; if (_local4){ stage.focus = _local4; }; }; } public function setDefaultAction(_arg1:Function):void{ this.defaultAction = _arg1; active = true; } public function get active():Boolean{ return (keyListenerSet); } protected function getNextLowestTabIndex(_arg1:int):InteractiveObject{ var _local2:InteractiveObject; var _local3:int = tabIndexes.length; var _local4:int = (_arg1 - 1); while (_local4 >= 0) { if (tabIndexes[_local4] != undefined){ _local2 = tabIndexes[_local4]; break; }; _local4--; }; return (_local2); } public function set active(_arg1:Boolean):void{ if (((keyListenerSet) && (!(_arg1)))){ stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); keyListenerSet = false; } else { if (((!(keyListenerSet)) && (_arg1))){ stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); keyListenerSet = true; }; }; } protected function init():void{ controllableItems = new Dictionary(); tabIndexes = new Array(); defaultAction = new Function(); stage.focus = stage; keyListenerSet = false; } protected function getHighestTabIndex():InteractiveObject{ var _local1:InteractiveObject; var _local2:int = (tabIndexes.length - 1); while (_local2 >= 0) { if (tabIndexes[_local2] != undefined){ _local1 = tabIndexes[_local2]; break; }; _local2--; }; return (_local1); } protected function getLowestTabIndex():InteractiveObject{ var _local1:InteractiveObject; var _local2:int = tabIndexes.length; var _local3:int; while (_local3 < _local2) { if (tabIndexes[_local3] != undefined){ _local1 = tabIndexes[_local3]; break; }; _local3++; }; return (_local1); } protected function getNextHighestTabIndex(_arg1:int):InteractiveObject{ var _local2:InteractiveObject; var _local3:int = tabIndexes.length; var _local4:int = (_arg1 + 1); while (_local4 < _local3) { if (tabIndexes[_local4] != undefined){ _local2 = tabIndexes[_local4]; break; }; _local4++; }; return (_local2); } public function dispose():void{ stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); controllableItems = null; tabIndexes = null; defaultAction = null; } } }//package com.kerb.game
Section 80
//ExtendedSound (com.kerb.sound.ExtendedSound) package com.kerb.sound { import flash.events.*; import flash.media.*; import flash.utils.*; public class ExtendedSound extends Sound { protected var fadeStartVolume:Number; protected var panStartPosition:Number; protected var stopAfterFade:Boolean; protected var masterVolume:Number;// = 1 protected var panTimer:Timer; protected var fadeTimer:Timer; protected var paused:Boolean; protected var fadeDuration:Number; protected var fadeStartTime:Number; protected var fadeEndVolume:Number; protected var playingLoops:Number; protected var panEndPosition:Number; protected var panStartTime:Number; protected var panDuration:Number; protected var pauseTime:Number; protected var transform:SoundTransform; protected var soundChannel:SoundChannel; private static const TIMER_UPDATE_RATE:Number = 20; public function stop():void{ stopFade(); if (soundChannel != null){ soundChannel.stop(); soundChannel.removeEventListener(Event.SOUND_COMPLETE, onSoundComplete); soundChannel = null; stopFade(); }; } protected function updatePan(_arg1:TimerEvent):void{ var _local2:Number; var _local3:Number = ((getTimer() - panStartTime) / panDuration); if (_local3 >= 1){ stopPan(); _local2 = panEndPosition; } else { if (_local3 > 0){ _local2 = ((_local3 * (panEndPosition - panStartPosition)) + panStartPosition); }; }; var _local4:Number = soundChannel.soundTransform.volume; transform = new SoundTransform(_local4, _local2); soundChannel.soundTransform = transform; } public function fadeTo(_arg1:Number, _arg2:Number):void{ if (((soundChannel) && (soundChannel.soundTransform))){ fadeStartTime = getTimer(); fadeDuration = _arg2; fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume); fadeEndVolume = _arg1; startFade(); }; } public function setMasterVolume(_arg1:Number):void{ var _local2:Number; masterVolume = Math.max(0, Math.min(1, _arg1)); if (soundChannel != null){ _local2 = soundChannel.soundTransform.pan; transform = new SoundTransform((_arg1 * masterVolume), _local2); soundChannel.soundTransform = transform; }; } protected function stopFade():void{ if (((!((fadeTimer == null))) && (fadeTimer.running))){ fadeTimer.reset(); }; } public function setVolume(_arg1:Number):void{ var _local2:Number; if (soundChannel != null){ _arg1 = Math.max(0, Math.min(1, _arg1)); _local2 = soundChannel.soundTransform.pan; transform = new SoundTransform((_arg1 * masterVolume), _local2); soundChannel.soundTransform = transform; stopFade(); }; } public function fadeOut(_arg1:Number=0):void{ if ((((((_arg1 > 0)) && (soundChannel))) && (soundChannel.soundTransform))){ fadeStartTime = getTimer(); fadeDuration = _arg1; fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume); fadeEndVolume = 0; stopAfterFade = true; startFade(); } else { stop(); }; } override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{ if (_arg3 != null){ _arg3.volume = (_arg3.volume * masterVolume); } else { _arg3 = new SoundTransform(masterVolume); }; soundChannel = super.play(_arg1, _arg2, _arg3); if (soundChannel != null){ soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete); }; playingLoops = _arg2; transform = _arg3; paused = false; return (soundChannel); } protected function stopPan():void{ if (((!((panTimer == null))) && (panTimer.running))){ panTimer.reset(); }; } public function fadeIn(_arg1:Number=0, _arg2:Number=1, _arg3:Number=0, _arg4:int=0, _arg5:Number=0):SoundChannel{ fadeStartVolume = Math.max(0, Math.min(1, _arg1)); play(_arg5, _arg4, new SoundTransform((fadeStartVolume * masterVolume))); if (_arg3 > 0){ fadeStartTime = getTimer(); fadeDuration = _arg3; fadeEndVolume = Math.max(0, Math.min(1, _arg2)); startFade(); }; return (soundChannel); } protected function onSoundComplete(_arg1:Event):void{ dispatchEvent(_arg1); } public function get position():Number{ if (soundChannel == null){ return (0); }; return (soundChannel.position); } protected function startPan():void{ if (panTimer == null){ panTimer = new Timer(TIMER_UPDATE_RATE); panTimer.addEventListener(TimerEvent.TIMER, updatePan); }; stopPan(); panTimer.start(); } public function setPan(_arg1:Number):void{ var _local2:Number; if (soundChannel != null){ _arg1 = Math.max(-1, Math.min(1, _arg1)); _local2 = soundChannel.soundTransform.volume; transform = new SoundTransform(_local2, _arg1); soundChannel.soundTransform = transform; stopPan(); }; } protected function updateFade(_arg1:TimerEvent):void{ var _local2:Number; var _local3:Number = ((getTimer() - fadeStartTime) / fadeDuration); if (_local3 >= 1){ if (stopAfterFade){ stopAfterFade = false; stop(); } else { stopFade(); }; _local2 = fadeEndVolume; return; } else { if (_local3 > 0){ _local2 = ((_local3 * (fadeEndVolume - fadeStartVolume)) + fadeStartVolume); }; }; var _local4:Number = soundChannel.soundTransform.pan; transform = new SoundTransform((_local2 * masterVolume), _local4); soundChannel.soundTransform = transform; } public function getSoundChannel():SoundChannel{ return (soundChannel); } override public function toString():String{ var _local1:String = getQualifiedClassName(this); if (soundChannel != null){ _local1 = (_local1 + ((" vol[" + (soundChannel.soundTransform.volume / masterVolume)) + "]")); _local1 = (_local1 + ((" pan[" + soundChannel.soundTransform.pan) + "]")); }; return (_local1); } public function pause():void{ if (soundChannel == null){ return; }; pauseTime = soundChannel.position; stop(); } public function panTo(_arg1:Number, _arg2:Number):void{ if (_arg2 > 0){ panStartTime = getTimer(); panDuration = _arg2; panStartPosition = soundChannel.soundTransform.pan; panEndPosition = _arg1; startPan(); } else { setPan(_arg1); }; } public function unpause():void{ play(pauseTime, playingLoops, transform); } protected function startFade():void{ if (fadeTimer == null){ fadeTimer = new Timer(TIMER_UPDATE_RATE); fadeTimer.addEventListener(TimerEvent.TIMER, updateFade); }; stopFade(); fadeTimer.start(); } } }//package com.kerb.sound
Section 81
//SoundManager (com.kerb.sound.SoundManager) package com.kerb.sound { import flash.utils.*; public class SoundManager { private var sounds:Array; private var prevMasterVolume:Number; private var muteState:Boolean;// = false private var masterVolume:Number;// = 1 public function SoundManager(){ prevMasterVolume = masterVolume; sounds = new Array(); super(); } public function unregisterSound(_arg1:String):void{ if (sounds[_arg1] != null){ sounds[_arg1].stop(); sounds[_arg1] = null; }; } public function stopAllSounds():void{ var _local1:String; for (_local1 in sounds) { sounds[_local1].stop(); }; } public function setMasterVolume(_arg1:Number):void{ var _local2:String; prevMasterVolume = masterVolume; masterVolume = Math.max(0, Math.min(1, _arg1)); for (_local2 in sounds) { sounds[_local2].setMasterVolume(masterVolume); }; } public function get muted():Boolean{ return (muteState); } public function registerSound(_arg1:ExtendedSound, _arg2:String=null, _arg3:Boolean=false):void{ if (_arg2 == null){ _arg2 = getQualifiedClassName(_arg1); }; if (sounds[_arg2] != null){ if (_arg3){ unregisterSound(_arg2); } else { throw (new Error((("Class name conflict: A sound with the class name [" + _arg2) + "] already exists in SoundManager."))); }; }; sounds[_arg2] = _arg1; _arg1.setMasterVolume(masterVolume); } public function unmute():void{ if (muteState){ muteState = false; setMasterVolume(prevMasterVolume); }; } public function getSoundByClassName(_arg1:String):ExtendedSound{ return (sounds[_arg1]); } public function mute():void{ if (!muteState){ muteState = true; setMasterVolume(0); }; } public function toString():String{ var _local2:String; var _local1 = "====================\n"; _local1 = (_local1 + "SoundManager\n"); _local1 = (_local1 + "--------------------\n"); _local1 = (_local1 + (("master vol[" + masterVolume) + "]\n")); _local1 = (_local1 + "--------------------"); for (_local2 in sounds) { _local1 = (_local1 + ("\n" + sounds[_local2].toString())); }; _local1 = (_local1 + "\n===================="); return (_local1); } } }//package com.kerb.sound
Section 82
//DoubleQuick (com.kerb.tracking.DoubleQuick) package com.kerb.tracking { import flash.events.*; import flash.display.*; import flash.net.*; import flash.utils.*; public class DoubleQuick { private static const SO_SESSION_PROPERTY_NAME:String = "sessionkey"; private static const SO_NAME:String = "doublequick"; private static const TICKER_PERIOD:Number = 30000; private static const TRACKER_SESSION_URL:String = "http://doublequick.kerb.co.uk/tracking/session.htm"; private static const TICKER_URL:String = "http://doublequick.kerb.co.uk/tracking/ticker.htm"; private static const TRACKER_URL:String = "http://doublequick.kerb.co.uk/tracking/trackflash.htm"; private static const SO_EXPIRY_PROPERTY_NAME:String = "expo"; private static var tickerURL:URLRequest = null; private static var initialised:Boolean = false; private static var queue:Array = new Array(); private static var projectId:Number; private static var baseurl:String; private static var dq:DoubleQuick; private static var traceEvents:Boolean; public function startTimer():void{ var _local1:Timer = new Timer(TICKER_PERIOD, 0); _local1.start(); _local1.addEventListener(TimerEvent.TIMER, pingProxy); } public function pingProxy(_arg1:TimerEvent):void{ DoubleQuick.ping(); } private static function doTrace(_arg1:String):void{ if (traceEvents){ trace(_arg1); }; } public static function event(_arg1:Number):void{ var loader:URLLoader; var request:URLRequest; var watchId = _arg1; if (!initialised){ doTrace((("DoubleQuick event " + watchId) + " queued")); queue.push(watchId); } else { doTrace(("DoubleQuick event " + watchId)); loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.VARIABLES; loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener); request = generateURL(watchId); request.method = URLRequestMethod.GET; try { loader.load(request); } catch(error:Error) { }; }; } public static function click(_arg1:Number, _arg2:String=null):void{ doTrace(("DoubleQuick clickThrough " + _arg1)); navigateToURL(generateURL(_arg1), _arg2); } private static function dummyListener(_arg1:Event):void{ } private static function onInit(_arg1:Event):void{ var _local4:Date; var _local2:URLLoader = URLLoader(_arg1.target); var _local3:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME); if (((!((_local2.data["sessionkey"] == ""))) && (!((_local2.data["sessionkey"] == null))))){ doTrace(("DoubleQuick acquired session key " + _local2.data["sessionkey"])); _local3.setProperty(DoubleQuick.SO_SESSION_PROPERTY_NAME, _local2.data["sessionkey"]); _local4 = new Date((new Date().getTime() + ((_local2.data["timeout"] * 60) * 1000))); _local3.setProperty(DoubleQuick.SO_EXPIRY_PROPERTY_NAME, _local4); }; DoubleQuick.initialisationFinished(); } public static function init(_arg1:DisplayObject, _arg2:Number, _arg3:Boolean=true):void{ var loader:URLLoader; var request:URLRequest; var root = _arg1; var _projectId = _arg2; var _traceEvents = _arg3; projectId = _projectId; traceEvents = _traceEvents; baseurl = root.loaderInfo.url; doTrace(((("DoubleQuick initialising with project " + projectId) + " and baseurl ") + baseurl)); var so:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME); var isExpired:Boolean; var currentDate:Date = new Date(); if (currentDate < so.data[DoubleQuick.SO_EXPIRY_PROPERTY_NAME]){ isExpired = false; }; if ((((so.data[DoubleQuick.SO_SESSION_PROPERTY_NAME] == undefined)) || (isExpired))){ doTrace("DoubleQuick requesting new session key"); loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.VARIABLES; loader.addEventListener(Event.COMPLETE, onInit); loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener); request = new URLRequest(((TRACKER_SESSION_URL + "?project=") + projectId)); request.method = URLRequestMethod.GET; try { loader.load(request); } catch(error:Error) { }; } else { DoubleQuick.initialisationFinished(); }; } public static function initialisationFinished():void{ doTrace("DoubleQuick initialised"); initialised = true; var _local1:int; while (_local1 < queue.length) { event(queue[_local1]); _local1++; }; queue = new Array(); var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME); tickerURL = new URLRequest(((((TICKER_URL + "?project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME])); tickerURL.method = URLRequestMethod.GET; dq = new (DoubleQuick); dq.startTimer(); } public static function ping():void{ var loader:URLLoader; if (tickerURL != null){ loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.VARIABLES; loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener); doTrace("DoubleQuick ticker"); try { loader.load(tickerURL); } catch(error:Error) { }; }; } private static function generateURL(_arg1:Number):URLRequest{ var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME); var _local3:String = ((((((((TRACKER_URL + "?watch=") + _arg1) + "&project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]) + "&baseurl=") + escape(baseurl)); return (new URLRequest(_local3)); } } }//package com.kerb.tracking
Section 83
//WebTrends (com.kerb.tracking.WebTrends) package com.kerb.tracking { import flash.events.*; import flash.display.*; import flash.net.*; public class WebTrends { private static var trackurl:String; private static var baseurl:String; private static var traceEvents:Boolean; public static function init(_arg1:DisplayObject, _arg2:String, _arg3:String, _arg4:String="", _arg5:Boolean=true):void{ var _local7:String; var _local8:String; traceEvents = _arg5; baseurl = _arg1.loaderInfo.url; trackurl = ""; if (_arg2.indexOf("://") == -1){ trackurl = (trackurl + "http://"); }; trackurl = (trackurl + (((_arg2 + "/") + _arg3) + "/dcs.gif?")); if (_arg4 != ""){ trackurl = (trackurl + (("WT.mc_id=" + escape(_arg4)) + "&")); }; var _local6:Array = baseurl.match("(.*?)://([^/:]+).*"); if (_local6 != null){ _local7 = _local6[1]; _local8 = _local6[2]; if (_local7.toLowerCase() != "file"){ trackurl = (trackurl + (("dcssip=" + escape(_local8)) + "&")); }; }; doTrace(((("WebTrends initialised with trackurl " + trackurl) + " and baseurl ") + baseurl)); } private static function doTrace(_arg1:String):void{ if (traceEvents){ trace(_arg1); }; } public static function event(_arg1:String, _arg2:String):void{ var uri = _arg1; var title = _arg2; doTrace(("WebTrends event " + uri)); var url:String = ((((trackurl + "dcsuri=") + escape(uri)) + "&WT.ti=") + escape(title)); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dummyListener); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); try { loader.load(new URLRequest(url)); } catch(e:Error) { doTrace(("WebTrends Error : " + e)); }; } private static function dummyListener(_arg1:Event):void{ } private static function ioErrorHandler(_arg1:IOErrorEvent):void{ doTrace(("WebTrends IOError : " + _arg1)); } } }//package com.kerb.tracking
Section 84
//DynamicButton (com.kerb.ui.DynamicButton) package com.kerb.ui { import flash.events.*; import flash.display.*; import com.kerb.utils.*; public class DynamicButton extends EventDispatcher { protected var select:MovieClip; protected var labelID:String; protected var over:MovieClip; protected var mc:MovieClip; protected var up:MovieClip; protected var down:MovieClip; protected var label:String; public function DynamicButton(_arg1:MovieClip, _arg2:String="", _arg3:Boolean=true){ this.mc = _arg1; this.labelID = _arg2; if (_arg1 == null){ throw (new Error("Null movieclip passed to DynamicButton")); }; if ((((((((_arg1.up == null)) || ((_arg1.down == null)))) || ((_arg1.over == null)))) || ((_arg1.hit == null)))){ throw (new Error((("Button " + _arg1) + " does not have all states"))); }; _arg1.addEventListener(MouseEvent.CLICK, onClick, false, 0, _arg3); _arg1.addEventListener(MouseEvent.ROLL_OVER, onRollOver, false, 0, _arg3); _arg1.addEventListener(MouseEvent.ROLL_OUT, onRollOut, false, 0, _arg3); _arg1.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, _arg3); _arg1.buttonMode = true; _arg1.mouseChildren = false; _arg1.hitArea = _arg1.hit; _arg1.hit.visible = false; _arg1.hit.mouseEnabled = false; up = _arg1.up; over = _arg1.over; down = _arg1.down; select = _arg1.select; initText(); _arg1.removeChild(over); _arg1.removeChild(down); if (select != null){ _arg1.removeChild(select); }; } public function enable():void{ mc.mouseEnabled = true; } private function onMouseDown(_arg1:MouseEvent):void{ if (up.parent){ mc.removeChild(up); }; if (over.parent){ mc.removeChild(over); }; if (!down.parent){ mc.addChild(down); }; down.gotoAndPlay(1); dispatchEvent(_arg1); } public function get name():String{ return (mc.name); } public function initText():void{ if (labelID != ""){ if (up.label_txt){ TextManager.getInstance().setTextField(up.label_txt, labelID); }; if (over.label_txt){ TextManager.getInstance().setTextField(over.label_txt, labelID); }; if (down.label_txt){ TextManager.getInstance().setTextField(down.label_txt, labelID); }; if (((select) && (select.label_txt))){ TextManager.getInstance().setTextField(select.label_txt, labelID); }; }; } public function dispose():void{ mc.removeEventListener(MouseEvent.CLICK, onClick); mc.removeEventListener(MouseEvent.ROLL_OVER, onRollOver); mc.removeEventListener(MouseEvent.ROLL_OUT, onRollOut); mc.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); } public function set visible(_arg1:Boolean):void{ mc.visible = _arg1; } public function get alpha():Number{ return (mc.alpha); } private function onClick(_arg1:MouseEvent):void{ dispatchEvent(_arg1); } private function onRollOver(_arg1:MouseEvent):void{ if (up.parent){ mc.removeChild(up); }; if (!over.parent){ mc.addChild(over); }; if (down.parent){ mc.removeChild(down); }; over.gotoAndPlay(1); dispatchEvent(_arg1); } private function onRollOut(_arg1:MouseEvent):void{ if (!up.parent){ mc.addChild(up); }; if (over.parent){ mc.removeChild(over); }; if (down.parent){ mc.removeChild(down); }; up.gotoAndPlay(1); dispatchEvent(_arg1); } public function get mcRef():MovieClip{ return (mc); } public function set selected(_arg1:Boolean):void{ if (!select){ return; }; if (_arg1){ mc.mouseEnabled = false; up.visible = false; down.visible = false; over.visible = false; if (!select.parent){ mc.addChild(select); }; } else { mc.mouseEnabled = true; up.visible = true; down.visible = true; over.visible = true; if (select.parent){ mc.removeChild(select); }; }; } public function disable():void{ mc.mouseEnabled = false; } public function get visible():Boolean{ return (mc.visible); } public function set alpha(_arg1:Number):void{ mc.alpha = _arg1; } } }//package com.kerb.ui
Section 85
//AbstractEnemy (com.kerb.uncharted.game.characters.AbstractEnemy) package com.kerb.uncharted.game.characters { import flash.display.*; import com.kerb.uncharted.*; import flash.geom.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.projectiles.*; import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import com.kerb.uncharted.game.render.*; import Box2D.Common.Math.*; public class AbstractEnemy extends Character { protected var pt:Point; protected var animation:MovieClip; protected var gunFlash:MovieClip; protected var framesSinceLastShot:int; protected var rayShape:b2Shape; public var activationPoint:Number; protected var prevState:String; protected var goalFrame:int; protected var prevFunc:Function; protected var raySegment:b2Segment; protected var walkMinX:Number; public var canWalk:Boolean; protected var updateFunction:Function; protected var lambda:Array; protected var headPos:b2Vec2; protected var pos:b2Vec2; protected var walkMaxX:Number; protected var idle:Boolean; protected var fireCounter:int; public var machineGunAmmo:int; public var pistolAmmo:int; protected var canTurn:Boolean; protected var maxLineOfSight:Number;// = 10 protected var animations:Array; protected var normal:b2Vec2; protected var walkGoal:Number; protected var currState:String; protected static const WALK_SPEED:Number = 0.07; protected static const ANGLE_2_GUN_FRAME:Number = 15.9154943091895; protected static const GUN_FRAME_2_ANGLE:Number = 0.0628318530717959; public function AbstractEnemy(_arg1:b2Body, _arg2:b2BodyDef, _arg3:b2ShapeDef, _arg4:String){ var _local7:MovieClip; var _local8:String; pt = new Point(); pos = new b2Vec2(); var _local5:Array = _arg1.GetUserData().split("_"); pistolAmmo = parseInt(_local5[1]); machineGunAmmo = parseInt(_local5[2]); super(_arg1, _arg2, _arg3); activationPoint = (_arg1.GetPosition().x - 12); mc = Main.afm.createMovieClip("enemies", _arg4); animations = []; var _local6:int = mc.numChildren; while (--_local6 > -1) { _local7 = MovieClip(mc.getChildAt(_local6)); _local8 = _local7.name; animations[_local8] = _local7; mc.removeChild(_local7); }; gunFlash = Main.afm.createMovieClip("graphics", "GunFlashAsset"); gunFlash.scaleX = (gunFlash.scaleY = 0.23); mc.addChild(gunFlash); currState = "stand"; animation = animations[currState]; animation.stop(); mc.addChild(animation); updateFunction = updateStand; fireCounter = 0; raySegment = new b2Segment(); headPos = new b2Vec2(0, -0.6); lambda = [1]; normal = new b2Vec2(); goalFrame = 1; canTurn = true; canWalk = false; idle = true; framesSinceLastShot = 0; } override public function die():void{ setState("die", updateDie); super.die(); Main.smSFX.getSoundByClassName("DeathSound").play(); } override public function damage(_arg1:int):void{ super.damage(_arg1); canTurn = true; if (updateFunction != updateHit){ prevState = currState; prevFunc = updateFunction; setState("hit", updateHit); }; } protected function updateHit():void{ if (mc.currentFrame == mc.totalFrames){ setState(prevState, prevFunc); }; } protected function updateStand():void{ if (((idle) && ((Math.random() < 0.005)))){ goalFrame = (int((Math.random() * animation.totalFrames)) + 1); }; var _local1:Number = 0.3; var _local2:int = animation.currentFrame; var _local3:int = (goalFrame - _local2); if (_local3 > 50){ _local3 = (_local3 - 100); } else { if (_local3 < -50){ _local3 = (_local3 + 100); }; }; _local2 = (_local2 + (_local1 * _local3)); _local2 = int(((_local2 + 100) % 100)); if (_local2 != animation.currentFrame){ animation.gotoAndStop(_local2); }; } protected function fireGun(_arg1:Physics, _arg2:Number, _arg3:Number):Bullet{ return (null); } protected function updateWalk():void{ pos.x = body.GetPosition().x; pos.y = body.GetPosition().y; if (pos.x > walkGoal){ if (mc.scaleX != -1){ mc.scaleX = -1; }; pos.x = (pos.x - WALK_SPEED); body.SetXForm(pos, 0); if (pos.x <= walkGoal){ walkGoal = ((walkGoal)==walkMinX) ? walkMaxX : walkMinX; }; } else { if (pos.x < walkGoal){ if (mc.scaleX != 1){ mc.scaleX = 1; }; pos.x = (pos.x + WALK_SPEED); body.SetXForm(pos, 0); if (pos.x >= walkGoal){ walkGoal = ((walkGoal)==walkMinX) ? walkMaxX : walkMinX; }; }; }; } public function ai(_arg1:Avatar, _arg2:Physics, _arg3:Graphics=null):Bullet{ var _local4:Number; var _local5:Number; var _local6:Bullet; var _local7:Number; var _local8:Number; _local4 = (_arg1.body.GetPosition().x - body.GetPosition().x); _local5 = (_arg1.body.GetPosition().y - body.GetPosition().y); if (updateFunction == updateStand){ if (((canTurn) && ((((((_local4 > 0)) && ((mc.scaleX < 0)))) || ((((_local4 < 0)) && ((mc.scaleX > 0)))))))){ mc.scaleX = -(mc.scaleX); _local4 = -(_local4); }; }; if ((((((_local4 < 0)) && ((mc.scaleX < 0)))) || ((((_local4 > 0)) && ((mc.scaleX > 0)))))){ canTurn = true; lambda[0] = 1; normal.SetZero(); raySegment.p1.SetV(body.GetWorldPoint(headPos)); raySegment.p2.SetV(_arg1.getHeadPosition()); rayShape = body.GetWorld().RaycastOne(raySegment, lambda, normal, false, null); if (rayShape){ if (rayShape.GetBody().GetUserData() == _arg1){ idle = false; _local7 = Math.atan2(_local5, (mc.scaleX * _local4)); goalFrame = (((100 - (ANGLE_2_GUN_FRAME * _local7)) % 100) + 1); _local4 = (mc.scaleX * (raySegment.p2.x - raySegment.p1.x)); _local5 = (raySegment.p2.y - raySegment.p1.y); _local8 = (lambda[0] * Math.sqrt(((_local4 * _local4) + (_local5 * _local5)))); if (_local8 <= maxLineOfSight){ if (updateFunction != updateStand){ setState("stand", updateStand); }; animation.gotoAndStop(goalFrame); _local6 = fireGun(_arg2, raySegment.p2.x, raySegment.p2.y); } else { if (((canWalk) && (!((updateFunction == updateWalk))))){ setState("walk", updateWalk); }; }; framesSinceLastShot = 0; } else { if (framesSinceLastShot++ > 100){ if (((canWalk) && (!((updateFunction == updateWalk))))){ setState("walk", updateWalk); }; }; }; } else { if (framesSinceLastShot++ > 100){ if (((canWalk) && (!((updateFunction == updateWalk))))){ setState("walk", updateWalk); }; }; }; }; return (_local6); } public function setWalkLimits(_arg1:Number, _arg2:Number):void{ canWalk = true; walkMinX = _arg1; walkMaxX = _arg2; walkGoal = ((Math.random())<0.5) ? _arg1 : _arg2; } override public function update():void{ super.update(); fireCounter++; updateFunction(); } protected function firePistol(_arg1:Physics, _arg2:Number, _arg3:Number):Bullet{ var _local4:Number = (GUN_FRAME_2_ANGLE * (100 - animation.currentFrame)); pt.x = 0; pt.y = 0; pt = animation.gun.localToGlobal(pt); pt = mc.globalToLocal(pt); gunFlash.x = pt.x; gunFlash.y = pt.y; gunFlash.rotation = (_local4 * Constants.RAD_2_DEG); if (gunFlash.currentFrame == 1){ gunFlash.play(); } else { gunFlash.gotoAndPlay(1); }; if (mc.scaleX < 0){ _local4 = (_local4 + Math.PI); }; var _local5:b2Vec2 = body.GetPosition().Copy(); body.GetPosition().Copy().x = (_local5.x + ((mc.scaleX * pt.x) * Renderer.INVERSE_RENDER_SCALE)); _local5.y = (_local5.y + (pt.y * Renderer.INVERSE_RENDER_SCALE)); _arg2 = (_arg2 - _local5.x); _arg3 = (_arg3 - _local5.y); _local4 = Math.atan2(_arg3, _arg2); _local4 = (_local4 + ((Math.random() * 0.2) - 0.1)); return (new PistolBullet(_arg1, _local5, _local4, this)); } protected function fireMachineGun(_arg1:Physics, _arg2:Number, _arg3:Number):Bullet{ var _local4:Number; _local4 = (GUN_FRAME_2_ANGLE * (100 - animation.currentFrame)); pt.x = 0; pt.y = 0; pt = animation.gun.localToGlobal(pt); pt = mc.globalToLocal(pt); gunFlash.x = pt.x; gunFlash.y = pt.y; gunFlash.rotation = (_local4 * Constants.RAD_2_DEG); if (gunFlash.currentFrame == 1){ gunFlash.play(); } else { gunFlash.gotoAndPlay(1); }; if (mc.scaleX < 0){ _local4 = (_local4 + Math.PI); }; var _local5:b2Vec2 = body.GetPosition().Copy(); body.GetPosition().Copy().x = (_local5.x + ((mc.scaleX * pt.x) * Renderer.INVERSE_RENDER_SCALE)); _local5.y = (_local5.y + (pt.y * Renderer.INVERSE_RENDER_SCALE)); _arg2 = (_arg2 - _local5.x); _arg3 = (_arg3 - _local5.y); _local4 = Math.atan2(_arg3, _arg2); _local4 = (_local4 + ((Math.random() * 0.2) - 0.1)); return (new MachineGunBullet(_arg1, _local5, _local4, this)); } public function walk():void{ canWalk = true; setState("walk", updateWalk); } protected function setState(_arg1:String, _arg2:Function):void{ mc.removeChild(animation); animation = animations[_arg1]; mc.addChild(animation); if (animation.currentFrame != 1){ animation.gotoAndPlay(1); } else { animation.play(); }; updateFunction = _arg2; currState = _arg1; } public function checkHit(_arg1:MovieClip, _arg2:int):Boolean{ if (mc.hitTestObject(_arg1)){ damage(_arg2); return (true); }; return (false); } protected function updateNull():void{ } public function activate():void{ body = world.CreateBody(bodyDef); body.CreateShape(shapeDef); body.SetMassFromShapes(); body.SetUserData(this); } public function deactivate():void{ destroyBody(); } protected function updateDie():void{ if (mc.currentFrame == mc.totalFrames){ (updateFunction == updateNull); }; } } }//package com.kerb.uncharted.game.characters
Section 86
//Avatar (com.kerb.uncharted.game.characters.Avatar) package com.kerb.uncharted.game.characters { import flash.display.*; import com.kerb.uncharted.*; import flash.geom.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.props.*; import com.kerb.uncharted.game.projectiles.*; import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import com.kerb.uncharted.game.render.*; import Box2D.Common.Math.*; import com.kerb.uncharted.game.*; import com.kerb.uncharted.game.levels.*; import com.kerb.uncharted.game.utils.*; public class Avatar extends Character { private const rightImpulse:b2Vec2; private const jumpRightImpulse:b2Vec2; private const WEAPON_ACTIONS:Array; private const jumpLeftImpulse:b2Vec2; private const jumpImpulse:b2Vec2; private const leftImpulse:b2Vec2; private var pt:Point; private var prevBackGoalY:Number; private var weaponModifier:String; private var prevState:String; private var accurateShots:int; private var hangY:Number; private var hangX:Number; private var hanging:Boolean; protected var hangBodyDef:b2BodyDef; protected var hangShapeDef:b2PolygonDef; private var hitSoundPlayed:Boolean; private var onGround:Boolean; private var minY:Number; private var backDropDownReady:Boolean; private var backJumpUpReady:Boolean; private var pos:b2Vec2; private var initJump:Boolean; private var aabb:b2AABB; private var animations:Array; private var gunAngle:Number; private var backModeFinishing:Boolean; private var backRight:Number; private var selectedWeaponNum:int; private var currState:String; private var level:AbstractLevel; protected var crouchShapeDef:b2PolygonDef; private var direction:uint; private var animation:MovieClip; private var gunFlash:MovieClip; private var score:int; private var ui:UI; private var backGrabReady:Boolean; private var headOffset:Number; private var backLeft:Number; public var treasure:int; private var hasPistol:Boolean; private var onGroundIDs:Array; private var hasMachineGun:Boolean; private var backCurrX:Number; private var updateFunction:Function; private var swapToHangBody:Boolean; private var weaponName:String; private var backFallReady:Boolean; private var backCurrY:Number; private var ammo:Array; private var totalShots:int; protected var crouchBodyDef:b2BodyDef; private var head:b2Vec2; protected var ON_GROUND_THRESHOLD:Number;// = 0.5 private var keys:uint; private var xf:b2XForm; private var backGoalY:Number; private static const RUN_IMPULSE:Number = 0.5; private static const LANDING_THRESHOLD:Number = 1.8; private static const JUMP_IMPULSE:Number = 15; private static const HEALTH_INCREASE:Number = 0.03; private static const MELEE_DAMAGE:int = 5; private static const STEALTH_DAMAGE:int = 1000; private static const STOPPING_RATE:Number = 0.3; public static const MACHINE_GUN:int = 2; private static const JUMP_MOVE_IMPULSE:Number = 0.2; public static const PISTOL:int = 1; private static const GUN_FRAME_SCALAR:Number = 15.9154943091895; private static const TOP_BOUNCE:Array = [8.4, 7.88, 7.35, 6.64, 5.89, 5.15, 3.99, 5.37, 6.42, 7.39, 8.44, 9.45, 8.14, 7.43, 6.83, 5.56, 4.27, 5.3, 5.67, 6.12, 6.83, 7.35, 7.88]; public static const FIST:int = 0; private static const MAX_FALL_HEIGHT:Number = 12; private static const LEG_BOUNCE:Array = [10.8, 10.28, 9.75, 9.04, 8.29, 7.55, 6.39, 7.77, 8.82, 9.79, 10.84, 11.85, 10.54, 9.83, 9.23, 7.96, 6.67, 7.7, 8.07, 8.52, 9.23, 9.75, 10.28]; private static const INIT_HIT_POINTS:int = 100; private static var checkpointY:Number = 0; private static var checkpointTreasure:int = 0; private static var checkpointX:Number = 0; private static var checkpointAmmo:Array = [0, 0, 0]; public function Avatar(_arg1:b2Body, _arg2:b2BodyDef, _arg3:b2ShapeDef){ var _local5:MovieClip; var _local6:String; leftImpulse = new b2Vec2(-(RUN_IMPULSE), 0); rightImpulse = new b2Vec2(RUN_IMPULSE, 0); jumpImpulse = new b2Vec2(0, -(JUMP_IMPULSE)); jumpLeftImpulse = new b2Vec2(-(JUMP_MOVE_IMPULSE), 0); jumpRightImpulse = new b2Vec2(JUMP_MOVE_IMPULSE, 0); WEAPON_ACTIONS = [melee, firePistol, fireMachineGun]; pt = new Point(); pos = new b2Vec2(); aabb = new b2AABB(); xf = new b2XForm(); super(_arg1, _arg2, _arg3); mc = Main.afm.createMovieClip("avatar", "AvatarAsset"); animations = []; var _local4:int = mc.numChildren; while (--_local4 > -1) { _local5 = MovieClip(mc.getChildAt(_local4)); _local6 = _local5.name; animations[_local6] = _local5; mc.removeChild(_local5); }; gunFlash = Main.afm.createMovieClip("graphics", "GunFlashAsset"); gunFlash.scaleX = (gunFlash.scaleY = 0.23); mc.addChild(gunFlash); initCrouchBodyDef(); initHangBodyDef(); head = new b2Vec2(); headOffset = 0.5; hasPistol = true; hasMachineGun = true; ammo = [0, 0, 0]; selectedWeaponNum = FIST; weaponModifier = "Fist"; currState = ""; score = UserData.totalScore; keys = 0; totalShots = 0; accurateShots = 0; treasure = 0; hitPoints = INIT_HIT_POINTS; onGroundIDs = []; onGround = false; initJump = false; hanging = false; swapToHangBody = false; backGrabReady = false; backJumpUpReady = false; backDropDownReady = false; backFallReady = false; backModeFinishing = true; backGoalY = -1; direction = KeyboardControl.LEFT; animation = animations[("stand" + weaponModifier)]; mc.addChild(animation); updateFunction = updateStand; } public function autoFireWeapon(_arg1:Physics):Bullet{ if (selectedWeaponNum == MACHINE_GUN){ return (WEAPON_ACTIONS[selectedWeaponNum](_arg1)); }; return (null); } private function updateRun():void{ var _local1:int; if (body.GetLinearVelocity().x > 10){ body.GetLinearVelocity().x = 10; } else { if (body.GetLinearVelocity().x < -10){ body.GetLinearVelocity().x = -10; }; }; if (currState == "runGun"){ _local1 = (animation.legs.currentFrame - 1); animation.gunAngle.y = TOP_BOUNCE[_local1]; animation.legs.y = LEG_BOUNCE[_local1]; if (_local1 == 5){ Main.smSFX.getSoundByClassName("FootstepLeftSound").play(); } else { if (_local1 == 17){ Main.smSFX.getSoundByClassName("FootstepRightSound").play(); }; }; } else { _local1 = animation.currentFrame; if (_local1 == 11){ Main.smSFX.getSoundByClassName("FootstepLeftSound").play(); } else { if (_local1 == 23){ Main.smSFX.getSoundByClassName("FootstepRightSound").play(); }; }; }; if (!onGround){ setState(("fall" + weaponModifier), updateFall); } else { if ((keys & KeyboardControl.UP_PRESSED)){ body.ApplyImpulse(jumpImpulse, position); setState(("jump" + weaponModifier), updateJump); Main.smSFX.getSoundByClassName("JumpSound").play(); initJump = true; } else { if ((keys & KeyboardControl.LEFT_DOWN)){ if ((keys & KeyboardControl.RIGHT_DOWN)){ setState(("stand" + weaponModifier), updateStand); } else { if (direction == KeyboardControl.RIGHT){ direction = KeyboardControl.LEFT; mc.scaleX = -1; body.GetLinearVelocity().x = 0; setState(("run" + weaponModifier), updateRun); if (weaponModifier == "Gun"){ updateGun(false); }; }; body.ApplyImpulse(leftImpulse, position); }; } else { if ((keys & KeyboardControl.RIGHT_DOWN)){ if (direction == KeyboardControl.LEFT){ direction = KeyboardControl.RIGHT; mc.scaleX = 1; body.GetLinearVelocity().x = 0; setState(("run" + weaponModifier), updateRun); if (weaponModifier == "Gun"){ updateGun(false); }; }; body.ApplyImpulse(rightImpulse, position); } else { setState(("stand" + weaponModifier), updateStand); }; }; }; }; } public function blownBack():void{ if (currState != "blowUp"){ setState("blowUp", updateBlowUp); }; } private function updateBackShimmyRight():void{ if ((keys & KeyboardControl.RIGHT_DOWN)){ if (backCurrX < backRight){ backCurrX = (backCurrX + 0.05); if (backCurrX > backRight){ backCurrX = backRight; setState(("backHang" + weaponModifier), updateBackHang); }; }; } else { if ((keys & KeyboardControl.LEFT_DOWN)){ setState("backShimmy", updateBackShimmyLeft); } else { if ((keys & KeyboardControl.DOWN_PRESSED)){ } else { setState(("backHang" + weaponModifier), updateBackHang); }; }; }; position.x = backCurrX; position.y = backCurrY; body.SetXForm(position, 0); pos.x = 0; pos.y = 0; body.SetLinearVelocity(pos); } public function updateRenderOnly():void{ updateFunction(); super.update(); } private function initHangBodyDef():void{ hangBodyDef = new b2BodyDef(); hangBodyDef.angularDamping = bodyDef.angularDamping; hangBodyDef.fixedRotation = bodyDef.fixedRotation; hangBodyDef.linearDamping = bodyDef.linearDamping; hangShapeDef = new b2PolygonDef(); hangShapeDef.density = shapeDef.density; hangShapeDef.friction = shapeDef.friction; hangShapeDef.restitution = shapeDef.restitution; hangShapeDef.isSensor = true; hangShapeDef.SetAsOrientedBox(0.3, 0.5, new b2Vec2(0, 0.4), 0); } public function selectNextWeapon():void{ var _local1:int = ((selectedWeaponNum + 1) % 3); selectWeaponNum(_local1); } private function updateBlowUp():void{ if (animation.currentFrame == animation.totalFrames){ if (onGround){ body.GetLinearVelocity().y = 0; setState(("land" + weaponModifier), updateLand); } else { setState(("fall" + weaponModifier), updateFall); }; }; } private function updateSideClimb():void{ var _local1:Number = (animation.currentFrame / animation.totalFrames); pos.x = (hangX + ((_local1 * mc.scaleX) * 0.3)); pos.y = (hangY - (_local1 * 1.5)); body.SetXForm(pos, 0); if (animation.currentFrame == animation.totalFrames){ createDefaultBody(); pos.y = (pos.y + 0.675); body.SetXForm(pos, 0); setState(("stand" + weaponModifier), updateStand); coupled = true; }; } private function setBody(_arg1:b2BodyDef, _arg2:b2ShapeDef):void{ var _local3:Number = 0; var _local4:Number = 0; if (body){ _local3 = body.GetLinearVelocity().x; _local4 = body.GetLinearVelocity().y; _arg1.position = body.GetPosition().Copy(); world.DestroyBody(body); }; body = world.CreateBody(_arg1); body.CreateShape(_arg2); body.SetMassFromShapes(); body.SetUserData(this); body.GetLinearVelocity().x = _local3; body.GetLinearVelocity().y = _local4; } private function updateCrouchDown():void{ body.GetLinearVelocity().x = 0; body.GetLinearVelocity().y = 0; if ((keys & KeyboardControl.DOWN_DOWN)){ if (animation.currentFrame == animation.totalFrames){ setState(("crouch" + weaponModifier), updateCrouch); }; } else { createDefaultBody(); setState(("land" + weaponModifier), updateLand); }; } public function selectWeaponNum(_arg1:int):void{ var _local2:String; var _local3:int; if (((!(((hasMachineGun) && ((_arg1 == MACHINE_GUN))))) && (!(((hasPistol) && ((_arg1 == PISTOL))))))){ _arg1 = FIST; weaponModifier = "Fist"; if (currState.indexOf("Gun") != -1){ _local2 = (currState.substring(0, (currState.length - 3)) + weaponModifier); }; } else { weaponModifier = "Gun"; weaponName = ((_arg1)==MACHINE_GUN) ? "machineGun" : "pistol"; if (currState.indexOf("Fist") != -1){ _local2 = (currState.substring(0, (currState.length - 4)) + weaponModifier); }; }; if (_arg1 != selectedWeaponNum){ selectedWeaponNum = _arg1; ui.updateWeapon(_arg1, ammo[_arg1]); if (selectedWeaponNum == 0){ Main.smSFX.getSoundByClassName("PunchSound").play(); } else { Main.smSFX.getSoundByClassName("WeaponSelectSound").play(); }; }; if (_local2){ _local3 = animation.currentFrame; currState = _local2; mc.removeChild(animation); animation = animations[currState]; mc.addChild(animation); animation.gotoAndPlay(_local3); if (animation.gunAngle){ animation.gunAngle.stop(); }; }; } private function updateMelee():void{ body.GetLinearVelocity().x = 0; if (animation.target){ if (level.checkMeleeTarget(animation.target, MELEE_DAMAGE)){ if (!hitSoundPlayed){ hitSoundPlayed = true; Main.smSFX.getSoundByClassName("HitSound").play(); }; }; }; if (animation.currentFrame == animation.totalFrames){ setState(("stand" + weaponModifier), updateStand); hitSoundPlayed = false; }; } private function updateSideGrab():void{ pos.x = body.GetPosition().x; pos.y = body.GetPosition().y; pos.x = (pos.x + (0.5 * (hangX - body.GetPosition().x))); pos.y = (pos.y + (0.5 * (hangY - body.GetPosition().y))); body.SetXForm(pos, 0); pos.x = 0; pos.y = 0; body.SetLinearVelocity(pos); if ((keys & KeyboardControl.DOWN_PRESSED)){ hanging = false; pos.x = (position.x - (mc.scaleX * 0.3)); pos.y = (position.y + 0.5); body.SetXForm(pos, 0); createDefaultBody(); setState(("fall" + weaponModifier), updateFall); } else { if ((keys & KeyboardControl.UP_PRESSED)){ coupled = false; setState("sideClimb", updateSideClimb); }; }; } private function updateBackFall():void{ if (animation.currentFrame == animation.totalFrames){ setState(("fall" + weaponModifier), updateFall); }; } public function setLevel(_arg1:AbstractLevel):void{ this.level = _arg1; } public function getAccurateShotPercentage():Number{ return (((totalShots)==0) ? 0 : (accurateShots / totalShots)); } private function firePistol(_arg1:Physics):Bullet{ if (((!(hasPistol)) || ((ammo[PISTOL] < 1)))){ return (null); }; var _local6 = ammo; var _local7 = PISTOL; var _local8 = (_local6[_local7] - 1); _local6[_local7] = _local8; ui.updateCurrentAmmo(_local8); pt.x = 0; pt.y = 0; if (animation.gunAngle){ if (animation.gunAngle.gun){ pt = animation.gunAngle.gun.localToGlobal(pt); pt = mc.globalToLocal(pt); gunFlash.x = pt.x; gunFlash.y = pt.y; gunFlash.rotation = (gunAngle * Constants.RAD_2_DEG); if (gunFlash.currentFrame == 1){ gunFlash.play(); } else { gunFlash.gotoAndPlay(1); }; }; }; var _local2:b2Vec2 = body.GetPosition().Copy(); _local2.x = (_local2.x + ((mc.scaleX * pt.x) * Renderer.INVERSE_RENDER_SCALE)); _local2.y = (_local2.y + (pt.y * Renderer.INVERSE_RENDER_SCALE)); var _local3:Number = (mc.scaleX * (mc.mouseX - pt.x)); var _local4:Number = (mc.mouseY - pt.y); var _local5:Number = Math.atan2(_local4, _local3); Main.smSFX.getSoundByClassName("PistolSound").play(); return (new PistolBullet(_arg1, _local2, _local5, this)); } private function fireMachineGun(_arg1:Physics):Bullet{ if (((!(hasMachineGun)) || ((ammo[MACHINE_GUN] < 1)))){ return (null); }; var _local6 = ammo; var _local7 = MACHINE_GUN; var _local8 = (_local6[_local7] - 1); _local6[_local7] = _local8; ui.updateCurrentAmmo(_local8); pt.x = 0; pt.y = 0; if (animation.gunAngle){ if (animation.gunAngle.gun){ pt = animation.gunAngle.gun.localToGlobal(pt); pt = mc.globalToLocal(pt); gunFlash.x = pt.x; gunFlash.y = pt.y; gunFlash.rotation = (gunAngle * Constants.RAD_2_DEG); if (gunFlash.currentFrame == 1){ gunFlash.play(); } else { gunFlash.gotoAndPlay(1); }; }; }; var _local2:b2Vec2 = body.GetPosition().Copy(); _local2.x = (_local2.x + ((mc.scaleX * pt.x) * Renderer.INVERSE_RENDER_SCALE)); _local2.y = (_local2.y + (pt.y * Renderer.INVERSE_RENDER_SCALE)); var _local3:Number = (mc.scaleX * (mc.mouseX - pt.x)); var _local4:Number = (mc.mouseY - pt.y); var _local5:Number = Math.atan2(_local4, _local3); return (new MachineGunBullet(_arg1, _local2, _local5, this)); } public function setAmmo(_arg1:int, _arg2:int):void{ ammo[1] = (checkpointAmmo[1] = _arg1); ammo[2] = (checkpointAmmo[2] = _arg2); } public function selectPrevWeapon():void{ var _local1:int = ((selectedWeaponNum + 2) % 3); selectWeaponNum(_local1); } public function addShotStatistic(_arg1:Boolean):void{ totalShots++; if (_arg1){ accurateShots++; }; } private function setState(_arg1:String, _arg2:Function):void{ prevState = currState; currState = _arg1; mc.removeChild(animation); animation = animations[_arg1]; mc.addChild(animation); if (animation.currentFrame != 1){ animation.gotoAndPlay(1); }; if (animation.gunAngle){ animation.gunAngle.stop(); }; updateFunction = _arg2; minY = body.GetPosition().y; } private function createHangBody():void{ hangShapeDef.SetAsOrientedBox(0.3, 0.5, new b2Vec2(0, 0.4), 0); setBody(hangBodyDef, hangShapeDef); headOffset = 0; } private function updateLand():void{ body.GetLinearVelocity().x = (body.GetLinearVelocity().x * STOPPING_RATE); body.GetLinearVelocity().y = 0; if ((keys & KeyboardControl.LEFT_DOWN)){ if (!(keys & KeyboardControl.RIGHT_DOWN)){ body.ApplyImpulse(leftImpulse, position); direction = KeyboardControl.LEFT; mc.scaleX = -1; if (body.GetLinearVelocity().x > 0){ body.GetLinearVelocity().x = -(body.GetLinearVelocity().x); }; setState(("run" + weaponModifier), updateRun); if (weaponModifier == "Gun"){ updateGun(false); }; }; } else { if ((keys & KeyboardControl.RIGHT_DOWN)){ body.ApplyImpulse(rightImpulse, position); direction = KeyboardControl.RIGHT; mc.scaleX = 1; if (body.GetLinearVelocity().x < 0){ body.GetLinearVelocity().x = -(body.GetLinearVelocity().x); }; setState(("run" + weaponModifier), updateRun); if (weaponModifier == "Gun"){ updateGun(false); }; } else { if ((keys & KeyboardControl.UP_DOWN)){ if (backGrabReady){ backCurrX = position.x; backCurrY = position.y; setState("backJump", updateBackJump); Main.smSFX.getSoundByClassName("JumpSound").play(); } else { body.ApplyImpulse(jumpImpulse, position); setState(("jump" + weaponModifier), updateJump); Main.smSFX.getSoundByClassName("JumpSound").play(); initJump = true; }; } else { if (animation.currentFrame == animation.totalFrames){ setState(("stand" + weaponModifier), updateStand); }; }; }; }; } private function health():void{ if (hitPoints > 0){ hitPoints = (hitPoints + HEALTH_INCREASE); if (hitPoints > INIT_HIT_POINTS){ hitPoints = INIT_HIT_POINTS; }; ui.updateLife(hitPoints); }; } override public function onRemoveContact(_arg1:b2ContactPoint):void{ var _local2:* = _arg1.shape2.GetBody().GetUserData(); if (_local2 == "backGrab"){ backGrabReady = false; } else { if (_local2 == "backJumpUp"){ backJumpUpReady = false; } else { if (_local2 == "backDropDown"){ backDropDownReady = false; } else { if (_local2 == "backFall"){ backFallReady = false; }; }; }; }; } override public function onPersistContact(_arg1:b2ContactPoint):void{ var _local3:Number; var _local2:* = _arg1.shape2.GetBody().GetUserData(); if ((((((_arg1.normal.y >= ON_GROUND_THRESHOLD)) && (!((_local2 is Bullet))))) && (!(_arg1.shape2.IsSensor())))){ onGround = true; if ((_local2 is CrumblingBlock)){ CrumblingBlock(_local2).crumble(); } else { if ((_local2 is CrumblingBridge)){ CrumblingBridge(_local2).crumble(); }; }; }; if (_local2 == "backGrab"){ _arg1.shape2.ComputeAABB(aabb, xf); _local3 = ((_arg1.shape2.GetBody().GetPosition().y + aabb.lowerBound.y) + 0.83); if (_local3 != prevBackGoalY){ backGoalY = _local3; backLeft = (_arg1.shape2.GetBody().GetPosition().x + aabb.lowerBound.x); backRight = (_arg1.shape2.GetBody().GetPosition().x + aabb.upperBound.x); backGrabReady = true; }; } else { if (_local2 == "backJumpUp"){ backJumpUpReady = true; } else { if (_local2 == "backDropDown"){ backDropDownReady = true; } else { if (_local2 == "backFall"){ backFallReady = true; }; }; }; }; } public function setKeys(_arg1:uint):void{ this.keys = _arg1; } private function melee(_arg1:Physics):void{ if (hanging){ return; }; if (!(((currState == "standFist")) || ((currState == "runFist")))){ return; }; if ((((currState == "kick")) || ((currState == "punch")))){ return; }; if (level.stealthAttackPossible()){ setState("stealth", updateStealthAttack); } else { if (Math.random() < 0.5){ setState("punch", updateMelee); Main.smSFX.getSoundByClassName("PunchSound").play(); } else { setState("kick", updateMelee); Main.smSFX.getSoundByClassName("PunchSound").play(); }; }; } override public function onAddContact(_arg1:b2ContactPoint):void{ var _local2:* = _arg1.shape2.GetBody().GetUserData(); if ((((_local2 is Bullet)) || ((_local2 == "terrain")))){ return; }; if ((_local2 is Treasure)){ score = (score + Treasure(_local2).value); treasure = (treasure + Treasure(_local2).value); ui.updateScore(treasure); ui.showTreasureFound(); Treasure(_local2).taken = true; Main.smSFX.getSoundByClassName("TreasureSound").play(); return; }; if ((_local2 is PistolAmmoDump)){ ammo[PISTOL] = (ammo[PISTOL] + PistolAmmoDump(_local2).value); PistolAmmoDump(_local2).taken = true; ui.updateAmmo(PISTOL, ammo[PISTOL]); Main.smSFX.getSoundByClassName("AmmoSound").play(); if ((((selectedWeaponNum < PISTOL)) || ((ammo[selectedWeaponNum] == 0)))){ selectWeaponNum(PISTOL); }; } else { if ((_local2 is MachineGunAmmoDump)){ ammo[MACHINE_GUN] = (ammo[MACHINE_GUN] + MachineGunAmmoDump(_local2).value); MachineGunAmmoDump(_local2).taken = true; ui.updateAmmo(MACHINE_GUN, ammo[MACHINE_GUN]); Main.smSFX.getSoundByClassName("AmmoSound").play(); if (selectedWeaponNum < MACHINE_GUN){ selectWeaponNum(MACHINE_GUN); }; }; }; if (initJump){ return; }; if (_local2 == "backGrab"){ backGrabReady = true; _arg1.shape2.ComputeAABB(aabb, xf); backLeft = (_arg1.shape2.GetBody().GetPosition().x + aabb.lowerBound.x); backRight = (_arg1.shape2.GetBody().GetPosition().x + aabb.upperBound.x); backGoalY = ((_arg1.shape2.GetBody().GetPosition().y + aabb.lowerBound.y) + 0.83); } else { if (_local2 == "backJumpUp"){ backJumpUpReady = true; } else { if (_local2 == "backDropDown"){ backDropDownReady = true; } else { if (_local2 == "backFall"){ backFallReady = true; } else { if (_local2 == "checkpoint"){ checkpointX = body.GetPosition().x; checkpointY = body.GetPosition().y; checkpointAmmo[1] = ammo[1]; checkpointAmmo[2] = ammo[2]; checkpointTreasure = treasure; } else { if ((((((((((((((((_local2 == "leftGrab")) && ((direction == KeyboardControl.RIGHT)))) && (!((currState == "sideHangFist"))))) && (!((currState == "sideHangGun"))))) && (!((currState == "sideClimb"))))) && (!((prevState == "sideHangFist"))))) && (!((prevState == "sideHangGun"))))) && (!(hanging)))){ hanging = true; hangX = _arg1.shape2.GetBody().GetPosition().x; hangY = _arg1.shape2.GetBody().GetPosition().y; swapToHangBody = true; } else { if ((((((((((((((((_local2 == "rightGrab")) && ((direction == KeyboardControl.LEFT)))) && (!((currState == "sideHangFist"))))) && (!((currState == "sideHangGun"))))) && (!((currState == "sideClimb"))))) && (!((prevState == "sideHangFist"))))) && (!((prevState == "sideHangGun"))))) && (!(hanging)))){ hanging = true; hangX = _arg1.shape2.GetBody().GetPosition().x; hangY = _arg1.shape2.GetBody().GetPosition().y; swapToHangBody = true; } else { if (String(_local2).indexOf("cutScene") != -1){ body.GetLinearVelocity().x = 0; body.GetLinearVelocity().y = 0; level.onCutScene(String(_local2)); } else { if ((_local2 is Pillar)){ if (_arg1.normal.y < -0.75){ damage(200); }; } else { if ((_local2 is Beam)){ if ((((_arg1.normal.y < -0.75)) && ((Beam(_local2).body.GetLinearVelocity().y > 1)))){ damage(200); }; }; }; }; }; }; }; }; }; }; }; if ((((((_arg1.normal.y >= ON_GROUND_THRESHOLD)) && (!((_local2 is Bullet))))) && (!(_arg1.shape2.IsSensor())))){ onGround = true; }; } override public function die():void{ createCrouchBody(); setState("die", updateDie); Main.smSFX.getSoundByClassName("DeathSound").play(); } override public function damage(_arg1:int):void{ super.damage(_arg1); ui.updateLife(hitPoints); } public function setUI(_arg1:UI):void{ this.ui = _arg1; _arg1.updateScore(treasure); _arg1.updateLife(hitPoints); _arg1.updateWeapon(0, 0); _arg1.updateTime(0); } private function createBackBody():void{ hangShapeDef.SetAsOrientedBox(0.3, 0.5, new b2Vec2(0, -0.35), 0); setBody(hangBodyDef, hangShapeDef); headOffset = 0; } private function updateJump():void{ body.GetLinearVelocity().x = (body.GetLinearVelocity().x * 0.9); body.GetLinearVelocity().y = (body.GetLinearVelocity().y * 0.8); if (backGrabReady){ backCurrX = position.x; backCurrY = position.y; setState("backJump", updateBackJump); return; }; if (animation.currentFrame == animation.totalFrames){ setState(("fall" + weaponModifier), updateFall); }; if (((onGround) && (!(initJump)))){ body.GetLinearVelocity().y = 0; setState(("stand" + weaponModifier), updateStand); }; if ((keys & KeyboardControl.LEFT_DOWN)){ if (!(keys & KeyboardControl.RIGHT_DOWN)){ body.ApplyImpulse(jumpLeftImpulse, position); direction = KeyboardControl.LEFT; mc.scaleX = -1; if (weaponModifier == "Gun"){ updateGun(false); }; }; } else { if ((keys & KeyboardControl.RIGHT_DOWN)){ body.ApplyImpulse(jumpRightImpulse, position); direction = KeyboardControl.RIGHT; mc.scaleX = 1; if (weaponModifier == "Gun"){ updateGun(false); }; }; }; initJump = false; } public function getHeadPosition():b2Vec2{ head.x = body.GetPosition().x; head.y = (body.GetPosition().y - headOffset); return (head); } public function getCheckpointX():Number{ return (checkpointX); } private function updateStand():void{ var _local1:Number = body.GetLinearVelocity().y; body.GetLinearVelocity().x = (body.GetLinearVelocity().x * STOPPING_RATE); body.GetLinearVelocity().y = 0; if (!onGround){ if (_local1 > 0.05){ setState(("fall" + weaponModifier), updateFall); }; } else { if ((keys & KeyboardControl.UP_PRESSED)){ if (backGrabReady){ backCurrX = position.x; backCurrY = position.y; setState("backJump", updateBackJump); Main.smSFX.getSoundByClassName("JumpSound").play(); } else { body.ApplyImpulse(jumpImpulse, position); setState(("jump" + weaponModifier), updateJump); Main.smSFX.getSoundByClassName("JumpSound").play(); initJump = true; }; } else { if ((keys & KeyboardControl.LEFT_DOWN)){ if (!(keys & KeyboardControl.RIGHT_DOWN)){ body.ApplyImpulse(leftImpulse, position); direction = KeyboardControl.LEFT; mc.scaleX = -1; if (body.GetLinearVelocity().x > 0){ body.GetLinearVelocity().x = -(body.GetLinearVelocity().x); }; setState(("run" + weaponModifier), updateRun); if (weaponModifier == "Gun"){ updateGun(false); }; }; } else { if ((keys & KeyboardControl.RIGHT_DOWN)){ body.ApplyImpulse(rightImpulse, position); direction = KeyboardControl.RIGHT; mc.scaleX = 1; if (body.GetLinearVelocity().x < 0){ body.GetLinearVelocity().x = -(body.GetLinearVelocity().x); }; setState(("run" + weaponModifier), updateRun); if (weaponModifier == "Gun"){ updateGun(false); }; } else { if ((keys & KeyboardControl.DOWN_DOWN)){ createCrouchBody(); setState(("crouchDown" + weaponModifier), updateCrouchDown); }; }; }; }; }; hanging = false; } private function createCrouchBody():void{ setBody(crouchBodyDef, crouchShapeDef); headOffset = 0; } private function updateBackJump():void{ backCurrY = (backCurrY + (0.3 * (backGoalY - backCurrY))); position.x = backCurrX; position.y = backCurrY; body.SetXForm(position, 0); pos.x = 0; pos.y = 0; body.SetLinearVelocity(pos); if (animation.currentFrame == animation.totalFrames){ setState(("backHang" + weaponModifier), updateBackHang); createBackBody(); }; } private function updateBackDropDown():void{ if (backGoalY == -1){ backCurrY = body.GetPosition().y; } else { setState(("backHang" + weaponModifier), updateBackHang); }; } private function updateGun(_arg1:Boolean=true):void{ if (!animation.gunAngle){ return; }; gunAngle = Math.atan2(mc.mouseY, mc.mouseX); var _local2:Number = (_arg1) ? 0.3 : 1; var _local3:int = (((100 - (GUN_FRAME_SCALAR * gunAngle)) % 100) + 1); var _local4:int = animation.gunAngle.currentFrame; var _local5:int = (_local3 - _local4); if (_local5 > 50){ _local5 = (_local5 - 100); } else { if (_local5 < -50){ _local5 = (_local5 + 100); }; }; _local4 = (_local4 + (_local2 * _local5)); _local4 = int(((_local4 + 100) % 100)); if (_local4 != animation.gunAngle.currentFrame){ animation.gunAngle.gotoAndStop(_local4); }; } private function initCrouchBodyDef():void{ crouchBodyDef = new b2BodyDef(); crouchBodyDef.angularDamping = bodyDef.angularDamping; crouchBodyDef.fixedRotation = bodyDef.fixedRotation; crouchBodyDef.linearDamping = bodyDef.linearDamping; crouchShapeDef = new b2PolygonDef(); crouchShapeDef.density = shapeDef.density; crouchShapeDef.friction = shapeDef.friction; crouchShapeDef.restitution = shapeDef.restitution; crouchShapeDef.SetAsOrientedBox(0.3, 0.5, new b2Vec2(0, 0.4), 0); } private function updateBackShimmyLeft():void{ if ((keys & KeyboardControl.LEFT_DOWN)){ if (backCurrX > backLeft){ backCurrX = (backCurrX - 0.05); if (backCurrX < backLeft){ backCurrX = backLeft; setState(("backHang" + weaponModifier), updateBackHang); }; }; } else { if ((keys & KeyboardControl.RIGHT_DOWN)){ setState("backShimmy", updateBackShimmyRight); } else { if ((keys & KeyboardControl.DOWN_PRESSED)){ } else { setState(("backHang" + weaponModifier), updateBackHang); }; }; }; position.x = backCurrX; position.y = backCurrY; body.SetXForm(position, 0); pos.x = 0; pos.y = 0; body.SetLinearVelocity(pos); } override public function update():void{ if (animation.gun){ animation.gun.gotoAndStop(weaponName); } else { if (animation.gunAngle){ if (animation.gunAngle.gun){ animation.gunAngle.gun.gotoAndStop(weaponName); }; updateGun(); }; }; if (swapToHangBody){ swapToHangBody = false; createHangBody(); setState(("sideHang" + weaponModifier), updateSideGrab); }; updateFunction(); super.update(); keys = 0; onGround = false; health(); } public function restoreAtCheckpoint():void{ pos.x = checkpointX; pos.y = checkpointY; body.SetXForm(pos, 0); setAmmo(checkpointAmmo[1], checkpointAmmo[2]); treasure = checkpointTreasure; score = (score + treasure); ui.updateScore(treasure); } public function stand():void{ setState(("stand" + weaponModifier), updateStand); } private function updateBackJumpUp():void{ if (backGoalY == -1){ body.GetLinearVelocity().y = (body.GetLinearVelocity().y * 0.3); backCurrY = body.GetPosition().y; } else { backCurrY = (backCurrY + (0.3 * (backGoalY - backCurrY))); position.x = backCurrX; position.y = backCurrY; body.SetXForm(position, 0); pos.x = 0; pos.y = 0; body.SetLinearVelocity(pos); }; if (animation.currentFrame == animation.totalFrames){ setState(("backHang" + weaponModifier), updateBackHang); }; } private function updateFall():void{ var _local1:Number = body.GetPosition().y; var _local2:Number = (_local1 - minY); if (_local1 < minY){ minY = _local1; }; body.GetLinearVelocity().x = (body.GetLinearVelocity().x * 0.9); if (body.GetLinearVelocity().y < 0){ body.GetLinearVelocity().y = 0; }; body.GetLinearVelocity().y = (body.GetLinearVelocity().y * 1.1); if (((backGrabReady) && (!(backModeFinishing)))){ backCurrX = position.x; backCurrY = position.y; setState("backJump", updateBackJump); return; }; if (onGround){ backModeFinishing = false; body.GetLinearVelocity().y = 0; if (_local2 < LANDING_THRESHOLD){ setState(("stand" + weaponModifier), updateStand); } else { setState(("land" + weaponModifier), updateLand); if (_local2 > MAX_FALL_HEIGHT){ damage(INIT_HIT_POINTS); }; Main.smSFX.getSoundByClassName("LandingSound").play(); }; }; if ((keys & KeyboardControl.LEFT_DOWN)){ if (!(keys & KeyboardControl.RIGHT_DOWN)){ body.ApplyImpulse(jumpLeftImpulse, position); direction = KeyboardControl.LEFT; mc.scaleX = -1; if (weaponModifier == "Gun"){ updateGun(false); }; }; } else { if ((keys & KeyboardControl.RIGHT_DOWN)){ body.ApplyImpulse(jumpRightImpulse, position); direction = KeyboardControl.RIGHT; mc.scaleX = 1; if (weaponModifier == "Gun"){ updateGun(false); }; }; }; } private function updateNull():void{ } private function updateStealthAttack():void{ body.GetLinearVelocity().x = 0; if (animation.currentFrame == 27){ level.checkMeleeTarget(animation.target, STEALTH_DAMAGE); } else { if (animation.currentFrame == animation.totalFrames){ setState(("stand" + weaponModifier), updateStand); }; }; } public function fireWeapon(_arg1:Physics):Bullet{ return (WEAPON_ACTIONS[selectedWeaponNum](_arg1)); } private function createDefaultBody():void{ setBody(bodyDef, shapeDef); headOffset = 0.5; } private function updateDie():void{ body.GetLinearVelocity().x = 0; } private function updateBackHang():void{ if (backCurrY > backGoalY){ backCurrY = (backCurrY + (0.3 * (backGoalY - backCurrY))); } else { backCurrY = (backCurrY + (0.7 * (backGoalY - backCurrY))); }; position.x = backCurrX; position.y = backCurrY; body.SetXForm(position, 0); pos.x = 0; pos.y = 0; body.SetLinearVelocity(pos); if ((keys & KeyboardControl.DOWN_PRESSED)){ if (backFallReady){ backModeFinishing = true; createDefaultBody(); setState("backFall", updateBackFall); } else { if (backDropDownReady){ pos.x = 0; pos.y = 2; body.ApplyImpulse(pos, position); prevBackGoalY = backGoalY; backGoalY = -1; setState("backDropDown", updateBackDropDown); }; }; } else { if ((keys & KeyboardControl.LEFT_DOWN)){ if (backCurrX > backLeft){ setState("backShimmy", updateBackShimmyLeft); }; } else { if ((keys & KeyboardControl.RIGHT_DOWN)){ if (backCurrX < backRight){ setState("backShimmy", updateBackShimmyRight); }; } else { if ((((keys & KeyboardControl.UP_PRESSED)) && (backJumpUpReady))){ body.ApplyImpulse(jumpImpulse, position); prevBackGoalY = backGoalY; backGoalY = -1; setState("backJumpUp", updateBackJumpUp); Main.smSFX.getSoundByClassName("JumpSound").play(); }; }; }; }; } private function updateCrouch():void{ body.GetLinearVelocity().x = 0; body.GetLinearVelocity().y = 0; if (!(keys & KeyboardControl.DOWN_DOWN)){ createDefaultBody(); setState(("land" + weaponModifier), updateLand); }; } } }//package com.kerb.uncharted.game.characters
Section 87
//Character (com.kerb.uncharted.game.characters.Character) package com.kerb.uncharted.game.characters { import com.kerb.uncharted.game.physics.*; import flash.utils.*; import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; public class Character extends MoveableBody implements IContactRespondable { protected var bodyDef:b2BodyDef; protected var shapeDef:b2ShapeDef; protected var world:b2World; protected var vec:b2Vec2; public var hitPoints:Number; private var injuryTimestamp:int; public function Character(_arg1:b2Body, _arg2:b2BodyDef, _arg3:b2ShapeDef){ vec = new b2Vec2(); this.bodyDef = _arg2; this.shapeDef = _arg3; this.world = _arg1.GetWorld(); super(_arg1); _arg1.SetUserData(this); injuryTimestamp = 0; } public function die():void{ destroyBody(); } public function onAddContact(_arg1:b2ContactPoint):void{ } public function damage(_arg1:int):void{ hitPoints = (hitPoints - _arg1); if (hitPoints <= 0){ hitPoints = 0; } else { if ((getTimer() - injuryTimestamp) > 1500){ injuryTimestamp = getTimer(); }; }; } public function onPersistContact(_arg1:b2ContactPoint):void{ } public function bulletRecoil(_arg1:Number):void{ var _local3:Number; var _local2:Number = 0.1; _local3 = 0.2; vec.x = (_local2 * Math.cos(_arg1)); vec.y = ((_local2 * Math.sin(_arg1)) - _local3); body.ApplyImpulse(vec, body.GetPosition()); } public function onRemoveContact(_arg1:b2ContactPoint):void{ } } }//package com.kerb.uncharted.game.characters
Section 88
//Enemy1 (com.kerb.uncharted.game.characters.Enemy1) package com.kerb.uncharted.game.characters { import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.projectiles.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; public class Enemy1 extends AbstractEnemy { public function Enemy1(_arg1:b2Body, _arg2:b2BodyDef, _arg3:b2ShapeDef){ super(_arg1, _arg2, _arg3, "Enemy1Asset"); hitPoints = 100; canTurn = false; } override protected function fireGun(_arg1:Physics, _arg2:Number, _arg3:Number):Bullet{ if (fireCounter > 17){ if (Math.random() < 0.1){ fireCounter = 0; return (firePistol(_arg1, _arg2, _arg3)); }; }; return (null); } } }//package com.kerb.uncharted.game.characters
Section 89
//Enemy2 (com.kerb.uncharted.game.characters.Enemy2) package com.kerb.uncharted.game.characters { import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.projectiles.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; public class Enemy2 extends AbstractEnemy { public function Enemy2(_arg1:b2Body, _arg2:b2BodyDef, _arg3:b2ShapeDef){ super(_arg1, _arg2, _arg3, "Enemy2Asset"); hitPoints = 130; } override protected function fireGun(_arg1:Physics, _arg2:Number, _arg3:Number):Bullet{ if (fireCounter > 17){ if (Math.random() < 0.2){ fireCounter = 0; return (firePistol(_arg1, _arg2, _arg3)); }; }; return (null); } } }//package com.kerb.uncharted.game.characters
Section 90
//Enemy3 (com.kerb.uncharted.game.characters.Enemy3) package com.kerb.uncharted.game.characters { import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.projectiles.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import com.kerb.uncharted.game.levels.*; public class Enemy3 extends AbstractEnemy { public function Enemy3(_arg1:b2Body, _arg2:b2BodyDef, _arg3:b2ShapeDef){ super(_arg1, _arg2, _arg3, "Enemy3Asset"); hitPoints = 160; } override protected function fireGun(_arg1:Physics, _arg2:Number, _arg3:Number):Bullet{ if (fireCounter > AbstractLevel.AUTOFIRE_INTERVAL){ if (Math.random() < 0.4){ fireCounter = 0; return (fireMachineGun(_arg1, _arg2, _arg3)); }; }; return (null); } } }//package com.kerb.uncharted.game.characters
Section 91
//AbstractCutScene (com.kerb.uncharted.game.cutScenes.AbstractCutScene) package com.kerb.uncharted.game.cutScenes { import flash.events.*; import flash.display.*; import com.kerb.uncharted.*; public class AbstractCutScene extends Sprite { protected var mc:MovieClip; public function AbstractCutScene(_arg1:String){ mc = Main.afm.createMovieClip("graphics", _arg1); addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); Main.smMusic.getSoundByClassName("ButtonBashLoopSound").play(0, 999999); } protected function init():void{ addChild(mc); } protected function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); init(); } protected function complete():void{ Main.smMusic.getSoundByClassName("ButtonBashLoopSound").stop(); dispatchEvent(new Event(Event.COMPLETE)); } public function dispose():void{ Main.smMusic.getSoundByClassName("ButtonBashLoopSound").stop(); } } }//package com.kerb.uncharted.game.cutScenes
Section 92
//Level1CutScene1 (com.kerb.uncharted.game.cutScenes.Level1CutScene1) package com.kerb.uncharted.game.cutScenes { import flash.events.*; import flash.utils.*; import flash.ui.*; public class Level1CutScene1 extends AbstractCutScene { private const KEY_TIME_THRESHOLD:int = 190; private var keyIsDown:Boolean; private var dir:int; private var keyTimestamp:int; public function Level1CutScene1(){ super("Level1CutScene1Asset"); } override protected function complete():void{ dispose(); super.complete(); } private function onKeyDown(_arg1:KeyboardEvent):void{ if (keyIsDown){ return; }; if (!(((_arg1.keyCode == Keyboard.DOWN)) || ((_arg1.keyCode == 83)))){ return; }; var _local2:int = getTimer(); if ((_local2 - keyTimestamp) < KEY_TIME_THRESHOLD){ dir = 1; } else { dir = -1; }; keyTimestamp = _local2; keyIsDown = true; } override protected function init():void{ super.init(); mc.animation.stop(); stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true); stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp, false, 0, true); mc.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); keyTimestamp = getTimer(); keyIsDown = false; } private function onEnterFrame(_arg1:Event):void{ var _local2:int = getTimer(); if ((_local2 - keyTimestamp) > KEY_TIME_THRESHOLD){ dir = -1; }; if (dir == 1){ mc.animation.nextFrame(); if (mc.animation.currentFrame == mc.animation.totalFrames){ complete(); }; } else { mc.animation.prevFrame(); }; } private function onKeyUp(_arg1:KeyboardEvent):void{ keyIsDown = false; } override public function dispose():void{ stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp); mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); } } }//package com.kerb.uncharted.game.cutScenes
Section 93
//Level2CutScene1 (com.kerb.uncharted.game.cutScenes.Level2CutScene1) package com.kerb.uncharted.game.cutScenes { import flash.events.*; import flash.utils.*; import flash.ui.*; public class Level2CutScene1 extends AbstractCutScene { private const KEY_TIME_THRESHOLD:int = 250; private var keyIsDown:Boolean; private var dir:int; private var keyTimestamp:int; public function Level2CutScene1(){ super("Level2CutScene1Asset"); } override protected function complete():void{ dispose(); super.complete(); } private function onKeyDown(_arg1:KeyboardEvent):void{ if (keyIsDown){ return; }; if (!(((_arg1.keyCode == Keyboard.DOWN)) || ((_arg1.keyCode == 83)))){ return; }; var _local2:int = getTimer(); if ((_local2 - keyTimestamp) < KEY_TIME_THRESHOLD){ dir = 1; } else { dir = -1; }; keyTimestamp = _local2; keyIsDown = true; } override protected function init():void{ super.init(); mc.animation.stop(); stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true); stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp, false, 0, true); mc.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); keyTimestamp = getTimer(); keyIsDown = false; } private function onEnterFrame(_arg1:Event):void{ var _local2:int = getTimer(); if ((_local2 - keyTimestamp) > KEY_TIME_THRESHOLD){ dir = -1; }; if (dir == 1){ mc.animation.nextFrame(); if (mc.animation.currentFrame == mc.animation.totalFrames){ complete(); }; } else { mc.animation.prevFrame(); }; } private function onKeyUp(_arg1:KeyboardEvent):void{ keyIsDown = false; } override public function dispose():void{ stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp); mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); } } }//package com.kerb.uncharted.game.cutScenes
Section 94
//Level2CutScene2 (com.kerb.uncharted.game.cutScenes.Level2CutScene2) package com.kerb.uncharted.game.cutScenes { import flash.events.*; public class Level2CutScene2 extends AbstractCutScene { public function Level2CutScene2(){ super("Level2CutScene2Asset"); } override protected function init():void{ super.init(); mc.addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onEnterFrame(_arg1:Event):void{ if (mc.currentFrame == mc.totalFrames){ mc.stop(); mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); complete(); }; } override public function dispose():void{ super.dispose(); mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); } } }//package com.kerb.uncharted.game.cutScenes
Section 95
//Level3CutScene1 (com.kerb.uncharted.game.cutScenes.Level3CutScene1) package com.kerb.uncharted.game.cutScenes { import flash.events.*; import flash.utils.*; import flash.ui.*; public class Level3CutScene1 extends AbstractCutScene { private const KEY_TIME_THRESHOLD:int = 250; private var keyIsDown:Boolean; private var dir:int; private var keyTimestamp:int; public function Level3CutScene1(){ super("Level3CutScene1Asset"); } override protected function complete():void{ dispose(); super.complete(); } private function onKeyDown(_arg1:KeyboardEvent):void{ if (keyIsDown){ return; }; if (!(((_arg1.keyCode == Keyboard.DOWN)) || ((_arg1.keyCode == 83)))){ return; }; var _local2:int = getTimer(); if ((_local2 - keyTimestamp) < KEY_TIME_THRESHOLD){ dir = 1; } else { dir = -1; }; keyTimestamp = _local2; keyIsDown = true; } override protected function init():void{ super.init(); mc.animation.stop(); stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true); stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp, false, 0, true); mc.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); keyTimestamp = getTimer(); keyIsDown = false; } private function onEnterFrame(_arg1:Event):void{ var _local2:int = getTimer(); if ((_local2 - keyTimestamp) > KEY_TIME_THRESHOLD){ dir = -1; }; if (dir == 1){ mc.animation.nextFrame(); if (mc.animation.currentFrame == mc.animation.totalFrames){ complete(); }; } else { mc.animation.prevFrame(); }; } private function onKeyUp(_arg1:KeyboardEvent):void{ keyIsDown = false; } override public function dispose():void{ stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp); mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); } } }//package com.kerb.uncharted.game.cutScenes
Section 96
//Explosion (com.kerb.uncharted.game.fx.Explosion) package com.kerb.uncharted.game.fx { import flash.display.*; import flash.geom.*; import flash.filters.*; public class Explosion extends Sprite { private var buffer:BitmapData; private var output:BitmapData; private var particleList:ExplosionParticle; private var firePalette:Array; private var energy:Number; private var ct:ColorTransform; private var blur:BlurFilter; private static const PARTICLE_ENERGY_DAMPING:Number = 0.95; private static const MIN_ENERGY:Number = 100; private static const ORIGIN:Point = new Point(0, 0); private static const EMPTY_ARRAY:Array = []; private static const NUM_PARTICLES:int = 200; public function Explosion(){ init(); } private function step():void{ buffer.lock(); var _local1:ExplosionParticle = particleList; while (_local1) { _local1.update(); buffer.setPixel(_local1.x, _local1.y, energy); _local1.update(); buffer.setPixel(_local1.x, _local1.y, energy); _local1 = _local1.next; }; buffer.applyFilter(buffer, buffer.rect, ORIGIN, blur); buffer.colorTransform(buffer.rect, ct); buffer.scroll(0, -2); buffer.unlock(); } private function init():void{ var _local3:ExplosionParticle; firePalette = ExplosionGradient.getArray([0, 0, 0x333333, 0xFF0000, 0xFFFF00, 0xFFFFFF, 0xFFFFFF], [0, 0, 1, 1, 1, 1, 1], [0, 34, 68, 80, 119, 136, 0xFF]); var _local1:int; while (_local1 < NUM_PARTICLES) { _local3 = new ExplosionParticle(particleList); particleList = _local3; _local1++; }; blur = new BlurFilter(2, 2, 2); ct = new ColorTransform(1, 1, 1, 0.96); buffer = new BitmapData(150, 150, false, 0); output = new BitmapData(150, 150, true, 0); var _local2:Bitmap = new Bitmap(output); _local2.scaleX = (_local2.scaleY = 2); addChild(_local2); } public function update():Boolean{ step(); step(); output.lock(); output.copyPixels(buffer, buffer.rect, ORIGIN); output.paletteMap(output, output.rect, ORIGIN, EMPTY_ARRAY, EMPTY_ARRAY, firePalette, EMPTY_ARRAY); output.unlock(); energy = (energy * PARTICLE_ENERGY_DAMPING); return ((energy < MIN_ENERGY)); } public function fire(_arg1:Number, _arg2:Number):void{ var _local3:Number; var _local4:Number; var _local5:Number; var _local6:Number; var _local7:ExplosionParticle = particleList; var _local8:int; var _local9:Number = ((2 * Math.random()) + 0.2); buffer.fillRect(buffer.rect, 0); output.fillRect(output.rect, 0); this.x = (_arg1 - output.width); this.y = (_arg2 - output.height); while (_local7) { var _temp1 = _local8; _local8 = (_local8 + 1); _local3 = (((_temp1 * 2) * Math.PI) / NUM_PARTICLES); _local6 = ((_local9 * Math.random()) + 1); _local4 = ((_local6 * Math.sin(_local3)) * 2); _local5 = ((_local6 * Math.cos(_local3)) * 2); _local7.init((0.5 * output.width), (0.5 * output.height), _local4, _local5); _local7 = _local7.next; }; energy = 0xFF; } public function dispose():void{ buffer.dispose(); output.dispose(); } } }//package com.kerb.uncharted.game.fx
Section 97
//ExplosionGradient (com.kerb.uncharted.game.fx.ExplosionGradient) package com.kerb.uncharted.game.fx { import flash.display.*; import flash.geom.*; public class ExplosionGradient { private static const IDENTITY:Matrix = new Matrix(); public static function getArray(_arg1:Array, _arg2:Array, _arg3:Array):Array{ var _local9:uint; var _local4:Array = new Array(); var _local5:Shape = new Shape(); var _local6:Matrix = new Matrix(); var _local7:BitmapData = new BitmapData(0x0100, 1, true, 0); var _local8:Graphics = _local5.graphics; _local6.createGradientBox(0x0100, 0x0100, 0, 0, 0); _local8.clear(); _local8.beginGradientFill("linear", _arg1, _arg2, _arg3, _local6); _local8.drawRect(0, 0, 0x0100, 0x0100); _local8.endFill(); _local7.draw(_local5, IDENTITY); var _local10:int; while (_local10 < 0x0100) { _local9 = _local7.getPixel32(_local10, 0); _local4.push(_local9); _local10++; }; return (_local4); } } }//package com.kerb.uncharted.game.fx
Section 98
//ExplosionParticle (com.kerb.uncharted.game.fx.ExplosionParticle) package com.kerb.uncharted.game.fx { public class ExplosionParticle { private var vx:Number; private var vy:Number; public var next:ExplosionParticle; public var x:Number; public var y:Number; public function ExplosionParticle(_arg1:ExplosionParticle){ this.next = _arg1; } public function update():void{ x = (x + vx); y = (y + vy); vy = (vy + 0.1); } public function init(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{ this.x = _arg1; this.y = (_arg2 + 10); this.vx = _arg3; this.vy = (_arg4 - 2); } } }//package com.kerb.uncharted.game.fx
Section 99
//AbstractLevel (com.kerb.uncharted.game.levels.AbstractLevel) package com.kerb.uncharted.game.levels { import flash.events.*; import flash.display.*; import com.kerb.sound.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.props.*; import com.kerb.uncharted.game.characters.*; import com.kerb.uncharted.game.projectiles.*; import flash.utils.*; import Box2D.Dynamics.*; import com.kerb.uncharted.game.render.*; import Box2D.Common.Math.*; import com.kerb.uncharted.game.render.layers.*; import com.kerb.uncharted.game.*; import mx.core.*; import com.kerb.uncharted.game.panels.*; import com.kerb.uncharted.game.utils.*; public class AbstractLevel extends Sprite { protected var panel:MovieClip; protected var keyControl:KeyboardControl; protected var enemies:Array; protected var pauseOffset:int; protected var totalTime:int; protected var physics:Physics; protected var moveableBodies:Array; protected var startTime:int; protected var worldWidth:int; public var avatar:Avatar; protected var worldHeight:int; protected var pauseStartTimestamp:int; protected var viewportHeight:int; protected var props:Array; protected var avatarLayer:SimpleLayer; protected var autoFire:Boolean; protected var maxBonusTime:int; protected var ui:UI; protected var fxLayer:SimpleLayer; protected var bullets:Array; protected var autoFireCounter:int; protected var viewportWidth:int; protected var propsLayer:SimpleLayer; public var renderer:Renderer; protected var mouseOffsetX:Number;// = 0 protected var mouseOffsetY:Number;// = 0 protected var gameOver:Boolean;// = false protected var deathCounter:int; public static const EVENT_WIN:String = "onWin"; public static const EVENT_LOSE:String = "onLose"; public static const AUTOFIRE_INTERVAL:int = 2; private static var timeBeforeDeath:int = 0; public function AbstractLevel(){ addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } protected function createAmmoDump(_arg1:AbstractEnemy):void{ var _local4:PistolAmmoDump; var _local5:MachineGunAmmoDump; var _local2:Number = _arg1.body.GetPosition().x; var _local3:Number = _arg1.body.GetPosition().y; if (_arg1.pistolAmmo > 0){ _local4 = new PistolAmmoDump(physics, _local2, _local3, _arg1.pistolAmmo); propsLayer.sprite.addChild(_local4.mc); props.push(_local4); }; if (_arg1.machineGunAmmo > 0){ _local5 = new MachineGunAmmoDump(physics, _local2, _local3, _arg1.machineGunAmmo); propsLayer.sprite.addChild(_local5.mc); props.push(_local5); }; } protected function removeProp(_arg1:AbstractProp):void{ var _local2:int = props.indexOf(_arg1); if (_local2 != -1){ props.splice(_local2, 1); }; } public function pauseGame():void{ var _local1:MoveableBody; removeEventListener(Event.ENTER_FRAME, onEnterFrame); disableUserInteraction(); pauseStartTimestamp = getTimer(); for each (_local1 in moveableBodies) { _local1.pause(); }; Main.smSFX.getSoundByClassName("MachineGunLoopSound").stop(); getLevelSound().stop(); } protected function winLevel():void{ pauseGame(); timeBeforeDeath = 0; addEventListener(Event.ENTER_FRAME, onEnterFrameRenderOnly, false, 0, true); dispatchEvent(new Event(EVENT_WIN)); } protected function initPhysics():void{ } public function dispose():void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); removeEventListener(Event.ENTER_FRAME, onEnterFrame); removeEventListener(Event.ENTER_FRAME, onEnterFrameRenderOnly); removeEventListener(Event.ENTER_FRAME, onEnterFrameLevelLose); stage.removeEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel); stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); stage.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp); ui.mc.help_btn.removeEventListener(MouseEvent.CLICK, onHelpClick); if (panel){ panel.removeEventListener(Event.CLOSE, onPanelCloseClick); }; renderer.dispose(); removeChild(renderer); renderer = null; physics.dispose(); physics = null; } public function getTreasure():int{ return (avatar.treasure); } protected function updateProps():void{ var _local2:AbstractProp; var _local1:int = props.length; while (--_local1 > -1) { _local2 = props[_local1]; if (_local2.taken){ _local2.destroy(); removeProp(_local2); }; }; } protected function getXMLData(_arg1:Class):XML{ var _local2:ByteArrayAsset = ByteArrayAsset(new (_arg1)); var _local3:String = _local2.readUTFBytes(3); if (_local3.length == 1){ return (new XML(_local2.readUTFBytes((_local2.length - 3)))); }; return (new XML((_local3 + _local2.readUTFBytes((_local2.length - 3))))); } public function getHitPercent():Number{ return (avatar.getAccurateShotPercentage()); } protected function init():void{ initProperties(); initPhysics(); initGraphics(); initMoveableBodies(); initEnemies(); initProps(); initHelpers(); onEnterFrame(); onEnterFrame(); onEnterFrame(); renderer.visible = true; startGame(); } protected function onEnterFrameRenderOnly(_arg1:Event):void{ var _local2:b2Vec2; physics.update(); avatar.updateRenderOnly(); _local2 = new b2Vec2(); _local2.x = (renderer.getCamera().x / Renderer.RENDER_SCALE); _local2.y = (renderer.getCamera().y / Renderer.RENDER_SCALE); renderer.draw(_local2); } protected function disableUserInteraction():void{ stage.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp); stage.removeEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel); stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); ui.mc.help_btn.removeEventListener(MouseEvent.CLICK, onHelpClick); ui.mc.help_btn.mouseEnabled = false; } protected function initProps():void{ var _local1:AbstractProp; props = Terrain.getInstance().getProps(); for each (_local1 in props) { propsLayer.sprite.addChild(_local1.mc); }; } protected function onMouseUp(_arg1:MouseEvent):void{ autoFire = false; Main.smSFX.getSoundByClassName("MachineGunLoopSound").stop(); } protected function enableUserInteraction():void{ stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true); stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp, false, 0, true); stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel, false, 0, true); stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true); ui.mc.help_btn.addEventListener(MouseEvent.CLICK, onHelpClick, false, 0, true); ui.mc.help_btn.mouseEnabled = true; } public function addEnemyBullet(_arg1:Bullet):void{ if (_arg1){ bullets.push(_arg1); Main.smSFX.getSoundByClassName("PistolSound").play(); }; } protected function initCustomBGGraphics():void{ } protected function initHelpers():void{ keyControl = new KeyboardControl(stage); } protected function initProperties():void{ viewportWidth = 536; viewportHeight = 300; startTime = 0; totalTime = 0; pauseStartTimestamp = 0; pauseOffset = 0; bullets = []; autoFire = false; deathCounter = 0; } protected function onEnterFrameLevelLose(_arg1:Event):void{ onEnterFrameRenderOnly(_arg1); if (++deathCounter == 32){ dispatchEvent(new Event(EVENT_LOSE)); }; } public function onCutScene(_arg1:String):void{ } protected function loseLevel():void{ pauseGame(); timeBeforeDeath = totalTime; addEventListener(Event.ENTER_FRAME, onEnterFrameLevelLose, false, 0, true); } public function startGame():void{ addEventListener(Event.ENTER_FRAME, onEnterFrame); enableUserInteraction(); startTime = (getTimer() - timeBeforeDeath); timeBeforeDeath = 0; stage.focus = stage; getLevelSound().play(0, 999999); } protected function initMoveableBodies():void{ var _local1:MoveableBody; moveableBodies = Terrain.getInstance().getMoveableBodies(); for each (_local1 in moveableBodies) { if ((_local1 is Avatar)){ avatar = Avatar(_local1); avatar.setUI(ui); avatar.setLevel(this); avatarLayer.sprite.addChild(avatar.mc); } else { propsLayer.sprite.addChild(_local1.mc); }; }; } protected function updateMoveableBodies():void{ var _local2:MoveableBody; var _local1:int = moveableBodies.length; while (--_local1 > -1) { _local2 = moveableBodies[_local1]; _local2.update(); if ((_local2 is Barrel)){ if (Barrel(_local2).checkExplosionCounter()){ explodeBarrel(Barrel(_local2)); }; } else { if ((_local2 is Character)){ if ((_local2 is AbstractEnemy)){ addEnemyBullet(AbstractEnemy(_local2).ai(avatar, physics)); }; if (Character(_local2).hitPoints == 0){ if ((_local2 is Avatar)){ loseLevel(); } else { createAmmoDump(AbstractEnemy(_local2)); removeMoveableBody(_local2); }; Character(_local2).die(); }; }; }; }; } public function getTimePercent():Number{ return (((totalTime)>maxBonusTime) ? 0 : (1 - (totalTime / maxBonusTime))); } protected function removeMoveableBody(_arg1:MoveableBody):void{ var _local2:int = moveableBodies.indexOf(_arg1); if (_local2 != -1){ moveableBodies.splice(_local2, 1); }; } protected function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); init(); } protected function onHelpClick(_arg1:MouseEvent):void{ Main.onButtonPress(); pauseGame(); panel = new HelpPanel(); panel.addEventListener(Event.CLOSE, onPanelCloseClick, false, 0, true); addChild(panel); } protected function onEnterFrame(_arg1:Event=null):void{ var _local2:b2Vec2; avatar.setKeys(keyControl.keys); physics.update(); _local2 = avatar.body.GetPosition().Copy(); var _local3:Number = Math.atan2(avatar.mc.mouseY, (avatar.mc.scaleX * avatar.mc.mouseX)); var _local4:Number = 1.7; var _local5:Number = (_local4 * Math.cos(_local3)); var _local6:Number = (_local4 * Math.sin(_local3)); mouseOffsetX = (mouseOffsetX + (0.05 * (_local5 - mouseOffsetX))); mouseOffsetY = (mouseOffsetY + (0.05 * (_local6 - mouseOffsetY))); _local2.x = (_local2.x + mouseOffsetX); _local2.y = (_local2.y + mouseOffsetY); renderer.draw(_local2); updateMoveableBodies(); updateProps(); updateBullets(); totalTime = ((getTimer() - startTime) - pauseOffset); ui.updateTime(totalTime); if (enemies.length > 0){ checkEnemies(); }; } protected function onPanelCloseClick(_arg1:Event):void{ Main.onButtonPress(); removeChild(panel); panel = null; resumeGame(); } protected function initGraphics():void{ renderer = new Renderer(worldWidth, worldHeight, viewportWidth, viewportHeight); renderer.x = 8; renderer.y = 50; renderer.visible = false; addChildAt(renderer, 0); initCustomBGGraphics(); propsLayer = renderer.createSimpleLayer(worldWidth, worldHeight); avatarLayer = renderer.createSimpleLayer(worldWidth, worldHeight); fxLayer = renderer.createSimpleLayer(worldWidth, worldHeight); initCustomFGGraphics(); if (ui == null){ ui = new UI(Main.afm.createMovieClip("interface", "UIAsset"), renderer); addChild(ui.mc); }; } public function retryLevel():void{ var _local4:AbstractEnemy; dispose(); init(); avatar.restoreAtCheckpoint(); renderer.reset(); var _local1:Number = avatar.getCheckpointX(); var _local2:int = enemies.length; while (--_local2 > -1) { _local4 = enemies[_local2]; if (_local4.activationPoint <= _local1){ enemies.splice(_local2, 1); _local4.destroy(); }; }; var _local3:b2Body = avatar.body.GetWorld().GetBodyList(); while (_local3) { if ((_local3.GetUserData() is Treasure)){ if (_local3.GetPosition().x <= _local1){ Treasure(_local3.GetUserData()).destroy(); }; }; _local3 = _local3.GetNext(); }; renderer.getCamera().cutTo(avatar.body.GetPosition().x, avatar.body.GetPosition().y); renderer.draw(avatar.body.GetPosition()); avatar.update(); avatar.setUI(ui); } public function resumeGame():void{ var _local1:MoveableBody; addEventListener(Event.ENTER_FRAME, onEnterFrame); enableUserInteraction(); pauseOffset = (pauseOffset + (getTimer() - pauseStartTimestamp)); stage.focus = stage; for each (_local1 in moveableBodies) { _local1.resume(); }; if (!gameOver){ getLevelSound().play(0, 999999); }; } protected function onKeyDown(_arg1:KeyboardEvent):void{ if (_arg1.keyCode == 49){ avatar.selectWeaponNum(0); } else { if (_arg1.keyCode == 50){ avatar.selectWeaponNum(1); } else { if (_arg1.keyCode == 51){ avatar.selectWeaponNum(2); } else { if (_arg1.keyCode == 97){ avatar.selectWeaponNum(0); } else { if (_arg1.keyCode == 98){ avatar.selectWeaponNum(1); } else { if (_arg1.keyCode == 99){ avatar.selectWeaponNum(2); }; }; }; }; }; }; } protected function updateBullets():void{ var _local2:Bullet; var _local3:Character; var _local1:int = bullets.length; while (--_local1 > -1) { _local2 = bullets[_local1]; if (_local2.hit){ if ((_local2.target.GetUserData() is Avatar)){ if (_local2.owner != avatar){ renderer.addBulletHit("BulletHitAsset", _local2.hitX, _local2.hitY, _local2.hitAngle, fxLayer); Avatar(_local2.target.GetUserData()).damage(_local2.damage); }; } else { if ((_local2.target.GetUserData() is Character)){ renderer.addBulletHit("BulletHitAsset", _local2.hitX, _local2.hitY, _local2.hitAngle, fxLayer); Character(_local2.target.GetUserData()).damage(_local2.damage); avatar.addShotStatistic(true); } else { if ((_local2.target.GetUserData() is Barrel)){ explodeBarrel(_local2.target.GetUserData()); } else { renderer.addBulletHit("BulletRicochetAsset", _local2.hitX, _local2.hitY, _local2.hitAngle, fxLayer); avatar.addShotStatistic(false); }; }; }; _local2.destroy(); bullets.splice(_local1, 1); }; }; if (((autoFire) && (((++autoFireCounter % AUTOFIRE_INTERVAL) == 0)))){ _local2 = avatar.autoFireWeapon(physics); if (_local2){ bullets.push(_local2); } else { Main.smSFX.getSoundByClassName("MachineGunLoopSound").stop(); }; }; } public function stealthAttackPossible():Boolean{ var _local1:MoveableBody; var _local2:AbstractEnemy; var _local5:Number; var _local6:Number; var _local3:Number = avatar.body.GetPosition().x; var _local4:Number = avatar.body.GetPosition().y; for each (_local1 in moveableBodies) { if ((_local1 is AbstractEnemy)){ _local2 = AbstractEnemy(_local1); if (_local2.body){ if (_local2.mc.scaleX == avatar.mc.scaleX){ _local5 = ((_local2.body.GetPosition().x - _local3) * _local2.mc.scaleX); _local6 = (_local2.body.GetPosition().y - _local4); if ((((_local5 > 0.2)) && ((_local5 < 1.4)))){ if ((((_local6 > -0.5)) && ((_local6 < 0.5)))){ return (true); }; }; }; }; }; }; return (false); } protected function initCustomFGGraphics():void{ } protected function onMouseDown(_arg1:MouseEvent):void{ if ((((_arg1.target is SimpleButton)) || (_arg1.target.hasEventListener(MouseEvent.MOUSE_DOWN)))){ return; }; var _local2:Bullet = avatar.fireWeapon(physics); if (_local2){ bullets.push(_local2); if ((_local2 is MachineGunBullet)){ Main.smSFX.getSoundByClassName("MachineGunLoopSound").play(0, 999999); }; }; autoFire = true; autoFireCounter = 0; } protected function getLevelSound():ExtendedSound{ return (null); } protected function explodeBarrel(_arg1:Barrel):void{ var _local2:b2Vec2 = _arg1.body.GetPosition(); _arg1.mc.gotoAndStop("destroyed"); renderer.addExplosion(_local2.x, _local2.y, fxLayer); removeMoveableBody(_arg1); _arg1.destroy(); physics.addBlastArea(_local2); Main.smSFX.getSoundByClassName("ExplosionSound").play(); } protected function onMouseWheel(_arg1:MouseEvent):void{ if (_arg1.delta > 0){ avatar.selectNextWeapon(); } else { if (_arg1.delta < 0){ avatar.selectPrevWeapon(); }; }; } protected function initEnemies():void{ var _local2:MoveableBody; enemies = []; var _local1:int = moveableBodies.length; while (--_local1 > -1) { _local2 = moveableBodies[_local1]; if ((_local2 is AbstractEnemy)){ enemies.push(_local2); AbstractEnemy(_local2).deactivate(); moveableBodies.splice(_local1, 1); }; }; enemies.sortOn("activationPoint", Array.NUMERIC); } public function checkMeleeTarget(_arg1:MovieClip, _arg2:int):Boolean{ var _local3:MoveableBody; for each (_local3 in moveableBodies) { if ((_local3 is AbstractEnemy)){ if (AbstractEnemy(_local3).checkHit(_arg1, _arg2)){ return (true); }; }; }; return (false); } protected function checkEnemies():void{ var _local1:Number = avatar.body.GetPosition().x; if (_local1 > enemies[0].activationPoint){ enemies[0].activate(); moveableBodies.push(enemies[0]); enemies.splice(0, 1); }; } } }//package com.kerb.uncharted.game.levels
Section 100
//Level1 (com.kerb.uncharted.game.levels.Level1) package com.kerb.uncharted.game.levels { import flash.events.*; import flash.display.*; import com.kerb.sound.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.render.*; import com.kerb.uncharted.game.render.layers.*; import com.kerb.uncharted.game.cutScenes.*; public class Level1 extends AbstractLevel { private var challengeCutScenePlayed:Boolean; private var backgroundLayer:MovieClip; private var challengeCutScene:Level1CutScene1; private var LevelData:Class; public function Level1(){ LevelData = Level1_LevelData; super(); } override protected function getLevelSound():ExtendedSound{ return (Main.smMusic.getSoundByClassName("Level1LoopSound")); } private function onChallengeCutSceneComplete(_arg1:Event):void{ backgroundLayer.cutSceneDoor.gotoAndStop("open"); challengeCutScene.removeEventListener(Event.COMPLETE, onChallengeCutSceneComplete); challengeCutScene.dispose(); removeChild(challengeCutScene); challengeCutScene = null; challengeCutScenePlayed = true; resumeGame(); } override public function onCutScene(_arg1:String):void{ if ((((_arg1 == "cutScene1")) && (!(challengeCutScenePlayed)))){ pauseGame(); challengeCutScene = new Level1CutScene1(); challengeCutScene.addEventListener(Event.COMPLETE, onChallengeCutSceneComplete, false, 0, true); addChildAt(challengeCutScene, 1); } else { if (_arg1 == "cutScene2"){ winLevel(); }; }; } override protected function initProperties():void{ super.initProperties(); worldWidth = 180; worldHeight = 24; maxBonusTime = 60000; } override protected function init():void{ super.init(); avatar.setAmmo(0, 0); challengeCutScenePlayed = false; renderer.setCameraRect(150, 120, (viewportWidth - 400), (viewportHeight - 200)); } override protected function initCustomBGGraphics():void{ var _local1:SimpleLayer; _local1 = renderer.createSimpleLayer((1080 * Renderer.INVERSE_RENDER_SCALE), 0); _local1.sprite.addChild(Main.afm.createMovieClip("graphics", "Level1BackdropAsset")); renderer.createMovieClipLayer((2879 * Renderer.INVERSE_RENDER_SCALE), (300 * Renderer.INVERSE_RENDER_SCALE), Main.afm.createMovieClip("graphics", "Level1Parallax1Asset")); renderer.createMovieClipLayer((5611 * Renderer.INVERSE_RENDER_SCALE), (500 * Renderer.INVERSE_RENDER_SCALE), Main.afm.createMovieClip("graphics", "Level1Parallax2Asset")); backgroundLayer = Main.afm.createMovieClip("graphics", "Level1BackgroundAsset"); renderer.createMovieClipLayer(worldWidth, worldHeight, backgroundLayer); } override protected function initCustomFGGraphics():void{ renderer.createMovieClipLayer(worldWidth, worldHeight, Main.afm.createMovieClip("graphics", "Level1ForegroundAsset")); } override protected function initEnemies():void{ super.initEnemies(); enemies[0].setWalkLimits(28, 42); enemies[1].setWalkLimits(58, 75); enemies[2].setWalkLimits(96, 108); enemies[3].setWalkLimits(125, 134); enemies[1].walk(); enemies[2].walk(); enemies[3].walk(); } override protected function initPhysics():void{ physics = new Physics(worldWidth, worldHeight, 0, 10, getXMLData(LevelData)); } override public function retryLevel():void{ super.retryLevel(); } override public function dispose():void{ super.dispose(); if (challengeCutScene){ challengeCutScene.dispose(); challengeCutScene.removeEventListener(Event.COMPLETE, onChallengeCutSceneComplete); }; } } }//package com.kerb.uncharted.game.levels
Section 101
//Level1_LevelData (com.kerb.uncharted.game.levels.Level1_LevelData) package com.kerb.uncharted.game.levels { import mx.core.*; public class Level1_LevelData extends ByteArrayAsset { } }//package com.kerb.uncharted.game.levels
Section 102
//Level2 (com.kerb.uncharted.game.levels.Level2) package com.kerb.uncharted.game.levels { import flash.events.*; import flash.display.*; import com.kerb.sound.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.props.*; import com.kerb.uncharted.game.characters.*; import Box2D.Common.Math.*; import com.kerb.uncharted.game.cutScenes.*; public class Level2 extends AbstractLevel { private var backgroundLayer:MovieClip; private var manualCameraPosition:b2Vec2; private var manualCameraGoalY:Number; private var postCutSceneDuration:Number; private var challengeCutScenePlayed:Boolean; private var manualCameraStartY:Number; private var endCutScene:Level2CutScene2; private var manualCameraDispY:Number; private var challengeCutScene:Level2CutScene1; private var LevelData:Class; private var postCutSceneCounter:Number; private var postCutScenePause:Number; private var cutSceneDoor:MovieClip; private var cutSceneBody:MoveableBody; public function Level2(){ LevelData = Level2_LevelData; super(); } override public function retryLevel():void{ super.retryLevel(); } override protected function initCustomFGGraphics():void{ renderer.createMovieClipLayer(worldWidth, worldHeight, Main.afm.createMovieClip("graphics", "Level2ForegroundAsset")); } override protected function init():void{ var _local1:MoveableBody; var _local2:AbstractProp; super.init(); avatar.setAmmo(100, 0); avatar.selectWeaponNum(Avatar.PISTOL); challengeCutScenePlayed = false; renderer.setCameraRect(150, 150, (viewportWidth - 400), (viewportHeight - 250)); for each (_local1 in moveableBodies) { if (_local1.body.GetUserData() == "cutSceneWall"){ cutSceneBody = _local1; break; }; }; for each (_local2 in props) { if ((_local2 is CrumblingBlock)){ CrumblingBlock(_local2).crumbleFrame = 74; }; }; cutSceneDoor = Main.afm.createMovieClip("graphics", "Level2CutSceneDoorAsset"); cutSceneDoor.x = 3654; cutSceneDoor.y = 831; propsLayer.sprite.addChild(cutSceneDoor); } override protected function initCustomBGGraphics():void{ backgroundLayer = Main.afm.createMovieClip("graphics", "Level2BackgroundAsset"); renderer.createMovieClipLayer(worldWidth, worldHeight, backgroundLayer); } private function updatePostCutScene(_arg1:Event):void{ var _local10:Number; var _local2:Number = (postCutSceneCounter % postCutSceneDuration); var _local3:Number = postCutSceneDuration; var _local4:Number = manualCameraStartY; var _local5:Number = manualCameraDispY; if (postCutScenePause == 0){ _local2 = (_local2 / (_local3 / 2)); if (_local2 < 1){ manualCameraPosition.y = ((((_local5 / 2) * _local2) * _local2) + _local4); } else { --_local2; manualCameraPosition.y = (((-(_local5) / 2) * ((_local2 * (_local2 - 2)) - 1)) + _local4); }; postCutSceneCounter++; }; var _local6:Number = Math.atan2(avatar.mc.mouseY, (avatar.mc.scaleX * avatar.mc.mouseX)); var _local7:Number = 1.7; var _local8:Number = (_local7 * Math.cos(_local6)); var _local9:Number = (_local7 * Math.sin(_local6)); mouseOffsetX = (mouseOffsetX + (0.05 * (_local8 - mouseOffsetX))); mouseOffsetY = (mouseOffsetY + (0.05 * (_local9 - mouseOffsetY))); manualCameraPosition.x = (manualCameraPosition.x + mouseOffsetX); manualCameraPosition.y = (manualCameraPosition.y + mouseOffsetY); renderer.draw(manualCameraPosition); manualCameraPosition.x = (manualCameraPosition.x - mouseOffsetX); manualCameraPosition.y = (manualCameraPosition.y - mouseOffsetY); if (postCutSceneCounter == postCutSceneDuration){ if (postCutScenePause++ == 0){ removeMoveableBody(cutSceneBody); cutSceneBody.destroy(); cutSceneBody = null; cutSceneDoor.gotoAndPlay("open"); } else { if (postCutScenePause == 15){ _local10 = manualCameraGoalY; manualCameraDispY = -(manualCameraDispY); manualCameraStartY = manualCameraGoalY; postCutScenePause = 0; }; }; } else { if (postCutSceneCounter == (2 * postCutSceneDuration)){ removeEventListener(Event.ENTER_FRAME, updatePostCutScene); resumeGame(); }; }; } override protected function initPhysics():void{ physics = new Physics(worldWidth, worldHeight, 0, 10, getXMLData(LevelData)); } override protected function getLevelSound():ExtendedSound{ return (Main.smMusic.getSoundByClassName("Level2LoopSound")); } override protected function initProperties():void{ super.initProperties(); worldWidth = 120; worldHeight = 32; maxBonusTime = 180000; } override public function dispose():void{ super.dispose(); if (challengeCutScene){ challengeCutScene.dispose(); challengeCutScene.removeEventListener(Event.COMPLETE, onChallengeCutSceneComplete); }; removeEventListener(Event.ENTER_FRAME, updatePostCutScene); } override public function onCutScene(_arg1:String):void{ if ((((_arg1 == "cutScene1")) && (!(challengeCutScenePlayed)))){ pauseGame(); challengeCutScene = new Level2CutScene1(); challengeCutScene.addEventListener(Event.COMPLETE, onChallengeCutSceneComplete, false, 0, true); addChildAt(challengeCutScene, 1); } else { if (_arg1 == "cutScene2"){ pauseGame(); endCutScene = new Level2CutScene2(); endCutScene.addEventListener(Event.COMPLETE, onEndCutSceneComplete, false, 0, true); addChildAt(endCutScene, 1); }; }; } private function onEndCutSceneComplete(_arg1:Event):void{ endCutScene.removeEventListener(Event.COMPLETE, onEndCutSceneComplete); endCutScene.dispose(); removeChild(endCutScene); endCutScene = null; winLevel(); } override protected function initEnemies():void{ super.initEnemies(); enemies[0].setWalkLimits(21, 24.8); enemies[1].setWalkLimits(25.6, 28.7); enemies[4].setWalkLimits(44, 50.2); enemies[9].setWalkLimits(77.4, 83.6); enemies[1].walk(); enemies[4].walk(); enemies[9].walk(); } private function onChallengeCutSceneComplete(_arg1:Event):void{ challengeCutScene.removeEventListener(Event.COMPLETE, onChallengeCutSceneComplete); challengeCutScene.dispose(); removeChild(challengeCutScene); challengeCutScene = null; challengeCutScenePlayed = true; manualCameraGoalY = cutSceneBody.body.GetPosition().y; Main.smSFX.getSoundByClassName("PortcullisSound").play(0, 1); postCutSceneCounter = 0; postCutSceneDuration = 50; postCutScenePause = 0; avatar.stand(); manualCameraPosition = avatar.body.GetPosition().Copy(); manualCameraStartY = manualCameraPosition.y; manualCameraDispY = (manualCameraGoalY - manualCameraStartY); addEventListener(Event.ENTER_FRAME, updatePostCutScene); } } }//package com.kerb.uncharted.game.levels
Section 103
//Level2_LevelData (com.kerb.uncharted.game.levels.Level2_LevelData) package com.kerb.uncharted.game.levels { import mx.core.*; public class Level2_LevelData extends ByteArrayAsset { } }//package com.kerb.uncharted.game.levels
Section 104
//Level3 (com.kerb.uncharted.game.levels.Level3) package com.kerb.uncharted.game.levels { import flash.events.*; import flash.display.*; import com.kerb.sound.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.props.*; import com.kerb.uncharted.game.characters.*; import com.kerb.uncharted.game.render.*; import com.kerb.uncharted.game.render.layers.*; import com.kerb.uncharted.game.cutScenes.*; public class Level3 extends AbstractLevel { private var challengeCutScenePlayed:Boolean; private var backgroundLayer:MovieClip; private var pillar:Pillar; private var challengeCutScene:Level3CutScene1; private var LevelData:Class; public function Level3(){ LevelData = Level3_LevelData; super(); } override protected function getLevelSound():ExtendedSound{ return (Main.smMusic.getSoundByClassName("Level3LoopSound")); } override protected function initCustomFGGraphics():void{ renderer.createMovieClipLayer(worldWidth, worldHeight, Main.afm.createMovieClip("graphics", "Level3ForegroundAsset")); } override public function onCutScene(_arg1:String):void{ if ((((_arg1 == "cutScene1")) && (!(challengeCutScenePlayed)))){ pauseGame(); challengeCutScene = new Level3CutScene1(); challengeCutScene.addEventListener(Event.COMPLETE, onChallengeCutSceneComplete, false, 0, true); addChildAt(challengeCutScene, 1); } else { if (_arg1 == "cutScene2"){ winLevel(); }; }; } override public function retryLevel():void{ super.retryLevel(); } override protected function init():void{ super.init(); pillar = new Pillar(physics, 21.81, 11.11, 1.44, 7.73); propsLayer.sprite.addChild(pillar.mc); moveableBodies.push(pillar); avatar.setAmmo(100, 0); avatar.selectWeaponNum(Avatar.PISTOL); renderer.setCameraRect(150, 150, (viewportWidth - 400), (viewportHeight - 280)); } override protected function initCustomBGGraphics():void{ var _local1:SimpleLayer; _local1 = renderer.createSimpleLayer((1080 * Renderer.INVERSE_RENDER_SCALE), 0); _local1.sprite.addChild(Main.afm.createMovieClip("graphics", "Level1BackdropAsset")); backgroundLayer = Main.afm.createMovieClip("graphics", "Level3BackgroundAsset"); renderer.createMovieClipLayer(worldWidth, worldHeight, backgroundLayer); } override protected function initProperties():void{ super.initProperties(); worldWidth = 95; worldHeight = 35; maxBonusTime = 180000; } private function onChallengeCutSceneComplete(_arg1:Event):void{ var _local2:MoveableBody; for each (_local2 in moveableBodies) { if (_local2.body.GetUserData() == "cutSceneFloor"){ removeMoveableBody(_local2); _local2.destroy(); break; }; }; backgroundLayer.cutSceneDoor.gotoAndPlay("open"); challengeCutScene.removeEventListener(Event.COMPLETE, onChallengeCutSceneComplete); challengeCutScene.dispose(); removeChild(challengeCutScene); challengeCutScene = null; challengeCutScenePlayed = true; resumeGame(); } override protected function initPhysics():void{ physics = new Physics(worldWidth, worldHeight, 0, 10, getXMLData(LevelData)); } override protected function initEnemies():void{ super.initEnemies(); } override public function dispose():void{ super.dispose(); if (challengeCutScene){ challengeCutScene.dispose(); challengeCutScene.removeEventListener(Event.COMPLETE, onChallengeCutSceneComplete); }; } } }//package com.kerb.uncharted.game.levels
Section 105
//Level3_LevelData (com.kerb.uncharted.game.levels.Level3_LevelData) package com.kerb.uncharted.game.levels { import mx.core.*; public class Level3_LevelData extends ByteArrayAsset { } }//package com.kerb.uncharted.game.levels
Section 106
//Level4 (com.kerb.uncharted.game.levels.Level4) package com.kerb.uncharted.game.levels { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.sound.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.render.*; import com.kerb.uncharted.game.render.layers.*; public class Level4 extends AbstractLevel { private var backgroundLayer:MovieClip; private var scaleGoal:Number; private var LevelData:Class; private var subtitle:MovieClip; private var levelComplete:Boolean; public function Level4(){ LevelData = Level4_LevelData; super(); } override protected function getLevelSound():ExtendedSound{ return (Main.smMusic.getSoundByClassName("Level4LoopSound")); } override public function onCutScene(_arg1:String):void{ levelComplete = true; } override protected function initProperties():void{ super.initProperties(); worldWidth = 130; worldHeight = 29; maxBonusTime = 60000; } override protected function initCustomFGGraphics():void{ } override protected function initCustomBGGraphics():void{ var _local1:SimpleLayer; _local1 = renderer.createSimpleLayer((880 * Renderer.INVERSE_RENDER_SCALE), 0); _local1.sprite.addChild(Main.afm.createMovieClip("graphics", "Level4BackdropAsset")); backgroundLayer = Main.afm.createMovieClip("graphics", "Level4BackgroundAsset"); renderer.createMovieClipLayer(worldWidth, worldHeight, backgroundLayer); } override protected function onEnterFrame(_arg1:Event=null):void{ var _local2:Number = Math.abs(avatar.body.GetLinearVelocity().x); if (_local2 > 10){ _local2 = 10; }; _local2 = (_local2 * 0.1); _local2 = (1 - _local2); _local2 = (_local2 * 0.25); scaleGoal = (0.75 + _local2); var _local3:Number = renderer.scale; _local3 = (_local3 + (0.05 * (scaleGoal - _local3))); renderer.scale = _local3; if (avatar.body.GetPosition().x > 105){ addChild(subtitle); }; super.onEnterFrame(_arg1); if (levelComplete){ winLevel(); }; } override protected function init():void{ super.init(); avatar.setAmmo(100, 0); scaleGoal = 1; levelComplete = false; subtitle = Main.afm.createMovieClip("cutScenes", "SubtitleAsset"); subtitle.x = 278; subtitle.y = 301; TextManager.getInstance().setTextField(subtitle.label_txt, "end.scene.copy.1"); renderer.setCameraRect(150, 120, (viewportWidth - 400), (viewportHeight - 200)); } override protected function initPhysics():void{ physics = new Physics(worldWidth, worldHeight, 0, 10, getXMLData(LevelData)); } override public function dispose():void{ super.dispose(); } } }//package com.kerb.uncharted.game.levels
Section 107
//Level4_LevelData (com.kerb.uncharted.game.levels.Level4_LevelData) package com.kerb.uncharted.game.levels { import mx.core.*; public class Level4_LevelData extends ByteArrayAsset { } }//package com.kerb.uncharted.game.levels
Section 108
//Level5 (com.kerb.uncharted.game.levels.Level5) package com.kerb.uncharted.game.levels { import flash.events.*; import flash.display.*; import com.kerb.sound.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.characters.*; import flash.utils.*; import com.kerb.uncharted.game.render.layers.*; import com.kerb.uncharted.game.panels.*; public class Level5 extends AbstractLevel { private var winPanel:GameWinPanel; private var LevelData:Class; private var background:MovieClip; private var helicopterSound:ExtendedSound; private var helicopterMachineGunSound:ExtendedSound; public function Level5(){ LevelData = Level5_LevelData; super(); } override protected function initCustomBGGraphics():void{ background = Main.afm.createMovieClip("cutScenes", "Level5BackdropAsset"); background.addEventListener("onHelicopterAppear", onHelicopterAppear, false, 0, true); background.addEventListener("onHelicopterShoot", onHelicopterShoot, false, 0, true); background.addEventListener("onHelicopterFadeOut", onHelicopterFadeOut, false, 0, true); var _local1:SimpleLayer = renderer.createSimpleLayer(0, 0); _local1.sprite.addChild(background); } override protected function getLevelSound():ExtendedSound{ return (Main.smMusic.getSoundByClassName("Level5LoopSound")); } private function onHelicopterFadeOut(_arg1:Event):void{ helicopterSound.fadeOut(500); helicopterMachineGunSound.fadeOut(1500); } private function onReplay(_arg1:Event):void{ winPanel.removeEventListener("replay", onReplay); winPanel.removeEventListener("highScore", onHighScore); dispatchEvent(new Event(EVENT_LOSE)); } private function onHelicopterShoot(_arg1:Event):void{ helicopterMachineGunSound.play(0, 999999); } override protected function initProperties():void{ super.initProperties(); worldWidth = 11; worldHeight = 8; maxBonusTime = 60000; } private function onHelicopterAppear(_arg1:Event):void{ helicopterSound.play(0, 999999); } override public function dispose():void{ background.removeEventListener("onHelicopterAppear", onHelicopterAppear); background.removeEventListener("onHelicopterShoot", onHelicopterShoot); background.removeEventListener("onHelicopterFadeOut", onHelicopterFadeOut); helicopterSound.stop(); helicopterMachineGunSound.stop(); super.dispose(); } override protected function initCustomFGGraphics():void{ } override protected function initPhysics():void{ physics = new Physics(worldWidth, worldHeight, 0, 10, getXMLData(LevelData)); } private function onHighScore(_arg1:Event):void{ winPanel.removeEventListener("replay", onReplay); winPanel.removeEventListener("highScore", onHighScore); dispatchEvent(new Event(EVENT_WIN)); } override protected function init():void{ helicopterSound = Main.smSFX.getSoundByClassName("HelicopterLoopSound"); helicopterMachineGunSound = Main.smSFX.getSoundByClassName("HelicopterMachineGunLoopSound"); super.init(); avatar.setAmmo(200, 200); avatar.selectWeaponNum(Avatar.MACHINE_GUN); renderer.setCameraRect(0, 0, viewportWidth, viewportHeight); } override protected function onEnterFrame(_arg1:Event=null):void{ var _local4:Number; avatar.setKeys(keyControl.keys); physics.update(); renderer.draw(avatar.body.GetPosition()); updateMoveableBodies(); updateBullets(); totalTime = ((getTimer() - startTime) - pauseOffset); ui.updateTime(totalTime); if (background.currentFrame == 293){ avatar.mc.visible = false; avatar.setAmmo(0, 0); }; var _local2:int = (background.totalFrames - background.currentFrame); var _local3:Number = 8; if (_local2 <= _local3){ _local4 = ((0.42 * (_local3 - _local2)) / _local3); _local4 = (_local4 + 0.58); renderer.fadeToBlack(_local4); if ((((_local2 == 0)) && ((winPanel == null)))){ background.stop(); pauseGame(); gameOver = true; winPanel = new GameWinPanel(); winPanel.addEventListener("replay", onReplay, false, 0, true); winPanel.addEventListener("highScore", onHighScore, false, 0, true); addChild(winPanel); }; }; } } }//package com.kerb.uncharted.game.levels
Section 109
//Level5_LevelData (com.kerb.uncharted.game.levels.Level5_LevelData) package com.kerb.uncharted.game.levels { import mx.core.*; public class Level5_LevelData extends ByteArrayAsset { } }//package com.kerb.uncharted.game.levels
Section 110
//GameWinPanel (com.kerb.uncharted.game.panels.GameWinPanel) package com.kerb.uncharted.game.panels { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import com.kerb.tracking.*; import com.kerb.ui.*; import com.kerb.uncharted.game.utils.*; public class GameWinPanel extends Sprite { private var hsl:HighScoreLoader; private var play_btn:DynamicButton; private var currPoints:int; private var mc:MovieClip; private var submit_btn:DynamicButton; private var goalPoints:int; private var pointIncrement:int; public function GameWinPanel(){ mc = Main.afm.createMovieClip("interface", "GameWinPanelAsset"); addChild(mc); addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); hsl = HighScoreLoader.getInstance(); hsl.addEventListener(HighScoreLoader.ON_SAVED, onSaved); hsl.addEventListener(HighScoreLoader.ON_SAVE_ERROR, onSaveError); } private function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); init(); } private function onSaved(_arg1:Event):void{ Main.smMusic.getSoundByClassName("EndScoreLoopSound").stop(); trace("score save ok"); hsl.removeEventListener(HighScoreLoader.ON_SAVED, onSaved); hsl.removeEventListener(HighScoreLoader.ON_SAVE_ERROR, onSaveError); removeEventListener(Event.ENTER_FRAME, onEnterFrame); dispatchEvent(new Event("highScore")); } private function onPlayClick(_arg1:MouseEvent):void{ Main.onButtonPress(); Main.smMusic.getSoundByClassName("EndScoreLoopSound").stop(); hsl.removeEventListener(HighScoreLoader.ON_SAVED, onSaved); hsl.removeEventListener(HighScoreLoader.ON_SAVE_ERROR, onSaveError); dispatchEvent(new Event("replay")); } private function init():void{ var _local1:TextManager = TextManager.getInstance(); _local1.setTextField(mc.scoreLabel.label_txt, "endgame.title.scoretotal"); _local1.setTextField(mc.submit.nameLabel.label_txt, "score.text.enter"); mc.totalPoints.label_txt.text = "00000"; play_btn = new DynamicButton(mc.playAgain.play_btn, "endgame.title.play"); play_btn.addEventListener(MouseEvent.CLICK, onPlayClick, false, 0, true); submit_btn = new DynamicButton(mc.submit.submit_btn, "endgame.title.submit"); submit_btn.addEventListener(MouseEvent.CLICK, onSubmitClick, false, 0, true); mc.playAgain.play_btn.hit.width = mc.playAgain.play_btn.up.label_txt.textWidth; mc.playAgain.play_btn.hit.x = ((mc.playAgain.play_btn.up.x + mc.playAgain.play_btn.up.width) - mc.playAgain.play_btn.hit.width); mc.submit.submit_btn.hit.width = mc.submit.submit_btn.up.label_txt.textWidth; mc.submit.submit_btn.hit.x = ((mc.submit.submit_btn.up.x + mc.submit.submit_btn.up.width) - mc.submit.submit_btn.hit.width); stage.focus = mc.submit.userName_txt; currPoints = 0; goalPoints = UserData.totalScore; pointIncrement = 187; addEventListener(Event.ENTER_FRAME, onEnterFrame); Main.smMusic.getSoundByClassName("EndScoreLoopSound").play(0, 999999); } private function onEnterFrame(_arg1:Event):void{ currPoints = (currPoints + pointIncrement); if (currPoints >= goalPoints){ currPoints = goalPoints; removeEventListener(Event.ENTER_FRAME, onEnterFrame); }; mc.totalPoints.label_txt.text = String(("00000" + currPoints)).substr(-5); } private function onSubmitClick(_arg1:MouseEvent):void{ Main.onButtonPress(); var _local2:String = mc.submit.userName_txt.text; if (_local2 != ""){ DoubleQuick.event((Constants.SEEDED) ? 527 : 542); WebTrends.event((Constants.locale + "/Global/ScoreSubmitted"), "Score Submitted"); hsl.save(UserData.totalScore, _local2); }; } private function onSaveError(_arg1:Event):void{ trace("score save error"); mc.submit.userName_txt.text = ""; stage.focus = mc.submit.userName_txt; } } }//package com.kerb.uncharted.game.panels
Section 111
//HelpPanel (com.kerb.uncharted.game.panels.HelpPanel) package com.kerb.uncharted.game.panels { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import com.kerb.ui.*; public class HelpPanel extends MovieClip { private var scoring_btn:DynamicButton; private var story_btn:DynamicButton; private var controls_btn:DynamicButton; private var mc:MovieClip; public function HelpPanel(){ addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } private function onControlsButtonClicked(_arg1:MouseEvent):void{ Main.onButtonPress(); setCurrentSection("controls"); } private function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); init(); } private function onScoringButtonClicked(_arg1:MouseEvent):void{ Main.onButtonPress(); setCurrentSection("scoring"); } private function setCurrentSection(_arg1:String):void{ mc.gotoAndStop(_arg1); story_btn.selected = (_arg1 == "story"); controls_btn.selected = (_arg1 == "controls"); scoring_btn.selected = (_arg1 == "scoring"); } private function onCloseClick(_arg1:MouseEvent):void{ Main.onButtonPress(); mc.close_btn.removeEventListener(MouseEvent.CLICK, onCloseClick); story_btn.dispose(); controls_btn.dispose(); scoring_btn.dispose(); dispatchEvent(new Event(Event.CLOSE)); } private function init():void{ mc = Main.afm.createMovieClip("interface", "HelpPanelAsset"); addChild(mc); mc.frame.mouseEnabled = false; if ((((Constants.locale == "es_ES")) || ((Constants.locale == "it_IT")))){ mc.frame.logo.gotoAndStop(Constants.locale); }; story_btn = new DynamicButton(mc.story_btn, "instructions.title.story"); story_btn.addEventListener(MouseEvent.CLICK, onStoryButtonClicked, false, 0, true); controls_btn = new DynamicButton(mc.controls_btn, "instructions.title.controls"); controls_btn.addEventListener(MouseEvent.CLICK, onControlsButtonClicked, false, 0, true); scoring_btn = new DynamicButton(mc.scoring_btn, "instructions.title.scoring"); scoring_btn.addEventListener(MouseEvent.CLICK, onScoringButtonClicked, false, 0, true); mc.close_btn.addEventListener(MouseEvent.CLICK, onCloseClick, false, 0, true); setCurrentSection("story"); mc.story_mc.mouseEnabled = false; mc.scoring_mc.mouseEnabled = false; mc.controls_mc.mouseEnabled = false; mc.story_mc.mouseChildren = false; mc.scoring_mc.mouseChildren = false; mc.controls_mc.mouseChildren = false; initText(); } private function initText():void{ var _local1:TextManager = TextManager.getInstance(); _local1.setTextField(mc.title_mc.label_txt, "nav.title.help"); _local1.setTextField(mc.titleBG_mc.label_txt, "nav.title.help"); _local1.setTextField(mc.story_mc.txt, "instructions.story.para1"); _local1.setTextField(mc.controls_mc.jumpgrab_txt, "instructions.keys.controls.up"); _local1.setTextField(mc.controls_mc.left_txt, "instructions.keys.controls.left"); _local1.setTextField(mc.controls_mc.right_txt, "instructions.keys.controls.right"); _local1.setTextField(mc.controls_mc.drophide_txt, "instructions.keys.controls.down"); _local1.setTextField(mc.controls_mc.shoot_txt, "instructions.mouse.controls.shoot"); _local1.setTextField(mc.controls_mc.aim_txt, "instructions.mouse.controls.aim"); _local1.setTextField(mc.controls_mc.changeweapon_txt, "instructions.mouse.controls.weapon"); _local1.setTextField(mc.scoring_mc.txt1_mc.txt, "instructions.scoring.para1"); _local1.setTextField(mc.scoring_mc.txt2_mc.txt, "instructions.scoring.para2"); _local1.centerTextField(mc.story_mc.txt); _local1.centerTextField(mc.scoring_mc.txt1_mc.txt); story_btn.initText(); controls_btn.initText(); scoring_btn.initText(); } private function onStoryButtonClicked(_arg1:MouseEvent):void{ Main.onButtonPress(); setCurrentSection("story"); } } }//package com.kerb.uncharted.game.panels
Section 112
//LevelWinPanel (com.kerb.uncharted.game.panels.LevelWinPanel) package com.kerb.uncharted.game.panels { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.utils.*; import flash.ui.*; public class LevelWinPanel extends Sprite { private var mc:MovieClip; private var currPoints:int; private var goalPoints:int; private var pointIncrement:int; public function LevelWinPanel(){ mc = Main.afm.createMovieClip("interface", "LevelWinPanelAsset"); addChild(mc); } private function onKeyDown(_arg1:KeyboardEvent):void{ if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){ complete(); }; } public function init(_arg1:int, _arg2:int, _arg3:int, _arg4:Stage):void{ mc.next_btn.addEventListener(MouseEvent.CLICK, onNextClick, false, 0, true); _arg4.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true); var _local5:TextManager = TextManager.getInstance(); _local5.setTextField(mc.treasureLabel.label_txt, "midgame.title.treasure"); _local5.setTextField(mc.accuracyLabel.label_txt, "midgame.title.accuracy"); _local5.setTextField(mc.scoreLabel.label_txt, "midgame.title.score"); mc.treasurePoints.label_txt.htmlText = (("<b>" + String(("00000" + _arg1)).substr(-5)) + "</b>"); mc.accuracyPoints.label_txt.htmlText = (("<b>" + String(("00000" + _arg3)).substr(-5)) + "</b>"); mc.totalPoints.label_txt.text = "00000"; currPoints = 0; goalPoints = UserData.totalScore; pointIncrement = 187; addEventListener(Event.ENTER_FRAME, onEnterFrame); Main.smMusic.getSoundByClassName("MidScoreLoopSound").play(0, 999999); } private function onEnterFrame(_arg1:Event):void{ currPoints = (currPoints + pointIncrement); if (currPoints >= goalPoints){ currPoints = goalPoints; removeEventListener(Event.ENTER_FRAME, onEnterFrame); }; mc.totalPoints.label_txt.text = String(("00000" + currPoints)).substr(-5); } private function complete():void{ Main.smMusic.getSoundByClassName("MidScoreLoopSound").stop(); mc.next_btn.removeEventListener(MouseEvent.CLICK, onNextClick); stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); removeEventListener(Event.ENTER_FRAME, onEnterFrame); dispatchEvent(new Event(Event.COMPLETE)); } private function onNextClick(_arg1:MouseEvent):void{ Main.onButtonPress(); complete(); } } }//package com.kerb.uncharted.game.panels
Section 113
//BlastArea (com.kerb.uncharted.game.physics.BlastArea) package com.kerb.uncharted.game.physics { import com.kerb.uncharted.game.props.*; import com.kerb.uncharted.game.characters.*; import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; public class BlastArea implements IContactRespondable { public var body:b2Body; private var impulse:b2Vec2; private var radius:Number; private var radiusSquared:Number; private static const BLAST_FORCE:Number = 8; private static const MAX_CHARACTER_DAMAGE:Number = 250; public function BlastArea(_arg1:b2Body, _arg2:Number){ this.body = _arg1; this.radius = _arg2; radiusSquared = (_arg2 * _arg2); impulse = new b2Vec2(); _arg1.SetUserData(this); } public function destroy():void{ body.SetUserData(null); body.GetWorld().DestroyBody(body); body = null; } public function onAddContact(_arg1:b2ContactPoint):void{ var _local2:b2Body; var _local3:Number; var _local4:Number; var _local5:b2Vec2; var _local7:int; var _local8:int; _local2 = ((_arg1.shape1.GetBody())==body) ? _arg1.shape2.GetBody() : _arg1.shape1.GetBody(); _local3 = (_local2.GetPosition().x - body.GetPosition().x); _local4 = (_local2.GetPosition().y - body.GetPosition().y); impulse.x = ((BLAST_FORCE * (radius - _local3)) / radius); impulse.y = ((BLAST_FORCE * (radius - _local4)) / radius); if (_local3 < 0){ impulse.x = -(impulse.x); }; if (_local4 < 0){ impulse.y = -(impulse.y); }; _local5 = _local2.GetPosition().Copy(); _local2.GetPosition().Copy().x = (_local5.x + (Math.random() - 0.5)); _local5.y = (_local5.y + (Math.random() - 0.5)); _local2.ApplyImpulse(impulse, _local5); var _local6:Number = (((_local3 * _local3) + (_local4 * _local4)) / radiusSquared); if (_local6 > 1){ _local6 = 1; }; _local6 = (1 - _local6); if ((_local2.GetUserData() is Barrel)){ _local7 = 6; _local8 = Math.ceil(((_local6 * _local7) + (2 * Math.random()))); Barrel(_local2.GetUserData()).setDeferredExplosion(_local8); } else { if ((_local2.GetUserData() is Avatar)){ } else { if ((_local2.GetUserData() is Character)){ Character(_local2.GetUserData()).damage((_local6 * MAX_CHARACTER_DAMAGE)); }; }; }; } public function onPersistContact(_arg1:b2ContactPoint):void{ } public function onRemoveContact(_arg1:b2ContactPoint):void{ } } }//package com.kerb.uncharted.game.physics
Section 114
//ContactListener (com.kerb.uncharted.game.physics.ContactListener) package com.kerb.uncharted.game.physics { import flash.utils.*; import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Dynamics.Contacts.*; public class ContactListener extends b2ContactListener { private var contactPointCount:Dictionary; public function ContactListener(){ contactPointCount = new Dictionary(true); super(); } override public function Add(_arg1:b2ContactPoint, _arg2:b2Contact):void{ var _local3:*; var _local4:*; if (!contactPointCount[_arg2]){ contactPointCount[_arg2] = 0; _local3 = _arg1.shape1.GetBody().GetUserData(); _local4 = _arg1.shape2.GetBody().GetUserData(); if ((_local3 is IContactRespondable)){ IContactRespondable(_local3).onAddContact(_arg1); }; if ((_local4 is IContactRespondable)){ IContactRespondable(_local4).onAddContact(_arg1); }; }; var _local5 = contactPointCount; var _local6 = _arg2; var _local7 = (_local5[_local6] + 1); _local5[_local6] = _local7; } override public function Persist(_arg1:b2ContactPoint, _arg2:b2Contact):void{ var _local3:* = _arg1.shape1.GetBody().GetUserData(); var _local4:* = _arg1.shape2.GetBody().GetUserData(); if ((_local3 is IContactRespondable)){ IContactRespondable(_local3).onPersistContact(_arg1); }; if ((_local4 is IContactRespondable)){ IContactRespondable(_local4).onPersistContact(_arg1); }; } override public function Remove(_arg1:b2ContactPoint, _arg2:b2Contact):void{ var _local3:*; var _local4:*; var _local5 = contactPointCount; var _local6 = _arg2; var _local7 = (_local5[_local6] - 1); _local5[_local6] = _local7; if (contactPointCount[_arg2] == 0){ _local3 = _arg1.shape1.GetBody().GetUserData(); _local4 = _arg1.shape2.GetBody().GetUserData(); if ((_local3 is IContactRespondable)){ IContactRespondable(_local3).onRemoveContact(_arg1); }; if ((_local4 is IContactRespondable)){ IContactRespondable(_local4).onRemoveContact(_arg1); }; }; } } }//package com.kerb.uncharted.game.physics
Section 115
//CustomContactFilter (com.kerb.uncharted.game.physics.CustomContactFilter) package com.kerb.uncharted.game.physics { import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; public class CustomContactFilter extends b2ContactFilter { override public function RayCollide(_arg1, _arg2:b2Shape):Boolean{ if (_arg2.IsSensor()){ return (false); }; return (super.RayCollide(_arg1, _arg2)); } } }//package com.kerb.uncharted.game.physics
Section 116
//IContactRespondable (com.kerb.uncharted.game.physics.IContactRespondable) package com.kerb.uncharted.game.physics { import Box2D.Collision.*; public interface IContactRespondable { function onPersistContact(_arg1:b2ContactPoint):void; function onRemoveContact(_arg1:b2ContactPoint):void; function onAddContact(_arg1:b2ContactPoint):void; } }//package com.kerb.uncharted.game.physics
Section 117
//MoveableBody (com.kerb.uncharted.game.physics.MoveableBody) package com.kerb.uncharted.game.physics { import flash.display.*; import com.kerb.uncharted.*; import Box2D.Dynamics.*; import com.kerb.uncharted.game.render.*; import Box2D.Common.Math.*; public class MoveableBody { public var body:b2Body; protected var coupled:Boolean;// = true protected var position:b2Vec2; public var mc:MovieClip; protected var velocity:b2Vec2; public static const MAX_VELOCITY:Number = 15; public function MoveableBody(_arg1:b2Body){ this.body = _arg1; this.mc = new MovieClip(); } public function destroy():void{ if (body){ destroyBody(); }; mc.parent.removeChild(mc); mc = null; } public function pause():void{ } protected function rescursiveStop(_arg1:MovieClip):void{ _arg1.stop(); var _local2:int; while (_local2 < _arg1.numChildren) { if ((_arg1.getChildAt(_local2) is MovieClip)){ rescursiveStop(MovieClip(_arg1.getChildAt(_local2))); }; _local2++; }; } public function update():void{ position = body.GetPosition(); velocity = body.GetLinearVelocity(); if (coupled){ mc.x = (Renderer.RENDER_SCALE * position.x); mc.y = (Renderer.RENDER_SCALE * position.y); mc.rotation = (Constants.RAD_2_DEG * body.GetAngle()); }; if (velocity.x > MAX_VELOCITY){ velocity.x = MAX_VELOCITY; body.SetLinearVelocity(velocity); } else { if (velocity.x < -(MAX_VELOCITY)){ velocity.x = -(MAX_VELOCITY); body.SetLinearVelocity(velocity); }; }; if (velocity.y > MAX_VELOCITY){ velocity.y = MAX_VELOCITY; body.SetLinearVelocity(velocity); } else { if (velocity.y < -(MAX_VELOCITY)){ velocity.y = -(MAX_VELOCITY); body.SetLinearVelocity(velocity); }; }; } public function resume():void{ } protected function rescursivePlay(_arg1:MovieClip):void{ var _local2:int; while (_local2 < _arg1.numChildren) { if ((_arg1.getChildAt(_local2) is MovieClip)){ rescursivePlay(MovieClip(_arg1.getChildAt(_local2))); }; _local2++; }; _arg1.play(); } public function destroyBody():void{ body.SetUserData(null); body.GetWorld().DestroyBody(body); body = null; } } }//package com.kerb.uncharted.game.physics
Section 118
//Physics (com.kerb.uncharted.game.physics.Physics) package com.kerb.uncharted.game.physics { import flash.display.*; import com.kerb.uncharted.game.characters.*; import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; import com.boristhebrave.Box2DWith.*; public class Physics { private var moveableBodies:Array; private var world:b2World; private var avatar:Avatar; private var blastAreas:Array; private var terrain:Terrain; private var debugDraw:b2DebugDraw; public static const DEFAULT_LINEAR_DAMPING:Number = 0; public static const DEFAULT_ANGULAR_DAMPING:Number = 0; public static const DEFAULT_FRICTION:Number = 0.1; public static const DEFAULT_RESTITUTION:Number = 0; private static const DT:Number = 0; public function Physics(_arg1:int, _arg2:int, _arg3:Number, _arg4:Number, _arg5:XML){ var _local12:b2Body; super(); var _local6:b2AABB = new b2AABB(); _local6.lowerBound.Set(-1, -1); _local6.upperBound.Set((_arg1 + 1), (_arg2 + 1)); var _local7:b2Vec2 = new b2Vec2(_arg3, _arg4); world = new b2World(_local6, _local7, false); world.SetContactListener(new ContactListener()); world.SetContactFilter(new CustomContactFilter()); terrain = Terrain.getInstance(); terrain.init(_arg1, _arg2); blastAreas = new Array(); moveableBodies = new Array(); loadData(_arg5); var _local8:Number = (0.5 * _arg1); var _local9:Number = (0.5 * _arg2); var _local10:Number = (_arg1 + 2); var _local11:Number = (_arg2 + 2); _local12 = addBox(_local8, -0.5, _local10, 1); _local12.SetUserData("top edge"); _local12 = addBox(_local8, (_arg2 + 0.5), _local10, 1); _local12.SetUserData("bottom edge"); _local12 = addBox(-0.5, _local9, 1, _local11); _local12.SetUserData("edge"); _local12 = addBox((_arg1 + 0.5), _local9, 1, _local11); _local12.SetUserData("edge"); } public function createPolyData(_arg1:Array, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0.1, _arg7:Number=0, _arg8:Boolean=false, _arg9:int=0, _arg10:uint=1, _arg11:uint=0xFFFF):b2PolygonDef{ var _local12:b2Vec2 = new b2Vec2(_arg2, _arg3); var _local13:b2PolygonDef = new b2PolygonDef(); _local13.vertices = _arg1; _local13.vertexCount = _arg1.length; _local13.density = _arg5; _local13.friction = _arg6; _local13.restitution = _arg7; _local13.isSensor = _arg8; _local13.filter.groupIndex = _arg9; _local13.filter.categoryBits = _arg10; _local13.filter.maskBits = _arg11; return (_local13); } public function addBlastArea(_arg1:b2Vec2):void{ var _local2:Number = 4; var _local3:b2Body = addCircle(_arg1.x, _arg1.y, _local2, 1, 0, 0, 0, 0, true); var _local4:BlastArea = new BlastArea(_local3, _local2); blastAreas.push(_local4); } public function update():void{ world.Step(DT, 10, 10); terrain.update(world); var _local1:int = blastAreas.length; while (--_local1 > -1) { blastAreas[_local1].destroy(); }; blastAreas = []; } public function setGravity(_arg1:Number, _arg2:Number):void{ world.SetGravity(new b2Vec2(_arg1, _arg2)); } public function addPoly():void{ } public function addCircle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=0, _arg5:Number=0.1, _arg6:Number=0, _arg7:Number=0, _arg8:Number=0, _arg9:Boolean=false, _arg10:Boolean=false, _arg11:Boolean=false, _arg12:Boolean=false, _arg13:int=0, _arg14:uint=1, _arg15:uint=0xFFFF):b2Body{ var _local16:b2CircleDef = createCircleData(_arg3, 0, 0, _arg4, _arg5, _arg6, _arg9, _arg13, _arg14, _arg15); return (createBody(_local16, _arg1, _arg2, 0, _arg12, _arg10, _arg11, _arg7, _arg8)); } public function dispose():void{ debugDraw = null; moveableBodies = null; avatar = null; var _local1:b2Body = world.GetBodyList(); while (_local1) { world.DestroyBody(_local1); _local1 = _local1.GetNext(); }; world = null; } public function setWireframeSprite(_arg1:Sprite):void{ debugDraw.SetSprite(_arg1); } public function loadData(_arg1:XML):void{ var _local2:MoveableBody; b2XML.loadWorld(_arg1, world); moveableBodies = moveableBodies.concat(terrain.getMoveableBodies()); for each (_local2 in moveableBodies) { if (_local2.body.GetUserData() == "avatar"){ avatar = Avatar(_local2); break; }; }; } public function addBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0, _arg7:Number=0.1, _arg8:Number=0, _arg9:Number=0, _arg10:Number=0, _arg11:Boolean=false, _arg12:Boolean=false, _arg13:Boolean=false, _arg14:Boolean=false, _arg15:int=0, _arg16:uint=1, _arg17:uint=0xFFFF):b2Body{ var _local18:b2PolygonDef = createBoxData(_arg3, _arg4, 0, 0, 0, _arg6, _arg7, _arg8, _arg11, _arg15, _arg16, _arg17); return (createBody(_local18, _arg1, _arg2, _arg5, _arg14, _arg12, _arg13, _arg9, _arg10)); } public function createCircleData(_arg1:Number, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0.1, _arg6:Number=0, _arg7:Boolean=false, _arg8:int=0, _arg9:uint=1, _arg10:uint=0xFFFF):b2CircleDef{ var _local11:b2Vec2 = new b2Vec2(_arg2, _arg3); _local11.x = _arg2; _local11.y = _arg3; var _local12:b2CircleDef = new b2CircleDef(); _local12.radius = _arg1; _local12.localPosition = _local11; _local12.density = _arg4; _local12.friction = _arg5; _local12.restitution = _arg6; _local12.isSensor = _arg7; _local12.filter.groupIndex = _arg8; _local12.filter.categoryBits = _arg9; _local12.filter.maskBits = _arg10; return (_local12); } public function createBoxData(_arg1:Number, _arg2:Number, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0, _arg7:Number=0.1, _arg8:Number=0, _arg9:Boolean=false, _arg10:int=0, _arg11:uint=1, _arg12:uint=0xFFFF):b2PolygonDef{ var _local13:b2Vec2 = new b2Vec2(_arg3, _arg4); var _local14:b2PolygonDef = new b2PolygonDef(); _local14.SetAsOrientedBox((0.5 * _arg1), (0.5 * _arg2), _local13, _arg5); _local14.density = _arg6; _local14.friction = _arg7; _local14.restitution = _arg8; _local14.isSensor = _arg9; _local14.filter.groupIndex = _arg10; _local14.filter.categoryBits = _arg11; _local14.filter.maskBits = _arg12; return (_local14); } public function createBody(_arg1:b2ShapeDef, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean=false, _arg6:Boolean=false, _arg7:Boolean=false, _arg8:Number=0, _arg9:Number=0):b2Body{ var _local10:b2BodyDef = new b2BodyDef(); _local10.position.Set(_arg2, _arg3); _local10.angle = _arg4; _local10.fixedRotation = _arg7; _local10.isBullet = _arg5; _local10.allowSleep = _arg6; _local10.angularDamping = _arg8; _local10.linearDamping = _arg9; var _local11:b2Body = world.CreateBody(_local10); _local11.CreateShape(_arg1); _local11.SetMassFromShapes(); return (_local11); } } }//package com.kerb.uncharted.game.physics
Section 119
//Terrain (com.kerb.uncharted.game.physics.Terrain) package com.kerb.uncharted.game.physics { import flash.display.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.props.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import com.kerb.uncharted.game.render.*; import Box2D.Common.Math.*; public class Terrain { private var moveableBodies:Array; protected var bins:Array; protected var binHeight:Number; protected var rows:int; protected var activeBodies:Array; private var props:Array; protected var numBins:int; protected var cols:int; protected var binWidth:Number; protected static const DEFAULT_BIN_WIDTH:Number = 20; protected static const DEFAULT_BIN_HEIGHT:Number = 20; private static var allowInstantiation:Boolean = false; private static var instance:Terrain = null; public function Terrain(){ if (!allowInstantiation){ throw (new Error("Terrain is a Singleton.")); }; } public function getMoveableBodies():Array{ return (moveableBodies); } public function drawBins(_arg1:Graphics):void{ _arg1.lineStyle(0, Constants.BIN_GRID_COLOUR, 0.2); var _local2:int; while (_local2 <= rows) { _arg1.moveTo(0, ((_local2 * binHeight) * Renderer.RENDER_SCALE)); _arg1.lineTo(((cols * binWidth) * Renderer.RENDER_SCALE), ((_local2 * binHeight) * Renderer.RENDER_SCALE)); _local2++; }; var _local3:int; while (_local3 <= cols) { _arg1.moveTo(((_local3 * binWidth) * Renderer.RENDER_SCALE), 0); _arg1.lineTo(((_local3 * binWidth) * Renderer.RENDER_SCALE), ((rows * binHeight) * Renderer.RENDER_SCALE)); _local3++; }; } public function unregisterMoveableBody(_arg1:MoveableBody):void{ if (moveableBodies.indexOf(_arg1) != -1){ moveableBodies.splice(moveableBodies.indexOf(_arg1), 1); }; } public function update(_arg1:b2World):void{ var _local2:int; var _local3:b2Vec2; var _local4:TerrainBody; var _local5:MoveableBody; var _local6:Array; var _local7:Array = []; for each (_local4 in activeBodies) { _local4.marked = true; }; for each (_local5 in moveableBodies) { _local3 = _local5.body.GetPosition(); _local6 = getBinFromPosition(_local3); if (_local6){ for each (_local4 in _local6) { if (_local4.checkProximity(_local3.x, _local3.y, _arg1)){ if (_local4.marked){ _local4.marked = false; } else { if ((((_local7.indexOf(_local4) == -1)) && ((activeBodies.indexOf(_local4) == -1)))){ _local7.push(_local4); }; }; }; }; }; }; _local2 = activeBodies.length; while (--_local2 > -1) { _local4 = activeBodies[_local2]; if (_local4.marked){ _local4.destroyBody(_arg1); activeBodies.splice(_local2, 1); }; }; if (_local7.length > 0){ activeBodies = activeBodies.concat(_local7); }; } public function init(_arg1:Number, _arg2:Number, _arg3:int=20, _arg4:int=20):void{ this.binWidth = _arg3; this.binHeight = _arg4; initBins(_arg1, _arg2); moveableBodies = new Array(); activeBodies = new Array(); props = new Array(); } public function addBody(_arg1:b2BodyDef, _arg2:b2ShapeDef):void{ var _local9:int; var _local10:int; var _local3:TerrainBody = new TerrainBody(_arg1, _arg2); var _local4:int = (_local3.l / binWidth); var _local5:int = (_local3.r / binWidth); var _local6:int = (_local3.t / binHeight); var _local7:int = (_local3.b / binHeight); if (_local4 < 0){ _local4 = 0; }; if (_local5 < 0){ _local5 = 0; }; if (_local6 < 0){ _local6 = 0; }; if (_local7 < 0){ _local7 = 0; }; var _local8:int = _local6; while (_local8 <= _local7) { _local9 = _local4; while (_local9 <= _local5) { _local10 = ((_local8 * cols) + _local9); if (_local10 < numBins){ bins[_local10].push(_local3); }; _local9++; }; _local8++; }; } protected function getBinFromPosition(_arg1:b2Vec2):Array{ var _local2:int = (_arg1.x / binWidth); var _local3:int = (_arg1.y / binHeight); var _local4:int = ((_local3 * cols) + _local2); if ((((_local4 < 0)) || ((_local4 >= numBins)))){ return (null); }; return (bins[_local4]); } public function registerProp(_arg1:AbstractProp):void{ if (props.indexOf(_arg1) == -1){ props.push(_arg1); }; } public function registerMoveableBody(_arg1:MoveableBody):void{ if (moveableBodies.indexOf(_arg1) == -1){ moveableBodies.push(_arg1); }; } public function getProps():Array{ return (props); } protected function initBins(_arg1:Number, _arg2:Number):void{ cols = Math.ceil((_arg1 / binWidth)); rows = Math.ceil((_arg2 / binHeight)); numBins = (cols * rows); bins = new Array(numBins); var _local3:int; while (_local3 < numBins) { bins[_local3] = new Array(); _local3++; }; } public static function getInstance():Terrain{ if (!instance){ allowInstantiation = true; instance = new (Terrain); allowInstantiation = false; }; return (instance); } } }//package com.kerb.uncharted.game.physics
Section 120
//TerrainBody (com.kerb.uncharted.game.physics.TerrainBody) package com.kerb.uncharted.game.physics { import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; public class TerrainBody { protected var bd:b2BodyDef; protected var body:b2Body; public var l:Number; public var b:Number; protected var sd:b2ShapeDef; public var r:Number; public var t:Number; public var marked:Boolean; public function TerrainBody(_arg1:b2BodyDef, _arg2:b2ShapeDef){ this.bd = _arg1; this.sd = _arg2; if ((_arg2 is b2CircleDef)){ setAABBFromCircle(b2CircleDef(_arg2)); } else { if ((_arg2 is b2PolygonDef)){ setAABBFromPolygon(b2PolygonDef(_arg2)); } else { throw (new Error("Unrecognised shape in TerrainBody constructor")); }; }; l = (l - MoveableBody.MAX_VELOCITY); r = (r + MoveableBody.MAX_VELOCITY); t = (t - MoveableBody.MAX_VELOCITY); b = (b + MoveableBody.MAX_VELOCITY); } public function destroyBody(_arg1:b2World):void{ if (body){ _arg1.DestroyBody(body); body = null; }; marked = false; } protected function setAABBFromPolygon(_arg1:b2PolygonDef):void{ var _local3:b2Vec2; var _local4:Number; var _local5:Number; l = Number.MAX_VALUE; r = Number.MIN_VALUE; t = Number.MAX_VALUE; b = Number.MIN_VALUE; var _local2:int; while (_local2 < _arg1.vertexCount) { _local3 = _arg1.vertices[_local2]; _local4 = (bd.position.x + _local3.x); _local5 = (bd.position.y + _local3.y); if (_local4 < l){ l = _local4; }; if (_local4 > r){ r = _local4; }; if (_local5 < t){ t = _local5; }; if (_local5 > b){ b = _local5; }; _local2++; }; } public function checkProximity(_arg1:Number, _arg2:Number, _arg3:b2World):Boolean{ if (_arg1 > l){ if (_arg1 < r){ if (_arg2 > t){ if (_arg2 < b){ if (body == null){ body = _arg3.CreateBody(bd); body.CreateShape(sd); }; return (true); }; }; }; }; return (false); } protected function setAABBFromCircle(_arg1:b2CircleDef):void{ l = (bd.position.x - _arg1.radius); r = (bd.position.x + _arg1.radius); t = (bd.position.y - _arg1.radius); b = (bd.position.y + _arg1.radius); } } }//package com.kerb.uncharted.game.physics
Section 121
//Bullet (com.kerb.uncharted.game.projectiles.Bullet) package com.kerb.uncharted.game.projectiles { import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.characters.*; import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Common.Math.*; public class Bullet implements IContactRespondable { public var hitAngle:Number; public var hitX:Number; public var body:b2Body; public var hitY:Number; public var damage:Number;// = 0 public var target:b2Body; public var hit:Boolean;// = false public var owner:Character; private static const RADIUS:Number = 0.02; private static const IMPULSE:Number = 20; private static const DENSITY:Number = 0.001; public function Bullet(_arg1:Physics, _arg2:b2Vec2, _arg3:Number, _arg4:Character){ var _local6:int; var _local7:int; var _local8:b2Vec2; super(); this.owner = _arg4; var _local5 = 1; if ((_arg4 is Avatar)){ _local6 = 8; _local7 = 5; } else { _local6 = 16; _local7 = 3; }; body = _arg1.addCircle(_arg2.x, _arg2.y, RADIUS, DENSITY, Physics.DEFAULT_FRICTION, Physics.DEFAULT_RESTITUTION, Physics.DEFAULT_LINEAR_DAMPING, Physics.DEFAULT_ANGULAR_DAMPING, false, true, false, false, _local5, _local6, _local7); body.SetUserData(this); body.SetBullet(true); _local8 = new b2Vec2(); _local8.x = (IMPULSE * Math.cos(_arg3)); _local8.y = (IMPULSE * Math.sin(_arg3)); body.ApplyImpulse(_local8, body.GetPosition()); } public function destroy():void{ body.SetUserData(null); body.GetWorld().DestroyBody(body); body = null; owner = null; } public function onPersistContact(_arg1:b2ContactPoint):void{ } public function onAddContact(_arg1:b2ContactPoint):void{ target = _arg1.shape1.GetBody(); if (target == body){ target = _arg1.shape2.GetBody(); if (_arg1.shape2.IsSensor()){ return; }; } else { if (_arg1.shape1.IsSensor()){ return; }; }; hit = true; hitX = _arg1.position.x; hitY = _arg1.position.y; hitAngle = Math.atan2(body.GetLinearVelocity().y, body.GetLinearVelocity().x); } public function onRemoveContact(_arg1:b2ContactPoint):void{ } } }//package com.kerb.uncharted.game.projectiles
Section 122
//MachineGunBullet (com.kerb.uncharted.game.projectiles.MachineGunBullet) package com.kerb.uncharted.game.projectiles { import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.characters.*; import Box2D.Common.Math.*; public class MachineGunBullet extends Bullet { public function MachineGunBullet(_arg1:Physics, _arg2:b2Vec2, _arg3:Number, _arg4:Character){ damage = ((_arg4 is Avatar)) ? 10 : 2; super(_arg1, _arg2, _arg3, _arg4); } } }//package com.kerb.uncharted.game.projectiles
Section 123
//PistolBullet (com.kerb.uncharted.game.projectiles.PistolBullet) package com.kerb.uncharted.game.projectiles { import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.characters.*; import Box2D.Common.Math.*; public class PistolBullet extends Bullet { public function PistolBullet(_arg1:Physics, _arg2:b2Vec2, _arg3:Number, _arg4:Character){ damage = ((_arg4 is Avatar)) ? 15 : 7; super(_arg1, _arg2, _arg3, _arg4); } } }//package com.kerb.uncharted.game.projectiles
Section 124
//AbstractProp (com.kerb.uncharted.game.props.AbstractProp) package com.kerb.uncharted.game.props { import flash.display.*; import Box2D.Dynamics.*; public class AbstractProp { public var body:b2Body; protected var _taken:Boolean; public var value:int; public var mc:MovieClip; public function AbstractProp(_arg1:b2Body){ this.body = _arg1; this.mc = new MovieClip(); _taken = false; } public function get taken():Boolean{ return (_taken); } public function set taken(_arg1:Boolean):void{ _taken = _arg1; } public function destroy():void{ destroyBody(); mc.parent.removeChild(mc); mc = null; } public function destroyBody():void{ body.SetUserData(null); body.GetWorld().DestroyBody(body); body = null; } } }//package com.kerb.uncharted.game.props
Section 125
//AmmoDump (com.kerb.uncharted.game.props.AmmoDump) package com.kerb.uncharted.game.props { import com.kerb.uncharted.game.physics.*; import Box2D.Dynamics.*; public class AmmoDump extends AbstractProp { public function AmmoDump(_arg1:Physics, _arg2:Number, _arg3:Number, _arg4:int){ value = _arg4; var _local5:b2Body = _arg1.addCircle(_arg2, _arg3, 0.5, 0, 0, 0, 0, 0, true); super(_local5); _local5.SetUserData(this); } } }//package com.kerb.uncharted.game.props
Section 126
//Barrel (com.kerb.uncharted.game.props.Barrel) package com.kerb.uncharted.game.props { import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import Box2D.Dynamics.*; public class Barrel extends MoveableBody { private var explosionCounter:int; public function Barrel(_arg1:b2Body){ super(_arg1); _arg1.SetUserData(this); mc = Main.afm.createMovieClip("graphics", "BarrelAsset"); explosionCounter = -1; } public function checkExplosionCounter():Boolean{ if (explosionCounter > 0){ return ((--explosionCounter == 0)); }; return (false); } public function setDeferredExplosion(_arg1:int):void{ explosionCounter = _arg1; } } }//package com.kerb.uncharted.game.props
Section 127
//Beam (com.kerb.uncharted.game.props.Beam) package com.kerb.uncharted.game.props { import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import Box2D.Dynamics.*; import com.kerb.uncharted.game.render.*; public class Beam extends MoveableBody { public function Beam(_arg1:b2Body){ super(_arg1); _arg1.SetUserData(this); mc = Main.afm.createMovieClip("graphics", "Level3BeamAsset"); mc.x = (_arg1.GetPosition().x * Renderer.RENDER_SCALE); mc.y = (_arg1.GetPosition().y * Renderer.RENDER_SCALE); } } }//package com.kerb.uncharted.game.props
Section 128
//CrumblingBlock (com.kerb.uncharted.game.props.CrumblingBlock) package com.kerb.uncharted.game.props { import com.kerb.uncharted.*; import Box2D.Dynamics.*; import com.kerb.uncharted.game.render.*; public class CrumblingBlock extends AbstractProp { private var soundPlayed:Boolean;// = false public var crumbleFrame:int;// = 2 public function CrumblingBlock(_arg1:b2Body){ super(_arg1); var _local2:String = _arg1.GetUserData(); _local2 = _local2.charAt((_local2.length - 1)); _arg1.SetUserData(this); mc = Main.afm.createMovieClip("graphics", (("CrumblingBlock" + _local2) + "Asset")); mc.x = (_arg1.GetPosition().x * Renderer.RENDER_SCALE); mc.y = (_arg1.GetPosition().y * Renderer.RENDER_SCALE); } override public function get taken():Boolean{ return ((mc.currentFrame > crumbleFrame)); } override public function destroy():void{ destroyBody(); } public function crumble():void{ if (!soundPlayed){ Main.smSFX.getSoundByClassName("CrumbleSound").play(); }; mc.play(); } } }//package com.kerb.uncharted.game.props
Section 129
//CrumblingBridge (com.kerb.uncharted.game.props.CrumblingBridge) package com.kerb.uncharted.game.props { import com.kerb.uncharted.*; import Box2D.Dynamics.*; import com.kerb.uncharted.game.render.*; public class CrumblingBridge extends AbstractProp { private var soundPlayed:Boolean;// = false private var takenFrame:int; public function CrumblingBridge(_arg1:b2Body){ super(_arg1); var _local2:String = _arg1.GetUserData(); _local2 = _local2.charAt((_local2.length - 1)); _arg1.SetUserData(this); mc = Main.afm.createMovieClip("graphics", (("CrumblingBridge" + _local2) + "Asset")); mc.x = (_arg1.GetPosition().x * Renderer.RENDER_SCALE); mc.y = (_arg1.GetPosition().y * Renderer.RENDER_SCALE); switch (_local2){ case "1": takenFrame = 17; break; case "2": takenFrame = 17; break; case "3": takenFrame = 17; break; default: takenFrame = 1; }; } public function crumble():void{ if (!soundPlayed){ Main.smSFX.getSoundByClassName("CrumbleSound").play(); }; mc.play(); } override public function get taken():Boolean{ return ((mc.currentFrame >= takenFrame)); } override public function destroy():void{ destroyBody(); } } }//package com.kerb.uncharted.game.props
Section 130
//MachineGunAmmoDump (com.kerb.uncharted.game.props.MachineGunAmmoDump) package com.kerb.uncharted.game.props { import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.render.*; public class MachineGunAmmoDump extends AmmoDump { public function MachineGunAmmoDump(_arg1:Physics, _arg2:Number, _arg3:Number, _arg4:int){ super(_arg1, _arg2, _arg3, _arg4); mc = Main.afm.createMovieClip("graphics", "MachineGunAmmoAsset"); mc.x = (body.GetPosition().x * Renderer.RENDER_SCALE); mc.y = (body.GetPosition().y * Renderer.RENDER_SCALE); } } }//package com.kerb.uncharted.game.props
Section 131
//Pillar (com.kerb.uncharted.game.props.Pillar) package com.kerb.uncharted.game.props { import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import Box2D.Collision.*; import Box2D.Dynamics.*; import Box2D.Collision.Shapes.*; import com.kerb.uncharted.game.render.*; import Box2D.Common.Math.*; public class Pillar extends MoveableBody implements IContactRespondable { private var soundPlayed:Boolean; private var wedgeShape:b2Shape; private var damageApplied:Boolean; private var damaged:Boolean; public function Pillar(_arg1:Physics, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number){ var _local6:Number = 10; var _local7:Array = []; _local7.push(new b2Vec2((-0.5 * _arg4), (-0.5 * _arg5))); _local7.push(new b2Vec2((0.5 * _arg4), (-0.5 * _arg5))); _local7.push(new b2Vec2((0.5 * _arg4), (0.5 * _arg5))); _local7.push(new b2Vec2((-0.5 * _arg4), (0.45 * _arg5))); var _local8:b2PolygonDef = _arg1.createPolyData(_local7, 0, 0, 0, _local6); var _local9:Array = []; _local9.push(new b2Vec2((-0.5 * _arg4), (0.45 * _arg5))); _local9.push(new b2Vec2((0.5 * _arg4), (0.5 * _arg5))); _local9.push(new b2Vec2((-0.5 * _arg4), (0.5 * _arg5))); var _local10:b2PolygonDef = _arg1.createPolyData(_local9, 0, 0, 0, _local6); var _local11:b2Body = _arg1.createBody(_local8, _arg2, _arg3, 0); wedgeShape = _local11.CreateShape(_local10); _local11.SetMassFromShapes(); super(_local11); mc = Main.afm.createMovieClip("graphics", "Level3PillarAsset"); mc.x = (body.GetPosition().x * Renderer.RENDER_SCALE); mc.y = (body.GetPosition().y * Renderer.RENDER_SCALE); body.SetUserData(this); damaged = false; damageApplied = false; soundPlayed = false; } public function onAddContact(_arg1:b2ContactPoint):void{ var _local2:b2Body = ((_arg1.shape1.GetBody())==body) ? _arg1.shape2.GetBody() : _arg1.shape1.GetBody(); if ((_local2.GetUserData() is BlastArea)){ damaged = true; }; if ((((_arg1.normal.x < 0)) && ((_arg1.normal.y > 0.9)))){ if (!soundPlayed){ soundPlayed = true; Main.smSFX.getSoundByClassName("CrashSound").play(); }; }; } override public function update():void{ super.update(); if (((damaged) && (!(damageApplied)))){ body.DestroyShape(wedgeShape); damageApplied = true; mc.gotoAndStop("damaged"); }; } public function onPersistContact(_arg1:b2ContactPoint):void{ } public function onRemoveContact(_arg1:b2ContactPoint):void{ } } }//package com.kerb.uncharted.game.props
Section 132
//PistolAmmoDump (com.kerb.uncharted.game.props.PistolAmmoDump) package com.kerb.uncharted.game.props { import com.kerb.uncharted.*; import com.kerb.uncharted.game.physics.*; import com.kerb.uncharted.game.render.*; public class PistolAmmoDump extends AmmoDump { public function PistolAmmoDump(_arg1:Physics, _arg2:Number, _arg3:Number, _arg4:int){ super(_arg1, _arg2, _arg3, _arg4); mc = Main.afm.createMovieClip("graphics", "PistolAmmoAsset"); mc.x = (body.GetPosition().x * Renderer.RENDER_SCALE); mc.y = (body.GetPosition().y * Renderer.RENDER_SCALE); } } }//package com.kerb.uncharted.game.props
Section 133
//Treasure (com.kerb.uncharted.game.props.Treasure) package com.kerb.uncharted.game.props { import com.kerb.uncharted.*; import Box2D.Dynamics.*; import com.kerb.uncharted.game.render.*; public class Treasure extends AbstractProp { public function Treasure(_arg1:b2Body){ super(_arg1); value = parseInt(_arg1.GetUserData().substr(9)); _arg1.SetUserData(this); mc = Main.afm.createMovieClip("graphics", "TreasureAsset"); mc.x = (_arg1.GetPosition().x * Renderer.RENDER_SCALE); mc.y = (_arg1.GetPosition().y * Renderer.RENDER_SCALE); } } }//package com.kerb.uncharted.game.props
Section 134
//MovieClipLayer (com.kerb.uncharted.game.render.layers.MovieClipLayer) package com.kerb.uncharted.game.render.layers { import flash.display.*; import flash.geom.*; public class MovieClipLayer extends SimpleLayer { protected var head:MovieClip; public function MovieClipLayer(_arg1:Number, _arg2:Number, _arg3:MovieClip){ super(_arg1, _arg2); initMovieClips(_arg3); } override public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{ super.update(_arg1, _arg2, _arg3, _arg4); var _local5:Number = -(_arg1); var _local6:Number = (_local5 + _arg3); var _local7:Number = -(_arg2); var _local8:Number = (_local7 + _arg4); var _local9:MovieClip = head; while (_local9) { if (_local9.l < _local6){ if (_local9.r > _local5){ if (_local9.t < _local8){ if (_local9.b > _local7){ if (!_local9.parent){ _local9.container.addChild(_local9); }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; _local9 = _local9.next; }; } protected function initMovieClips(_arg1:MovieClip):void{ var _local2:int; var _local3:int; var _local4:MovieClip; var _local5:MovieClip; var _local6:Sprite; var _local7:Rectangle; var _local8:Boolean; if (_arg1){ _local3 = _arg1.numChildren; _local2 = 0; while (_local2 < _local3) { if ((_arg1.getChildAt(_local2) is MovieClip)){ _local5 = MovieClip(_arg1.getChildAt(_local2)); _arg1.removeChild(_local5); _local2--; _local3--; if (_local4){ _local4.next = _local5; } else { head = _local5; }; _local4 = _local5; _local6 = new Sprite(); _local5.container = _local6; sprite.addChild(_local6); _local7 = _local5.getBounds(_arg1); _local5.l = _local7.left; _local5.r = _local7.right; _local5.t = _local7.top; _local5.b = _local7.bottom; } else { _local8 = true; }; _local2++; }; }; if (_local8){ trace("WARNING:"); trace((("The source movieclip (" + _arg1) + ") contains children that are not movieclips.")); trace("These children will not be rendered."); }; } override public function dispose():void{ var _local2:MovieClip; var _local1:MovieClip = head; while (_local1) { _local2 = _local1.next; _local1 = null; _local1 = _local2; }; super.dispose(); } } }//package com.kerb.uncharted.game.render.layers
Section 135
//MovieClipLayerFixedX (com.kerb.uncharted.game.render.layers.MovieClipLayerFixedX) package com.kerb.uncharted.game.render.layers { import flash.display.*; public class MovieClipLayerFixedX extends MovieClipLayer { public function MovieClipLayerFixedX(_arg1:Number, _arg2:Number, _arg3:MovieClip){ super(_arg1, _arg2, _arg3); } override public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{ sprite.y = (this.y = _arg2); var _local5:Number = -(_arg1); var _local6:Number = (_local5 + _arg3); var _local7:Number = -(_arg2); var _local8:Number = (_local7 + _arg4); var _local9:MovieClip = head; while (_local9) { if (_local9.l < _local6){ if (_local9.r > _local5){ if (_local9.t < _local8){ if (_local9.b > _local7){ if (!_local9.parent){ _local9.container.addChild(_local9); }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; _local9 = _local9.next; }; } } }//package com.kerb.uncharted.game.render.layers
Section 136
//MovieClipLayerFixedY (com.kerb.uncharted.game.render.layers.MovieClipLayerFixedY) package com.kerb.uncharted.game.render.layers { import flash.display.*; public class MovieClipLayerFixedY extends MovieClipLayer { public function MovieClipLayerFixedY(_arg1:Number, _arg2:Number, _arg3:MovieClip){ super(_arg1, _arg2, _arg3); } override public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{ sprite.x = (this.x = _arg1); var _local5:Number = -(_arg1); var _local6:Number = (_local5 + _arg3); var _local7:Number = -(_arg2); var _local8:Number = (_local7 + _arg4); var _local9:MovieClip = head; while (_local9) { if (_local9.l < _local6){ if (_local9.r > _local5){ if (!_local9.parent){ _local9.container.addChild(_local9); }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; } else { if (_local9.parent){ _local9.container.removeChild(_local9); }; }; _local9 = _local9.next; }; } } }//package com.kerb.uncharted.game.render.layers
Section 137
//SimpleLayer (com.kerb.uncharted.game.render.layers.SimpleLayer) package com.kerb.uncharted.game.render.layers { import flash.display.*; public class SimpleLayer { public var sprite:Sprite; public var h:int; public var next:SimpleLayer; public var w:int; public var x:Number; public var y:Number; public function SimpleLayer(_arg1:Number, _arg2:Number){ this.w = _arg1; this.h = _arg2; x = 0; y = 0; sprite = new Sprite(); } public function dispose():void{ sprite = null; next = null; } public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{ sprite.x = (this.x = _arg1); sprite.y = (this.y = _arg2); } } }//package com.kerb.uncharted.game.render.layers
Section 138
//SimpleLayerFixedX (com.kerb.uncharted.game.render.layers.SimpleLayerFixedX) package com.kerb.uncharted.game.render.layers { public class SimpleLayerFixedX extends SimpleLayer { public function SimpleLayerFixedX(_arg1:Number, _arg2:Number){ super(_arg1, _arg2); } override public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{ sprite.y = (this.y = _arg2); } } }//package com.kerb.uncharted.game.render.layers
Section 139
//SimpleLayerFixedY (com.kerb.uncharted.game.render.layers.SimpleLayerFixedY) package com.kerb.uncharted.game.render.layers { public class SimpleLayerFixedY extends SimpleLayer { public function SimpleLayerFixedY(_arg1:Number, _arg2:Number){ super(_arg1, _arg2); } override public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{ sprite.x = (this.x = _arg1); } } }//package com.kerb.uncharted.game.render.layers
Section 140
//Camera (com.kerb.uncharted.game.render.Camera) package com.kerb.uncharted.game.render { public class Camera { protected var _goalX:Number; protected var _goalY:Number; protected var _easingX:Number; protected var _easingY:Number; protected var _x:Number; protected var _y:Number; public function Camera(_arg1:Number, _arg2:Number){ cutTo(_arg1, _arg2); setEasing(1, 1); } public function get y():Number{ return (_y); } public function get easingX():Number{ return (_easingX); } public function cutTo(_arg1:Number, _arg2:Number):void{ _goalX = (_x = _arg1); _goalY = (_y = _arg2); } public function get goalX():Number{ return (_goalX); } public function moveBy(_arg1:Number, _arg2:Number):void{ _goalX = (_goalX + _arg1); _goalY = (_goalY + _arg2); } public function update():void{ _x = (_x + (_easingX * (_goalX - _x))); _y = (_y + (_easingY * (_goalY - _y))); } public function get goalY():Number{ return (_goalY); } public function setEasing(_arg1:Number, _arg2:Number):void{ if (_arg1 > 1){ _arg1 = 1; } else { if (_arg1 < 0){ _arg1 = 0; }; }; _easingX = _arg1; if (_arg2 > 1){ _arg2 = 1; } else { if (_arg2 < 0){ _arg2 = 0; }; }; _easingY = _arg2; } public function get x():Number{ return (_x); } public function moveTo(_arg1:Number, _arg2:Number):void{ _goalX = _arg1; _goalY = _arg2; } public function get easingY():Number{ return (_easingY); } } }//package com.kerb.uncharted.game.render
Section 141
//Renderer (com.kerb.uncharted.game.render.Renderer) package com.kerb.uncharted.game.render { import flash.display.*; import com.kerb.uncharted.*; import flash.geom.*; import Box2D.Common.Math.*; import com.kerb.uncharted.game.render.layers.*; import com.kerb.uncharted.game.fx.*; import flash.filters.*; public class Renderer extends Sprite { private var shakeCounterX:int; private var shakeCounterY:int; protected var scaledViewportWidth:Number; private var currDesaturate:Number; private var desaturateMatrix:Array; private var shakePowerX:Number; private var shakePowerY:Number; protected var scaledCameraRect:Rectangle; protected var camera:Camera; protected var cameraRect:Rectangle; protected var zoomScale:Number; private var cmf:ColorMatrixFilter; private var blurFilter:BlurFilter; protected var viewportWidth:int; protected var fxMovieClips:Array; protected var moveableLayers:SimpleLayer; protected var explosionPool:Array; protected var worldWidth:int; protected var fixedLayers:SimpleLayer; protected var worldHeight:int; private var greyLuma:Array; protected var layerMask:Shape; private var shakeInitX:Number; private var shakeInitY:Number; protected var scaledViewportHeight:Number; protected var viewportHeight:int; protected var layerSprite:Sprite; protected var explosions:Array; public static const INVERSE_RENDER_SCALE:Number = 0; public static const RENDER_SCALE:Number = 50; private static const MAX_SHAKE_DISTANCE:Number = 0; private static const SHAKE_DURATION:int = 15; private static var goalDesaturate:Number; public function Renderer(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number){ this.worldWidth = _arg1; this.worldHeight = _arg2; zoomScale = 1; layerSprite = new Sprite(); addChild(layerSprite); setViewport(_arg3, _arg4); camera = new Camera(0, 0); cameraRect = new Rectangle(0, 0, _arg3, _arg4); scaledCameraRect = cameraRect.clone(); fxMovieClips = []; explosions = []; explosionPool = []; var _local5:int; while (_local5 < 10) { explosionPool.push(new Explosion()); _local5++; }; cmf = new ColorMatrixFilter(); greyLuma = [0.413524, 0.816596, 0.10988, 0, 45.41, 0.413524, 0.816596, 0.10988, 0, 45.41, 0.413524, 0.816596, 0.10988, 0, 45.41, 0, 0, 0, 1, 0]; desaturateMatrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]; blurFilter = new BlurFilter(1, 1, 3); currDesaturate = 1; goalDesaturate = 1; } public function addBulletHit(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:SimpleLayer):void{ var _local6:MovieClip = Main.afm.createMovieClip("graphics", _arg1); _local6.x = (_arg2 * RENDER_SCALE); _local6.y = (_arg3 * RENDER_SCALE); _local6.rotation = (Constants.RAD_2_DEG * _arg4); _arg5.sprite.addChild(_local6); fxMovieClips.push(_local6); } private function shakeX():void{ shakeCounterX--; var _local1:Number = ((shakeCounterX * shakePowerX) * MAX_SHAKE_DISTANCE); if ((shakeCounterX % 2) == 1){ _local1 = -(_local1); }; x = (shakeInitX + _local1); } private function shakeY():void{ shakeCounterY--; var _local1:Number = ((shakeCounterY * shakePowerY) * MAX_SHAKE_DISTANCE); if ((shakeCounterY % 2) == 1){ _local1 = -(_local1); }; y = (shakeInitY + _local1); } public function set scale(_arg1:Number):void{ zoomScale = _arg1; layerSprite.scaleX = (layerSprite.scaleY = zoomScale); scaledViewportWidth = (viewportWidth / zoomScale); scaledViewportHeight = (viewportHeight / zoomScale); scaledCameraRect.left = (cameraRect.left / zoomScale); scaledCameraRect.right = (cameraRect.right / zoomScale); scaledCameraRect.top = (cameraRect.top / zoomScale); scaledCameraRect.bottom = (cameraRect.bottom / zoomScale); var _local2:SimpleLayer = fixedLayers; var _local3:Number = (1 / zoomScale); while (_local2) { _local2.sprite.scaleX = (_local2.sprite.scaleY = _local3); _local2 = _local2.next; }; } public function getCamera():Camera{ return (camera); } public function dispose():void{ var _local1:Explosion; var _local2:SimpleLayer; var _local3:SimpleLayer; for each (_local1 in explosionPool) { _local1.dispose(); }; _local2 = fixedLayers; while (_local2) { _local3 = _local2.next; _local2.dispose(); _local2 = _local3; }; _local2 = moveableLayers; while (_local2) { _local3 = _local2.next; _local2.dispose(); _local2 = _local3; }; } public function getCameraRect():Rectangle{ return (cameraRect); } public function createSimpleLayer(_arg1:int, _arg2:int, _arg3:int=-1):SimpleLayer{ var _local4:SimpleLayer; if ((((_arg1 == 0)) && ((_arg2 > 0)))){ _local4 = new SimpleLayerFixedX(_arg1, _arg2); } else { if ((((_arg1 > 0)) && ((_arg2 == 0)))){ _local4 = new SimpleLayerFixedY(_arg1, _arg2); } else { _local4 = new SimpleLayer(_arg1, _arg2); }; }; setupNewLayer(_local4, _arg3); return (_local4); } public function setCameraRect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{ cameraRect.x = _arg1; cameraRect.y = _arg2; cameraRect.width = _arg3; cameraRect.height = _arg4; scaledCameraRect.left = (cameraRect.left / zoomScale); scaledCameraRect.right = (cameraRect.right / zoomScale); scaledCameraRect.top = (cameraRect.top / zoomScale); scaledCameraRect.bottom = (cameraRect.bottom / zoomScale); } public function createMovieClipLayer(_arg1:int, _arg2:int, _arg3:MovieClip, _arg4:int=-1):MovieClipLayer{ var _local5:MovieClipLayer; if ((((_arg1 == 0)) && ((_arg2 > 0)))){ _local5 = new MovieClipLayerFixedX(_arg1, _arg2, _arg3); } else { if ((((_arg1 > 0)) && ((_arg2 == 0)))){ _local5 = new MovieClipLayerFixedY(_arg1, _arg2, _arg3); } else { _local5 = new MovieClipLayer(_arg1, _arg2, _arg3); }; }; setupNewLayer(_local5, _arg4); return (_local5); } protected function setupNewLayer(_arg1:SimpleLayer, _arg2:int=-1):void{ if (_arg2 == -1){ layerSprite.addChild(_arg1.sprite); } else { if (_arg2 < 0){ _arg2 = 0; } else { if (_arg2 > layerSprite.numChildren){ _arg2 = layerSprite.numChildren; }; }; layerSprite.addChildAt(_arg1.sprite, _arg2); }; if ((((_arg1.w == 0)) && ((_arg1.h == 0)))){ _arg1.next = fixedLayers; fixedLayers = _arg1; _arg1.update(_arg1.x, _arg1.y, scaledViewportWidth, scaledViewportHeight); } else { _arg1.next = moveableLayers; moveableLayers = _arg1; }; } public function fadeToBlack(_arg1:Number):void{ _arg1 = (_arg1 * -255); var _local2:ColorTransform = new ColorTransform(); _local2.redOffset = _arg1; _local2.greenOffset = _arg1; _local2.blueOffset = _arg1; transform.colorTransform = _local2; } public function desaturate(_arg1:Number):void{ goalDesaturate = _arg1; } private function easeDesaturation():void{ currDesaturate = (currDesaturate + (0.1 * (goalDesaturate - currDesaturate))); var _local1:int = desaturateMatrix.length; while (_local1--) { desaturateMatrix[_local1] = (greyLuma[_local1] + ((desaturateMatrix[_local1] - greyLuma[_local1]) * currDesaturate)); }; cmf.matrix = desaturateMatrix; blurFilter.blurX = (blurFilter.blurY = (10 * (1 - currDesaturate))); filters = ((currDesaturate)==1) ? [] : [cmf, blurFilter]; } public function draw(_arg1:b2Vec2):void{ var _local8:Number; var _local9:Number; var _local10:MovieClip; var _local11:Explosion; camera.moveTo((_arg1.x * RENDER_SCALE), (_arg1.y * RENDER_SCALE)); camera.update(); var _local2:Number = (camera.x / (worldWidth * RENDER_SCALE)); var _local3:Number = (camera.y / (worldHeight * RENDER_SCALE)); var _local4:Number = ((_local2 * scaledCameraRect.width) + scaledCameraRect.x); var _local5:Number = ((_local3 * scaledCameraRect.height) + scaledCameraRect.y); var _local6:SimpleLayer = moveableLayers; while (_local6) { _local8 = ((-(_local6.w) * _local2) * RENDER_SCALE); _local9 = ((-(_local6.h) * _local3) * RENDER_SCALE); _local8 = (_local8 + _local4); _local9 = (_local9 + _local5); _local6.update(Math.round(_local8), Math.round(_local9), scaledViewportWidth, scaledViewportHeight); _local6 = _local6.next; }; var _local7:int = fxMovieClips.length; while (--_local7 > -1) { _local10 = fxMovieClips[_local7]; if (_local10.currentFrame == _local10.totalFrames){ _local10.parent.removeChild(_local10); fxMovieClips.splice(_local7, 1); }; }; _local7 = explosions.length; while (--_local7 > -1) { _local11 = explosions[_local7]; if (_local11.update()){ explosions.splice(_local7, 1); explosionPool.push(_local11); _local11.parent.removeChild(_local11); }; }; if (shakeCounterX > 0){ shakeX(); }; if (shakeCounterY > 0){ shakeY(); }; if (currDesaturate != goalDesaturate){ easeDesaturation(); }; } public function reset():void{ zoomScale = 1; currDesaturate = 1; goalDesaturate = 1; } public function setViewport(_arg1:Number, _arg2:Number):void{ this.viewportWidth = _arg1; this.viewportHeight = _arg2; scaledViewportWidth = (_arg1 / zoomScale); scaledViewportHeight = (_arg2 / zoomScale); if (!layerMask){ layerMask = new Shape(); addChild(layerMask); layerSprite.mask = layerMask; }; layerMask.graphics.clear(); layerMask.graphics.beginFill(0); layerMask.graphics.drawRect(0, 0, _arg1, _arg2); layerMask.graphics.endFill(); graphics.clear(); graphics.beginFill(Constants.VIEWPORT_BACKGROUND_COLOUR); graphics.drawRect(0, 0, _arg1, _arg2); graphics.endFill(); } public function initShake(_arg1:Number, _arg2:Number):void{ this.shakePowerX = _arg1; this.shakePowerY = _arg2; shakeCounterX = (_arg1 * SHAKE_DURATION); shakeCounterY = (_arg2 * SHAKE_DURATION); shakeInitX = x; shakeInitY = y; } public function addExplosion(_arg1:Number, _arg2:Number, _arg3:SimpleLayer):void{ var _local4:Explosion; _local4 = explosionPool.pop(); if (!_local4){ _local4 = new Explosion(); }; _arg3.sprite.addChild(_local4); _local4.fire((_arg1 * RENDER_SCALE), (_arg2 * RENDER_SCALE)); explosions.push(_local4); initShake(0, 1.6); } public function get scale():Number{ return (zoomScale); } } }//package com.kerb.uncharted.game.render
Section 142
//ISerialisable (com.kerb.uncharted.game.utils.ISerialisable) package com.kerb.uncharted.game.utils { import flash.utils.*; public interface ISerialisable { function deserialise(_arg1:ByteArray):void; function serialise():ByteArray; } }//package com.kerb.uncharted.game.utils
Section 143
//KeyboardControl (com.kerb.uncharted.game.utils.KeyboardControl) package com.kerb.uncharted.game.utils { import flash.events.*; import flash.display.*; import flash.utils.*; import flash.ui.*; import flash.errors.*; public class KeyboardControl extends EventDispatcher implements ISerialisable { protected var k:uint;// = 0 protected var replayingHistory:Boolean; protected var replayCompleteEvent:Event; protected var history:ByteArray; public static const RIGHT_DOWN:uint = (1 << 3); public static const UP_DOWN:uint = (1 << 5); public static const LEFT:uint = (LEFT_PRESSED + LEFT_DOWN); protected static const ALL_PRESSED:uint = ((((LEFT_PRESSED + RIGHT_PRESSED) + UP_PRESSED) + DOWN_PRESSED) + SPACE_PRESSED); public static const LEFT_PRESSED:uint = (1 << 0); public static const LEFT_DOWN:uint = (1 << 1); public static const SPACE_DOWN:uint = (1 << 9); public static const UP_PRESSED:uint = (1 << 4); public static const DOWN_DOWN:uint = (1 << 7); protected static const ALL_DOWN:uint = ((((LEFT_DOWN + RIGHT_DOWN) + UP_DOWN) + DOWN_DOWN) + SPACE_DOWN); public static const DOWN_PRESSED:uint = (1 << 6); public static const SPACE:uint = (SPACE_PRESSED + SPACE_DOWN); public static const SPACE_PRESSED:uint = (1 << 8); public static const UP:uint = (UP_PRESSED + UP_DOWN); public static const DOWN:uint = (DOWN_PRESSED + DOWN_DOWN); public static const RIGHT:uint = (RIGHT_PRESSED + RIGHT_DOWN); public static const RIGHT_PRESSED:uint = (1 << 2); public function KeyboardControl(_arg1:Stage){ _arg1.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true); _arg1.addEventListener(KeyboardEvent.KEY_UP, onKeyUp, false, 0, true); replayCompleteEvent = new Event(Event.COMPLETE); resetHistory(); } protected function onKeyDown(_arg1:KeyboardEvent):void{ var _local2:uint = _arg1.keyCode; if ((((((_local2 == Keyboard.LEFT)) || ((_local2 == 65)))) && (!((k & LEFT_DOWN))))){ k = (k | LEFT); } else { if ((((((_local2 == Keyboard.RIGHT)) || ((_local2 == 68)))) && (!((k & RIGHT_DOWN))))){ k = (k | RIGHT); } else { if ((((((_local2 == Keyboard.UP)) || ((_local2 == 87)))) && (!((k & UP_DOWN))))){ k = (k | UP); } else { if ((((((_local2 == Keyboard.DOWN)) || ((_local2 == 83)))) && (!((k & DOWN_DOWN))))){ k = (k | DOWN); } else { if ((((_local2 == Keyboard.SPACE)) && (!((k & SPACE_DOWN))))){ k = (k | SPACE); }; }; }; }; }; } public function get keys():uint{ var kOut:uint; if (replayingHistory){ try { kOut = history.readUnsignedInt(); } catch(e:EOFError) { kOut = 0; dispatchEvent(replayCompleteEvent); }; } else { history.writeUnsignedInt(k); kOut = k; k = (k & ALL_DOWN); }; return (kOut); } public function resetHistory():void{ history = new ByteArray(); replayingHistory = false; } public function deserialise(_arg1:ByteArray):void{ _arg1.position = 0; var _local2:Object = _arg1.readObject(); history = _local2.history; } public function serialise():ByteArray{ var _local1:Object = new Object(); _local1.history = history; var _local2:ByteArray = new ByteArray(); _local2.writeObject(_local1); return (_local2); } protected function onKeyUp(_arg1:KeyboardEvent):void{ var _local2:uint = _arg1.keyCode; if ((((_local2 == Keyboard.LEFT)) || ((_local2 == 65)))){ k = (k & ~(LEFT)); } else { if ((((_local2 == Keyboard.RIGHT)) || ((_local2 == 68)))){ k = (k & ~(RIGHT)); } else { if ((((_local2 == Keyboard.UP)) || ((_local2 == 87)))){ k = (k & ~(UP)); } else { if ((((_local2 == Keyboard.DOWN)) || ((_local2 == 83)))){ k = (k & ~(DOWN)); } else { if (_local2 == Keyboard.SPACE){ k = (k & ~(SPACE)); }; }; }; }; }; } public function replayHistory():void{ history.position = 0; replayingHistory = true; } } }//package com.kerb.uncharted.game.utils
Section 144
//UserData (com.kerb.uncharted.game.utils.UserData) package com.kerb.uncharted.game.utils { public class UserData { public static var treasureScores:Array = []; public static var accuracyScores:Array = []; public static function get totalAccuracyScore():int{ var _local1:int; var _local2:int; while (_local2 < accuracyScores.length) { _local1 = (_local1 + accuracyScores[_local2]); _local2++; }; return (_local1); } public static function get totalScore():int{ return ((totalTreasureScore + totalAccuracyScore)); } public static function get totalTreasureScore():int{ var _local1:int; var _local2:int; while (_local2 < treasureScores.length) { _local1 = (_local1 + treasureScores[_local2]); _local2++; }; return (_local1); } } }//package com.kerb.uncharted.game.utils
Section 145
//UI (com.kerb.uncharted.game.UI) package com.kerb.uncharted.game { import flash.events.*; import flash.display.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.render.*; import com.kerb.tracking.*; public class UI { private var renderer:Renderer; private var life:int;// = 0 private var currWeapon:int; public var mc:MovieClip; public function UI(_arg1:MovieClip, _arg2:Renderer){ this.mc = _arg1; this.renderer = _arg2; _arg1.weapon.stop(); _arg1.mouseEnabled = false; _arg1.mouseChildren = true; _arg1.bg.mouseEnabled = false; _arg1.life.stop(); if ((((Constants.locale == "es_ES")) || ((Constants.locale == "it_IT")))){ _arg1.bg.logo.gotoAndStop(Constants.locale); }; _arg1.bg.logo.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true); _arg1.bg.logo.buttonMode = true; } public function updateLife(_arg1:int):void{ var _local2:int = ((_arg1)==0) ? 11 : Math.round((((100 - _arg1) / 10) + 1)); mc.life.gotoAndStop(_local2); if (_arg1 < this.life){ mc.damage.gotoAndPlay("damage"); }; this.life = _arg1; if (_arg1 < 0.5){ renderer.desaturate((2 * _arg1)); } else { renderer.desaturate(1); }; } public function updateScore(_arg1:int):void{ mc.score_txt.text = String(("00000" + _arg1)).substr(-5); } private function onLogoClick(_arg1:MouseEvent):void{ DoubleQuick.click((Constants.SEEDED) ? 532 : 545); WebTrends.event((Constants.locale + "/Global/Logo"), "Logo Clicked"); } public function updateTime(_arg1:int):void{ } public function updateWeapon(_arg1:int, _arg2:int):void{ currWeapon = _arg1; mc.weapon.gotoAndStop((_arg1 + 1)); if (_arg1 == 0){ mc.ammo_txt.text = ""; } else { mc.ammo_txt.text = _arg2; }; } public function showTreasureFound():void{ mc.treasure.gotoAndPlay("show"); } public function updateAmmo(_arg1:int, _arg2:int):void{ if (_arg1 == currWeapon){ updateCurrentAmmo(_arg2); }; } public function updateCurrentAmmo(_arg1:int):void{ mc.ammo_txt.text = _arg1; } } }//package com.kerb.uncharted.game
Section 146
//LanguagePanel (com.kerb.uncharted.panels.LanguagePanel) package com.kerb.uncharted.panels { import flash.events.*; import flash.display.*; import com.kerb.uncharted.*; public class LanguagePanel extends Sprite { private const LANGUAGES:Array; private var mc:MovieClip; public function LanguagePanel(){ var _local1:String; LANGUAGES = ["de_AT", "en_AU", "nl_BE", "fr_BE", "da_DK", "fi_FI", "fr_FR", "de_DE", "en_IE", "it_IT", "de_LU", "fr_LU", "nl_NL", "en_NZ", "no_NO", "it_CH", "de_CH", "fr_CH", "pt_PT", "es_ES", "sv_SE", "pl_PL", "ru_RU", "en_GB"]; super(); mc = Main.afm.createMovieClip("interface", "LanguageSelectPanelAsset"); addChild(mc); for each (_local1 in LANGUAGES) { if (mc.buttons.getChildByName((_local1 + "_btn")) != null){ mc.buttons.getChildByName((_local1 + "_btn")).addEventListener(MouseEvent.CLICK, onLanguageSelect, false, 0, true); } else { trace(("missing language button for " + _local1)); }; }; } protected function onLanguageSelect(_arg1:MouseEvent):void{ Main.onButtonPress(); var _local2:String = SimpleButton(_arg1.currentTarget).name; Constants.locale = _local2.substring(0, (_local2.length - 4)); Main.initText(); dispose(); dispatchEvent(new Event(Event.CLOSE)); } protected function dispose():void{ var _local1:String; for each (_local1 in LANGUAGES) { if (mc.buttons.getChildByName((_local1 + "_btn")) != null){ mc.buttons.getChildByName((_local1 + "_btn")).removeEventListener(MouseEvent.CLICK, onLanguageSelect); }; }; } } }//package com.kerb.uncharted.panels
Section 147
//AbstractScreen (com.kerb.uncharted.screens.control.AbstractScreen) package com.kerb.uncharted.screens.control { import flash.events.*; import flash.display.*; public class AbstractScreen extends Sprite { public var initialisationEvent:ScreenEvent; public function AbstractScreen(){ addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } public function onTopOfEverything():Boolean{ return (false); } protected function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); stage.focus = stage; init(); } public function enable():void{ } public function onLanguageChanged():void{ initText(); } public function disable():void{ } public function notify(_arg1:ScreenEvent):void{ if (_arg1.id == ScreenEvent.DISABLE){ disable(); } else { if (_arg1.id == ScreenEvent.ENABLE){ enable(); stage.focus = stage; }; }; } public function showConfirmScreenOnExit():Boolean{ return (false); } protected function init():void{ } protected function initText():void{ } public function dispose():void{ } } }//package com.kerb.uncharted.screens.control
Section 148
//ScreenEvent (com.kerb.uncharted.screens.control.ScreenEvent) package com.kerb.uncharted.screens.control { import flash.events.*; public class ScreenEvent extends Event { public var id:int; public var data; public var confirmId:String; public static const EVENT:String = "onEvent"; public static const ENABLE:int = 3; public static const TITLE_MENU:int = 11; public static const CHANGE_LANGUAGE:int = 666; public static const DISABLE:int = 2; public static const MANUAL_CAMERA_TO_POINT:int = 102; public static const ENABLE_MENU:int = 888; public static const MENU_SELECT:int = 13; public static const NO_MENU:int = 10; public static const DEACTIVATE_PERFORMANCE_METER:int = 104; public static const ACTIVATE_MANUAL_CAMERA:int = 100; public static const DEACTIVATE_MANUAL_CAMERA:int = 101; public static const ACTIVATE_PERFORMANCE_METER:int = 103; public static const DISABLE_MENU:int = 777; public static const NORMAL_MENU:int = 12; public static const SHOW:int = 1; public function ScreenEvent(_arg1:int, _arg2:String=null, _arg3=null){ this.id = _arg1; this.confirmId = _arg2; this.data = _arg3; super(EVENT); } } }//package com.kerb.uncharted.screens.control
Section 149
//ScreenManager (com.kerb.uncharted.screens.control.ScreenManager) package com.kerb.uncharted.screens.control { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import com.kerb.ui.*; import com.kerb.uncharted.screens.*; public class ScreenManager extends Sprite { private var confirm:MovieClip; private var confirmYes_btn:DynamicButton; private var currentScreen:AbstractScreen; private var confirmScreen:AbstractScreen; private var terms:MovieClip; private var confirmNo_btn:DynamicButton; private var menu:Menu; public function ScreenManager(_arg1:AbstractScreen){ confirm = Main.afm.createMovieClip("interface", "ConfirmExitPanelAsset"); confirmYes_btn = new DynamicButton(confirm.yes_btn, "exit.yes"); confirmYes_btn.addEventListener(MouseEvent.CLICK, onConfirmYes); confirmNo_btn = new DynamicButton(confirm.no_btn, "exit.no"); confirmNo_btn.addEventListener(MouseEvent.CLICK, onConfirmNo); menu = new Menu(); menu.addEventListener(ScreenEvent.EVENT, onScreenEvent); addChild(menu); terms = Main.afm.createMovieClip("interface", "TermsConditionsAsset"); showScreen(_arg1); } private function onConfirmNo(_arg1:Event=null):void{ closeConfirm(); } private function showConfirm(_arg1:String):void{ if (confirm.parent == null){ addChild(confirm); }; TextManager.getInstance().setTextField(confirm.label.copy_txt, _arg1); disableAll(); menu.disable(); } private function onConfirmYes(_arg1:Event=null):void{ closeConfirm(); menu.enable(); if (confirmScreen != null){ showScreen(confirmScreen); }; } public function showScreen(_arg1:AbstractScreen):void{ if (currentScreen != null){ if ((currentScreen is Title)){ removeChild(terms); }; currentScreen.dispose(); removeChild(currentScreen); currentScreen.removeEventListener(ScreenEvent.EVENT, onScreenEvent); currentScreen = null; }; currentScreen = _arg1; _arg1.addEventListener(ScreenEvent.EVENT, onScreenEvent, false, 0, true); if (_arg1.onTopOfEverything()){ addChild(_arg1); } else { addChildAt(_arg1, 0); }; if (_arg1.initialisationEvent){ _arg1.dispatchEvent(_arg1.initialisationEvent); _arg1.initialisationEvent = null; }; if ((currentScreen is Title)){ addChild(terms); if (!Title.fadeInPlayed){ terms.gotoAndPlay(1); }; }; } private function closeConfirm():void{ removeChild(confirm); enableAll(); menu.enable(); } protected function onScreenEvent(_arg1:ScreenEvent):void{ switch (_arg1.id){ case ScreenEvent.SHOW: if (((((!((_arg1.confirmId == null))) && (!((currentScreen == null))))) && (currentScreen.showConfirmScreenOnExit()))){ confirmScreen = _arg1.data; showConfirm(_arg1.confirmId); } else { showScreen(AbstractScreen(_arg1.data)); }; break; case ScreenEvent.CHANGE_LANGUAGE: if (menu != null){ menu.onLanguageChanged(); }; if (currentScreen != null){ currentScreen.onLanguageChanged(); }; confirmYes_btn.initText(); confirmNo_btn.initText(); break; case ScreenEvent.MENU_SELECT: menu.setSelected(String(_arg1.data)); break; case ScreenEvent.DISABLE_MENU: menu.disable(); break; case ScreenEvent.ENABLE_MENU: menu.enable(); break; case ScreenEvent.NO_MENU: menu.visible = false; break; case ScreenEvent.TITLE_MENU: menu.visible = true; menu.setType("title"); break; case ScreenEvent.NORMAL_MENU: menu.visible = true; menu.setType("normal"); break; case ScreenEvent.DISABLE: disableAll(); break; case ScreenEvent.ENABLE: enableAll(); break; }; } public function enableAll():void{ if (currentScreen != null){ currentScreen.enable(); }; } public function disableAll():void{ if (currentScreen != null){ currentScreen.disable(); }; } } }//package com.kerb.uncharted.screens.control
Section 150
//About (com.kerb.uncharted.screens.About) package com.kerb.uncharted.screens { import flash.events.*; import com.kerb.uncharted.screens.control.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import com.kerb.tracking.*; import com.kerb.ui.*; public class About extends GenericScreen { private var next_btn:DynamicButton; private var prev_btn:DynamicButton; private function onNextClicked(_arg1:MouseEvent):void{ Main.onButtonPress(); mc.nextFrame(); } override public function dispose():void{ super.dispose(); next_btn.removeEventListener(MouseEvent.CLICK, onNextClicked); prev_btn.removeEventListener(MouseEvent.CLICK, onPrevClicked); next_btn.dispose(); prev_btn.dispose(); } override protected function init():void{ mc = Main.afm.createMovieClip("interface", "AboutScreenAsset"); addChild(mc); if ((((Constants.locale == "es_ES")) || ((Constants.locale == "it_IT")))){ mc.frame.logo.gotoAndStop(Constants.locale); }; next_btn = new DynamicButton(mc.next_btn); next_btn.addEventListener(MouseEvent.CLICK, onNextClicked, false, 0, true); prev_btn = new DynamicButton(mc.prev_btn); prev_btn.addEventListener(MouseEvent.CLICK, onPrevClicked, false, 0, true); super.init(); mc.txt1_mc.mouseEnabled = false; mc.txt2_mc.mouseEnabled = false; mc.txt3_mc.mouseEnabled = false; mc.txt4_mc.mouseEnabled = false; mc.txt1_mc.mouseChildren = false; mc.txt2_mc.mouseChildren = false; mc.txt3_mc.mouseChildren = false; mc.txt4_mc.mouseChildren = false; mc.gotoAndStop(1); mc.frame.logo.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true); mc.frame.logo.buttonMode = true; initText(); dispatchEvent(new ScreenEvent(ScreenEvent.NORMAL_MENU)); dispatchEvent(new ScreenEvent(ScreenEvent.MENU_SELECT, null, "about")); Main.playTitleMusic(); } private function onPrevClicked(_arg1:MouseEvent):void{ Main.onButtonPress(); mc.prevFrame(); } override protected function initText():void{ super.initText(); var _local1:TextManager = TextManager.getInstance(); _local1.setTextField(mc.title_mc.txt, "about.title"); _local1.setTextField(mc.titleShadow_mc.txt, "about.title"); _local1.setTextField(mc.txt1_mc.txt, "about.para.1"); _local1.setTextField(mc.txt2_mc.txt, "about.para.2"); _local1.setTextField(mc.txt3_mc.txt, "about.para.3"); _local1.centerTextField(mc.title_mc.txt); _local1.centerTextField(mc.txt1_mc.txt); _local1.centerTextField(mc.txt2_mc.txt); _local1.centerTextField(mc.txt3_mc.txt); _local1.centerTextField(mc.txt4_mc.txt); next_btn.initText(); } private function onLogoClick(_arg1:MouseEvent):void{ Main.onButtonPress(); WebTrends.event((Constants.locale + "/Global/Logo"), "Logo Clicked"); DoubleQuick.click((Constants.SEEDED) ? 532 : 545); } } }//package com.kerb.uncharted.screens
Section 151
//AgeSelect (com.kerb.uncharted.screens.AgeSelect) package com.kerb.uncharted.screens { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import com.kerb.ui.*; import com.kerb.uncharted.ui.*; public class AgeSelect extends AbstractScreen { private var dateCombo:ScrollingComboBox; private var monthSet:Boolean; private var minAge:int; private var yearCombo:ScrollingComboBox; private var dateSet:Boolean; private var mc:MovieClip; private var userDate:Date; private var yearSet:Boolean; private var monthCombo:ScrollingComboBox; private var submit_btn:DynamicButton; private static const MINIMUM_AGE:int = 16; private static const MINIMUM_AGE_AUSTRALIA:int = 15; private function checkUserDate():void{ var _local1:Date = new Date(); _local1.fullYear = (_local1.fullYear - minAge); if (userDate.time <= _local1.time){ dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new Title())); } else { mc.gotoAndStop("denied"); }; } override public function enable():void{ mc.submit_btn.addEventListener(MouseEvent.CLICK, onSubmit); dateCombo.enable(); monthCombo.enable(); yearCombo.enable(); submit_btn.enable(); } private function onDateSelect(_arg1:Event):void{ var _local2:int = ScrollingComboBox(_arg1.currentTarget).selection; userDate.date = _local2; mc.date_txt.text = _local2; dateSet = true; } override protected function init():void{ mc = Main.afm.createMovieClip("interface", "AgeSelectScreenAsset"); addChild(mc); userDate = new Date(); minAge = ((Constants.locale)=="en_AU") ? MINIMUM_AGE_AUSTRALIA : MINIMUM_AGE; initCombos(); initText(); submit_btn = new DynamicButton(mc.submit_btn); mc.submit_btn.addEventListener(MouseEvent.CLICK, onSubmit); dateSet = false; monthSet = false; yearSet = false; } private function initCombos():void{ var _local4:int; var _local1:Array = []; var _local2:Array = []; var _local3:Array = []; _local4 = 1; while (_local4 <= 31) { _local1.push(_local4); _local4++; }; _local4 = 1; while (_local4 <= 12) { _local2.push(_local4); _local4++; }; _local4 = 1949; while (_local4 <= 2009) { _local3.push(_local4); _local4++; }; dateCombo = new ScrollingComboBox(mc.dateCombo, _local1); monthCombo = new ScrollingComboBox(mc.monthCombo, _local2); yearCombo = new ScrollingComboBox(mc.yearCombo, _local3); dateCombo.addEventListener(Event.SELECT, onDateSelect, false, 0, true); monthCombo.addEventListener(Event.SELECT, onMonthSelect, false, 0, true); yearCombo.addEventListener(Event.SELECT, onYearSelect, false, 0, true); } private function onSubmit(_arg1:MouseEvent):void{ Main.onButtonPress(); if (((((dateSet) && (monthSet))) && (yearSet))){ checkUserDate(); }; } private function onYearSelect(_arg1:Event):void{ var _local2:int = ScrollingComboBox(_arg1.currentTarget).selection; userDate.fullYear = _local2; mc.year_txt.text = _local2; yearSet = true; } override protected function initText():void{ var _local1:TextManager = TextManager.getInstance(); _local1.setTextField(mc.title_mc.txt, "age.warning"); _local1.setTextField(mc.enter_mc.txt, "age.instruction"); _local1.setTextField(mc.sorry_mc.txt, "age.rejected"); var _local2:Array = _local1.getTextById("age.dob").split(" "); mc.date_txt.text = _local2[0]; mc.month_txt.text = _local2[1]; mc.year_txt.text = _local2[2]; } override public function dispose():void{ mc.submit_btn.removeEventListener(MouseEvent.CLICK, onSubmit); dateCombo.removeEventListener(Event.SELECT, onDateSelect); monthCombo.removeEventListener(Event.SELECT, onMonthSelect); yearCombo.removeEventListener(Event.SELECT, onYearSelect); submit_btn.dispose(); } override public function disable():void{ mc.submit_btn.removeEventListener(MouseEvent.CLICK, onSubmit); dateCombo.disable(); monthCombo.disable(); yearCombo.disable(); submit_btn.disable(); } private function onMonthSelect(_arg1:Event):void{ var _local2:int = (ScrollingComboBox(_arg1.currentTarget).selection - 1); userDate.month = _local2; mc.month_txt.text = (_local2 + 1); monthSet = true; } } }//package com.kerb.uncharted.screens
Section 152
//Gallery (com.kerb.uncharted.screens.Gallery) package com.kerb.uncharted.screens { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import com.kerb.tracking.*; public class Gallery extends GenericScreen { private static const NUM_THUMBS:int = 9; override protected function init():void{ mc = Main.afm.createMovieClip("interface", "GalleryScreenAsset"); addChild(mc); if ((((Constants.locale == "es_ES")) || ((Constants.locale == "it_IT")))){ mc.frame.logo.gotoAndStop(Constants.locale); }; TextManager.getInstance().setTextField(mc.title_mc.txt, "gallery.title"); TextManager.getInstance().setTextField(mc.titleShadow_mc.txt, "gallery.title"); mc.frame.logo.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true); mc.frame.logo.buttonMode = true; super.init(); dispatchEvent(new ScreenEvent(ScreenEvent.NORMAL_MENU)); dispatchEvent(new ScreenEvent(ScreenEvent.MENU_SELECT, null, "gallery")); mc.frame.mouseEnabled = false; mc.image_mc.stop(); enable(); Main.playTitleMusic(); } private function onThumbClick(_arg1:MouseEvent):void{ Main.onButtonPress(); var _local2:int = parseInt(SimpleButton(_arg1.currentTarget).name.charAt(5)); mc.image_mc.gotoAndStop((_local2 + 1)); } override public function enable():void{ var _local2:SimpleButton; var _local1:int; while (_local1 < NUM_THUMBS) { _local2 = SimpleButton(mc.getChildByName((("thumb" + _local1) + "_btn"))); _local2.addEventListener(MouseEvent.CLICK, onThumbClick, false, 0, true); _local1++; }; } override public function disable():void{ var _local2:SimpleButton; var _local1:int; while (_local1 < NUM_THUMBS) { _local2 = SimpleButton(mc.getChildByName((("thumb" + _local1) + "_btn"))); _local2.removeEventListener(MouseEvent.CLICK, onThumbClick); _local1++; }; } private function onLogoClick(_arg1:MouseEvent):void{ Main.onButtonPress(); WebTrends.event((Constants.locale + "/Global/Logo"), "Logo Clicked"); DoubleQuick.click((Constants.SEEDED) ? 532 : 545); } override public function dispose():void{ disable(); } } }//package com.kerb.uncharted.screens
Section 153
//Game (com.kerb.uncharted.screens.Game) package com.kerb.uncharted.screens { import flash.events.*; import com.kerb.uncharted.screens.control.*; import com.kerb.uncharted.*; import com.kerb.uncharted.game.render.layers.*; import com.kerb.uncharted.game.levels.*; import com.kerb.tracking.*; import com.kerb.uncharted.game.panels.*; import com.kerb.uncharted.game.utils.*; public class Game extends AbstractScreen { private var LevelClasses:Array; private var levelWinPanel:LevelWinPanel; private var currLevel:AbstractLevel; private var currLevelNum:int; private static const MAX_TIME_BONUS_POINTS:int = 10000; private static const MAX_SHOTS_BONUS_POINTS:int = 10000; public function Game(){ LevelClasses = [Level1, Level2, Level3, Level4]; super(); } private function onFinalSceneToHighScore(_arg1:Event):void{ currLevel.removeEventListener(AbstractLevel.EVENT_WIN, onFinalSceneToHighScore); currLevel.removeEventListener(AbstractLevel.EVENT_LOSE, onFinalSceneToReplay); currLevel.dispose(); removeChild(currLevel); currLevel = null; dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new HighScores())); } override public function enable():void{ currLevel.resumeGame(); } override public function disable():void{ if (currLevel){ currLevel.pauseGame(); }; } override public function notify(_arg1:ScreenEvent):void{ super.notify(_arg1); } override protected function init():void{ initLevel(0); levelWinPanel = new LevelWinPanel(); levelWinPanel.addEventListener(Event.COMPLETE, onLevelWinComplete, false, 0, true); dispatchEvent(new ScreenEvent(ScreenEvent.NORMAL_MENU)); dispatchEvent(new ScreenEvent(ScreenEvent.MENU_SELECT, null, "game")); UserData.treasureScores = []; UserData.accuracyScores = []; } override public function showConfirmScreenOnExit():Boolean{ return (true); } private function showFinalScene():void{ DoubleQuick.event((Constants.SEEDED) ? 526 : 539); WebTrends.event((Constants.locale + "/Level5/Loaded"), "Level 5 Loaded"); currLevel.removeEventListener(AbstractLevel.EVENT_WIN, onLevelWin); currLevel.removeEventListener(AbstractLevel.EVENT_LOSE, onLevelLose); currLevel.dispose(); removeChild(currLevel); currLevel = new Level5(); currLevel.addEventListener(AbstractLevel.EVENT_WIN, onFinalSceneToHighScore, false, 0, true); currLevel.addEventListener(AbstractLevel.EVENT_LOSE, onFinalSceneToReplay, false, 0, true); addChild(currLevel); } private function onLevelWin(_arg1:Event):void{ var _local3:int; var _local4:int; var _local2:int = currLevel.getTreasure(); UserData.treasureScores[currLevelNum] = _local2; if (currLevelNum == (LevelClasses.length - 1)){ showFinalScene(); } else { _local3 = (MAX_TIME_BONUS_POINTS * currLevel.getTimePercent()); _local4 = (MAX_SHOTS_BONUS_POINTS * currLevel.getHitPercent()); UserData.accuracyScores[currLevelNum] = _local4; levelWinPanel.init(_local2, _local3, _local4, stage); addChild(levelWinPanel); }; } private function onLevelLose(_arg1:Event):void{ currLevel.retryLevel(); } private function initLevel(_arg1:int):void{ currLevelNum = _arg1; DoubleQuick.event((Constants.SEEDED) ? (522 + _arg1) : (535 + _arg1)); WebTrends.event((((Constants.locale + "/Level") + (_arg1 + 1)) + "/Loaded"), (("Level " + (_arg1 + 1)) + " Loaded")); if (currLevel){ currLevel.removeEventListener(AbstractLevel.EVENT_WIN, onLevelWin); currLevel.removeEventListener(AbstractLevel.EVENT_LOSE, onLevelLose); currLevel.dispose(); removeChild(currLevel); currLevel = null; }; currLevel = new (LevelClasses[currLevelNum]); currLevel.addEventListener(AbstractLevel.EVENT_WIN, onLevelWin, false, 0, true); currLevel.addEventListener(AbstractLevel.EVENT_LOSE, onLevelLose, false, 0, true); addChild(currLevel); } private function onLevelWinComplete(_arg1:Event):void{ removeChild(levelWinPanel); initLevel((currLevelNum + 1)); } private function onFinalSceneToReplay(_arg1:Event):void{ currLevel.removeEventListener(AbstractLevel.EVENT_WIN, onFinalSceneToHighScore); currLevel.removeEventListener(AbstractLevel.EVENT_LOSE, onFinalSceneToReplay); currLevel.dispose(); removeChild(currLevel); currLevel = null; dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new Game())); } override public function dispose():void{ disable(); if (currLevel){ currLevel.dispose(); }; if (levelWinPanel){ levelWinPanel.removeEventListener(Event.COMPLETE, onLevelWinComplete); }; } } }//package com.kerb.uncharted.screens
Section 154
//GameIntro (com.kerb.uncharted.screens.GameIntro) package com.kerb.uncharted.screens { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import flash.net.*; import com.kerb.uncharted.*; import com.kerb.tracking.*; import com.kerb.ui.*; import com.kerb.game.*; public class GameIntro extends AbstractScreen { protected var keyNav:KeyboardNavigator; private var mc:MovieClip; private var skip_btn:DynamicButton; override public function enable():void{ keyNav.active = true; skip_btn.enable(); mc.addEventListener(Event.ENTER_FRAME, onEnterFrame); } override public function disable():void{ keyNav.active = false; skip_btn.disable(); mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onSkipClick(_arg1:MouseEvent=null):void{ Main.onButtonPress(); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new Game())); } override protected function init():void{ mc = Main.afm.createMovieClip("cutScenes", "GameIntroScreenAsset"); addChild(mc); mc.addEventListener(Event.ENTER_FRAME, onEnterFrame); skip_btn = new DynamicButton(mc.skip_btn, "game.intro.skip"); skip_btn.addEventListener(MouseEvent.CLICK, onSkipClick); if ((((Constants.locale == "es_ES")) || ((Constants.locale == "it_IT")))){ mc.frame.logo.gotoAndStop(Constants.locale); }; mc.frame.logo.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true); mc.frame.logo.buttonMode = true; keyNav = new KeyboardNavigator(stage); keyNav.setDefaultAction(onSkipClick); var so:SharedObject = SharedObject.getLocal("uncharted2"); so.data.introPlayed = true; try { so.flush(100); } catch(error:Error) { }; dispatchEvent(new ScreenEvent(ScreenEvent.NORMAL_MENU)); Main.stopTitleMusic(); Main.smMusic.getSoundByClassName("IntroAnimationLoopSound").play(0, 999999); } private function onEnterFrame(_arg1:Event):void{ if (mc.currentFrame == mc.totalFrames){ dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new Game())); }; } private function onLogoClick(_arg1:MouseEvent):void{ Main.onButtonPress(); WebTrends.event((Constants.locale + "/Global/Logo"), "Logo Clicked"); DoubleQuick.click((Constants.SEEDED) ? 532 : 545); } override public function dispose():void{ Main.smMusic.getSoundByClassName("IntroAnimationLoopSound").stop(); disable(); keyNav.dispose(); skip_btn.removeEventListener(MouseEvent.CLICK, onSkipClick); skip_btn.dispose(); mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); } } }//package com.kerb.uncharted.screens
Section 155
//GenericScreen (com.kerb.uncharted.screens.GenericScreen) package com.kerb.uncharted.screens { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.game.*; public class GenericScreen extends AbstractScreen { protected var keyNav:KeyboardNavigator; protected var mc:MovieClip; override protected function init():void{ keyNav = new KeyboardNavigator(stage); } private function onBackClick(_arg1:MouseEvent=null):void{ dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new Title())); } override public function enable():void{ keyNav.active = true; } override protected function initText():void{ super.initText(); } override public function dispose():void{ disable(); keyNav.dispose(); } override public function disable():void{ keyNav.active = false; } } }//package com.kerb.uncharted.screens
Section 156
//HighScores (com.kerb.uncharted.screens.HighScores) package com.kerb.uncharted.screens { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import com.kerb.tracking.*; import com.kerb.ui.*; public class HighScores extends GenericScreen { private var search_btn:DynamicButton; private var hs:HighScoreLoader; private var next_btn:DynamicButton; private var prev_btn:DynamicButton; public function HighScores(){ hs = HighScoreLoader.getInstance(); super(); } private function onSearchClick(_arg1:MouseEvent):void{ Main.onButtonPress(); loadScores(1, -1, mc.searchname_txt.text); } override public function enable():void{ next_btn.enable(); prev_btn.enable(); search_btn.enable(); super.enable(); } private function onLoaded(_arg1:Event):void{ var _local3:Object; var _local4:MovieClip; hs.removeEventListener(HighScoreLoader.ON_LOADED, onLoaded); prev_btn.enable(); next_btn.enable(); if (hs.getTotalPages() == 0){ mc.nav.page_txt.text = ""; } else { mc.nav.page_txt.text = ((hs.getCurrentPage() + "/") + hs.getTotalPages()); }; var _local2:uint; while (_local2 < hs.getDataArray().length) { _local3 = hs.getDataArray()[_local2]; _local4 = Main.afm.createMovieClip("interface", "ScoreRowAsset"); _local4.pos_txt.text = _local3["rank"]; _local4.name_txt.text = _local3["name"]; _local4.score_txt.text = _local3["score"]; _local4.y = (_local2 * 18); mc.scoreholder_mc.addChild(_local4); _local2++; }; prev_btn.visible = (hs.getCurrentPage() > 1); next_btn.visible = (hs.getCurrentPage() < hs.getTotalPages()); } override public function disable():void{ next_btn.disable(); prev_btn.disable(); search_btn.disable(); super.disable(); } protected function loadScores(_arg1:int, _arg2:int=-1, _arg3:String=""):void{ prev_btn.disable(); next_btn.disable(); while (mc.scoreholder_mc.numChildren > 0) { mc.scoreholder_mc.removeChildAt(0); }; hs.addEventListener(HighScoreLoader.ON_LOADED, onLoaded); hs.load(_arg1, _arg2, _arg3); } private function onPrevClick(_arg1:MouseEvent):void{ Main.onButtonPress(); var _local2:int = (hs.getCurrentPage() - 1); if (_local2 < 1){ _local2 = 1; }; loadScores(_local2, -1, mc.searchname_txt.text); } override protected function init():void{ mc = Main.afm.createMovieClip("interface", "HighscoresScreenAsset"); addChild(mc); if ((((Constants.locale == "es_ES")) || ((Constants.locale == "it_IT")))){ mc.frame.logo.gotoAndStop(Constants.locale); }; mc.frame.mouseEnabled = false; mc.searchname_txt.text = ""; super.init(); dispatchEvent(new ScreenEvent(ScreenEvent.NORMAL_MENU)); dispatchEvent(new ScreenEvent(ScreenEvent.MENU_SELECT, null, "highscores")); prev_btn = new DynamicButton(mc.nav.prev_btn, "highscores.previous"); prev_btn.addEventListener(MouseEvent.CLICK, onPrevClick, false, 0, true); next_btn = new DynamicButton(mc.nav.next_btn, "highscores.next"); next_btn.addEventListener(MouseEvent.CLICK, onNextClick, false, 0, true); search_btn = new DynamicButton(mc.search_btn, "highscore.search"); search_btn.addEventListener(MouseEvent.CLICK, onSearchClick, false, 0, true); prev_btn.visible = false; next_btn.visible = false; mc.frame.logo.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true); mc.frame.logo.buttonMode = true; mc.searchglass_btn.addEventListener(MouseEvent.CLICK, onSearchClick, false, 0, true); initText(); loadScores(1, hs.getLastId(), ""); Main.playTitleMusic(); } private function onNextClick(_arg1:MouseEvent):void{ Main.onButtonPress(); var _local2:int = (hs.getCurrentPage() + 1); if (_local2 > hs.getTotalPages()){ _local2 = hs.getTotalPages(); }; loadScores(_local2, -1, mc.searchname_txt.text); } override protected function initText():void{ TextManager.getInstance().setTextField(mc.title_mc.txt, "score.title"); TextManager.getInstance().setTextField(mc.titleShadow_mc.txt, "score.title"); TextManager.getInstance().setTextField(mc.position_txt, "score.row.position"); TextManager.getInstance().setTextField(mc.score_txt, "score.row.score"); TextManager.getInstance().setTextField(mc.name_txt, "score.row.name"); prev_btn.initText(); next_btn.initText(); search_btn.initText(); } private function onLogoClick(_arg1:MouseEvent):void{ Main.onButtonPress(); WebTrends.event((Constants.locale + "/Global/Logo"), "Logo Clicked"); DoubleQuick.click((Constants.SEEDED) ? 532 : 545); } override public function dispose():void{ next_btn.removeEventListener(MouseEvent.CLICK, onNextClick); prev_btn.removeEventListener(MouseEvent.CLICK, onPrevClick); search_btn.removeEventListener(MouseEvent.CLICK, onSearchClick); mc.searchglass_btn.removeEventListener(MouseEvent.CLICK, onSearchClick); super.dispose(); } } }//package com.kerb.uncharted.screens
Section 157
//Instructions (com.kerb.uncharted.screens.Instructions) package com.kerb.uncharted.screens { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import com.kerb.tracking.*; import com.kerb.ui.*; import com.kerb.game.*; public class Instructions extends AbstractScreen { protected var keyNav:KeyboardNavigator; private var play_btn:DynamicButton; private var story_btn:DynamicButton; private var controls_btn:DynamicButton; private var mc:MovieClip; private var scoring_btn:DynamicButton; private function onBackClick(_arg1:MouseEvent=null):void{ Main.onButtonPress(); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new Title())); } override public function enable():void{ keyNav.active = true; play_btn.enable(); } private function onScoringButtonClicked(_arg1:MouseEvent):void{ Main.onButtonPress(); setCurrentSection("scoring"); } override protected function init():void{ mc = Main.afm.createMovieClip("interface", "InstructionsScreenAsset"); addChild(mc); mc.frame.mouseEnabled = false; if ((((Constants.locale == "es_ES")) || ((Constants.locale == "it_IT")))){ mc.frame.logo.gotoAndStop(Constants.locale); }; play_btn = new DynamicButton(mc.play_btn, "instructions.button.play"); play_btn.addEventListener(MouseEvent.CLICK, onPlayClick, false, 0, true); mc.play_btn.hit.width = mc.play_btn.up.label_txt.textWidth; mc.play_btn.hit.x = ((mc.play_btn.up.x + mc.play_btn.up.width) - mc.play_btn.hit.width); mc.frame.logo.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true); mc.frame.logo.buttonMode = true; story_btn = new DynamicButton(mc.story_btn, "instructions.title.story"); story_btn.addEventListener(MouseEvent.CLICK, onStoryButtonClicked, false, 0, true); controls_btn = new DynamicButton(mc.controls_btn, "instructions.title.controls"); controls_btn.addEventListener(MouseEvent.CLICK, onControlsButtonClicked, false, 0, true); scoring_btn = new DynamicButton(mc.scoring_btn, "instructions.title.scoring"); scoring_btn.addEventListener(MouseEvent.CLICK, onScoringButtonClicked, false, 0, true); keyNav = new KeyboardNavigator(stage); keyNav.setDefaultAction(onPlayClick); keyNav.addInteractiveObject(mc.play_btn, onPlayClick, 1); keyNav.addInteractiveObject(mc.story_btn, onStoryButtonClicked, 2); keyNav.addInteractiveObject(mc.controls_btn, onControlsButtonClicked, 3); keyNav.addInteractiveObject(mc.scoring_btn, onScoringButtonClicked, 4); setCurrentSection("story"); mc.story_mc.mouseEnabled = false; mc.scoring_mc.mouseEnabled = false; mc.controls_mc.mouseEnabled = false; mc.story_mc.mouseChildren = false; mc.scoring_mc.mouseChildren = false; mc.controls_mc.mouseChildren = false; initText(); dispatchEvent(new ScreenEvent(ScreenEvent.NORMAL_MENU)); dispatchEvent(new ScreenEvent(ScreenEvent.MENU_SELECT, null, "instructions")); } private function onPlayClick(_arg1:MouseEvent=null):void{ Main.onButtonPress(); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new GameIntro())); } override protected function initText():void{ super.initText(); TextManager.getInstance().setTextField(mc.story_mc.txt, "instructions.story.para1"); TextManager.getInstance().setTextField(mc.controls_mc.jumpgrab_txt, "instructions.keys.controls.up"); TextManager.getInstance().setTextField(mc.controls_mc.left_txt, "instructions.keys.controls.left"); TextManager.getInstance().setTextField(mc.controls_mc.right_txt, "instructions.keys.controls.right"); TextManager.getInstance().setTextField(mc.controls_mc.drophide_txt, "instructions.keys.controls.down"); TextManager.getInstance().setTextField(mc.controls_mc.shoot_txt, "instructions.mouse.controls.shoot"); TextManager.getInstance().setTextField(mc.controls_mc.aim_txt, "instructions.mouse.controls.aim"); TextManager.getInstance().setTextField(mc.controls_mc.changeweapon_txt, "instructions.mouse.controls.weapon"); TextManager.getInstance().setTextField(mc.scoring_mc.txt1_mc.txt, "instructions.scoring.para1"); TextManager.getInstance().setTextField(mc.scoring_mc.txt2_mc.txt, "instructions.scoring.para2"); TextManager.getInstance().centerTextField(mc.story_mc.txt); TextManager.getInstance().centerTextField(mc.scoring_mc.txt1_mc.txt); play_btn.initText(); story_btn.initText(); controls_btn.initText(); scoring_btn.initText(); } override public function dispose():void{ disable(); keyNav.dispose(); play_btn.removeEventListener(MouseEvent.CLICK, onPlayClick); story_btn.removeEventListener(MouseEvent.CLICK, onStoryButtonClicked); controls_btn.removeEventListener(MouseEvent.CLICK, onControlsButtonClicked); scoring_btn.removeEventListener(MouseEvent.CLICK, onScoringButtonClicked); play_btn.dispose(); story_btn.dispose(); controls_btn.dispose(); scoring_btn.dispose(); } private function onControlsButtonClicked(_arg1:MouseEvent):void{ Main.onButtonPress(); setCurrentSection("controls"); } override public function disable():void{ keyNav.active = false; play_btn.disable(); } private function setCurrentSection(_arg1:String):void{ mc.gotoAndStop(_arg1); story_btn.selected = (_arg1 == "story"); controls_btn.selected = (_arg1 == "controls"); scoring_btn.selected = (_arg1 == "scoring"); } private function onStoryButtonClicked(_arg1:MouseEvent):void{ Main.onButtonPress(); setCurrentSection("story"); } private function onLogoClick(_arg1:MouseEvent):void{ Main.onButtonPress(); DoubleQuick.click((Constants.SEEDED) ? 532 : 545); WebTrends.event((Constants.locale + "/Global/Logo"), "Logo Clicked"); } } }//package com.kerb.uncharted.screens
Section 158
//LanguageSelect (com.kerb.uncharted.screens.LanguageSelect) package com.kerb.uncharted.screens { import flash.events.*; import com.kerb.uncharted.screens.control.*; import com.kerb.uncharted.panels.*; public class LanguageSelect extends AbstractScreen { private var lp:LanguagePanel; private function onLanguageClose(_arg1:Event=null):void{ lp.removeEventListener(Event.CLOSE, onLanguageClose); dispatchEvent(new ScreenEvent(ScreenEvent.CHANGE_LANGUAGE)); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new AgeSelect())); } override protected function init():void{ lp = new LanguagePanel(); lp.addEventListener(Event.CLOSE, onLanguageClose, false, 0, true); addChild(lp); dispatchEvent(new ScreenEvent(ScreenEvent.NO_MENU)); } } }//package com.kerb.uncharted.screens
Section 159
//PSIdent (com.kerb.uncharted.screens.PSIdent) package com.kerb.uncharted.screens { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.uncharted.*; public class PSIdent extends AbstractScreen { private var mc:MovieClip; override protected function init():void{ mc = Main.afm.createMovieClip("interface", "IdentScreenAsset"); mc.addEventListener(Event.ENTER_FRAME, onEnterFrame); addChild(mc); dispatchEvent(new ScreenEvent(ScreenEvent.NO_MENU)); } private function onEnterFrame(_arg1:Event):void{ if (mc.currentFrame == mc.totalFrames){ mc.stop(); if (Constants.SEEDED){ dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new LanguageSelect())); } else { dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new Title())); }; }; } } }//package com.kerb.uncharted.screens
Section 160
//Title (com.kerb.uncharted.screens.Title) package com.kerb.uncharted.screens { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.uncharted.*; import com.kerb.tracking.*; import com.kerb.ui.*; import com.kerb.game.*; public class Title extends AbstractScreen { protected var keyNav:KeyboardNavigator; private var play_btn:DynamicButton; private var language_btn:DynamicButton; private var mc:MovieClip; public static var fadeInPlayed:Boolean = false; override public function enable():void{ keyNav.active = true; play_btn.enable(); } private function onPlaystationClick(_arg1:MouseEvent):void{ Main.onButtonPress(); WebTrends.event((Constants.locale + "/Global/Logo"), "Logo Clicked"); DoubleQuick.click((Constants.SEEDED) ? 533 : 546); } override public function disable():void{ keyNav.active = false; play_btn.disable(); } override protected function init():void{ mc = Main.afm.createMovieClip("interface", "TitleScreenAsset"); if (fadeInPlayed){ mc.gotoAndStop(mc.totalFrames); }; fadeInPlayed = true; addChild(mc); if ((((Constants.locale == "es_ES")) || ((Constants.locale == "it_IT")))){ mc.logo.gotoAndStop(Constants.locale); }; play_btn = new DynamicButton(mc.play_btn, "instructions.button.play"); play_btn.addEventListener(MouseEvent.CLICK, onPlayClick, false, 0, true); mc.play_btn.hit.width = mc.play_btn.up.label_txt.textWidth; mc.play_btn.hit.x = ((mc.play_btn.up.x + mc.play_btn.up.width) - mc.play_btn.hit.width); keyNav = new KeyboardNavigator(stage); keyNav.setDefaultAction(onPlayClick); initText(); mc.logos.playstationseeded_btn.addEventListener(MouseEvent.CLICK, onPlaystationClick, false, 0, true); mc.logos.playstationhosted_btn.addEventListener(MouseEvent.CLICK, onPlaystationClick, false, 0, true); mc.logos.playstationseeded_btn.visible = Constants.SEEDED; mc.logos.playstationhosted_btn.visible = !(Constants.SEEDED); if (Constants.locale == "de_DE"){ mc.logos.rating.gotoAndStop("de_DE"); } else { if ((((Constants.locale == "en_NZ")) || ((Constants.locale == "en_AU")))){ mc.logos.rating.gotoAndStop("en_AU"); }; }; mc.logo.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true); mc.logo.buttonMode = true; dispatchEvent(new ScreenEvent(ScreenEvent.TITLE_MENU)); dispatchEvent(new ScreenEvent(ScreenEvent.MENU_SELECT, null, "title")); Main.playTitleMusic(); } private function onPlayClick(_arg1:MouseEvent=null):void{ Main.onButtonPress(); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new Instructions())); } override protected function initText():void{ play_btn.initText(); } private function onLogoClick(_arg1:MouseEvent):void{ Main.onButtonPress(); DoubleQuick.click((Constants.SEEDED) ? 532 : 545); } override public function dispose():void{ disable(); keyNav.dispose(); play_btn.removeEventListener(MouseEvent.CLICK, onPlayClick); play_btn.dispose(); mc.logos.playstationseeded_btn.removeEventListener(MouseEvent.CLICK, onPlaystationClick); mc.logos.playstationhosted_btn.removeEventListener(MouseEvent.CLICK, onPlaystationClick); } } }//package com.kerb.uncharted.screens
Section 161
//Trailer (com.kerb.uncharted.screens.Trailer) package com.kerb.uncharted.screens { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.utils.*; import com.kerb.uncharted.*; import fl.video.*; import com.kerb.tracking.*; public class Trailer extends GenericScreen { private var flv:FLVPlayback; private static const VIDEO_URL:String = "http://e1.dl.playstation.net/e1/campaignsite/unchartedps3.com/Uncharted2E3trailer.flv"; private static const URLS:Array = []; private function onThumbClick(_arg1:MouseEvent):void{ Main.onButtonPress(); var _local2:int = parseInt(SimpleButton(_arg1.currentTarget).name.charAt(5)); showVideo(URLS[_local2]); } override public function enable():void{ var _local2:SimpleButton; var _local1:int; while (_local1 < URLS.length) { _local2 = SimpleButton(mc.getChildByName((("thumb" + _local1) + "_btn"))); _local2.addEventListener(MouseEvent.CLICK, onThumbClick, false, 0, true); _local1++; }; } private function showVideo(_arg1:String):void{ flv.source = _arg1; } override public function dispose():void{ disable(); mc.removeEventListener(Event.ENTER_FRAME, matchMute); } override protected function init():void{ mc = Main.afm.createMovieClip("interface", "TrailerScreenAsset"); addChild(mc); if ((((Constants.locale == "es_ES")) || ((Constants.locale == "it_IT")))){ mc.frame.logo.gotoAndStop(Constants.locale); }; TextManager.getInstance().setTextField(mc.title_mc.txt, "movie.title"); TextManager.getInstance().setTextField(mc.titleShadow_mc.txt, "movie.title"); mc.frame.logo.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true); mc.frame.logo.buttonMode = true; super.init(); dispatchEvent(new ScreenEvent(ScreenEvent.NORMAL_MENU)); dispatchEvent(new ScreenEvent(ScreenEvent.MENU_SELECT, null, "trailer")); mc.frame.mouseEnabled = false; enable(); flv = mc.video; showVideo(VIDEO_URL); mc.addEventListener(Event.ENTER_FRAME, matchMute, false, 0, true); Main.stopTitleMusic(); } override public function disable():void{ var btn:SimpleButton; var i:int; while (i < URLS.length) { btn = SimpleButton(mc.getChildByName((("thumb" + i) + "_btn"))); btn.removeEventListener(MouseEvent.CLICK, onThumbClick); i = (i + 1); }; try { flv.stop(); flv.getVideoPlayer(0).close(); } catch(e:Error) { }; } private function onLogoClick(_arg1:MouseEvent):void{ Main.onButtonPress(); DoubleQuick.click((Constants.SEEDED) ? 532 : 545); WebTrends.event((Constants.locale + "/Global/Logo"), "Logo Clicked"); } private function matchMute(_arg1:Event):void{ flv.volume = (Main.smSFX.muted) ? 0 : 1; } } }//package com.kerb.uncharted.screens
Section 162
//ScrollingComboBox (com.kerb.uncharted.ui.ScrollingComboBox) package com.kerb.uncharted.ui { import flash.events.*; import flash.display.*; import flash.text.*; import com.kerb.uncharted.*; public class ScrollingComboBox extends EventDispatcher { private var contentMinY:Number; private var contentGoalY:Number; private var contentMaxY:Number; private var selectedValue:int; private var mc:MovieClip; private static const MAX_SCROLL_SPEED:Number = 20; private static const SCROLL_PADDING:Number = 10; private static const HILITE_FORMAT:TextFormat = new TextFormat(null, null, 14635045); private static const NORMAL_FORMAT:TextFormat = new TextFormat(null, null, 0xCCCCCC); public function ScrollingComboBox(_arg1:MovieClip, _arg2:Array){ this.mc = _arg1; init(_arg2); } private function hide():void{ mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); mc.alpha = 0; mc.reveal_btn.mouseEnabled = true; mc.content.mouseChildren = false; } public function enable():void{ mc.mouseChildren = true; } public function get selection():int{ return (selectedValue); } private function onItemClick(_arg1:MouseEvent):void{ Main.onButtonPress(); selectedValue = parseInt(MovieClip(_arg1.currentTarget).label_txt.text); dispatchEvent(new Event(Event.SELECT)); hide(); } private function onItemRollOut(_arg1:MouseEvent):void{ MovieClip(_arg1.currentTarget).label_txt.setTextFormat(NORMAL_FORMAT); } public function disable():void{ mc.mouseChildren = false; } private function onItemRollOver(_arg1:MouseEvent):void{ MovieClip(_arg1.currentTarget).label_txt.setTextFormat(HILITE_FORMAT); } private function init(_arg1:Array):void{ var _local5:MovieClip; mc.reveal_btn.addEventListener(MouseEvent.MOUSE_DOWN, onReveal); var _local2:MovieClip = new MovieClip(); mc.addChildAt(_local2, 1); var _local3:Number = 0; var _local4:int; while (_local4 < _arg1.length) { _local5 = Main.afm.createMovieClip("interface", "ComboBoxItemAsset"); _local5.label_txt.text = _arg1[_local4]; _local5.y = _local3; _local5.label_txt.width = mc.contentMask.width; _local5.bg.width = mc.contentMask.width; _local5.addEventListener(MouseEvent.ROLL_OVER, onItemRollOver, false, 0, true); _local5.addEventListener(MouseEvent.ROLL_OUT, onItemRollOut, false, 0, true); _local5.addEventListener(MouseEvent.CLICK, onItemClick, false, 0, true); _local3 = (_local3 + _local5.bg.height); _local2.addChild(_local5); _local4++; }; _local2.x = mc.contentMask.x; _local2.y = (-0.5 * _local2.height); _local2.mask = mc.contentMask; mc.content = _local2; contentMinY = ((mc.contentMask.y + mc.contentMask.height) - _local2.height); contentMaxY = mc.contentMask.y; contentGoalY = _local2.y; hide(); } private function onEnterFrame(_arg1:Event):void{ if (!mc.bg.hitTestPoint(mc.stage.mouseX, mc.stage.mouseY)){ hide(); }; var _local2:Number = ((mc.contentMask.mouseY - SCROLL_PADDING) / (mc.contentMask.height - (2 * SCROLL_PADDING))); _local2 = (1 - Math.max(0, Math.min(1, _local2))); contentGoalY = ((_local2 * (contentMaxY - contentMinY)) + contentMinY); var _local3:Number = (0.2 * (contentGoalY - mc.content.y)); _local3 = Math.max(-(MAX_SCROLL_SPEED), Math.min(MAX_SCROLL_SPEED, _local3)); mc.content.y = (mc.content.y + _local3); } private function show():void{ var _local1:Number = ((mc.contentMask.mouseY - SCROLL_PADDING) / (mc.contentMask.height - (2 * SCROLL_PADDING))); mc.content.y = (-(_local1) * mc.content.height); mc.contentGoalY = mc.content.y; mc.content.mouseChildren = true; mc.alpha = 1; mc.addEventListener(Event.ENTER_FRAME, onEnterFrame); mc.reveal_btn.mouseEnabled = false; } private function onReveal(_arg1:MouseEvent):void{ Main.onButtonPress(); show(); } public function dispose():void{ mc.reveal_btn.removeEventListener(MouseEvent.MOUSE_DOWN, onReveal); mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); } } }//package com.kerb.uncharted.ui
Section 163
//SoundControl (com.kerb.uncharted.ui.SoundControl) package com.kerb.uncharted.ui { import flash.events.*; import flash.display.*; import com.kerb.sound.*; public class SoundControl { private var master:Toggle; private var sfxSoundManager:SoundManager; private var music:Toggle; private var musicSoundManager:SoundManager; private var sfx:Toggle; public var mc:MovieClip; private var propagateChange:Boolean; public function SoundControl(_arg1:MovieClip, _arg2:SoundManager, _arg3:SoundManager){ this.mc = _arg1; this.musicSoundManager = _arg2; this.sfxSoundManager = _arg3; init(); } private function setMutes():void{ if (((music.isOn) && (musicSoundManager.muted))){ musicSoundManager.unmute(); } else { if (((!(music.isOn)) && (!(musicSoundManager.muted)))){ musicSoundManager.mute(); }; }; if (((sfx.isOn) && (sfxSoundManager.muted))){ sfxSoundManager.unmute(); } else { if (((!(sfx.isOn)) && (!(sfxSoundManager.muted)))){ sfxSoundManager.mute(); }; }; } private function updateMaster():void{ if (propagateChange){ propagateChange = false; if (((music.isOn) || (sfx.isOn))){ master.isOn = true; } else { if (((!(music.isOn)) && (!(sfx.isOn)))){ master.isOn = false; }; }; propagateChange = true; }; setMutes(); } private function onSFXChange(_arg1:Event=null):void{ updateMaster(); } private function init():void{ mc.mouseEnabled = false; master = new Toggle(mc.master); music = new Toggle(mc.music); sfx = new Toggle(mc.sfx); master.addEventListener(Event.CHANGE, onMasterChange, false, 0, true); music.addEventListener(Event.CHANGE, onMusicChange, false, 0, true); sfx.addEventListener(Event.CHANGE, onSFXChange, false, 0, true); mc.master.addEventListener(MouseEvent.ROLL_OVER, onMasterRollOver, false, 0, true); music.visible = false; sfx.visible = false; propagateChange = true; } private function onMasterChange(_arg1:Event=null):void{ if (propagateChange){ propagateChange = false; music.isOn = master.isOn; sfx.isOn = master.isOn; propagateChange = true; }; setMutes(); } private function onEnterFrame(_arg1:Event=null):void{ var _local2:Boolean = ((((master.mouseIsOver) || (music.mouseIsOver))) || (sfx.mouseIsOver)); if (!_local2){ music.visible = false; sfx.visible = false; mc.removeEventListener(Event.ENTER_FRAME, onEnterFrame); }; } private function onMusicChange(_arg1:Event=null):void{ updateMaster(); } private function onMasterRollOver(_arg1:MouseEvent=null):void{ music.visible = true; sfx.visible = true; mc.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true); } } }//package com.kerb.uncharted.ui
Section 164
//Toggle (com.kerb.uncharted.ui.Toggle) package com.kerb.uncharted.ui { import flash.events.*; import flash.display.*; public class Toggle extends EventDispatcher { private var mouseOver:Boolean; private var mouseDown:Boolean; private var toggleOn:Boolean; private var mc:MovieClip; public function Toggle(_arg1:MovieClip, _arg2:Boolean=true){ this.mc = _arg1; this.toggleOn = _arg2; init(); } private function onRollOut(_arg1:MouseEvent=null):void{ mouseOver = false; mouseDown = false; setGraphics(); } public function get mouseIsOver():Boolean{ return (mouseOver); } public function set visible(_arg1:Boolean):void{ mc.visible = _arg1; } private function onMouseDown(_arg1:MouseEvent=null):void{ mouseDown = true; setGraphics(); } public function get isOn():Boolean{ return (toggleOn); } private function setGraphics():void{ mc.upOff.visible = ((!(toggleOn)) && (!(mouseOver))); mc.overOff.visible = ((((!(toggleOn)) && (mouseOver))) && (!(mouseDown))); mc.downOff.visible = ((!(toggleOn)) && (mouseDown)); mc.upOn.visible = ((toggleOn) && (!(mouseOver))); mc.overOn.visible = ((((toggleOn) && (mouseOver))) && (!(mouseDown))); mc.downOn.visible = ((toggleOn) && (mouseDown)); } private function init():void{ mc.addEventListener(MouseEvent.ROLL_OVER, onRollOver, false, 0, true); mc.addEventListener(MouseEvent.ROLL_OUT, onRollOut, false, 0, true); mc.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true); mc.addEventListener(MouseEvent.CLICK, onClick, false, 0, true); mc.buttonMode = true; mc.mouseChildren = false; mc.hitArea = mc.hit; mc.hit.visible = false; mouseOver = false; mouseDown = false; setGraphics(); } public function get mouseIsDown():Boolean{ return (mouseDown); } public function set isOn(_arg1:Boolean):void{ toggleOn = _arg1; setGraphics(); dispatchEvent(new Event(Event.CHANGE)); } private function onRollOver(_arg1:MouseEvent=null):void{ mouseOver = true; setGraphics(); } private function onClick(_arg1:MouseEvent=null):void{ mouseDown = false; isOn = !(toggleOn); } } }//package com.kerb.uncharted.ui
Section 165
//Constants (com.kerb.uncharted.Constants) package com.kerb.uncharted { public class Constants { public static const SHOW_QUALITY_MENU:Boolean = false; public static const RIGID_BODY_STROKE_THICKNESS:Number = 0; public static const KERB_SITE_URL:String = "http://www.kerb.co.uk"; public static const HALF_PI:Number = 1.5707963267949; public static const RIGID_BODY_FILL_ALPHA:Number = 0.3; public static const BIN_GRID_COLOUR:uint = 0xFFFF00; public static const RAD_2_DEG:Number = 57.2957795130823; public static const SEEDED:Boolean = true; public static const RIGID_BODY_STROKE_COLOUR:uint = 0xFFFFFF; public static const QUARTER_PI:Number = 0.785398163397448; public static const DEG_2_RAD:Number = 0.0174532925199433; public static const HIGHSCORES_PERPAGE:int = 10; public static const MAIN_CLASS_NAME:String = "Uncharted2"; public static const VIEWPORT_BACKGROUND_COLOUR:uint = 0; public static const CAMERA_COLOUR:uint = 0xFF00; public static const SHOW_KERB_MENU_LINK:Boolean = true; public static const HIGHSCORES_URL:String = "highscores.php"; public static const VIEWPORT_BORDER_COLOUR:uint = 0xFF00; public static const RIGID_BODY_FILL_COLOUR:uint = 0xFFFFFF; public static const TWO_PI:Number = 6.28318530717959; public static const KERB_GAMES_URL:String = "http://www.kerbgames.com"; public static const SAVESCORE_URL:String = "savescore.php"; public static var locale:String = "en_GB"; public static var basePath:String = "http://www.unchartedps3.com/game/"; } }//package com.kerb.uncharted
Section 166
//HighScoreLoader (com.kerb.uncharted.HighScoreLoader) package com.kerb.uncharted { import flash.events.*; import com.kerb.utils.*; import flash.net.*; public class HighScoreLoader extends EventDispatcher implements IDisposable { private var _currentPage:int; private var _data:Array; private var _lastId:int; private var _scoreCount:int; private var _totalPages:int; public static const ON_LOADED:String = "onHighscoresLoaded"; public static const ON_SAVE_ERROR:String = "onHighscoresSaveError"; public static const ON_SAVED:String = "onHighscoresSaved"; private static var instance:HighScoreLoader = null; public function HighScoreLoader(){ _currentPage = 1; } public function getScoreCount():int{ return (_scoreCount); } private function _onHighscoresFetchedFromServer(_arg1:Event):void{ var _local5:XML; var _local2:URLLoader = (_arg1.target as URLLoader); var _local3:XML = new XML(_local2.data); var _local4:XMLList = _local3.child("scores").child("score"); _data = []; for each (_local5 in _local4) { _data.push({rank:_local5.child("pos"), name:_local5.child("name"), score:_local5.child("score")}); }; _totalPages = parseInt(_local3.child("totalPages")); _currentPage = parseInt(_local3.child("page")); _scoreCount = parseInt(_local3.child("scoreCount")); dispatchEvent(new Event(ON_LOADED)); } public function load(_arg1:int, _arg2:int=-1, _arg3:String=""):void{ var _local4:URLRequest = new URLRequest((Constants.basePath + Constants.HIGHSCORES_URL)); _local4.method = URLRequestMethod.POST; var _local5:URLVariables = new URLVariables(); _local5.perPage = Constants.HIGHSCORES_PERPAGE; if (_arg2 != -1){ _local5.goto = _arg2; } else { _local5.page = _arg1; }; _local5.username = _arg3; _local4.data = _local5; var _local6:URLLoader = new URLLoader(_local4); _local6.addEventListener(Event.COMPLETE, _onHighscoresFetchedFromServer, false, 0, true); _local6.addEventListener(SecurityErrorEvent.SECURITY_ERROR, _onLoaderError, false, 0, true); _local6.addEventListener(IOErrorEvent.IO_ERROR, _onLoaderError, false, 0, true); _local6.dataFormat = URLLoaderDataFormat.TEXT; _local6.load(_local4); } public function getLastId():int{ return (_lastId); } public function getDataArray():Array{ return (_data); } public function getCurrentPage():int{ return (_currentPage); } public function dispose():void{ } public function getTotalPages():int{ return (_totalPages); } private function _onLoaderError(_arg1:Event):void{ trace("HIGH SCORE LOADER ERROR\n", _arg1); } private function _onHighscoreSavedToServer(_arg1:Event):void{ var _local2:URLLoader = (_arg1.target as URLLoader); var _local3:XML = new XML(_local2.data); if (_local3.child("message").length() > 0){ trace(("Error : " + _local3.child("message"))); _lastId = -1; dispatchEvent(new Event(ON_SAVE_ERROR, _local3.child("message"))); } else { _lastId = parseInt(_local3.child("id")); dispatchEvent(new Event(ON_SAVED)); }; } public function save(_arg1:Number, _arg2:String):void{ var _local3:URLRequest = new URLRequest((Constants.basePath + Constants.SAVESCORE_URL)); _local3.method = URLRequestMethod.POST; var _local4:URLVariables = new URLVariables(); _local4.username = _arg2; _local4.score = escape(Crypto.encrypt(_arg1)); _local3.data = _local4; var _local5:URLLoader = new URLLoader(_local3); _local5.addEventListener(Event.COMPLETE, _onHighscoreSavedToServer); _local5.addEventListener(SecurityErrorEvent.SECURITY_ERROR, _onLoaderError, false, 0, true); _local5.addEventListener(IOErrorEvent.IO_ERROR, _onLoaderError, false, 0, true); _local5.dataFormat = URLLoaderDataFormat.TEXT; _local5.load(_local3); } public static function getInstance():HighScoreLoader{ if (instance == null){ instance = new (HighScoreLoader); }; return (instance); } } }//package com.kerb.uncharted
Section 167
//Main (com.kerb.uncharted.Main) package com.kerb.uncharted { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.utils.*; import com.kerb.sound.*; import com.kerb.tracking.*; import com.kerb.uncharted.screens.*; public class Main extends Sprite { protected var screenManager:ScreenManager; private var AvatarSWFBytes:Class; private var InterfaceSWFBytes:Class; private var SoundsSWFBytes:Class; private var EnemiesSWFBytes:Class; private var CutScenesSWFBytes:Class; private var GraphicsSWFBytes:Class; public static const smSFX:SoundManager = new SoundManager(); public static const afm:AssetFactoryManager = new AssetFactoryManager(); public static const smMusic:SoundManager = new SoundManager(); public static var text_fr_BE:Class = Main_text_fr_BE; public static var text_fr_FR:Class = Main_text_fr_FR; public static var text_en_NZ:Class = Main_text_en_NZ; public static var text_sv_SE:Class = Main_text_sv_SE; public static var text_de_AT:Class = Main_text_de_AT; public static var text_pl_PL:Class = Main_text_pl_PL; public static var text_en_GB:Class = Main_text_en_GB; public static var text_it_IT:Class = Main_text_it_IT; public static var text_pt_PT:Class = Main_text_pt_PT; public static var text_ru_RU:Class = Main_text_ru_RU; public static var text_fr_CH:Class = Main_text_fr_CH; public static var text_fi_FI:Class = Main_text_fi_FI; private static var titleMusicPlaying:Boolean = false; public static var text_fr_LU:Class = Main_text_fr_LU; public static var text_es_ES:Class = Main_text_es_ES; public static var text_de_CH:Class = Main_text_de_CH; public static var text_nl_BE:Class = Main_text_nl_BE; public static var text_nl_NL:Class = Main_text_nl_NL; public static var text_en_IE:Class = Main_text_en_IE; public static var text_it_CH:Class = Main_text_it_CH; public static var text_de_DE:Class = Main_text_de_DE; public static var text_no_NO:Class = Main_text_no_NO; public static var text_de_LU:Class = Main_text_de_LU; public static var text_da_DK:Class = Main_text_da_DK; public static var text_en_AU:Class = Main_text_en_AU; public function Main(){ GraphicsSWFBytes = Main_GraphicsSWFBytes; AvatarSWFBytes = Main_AvatarSWFBytes; EnemiesSWFBytes = Main_EnemiesSWFBytes; InterfaceSWFBytes = Main_InterfaceSWFBytes; CutScenesSWFBytes = Main_CutScenesSWFBytes; SoundsSWFBytes = Main_SoundsSWFBytes; super(); addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true); } protected function initSounds():void{ smSFX.registerSound(afm.createExtendedSound("sound", "AmmoSound")); smSFX.registerSound(afm.createExtendedSound("sound", "ButtonPressSound")); smSFX.registerSound(afm.createExtendedSound("sound", "CrashSound")); smSFX.registerSound(afm.createExtendedSound("sound", "CrumbleSound")); smSFX.registerSound(afm.createExtendedSound("sound", "DeathSound")); smSFX.registerSound(afm.createExtendedSound("sound", "ExplosionSound")); smSFX.registerSound(afm.createExtendedSound("sound", "FootstepLeftSound")); smSFX.registerSound(afm.createExtendedSound("sound", "FootstepRightSound")); smSFX.registerSound(afm.createExtendedSound("sound", "HelicopterLoopSound")); smSFX.registerSound(afm.createExtendedSound("sound", "HelicopterMachineGunLoopSound")); smSFX.registerSound(afm.createExtendedSound("sound", "HitSound")); smSFX.registerSound(afm.createExtendedSound("sound", "InjurySound")); smSFX.registerSound(afm.createExtendedSound("sound", "JumpSound")); smSFX.registerSound(afm.createExtendedSound("sound", "LandingSound")); smSFX.registerSound(afm.createExtendedSound("sound", "MachineGunLoopSound")); smSFX.registerSound(afm.createExtendedSound("sound", "PistolSound")); smSFX.registerSound(afm.createExtendedSound("sound", "PortcullisSound")); smSFX.registerSound(afm.createExtendedSound("sound", "PunchSound")); smSFX.registerSound(afm.createExtendedSound("sound", "TreasureSound")); smSFX.registerSound(afm.createExtendedSound("sound", "WeaponSelectSound")); smMusic.registerSound(afm.createExtendedSound("sound", "ButtonBashLoopSound")); smMusic.registerSound(afm.createExtendedSound("sound", "EndScoreLoopSound")); smMusic.registerSound(afm.createExtendedSound("sound", "IntroAnimationLoopSound")); smMusic.registerSound(afm.createExtendedSound("sound", "Level1LoopSound")); smMusic.registerSound(afm.createExtendedSound("sound", "Level2LoopSound")); smMusic.registerSound(afm.createExtendedSound("sound", "Level3LoopSound")); smMusic.registerSound(afm.createExtendedSound("sound", "Level4LoopSound")); smMusic.registerSound(afm.createExtendedSound("sound", "Level5LoopSound")); smMusic.registerSound(afm.createExtendedSound("sound", "MidScoreLoopSound")); smMusic.registerSound(afm.createExtendedSound("sound", "TitleLoopSound")); } protected function initTracking():void{ DoubleQuick.init(root, (Constants.SEEDED) ? 92 : 83); WebTrends.init(root, "webtrends.eu.playstation.com", "dcswgqpcj0000008i35378a2r_7o2i", "game_10010"); DoubleQuick.event((Constants.SEEDED) ? 521 : 534); WebTrends.event((Constants.locale + "/Global/Loaded"), "Game Loaded"); } protected function init():void{ initTracking(); initSounds(); initText(); initScreenManager(); } protected function onAssetFactoryManagerReady(_arg1:Event):void{ afm.removeEventListener(Event.COMPLETE, onAssetFactoryManagerReady); init(); } protected function initScreenManager():void{ screenManager = new ScreenManager(new PSIdent()); addChild(screenManager); } protected function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); afm.addEventListener(Event.COMPLETE, onAssetFactoryManagerReady, false, 0, true); afm.addAssetFactory("graphics", GraphicsSWFBytes); afm.addAssetFactory("avatar", AvatarSWFBytes); afm.addAssetFactory("enemies", EnemiesSWFBytes); afm.addAssetFactory("interface", InterfaceSWFBytes); afm.addAssetFactory("cutScenes", CutScenesSWFBytes); afm.addAssetFactory("sound", SoundsSWFBytes); } public static function playTitleMusic():void{ if (titleMusicPlaying){ return; }; titleMusicPlaying = true; Main.smMusic.getSoundByClassName("TitleLoopSound").play(0, 999999); } public static function stopTitleMusic():void{ if (!titleMusicPlaying){ return; }; titleMusicPlaying = false; Main.smMusic.getSoundByClassName("TitleLoopSound").stop(); } public static function onButtonPress():void{ smSFX.getSoundByClassName("ButtonPressSound").play(0, 1); } public static function initText():void{ var _local1:Class; _local1 = Main[("text_" + Constants.locale)]; TextManager.getInstance().initFromClass(_local1); } } }//package com.kerb.uncharted
Section 168
//Main_AvatarSWFBytes (com.kerb.uncharted.Main_AvatarSWFBytes) package com.kerb.uncharted { import mx.core.*; public class Main_AvatarSWFBytes extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 169
//Main_CutScenesSWFBytes (com.kerb.uncharted.Main_CutScenesSWFBytes) package com.kerb.uncharted { import mx.core.*; public class Main_CutScenesSWFBytes extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 170
//Main_EnemiesSWFBytes (com.kerb.uncharted.Main_EnemiesSWFBytes) package com.kerb.uncharted { import mx.core.*; public class Main_EnemiesSWFBytes extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 171
//Main_GraphicsSWFBytes (com.kerb.uncharted.Main_GraphicsSWFBytes) package com.kerb.uncharted { import mx.core.*; public class Main_GraphicsSWFBytes extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 172
//Main_InterfaceSWFBytes (com.kerb.uncharted.Main_InterfaceSWFBytes) package com.kerb.uncharted { import mx.core.*; public class Main_InterfaceSWFBytes extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 173
//Main_SoundsSWFBytes (com.kerb.uncharted.Main_SoundsSWFBytes) package com.kerb.uncharted { import mx.core.*; public class Main_SoundsSWFBytes extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 174
//Main_text_da_DK (com.kerb.uncharted.Main_text_da_DK) package com.kerb.uncharted { import mx.core.*; public class Main_text_da_DK extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 175
//Main_text_de_AT (com.kerb.uncharted.Main_text_de_AT) package com.kerb.uncharted { import mx.core.*; public class Main_text_de_AT extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 176
//Main_text_de_CH (com.kerb.uncharted.Main_text_de_CH) package com.kerb.uncharted { import mx.core.*; public class Main_text_de_CH extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 177
//Main_text_de_DE (com.kerb.uncharted.Main_text_de_DE) package com.kerb.uncharted { import mx.core.*; public class Main_text_de_DE extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 178
//Main_text_de_LU (com.kerb.uncharted.Main_text_de_LU) package com.kerb.uncharted { import mx.core.*; public class Main_text_de_LU extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 179
//Main_text_en_AU (com.kerb.uncharted.Main_text_en_AU) package com.kerb.uncharted { import mx.core.*; public class Main_text_en_AU extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 180
//Main_text_en_GB (com.kerb.uncharted.Main_text_en_GB) package com.kerb.uncharted { import mx.core.*; public class Main_text_en_GB extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 181
//Main_text_en_IE (com.kerb.uncharted.Main_text_en_IE) package com.kerb.uncharted { import mx.core.*; public class Main_text_en_IE extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 182
//Main_text_en_NZ (com.kerb.uncharted.Main_text_en_NZ) package com.kerb.uncharted { import mx.core.*; public class Main_text_en_NZ extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 183
//Main_text_es_ES (com.kerb.uncharted.Main_text_es_ES) package com.kerb.uncharted { import mx.core.*; public class Main_text_es_ES extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 184
//Main_text_fi_FI (com.kerb.uncharted.Main_text_fi_FI) package com.kerb.uncharted { import mx.core.*; public class Main_text_fi_FI extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 185
//Main_text_fr_BE (com.kerb.uncharted.Main_text_fr_BE) package com.kerb.uncharted { import mx.core.*; public class Main_text_fr_BE extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 186
//Main_text_fr_CH (com.kerb.uncharted.Main_text_fr_CH) package com.kerb.uncharted { import mx.core.*; public class Main_text_fr_CH extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 187
//Main_text_fr_FR (com.kerb.uncharted.Main_text_fr_FR) package com.kerb.uncharted { import mx.core.*; public class Main_text_fr_FR extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 188
//Main_text_fr_LU (com.kerb.uncharted.Main_text_fr_LU) package com.kerb.uncharted { import mx.core.*; public class Main_text_fr_LU extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 189
//Main_text_it_CH (com.kerb.uncharted.Main_text_it_CH) package com.kerb.uncharted { import mx.core.*; public class Main_text_it_CH extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 190
//Main_text_it_IT (com.kerb.uncharted.Main_text_it_IT) package com.kerb.uncharted { import mx.core.*; public class Main_text_it_IT extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 191
//Main_text_nl_BE (com.kerb.uncharted.Main_text_nl_BE) package com.kerb.uncharted { import mx.core.*; public class Main_text_nl_BE extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 192
//Main_text_nl_NL (com.kerb.uncharted.Main_text_nl_NL) package com.kerb.uncharted { import mx.core.*; public class Main_text_nl_NL extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 193
//Main_text_no_NO (com.kerb.uncharted.Main_text_no_NO) package com.kerb.uncharted { import mx.core.*; public class Main_text_no_NO extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 194
//Main_text_pl_PL (com.kerb.uncharted.Main_text_pl_PL) package com.kerb.uncharted { import mx.core.*; public class Main_text_pl_PL extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 195
//Main_text_pt_PT (com.kerb.uncharted.Main_text_pt_PT) package com.kerb.uncharted { import mx.core.*; public class Main_text_pt_PT extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 196
//Main_text_ru_RU (com.kerb.uncharted.Main_text_ru_RU) package com.kerb.uncharted { import mx.core.*; public class Main_text_ru_RU extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 197
//Main_text_sv_SE (com.kerb.uncharted.Main_text_sv_SE) package com.kerb.uncharted { import mx.core.*; public class Main_text_sv_SE extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 198
//Menu (com.kerb.uncharted.Menu) package com.kerb.uncharted { import flash.events.*; import flash.display.*; import com.kerb.uncharted.screens.control.*; import com.kerb.tracking.*; import com.kerb.ui.*; import com.kerb.uncharted.screens.*; import com.kerb.uncharted.ui.*; public class Menu extends Sprite { private var home_btn:DynamicButton; private var soundControl:SoundControl; private var trailer_btn:DynamicButton; private var mc:MovieClip; private var highscores_btn:DynamicButton; private var about_btn:DynamicButton; private var gallery_btn:DynamicButton; private var language_btn:DynamicButton; public function Menu(){ mc = Main.afm.createMovieClip("interface", "MenuAsset"); home_btn = new DynamicButton(mc.home_btn, "nav.title.home"); home_btn.addEventListener(MouseEvent.CLICK, onHomeClick, false, 0, true); about_btn = new DynamicButton(mc.about_btn, "nav.title.about"); about_btn.addEventListener(MouseEvent.CLICK, onAboutClick, false, 0, true); gallery_btn = new DynamicButton(mc.gallery_btn, "nav.title.gallery"); gallery_btn.addEventListener(MouseEvent.CLICK, onGalleryClick, false, 0, true); trailer_btn = new DynamicButton(mc.trailer_btn, "nav.title.movie"); trailer_btn.addEventListener(MouseEvent.CLICK, onTrailerClick, false, 0, true); highscores_btn = new DynamicButton(mc.highscores_btn, "nav.title.hiscore"); highscores_btn.addEventListener(MouseEvent.CLICK, onHighScoresClick, false, 0, true); language_btn = new DynamicButton(mc.language_btn); language_btn.addEventListener(MouseEvent.CLICK, onLanguageClick, false, 0, true); language_btn.addEventListener(MouseEvent.ROLL_OVER, onLanguageUpdate, false, 0, true); language_btn.addEventListener(MouseEvent.ROLL_OUT, onLanguageUpdate, false, 0, true); language_btn.addEventListener(MouseEvent.MOUSE_DOWN, onLanguageUpdate, false, 0, true); onLanguageUpdate(); language_btn.visible = Constants.SEEDED; soundControl = new SoundControl(mc.soundControl_mc, Main.smMusic, Main.smSFX); addChild(mc); dispatchEvent(new ScreenEvent(ScreenEvent.DISABLE)); } public function enable():void{ home_btn.enable(); about_btn.enable(); gallery_btn.enable(); trailer_btn.enable(); highscores_btn.enable(); language_btn.enable(); } private function onHighScoresClick(_arg1:MouseEvent):void{ Main.onButtonPress(); DoubleQuick.event((Constants.SEEDED) ? 531 : 544); WebTrends.event((Constants.locale + "/Global/HighScores"), "High Scores Viewed"); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, "exit.hiscore", new HighScores())); } private function onLanguageUpdate(_arg1:MouseEvent=null):void{ mc.language_btn.up.gotoAndStop(Constants.locale); mc.language_btn.over.gotoAndStop(Constants.locale); mc.language_btn.down.gotoAndStop(Constants.locale); } private function onLanguageClick(_arg1:MouseEvent):void{ Main.onButtonPress(); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, null, new LanguageSelect())); } private function onHomeClick(_arg1:MouseEvent):void{ Main.onButtonPress(); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, "exit.home", new Title())); } private function onGalleryClick(_arg1:MouseEvent):void{ Main.onButtonPress(); DoubleQuick.event((Constants.SEEDED) ? 530 : 541); WebTrends.event((Constants.locale + "/Global/Gallery"), "Gallery Viewed"); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, "exit.gallery", new Gallery())); } private function onTrailerClick(_arg1:MouseEvent):void{ Main.onButtonPress(); DoubleQuick.event((Constants.SEEDED) ? 529 : 543); WebTrends.event((Constants.locale + "/Global/Trailer"), "Trailer Viewed"); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, "exit.trailer", new Trailer())); } public function initText():void{ home_btn.initText(); about_btn.initText(); gallery_btn.initText(); trailer_btn.initText(); highscores_btn.initText(); onLanguageUpdate(); } public function setSelected(_arg1:String):void{ home_btn.selected = (_arg1 == "title"); about_btn.selected = (_arg1 == "about"); gallery_btn.selected = (_arg1 == "gallery"); trailer_btn.selected = (_arg1 == "trailer"); highscores_btn.selected = (_arg1 == "highscores"); } public function disable():void{ home_btn.disable(); about_btn.disable(); gallery_btn.disable(); trailer_btn.disable(); highscores_btn.disable(); language_btn.disable(); } private function onAboutClick(_arg1:MouseEvent):void{ Main.onButtonPress(); DoubleQuick.event((Constants.SEEDED) ? 528 : 540); WebTrends.event((Constants.locale + "/Global/About"), "About Viewed"); dispatchEvent(new ScreenEvent(ScreenEvent.SHOW, "exit.about", new About())); } public function setType(_arg1:String):void{ mc.gotoAndStop(_arg1); } public function onLanguageChanged():void{ initText(); } } }//package com.kerb.uncharted
Section 199
//Preload (com.kerb.uncharted.Preload) package com.kerb.uncharted { import flash.events.*; import flash.display.*; import com.kerb.utils.*; import flash.ui.*; import flash.utils.*; import flash.net.*; public class Preload extends MovieClip { protected var af:AssetFactory; protected var SWFBytes:Class; protected var url:String; protected var highQualityItem:ContextMenuItem; protected var mc:MovieClip; protected var mediumQualityItem:ContextMenuItem; protected var lowQualityItem:ContextMenuItem; public function Preload(){ SWFBytes = Preload_SWFBytes; super(); stop(); checkFlashvars(); initStage(); initContextMenu(); initAssetFactory(); } protected function drawLetterbox():void{ var _local1:int = loaderInfo.width; var _local2:int = loaderInfo.height; var _local3:Sprite = new Sprite(); var _local4:Graphics = _local3.graphics; _local4.beginFill(0); _local4.drawRect(-1000, -1000, (2000 + _local1), 1000); _local4.drawRect(-1000, _local2, (2000 + _local1), 1000); _local4.drawRect(-1000, -1000, 1000, (1000 + _local2)); _local4.drawRect(_local1, -1000, 1000, (1000 + _local2)); _local4.endFill(); addChild(_local3); } protected function preloadComplete():void{ var _local1:Class; if (currentFrame == 1){ nextFrame(); } else { removeEventListener(Event.ENTER_FRAME, onEnterFrame); _local1 = Class(getDefinitionByName(Constants.MAIN_CLASS_NAME)); addChild((new (_local1) as DisplayObject)); removeChild(mc); mc = null; }; } protected function initContextMenu():void{ var _local1:ContextMenuItem; contextMenu = new ContextMenu(); contextMenu.hideBuiltInItems(); url = loaderInfo.url; if (Constants.SHOW_KERB_MENU_LINK){ _local1 = new ContextMenuItem("Built by Kerb!", false); _local1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onKerbMenuItemSelect); contextMenu.customItems.push(_local1); }; if (Constants.SHOW_QUALITY_MENU){ lowQualityItem = new ContextMenuItem("Low Quality (fastest)", true); lowQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect); contextMenu.customItems.push(lowQualityItem); mediumQualityItem = new ContextMenuItem("Medium Quality", false); mediumQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect); contextMenu.customItems.push(mediumQualityItem); highQualityItem = new ContextMenuItem("• High Quality (slowest)", false); highQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect); contextMenu.customItems.push(highQualityItem); }; } protected function initStage():void{ stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.stageFocusRect = false; } protected function initAssetFactory():void{ af = new AssetFactory(); af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady); af.initialize(SWFBytes); } protected function checkFlashvars():void{ if (root.loaderInfo.parameters.locale){ Constants.locale = root.loaderInfo.parameters.locale; }; if (root.loaderInfo.parameters.basePath){ Constants.basePath = root.loaderInfo.parameters.basePath; }; } protected function onQualityMenuItemSelect(_arg1:Event):void{ lowQualityItem.caption = "Low Quality (fast)"; mediumQualityItem.caption = "Medium Quality"; highQualityItem.caption = "High Quality (slow)"; switch (_arg1.currentTarget){ case lowQualityItem: lowQualityItem.caption = ("• " + lowQualityItem.caption); stage.quality = StageQuality.LOW; break; case mediumQualityItem: mediumQualityItem.caption = ("• " + mediumQualityItem.caption); stage.quality = StageQuality.MEDIUM; break; case highQualityItem: highQualityItem.caption = ("• " + highQualityItem.caption); stage.quality = StageQuality.HIGH; break; }; } protected function onKerbMenuItemSelect(_arg1:Event):void{ navigateToURL(new URLRequest(Constants.KERB_SITE_URL), "_blank"); } protected function onAssetFactoryReady(_arg1:Event):void{ af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady); mc = (af.createDisplayObject("PreloadAsset") as MovieClip); addChildAt(mc, 0); af = null; drawLetterbox(); addEventListener(Event.ENTER_FRAME, onEnterFrame); } protected function onEnterFrame(_arg1:Event):void{ var _local2:int = root.loaderInfo.bytesLoaded; var _local3:int = root.loaderInfo.bytesTotal; var _local4:int = Math.ceil(((100 * _local2) / _local3)); if (mc.currentFrame != _local4){ mc.gotoAndStop(_local4); }; if (_local4 == 100){ preloadComplete(); }; } } }//package com.kerb.uncharted
Section 200
//Preload_SWFBytes (com.kerb.uncharted.Preload_SWFBytes) package com.kerb.uncharted { import mx.core.*; public class Preload_SWFBytes extends ByteArrayAsset { } }//package com.kerb.uncharted
Section 201
//AssetFactory (com.kerb.utils.AssetFactory) package com.kerb.utils { import flash.events.*; import flash.display.*; import flash.media.*; import com.kerb.sound.*; public final class AssetFactory extends EventDispatcher { private var _loader:Loader;// = null public static const EVENT_ASSET_FACTORY_READY:String = "EVENT_ASSET_FACTORY_READY"; public function initialize(_arg1:Class):void{ _loader = new Loader(); _loader.contentLoaderInfo.addEventListener(Event.INIT, _onLibraryReady); _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError); _loader.loadBytes(new (_arg1)); } public function createExtendedSound(_arg1:String):ExtendedSound{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new (_local2) as ExtendedSound)); } public function createDisplayObject(_arg1:String):DisplayObject{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new (_local2) as DisplayObject)); } private function _onLibraryReady(_arg1:Event):void{ _loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLibraryReady); dispatchEvent(new Event(EVENT_ASSET_FACTORY_READY)); } public function createSound(_arg1:String):Sound{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new (_local2) as Sound)); } public function createMovieClip(_arg1:String):MovieClip{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new (_local2) as MovieClip)); } public function createBitmapDataObject(_arg1:String):BitmapData{ var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1)); return ((new _local2(0, 0) as BitmapData)); } private function _onIOError(_arg1:Event):void{ } } }//package com.kerb.utils
Section 202
//AssetFactoryManager (com.kerb.utils.AssetFactoryManager) package com.kerb.utils { import flash.events.*; import flash.display.*; import flash.media.*; import com.kerb.sound.*; import flash.utils.*; public class AssetFactoryManager extends EventDispatcher { protected var numFactories:int; protected var numLoaded:int; protected var assetFactories:Dictionary; public function AssetFactoryManager(){ assetFactories = new Dictionary(); numFactories = 0; numLoaded = 0; } public function createExtendedSound(_arg1:String, _arg2:String):ExtendedSound{ if (assetFactories[_arg1]){ return (assetFactories[_arg1].createExtendedSound(_arg2)); }; return (null); } public function createDisplayObject(_arg1:String, _arg2:String):DisplayObject{ if (assetFactories[_arg1]){ return (assetFactories[_arg1].createDisplayObject(_arg2)); }; return (null); } protected function onAssetFactoryReady(_arg1:Event):void{ _arg1.target.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady); if (++numLoaded == numFactories){ dispatchEvent(new Event(Event.COMPLETE)); }; } public function createBitmapDataObject(_arg1:String, _arg2:String):BitmapData{ if (assetFactories[_arg1]){ return (assetFactories[_arg1].createBitmapDataObject(_arg2)); }; return (null); } public function getAssetFactory(_arg1:String):AssetFactory{ return (assetFactories[_arg1]); } public function createSound(_arg1:String, _arg2:String):Sound{ if (assetFactories[_arg1]){ return (assetFactories[_arg1].createSound(_arg2)); }; return (null); } public function addAssetFactory(_arg1:String, _arg2:Class):void{ var _local3:AssetFactory = new AssetFactory(); assetFactories[_arg1] = _local3; numFactories++; _local3.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady); _local3.initialize(_arg2); } public function createMovieClip(_arg1:String, _arg2:String):MovieClip{ if (assetFactories[_arg1]){ return (assetFactories[_arg1].createMovieClip(_arg2)); }; return (null); } } }//package com.kerb.utils
Section 203
//Crypto (com.kerb.utils.Crypto) package com.kerb.utils { public final class Crypto { private static var KEYS:Array = new Array("98sdfa23Ql", "ADF8b3w2fq", "ER2b79hwfO", "clkenf0FSj", "4R7d6ASYU3", "ASDQsjhW02", "kCQ6YH9asc", "ADIx7g19SP", "Nd98fhiOAF", "a09hADNFkf"); private static var SALT:String = "8008135"; public static function encrypt(_arg1:int):String{ var _local2:String = ((_arg1 + "") + SALT); var _local3 = ""; var _local4:int = Math.floor((Math.random() * KEYS.length)); var _local5:int = _local4; var _local6:int; while (_local6 < _local2.length) { _local3 = (_local3 + KEYS[_local5].charAt(parseInt(_local2.charAt(_local6)))); _local5 = ((_local5 + 1) % KEYS.length); _local6++; }; _local3 = (_local3 + ("" + _local4)); return (_local3); } public static function decrypt(_arg1:String):int{ var _local6:int; var _local2:int = parseInt(_arg1.substr(-1)); var _local3:String = _arg1.substr(0, (_arg1.length - 1)); var _local4 = ""; var _local5:int; while (_local5 < _local3.length) { _local6 = KEYS[_local2].indexOf(_local3.charAt(_local5)); if (_local6 > -1){ _local4 = (_local4 + ("" + _local6)); } else { return (0); }; _local2 = ((_local2 + 1) % KEYS.length); _local5++; }; if (_local4.substr(-(SALT.length)) != SALT){ return (0); }; return (parseInt(_local4.substr(0, (_local4.length - SALT.length)))); } } }//package com.kerb.utils
Section 204
//IDisposable (com.kerb.utils.IDisposable) package com.kerb.utils { public interface IDisposable { function dispose():void; } }//package com.kerb.utils
Section 205
//TextManager (com.kerb.utils.TextManager) package com.kerb.utils { import flash.text.*; import flash.utils.*; public class TextManager { private var _xmlData:XML; private var _fontOverrideFunction:Function; private static var instance:TextManager; public function setRawTextField(_arg1:TextField, _arg2:String, _arg3:Boolean=false):void{ var _local4:TextFormat; if (_fontOverrideFunction != null){ _fontOverrideFunction(_arg1); }; if (_arg3){ _arg1.htmlText = _arg2; } else { if ((((((((_fontOverrideFunction == null)) && ((_arg1.length > 0)))) && (!(_arg1.defaultTextFormat.bold)))) && (_arg1.getTextFormat(0).bold))){ _local4 = new TextFormat(); _local4.bold = true; _arg1.defaultTextFormat = _local4; }; _arg1.text = _arg2; }; } public function setTextField(_arg1:TextField, _arg2:String, _arg3:Boolean=false):void{ setRawTextField(_arg1, getTextById(_arg2), _arg3); } public function setFontOverrideFunction(_arg1:Function):void{ _fontOverrideFunction = _arg1; } public function init(_arg1:XML):void{ this._xmlData = _arg1; } public function getTextById(_arg1:String):String{ var result:String; var id = _arg1; if (_xmlData){ result = _xmlData.text.(@id == id); if (result){ return (result); }; return ((("[text key missing : " + id) + "]")); //unresolved jump }; return (id); } public function centerTextField(_arg1:TextField, _arg2:Boolean=true):void{ _arg1.y = ((_arg2) ? 0 : _arg1.y + ((_arg1.height - (_arg1.textHeight + 4)) / 2)); } public function hasId(_arg1:String):Boolean{ var result:String; var id = _arg1; if (_xmlData){ result = _xmlData.text.(@id == id); if (result){ return (true); }; }; return (false); } public function initFromClass(_arg1:Class):void{ var _local3:XML; var _local2:ByteArray = ByteArray(new (_arg1)); var _local4:String = _local2.readUTFBytes(3); if (_local4.length == 1){ this._xmlData = new XML(_local2.readUTFBytes((_local2.length - 3))); } else { this._xmlData = new XML((_local4 + _local2.readUTFBytes((_local2.length - 3)))); }; } public static function getInstance():TextManager{ if (instance == null){ instance = new (TextManager); }; return (instance); } } }//package com.kerb.utils
Section 206
//AutoLayoutEvent (fl.video.AutoLayoutEvent) package fl.video { import flash.events.*; import flash.geom.*; public class AutoLayoutEvent extends LayoutEvent implements IVPEvent { private var _vp:uint; public static const AUTO_LAYOUT:String = "autoLayout"; public function AutoLayoutEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Rectangle=null, _arg5:Rectangle=null, _arg6:uint=0){ super(_arg1, _arg2, _arg3, _arg4, _arg5); _vp = _arg6; } override public function clone():Event{ return (new AutoLayoutEvent(type, bubbles, cancelable, Rectangle(oldBounds.clone()), Rectangle(oldRegistrationBounds.clone()), vp)); } public function set vp(_arg1:uint):void{ _vp = _arg1; } public function get vp():uint{ return (_vp); } } }//package fl.video
Section 207
//ConnectClient (fl.video.ConnectClient) package fl.video { import flash.net.*; public class ConnectClient { public var connIndex:uint; public var nc:NetConnection; public var pending:Boolean; public var owner:NCManager; public function ConnectClient(_arg1:NCManager, _arg2:NetConnection, _arg3:uint=0){ this.owner = _arg1; this.nc = _arg2; this.connIndex = _arg3; this.pending = false; } public function onBWCheck(... _args):Number{ return (++owner._payload); } public function onBWDone(... _args):void{ var _local2:Number; if (_args.length > 0){ _local2 = _args[0]; }; owner.onConnected(nc, _local2); } public function close():void{ } } }//package fl.video
Section 208
//ControlData (fl.video.ControlData) package fl.video { import flash.display.*; public class ControlData { public var state_mc:Array; public var origWidth:Number; public var handle_mc:Sprite; public var state:uint; public var leftMargin:Number; public var fullness_mc:DisplayObject; public var isDragging:Boolean; public var currentState_mc:DisplayObject; public var percentage:Number; public var owner:DisplayObject; public var origX:Number; public var origY:Number; public var bottomMargin:Number; public var disabled_mc:DisplayObject; public var enabled:Boolean; public var hit_mc:Sprite; public var origHeight:Number; public var index:int; public var mask_mc:DisplayObject; public var avatar:DisplayObject; public var fill_mc:DisplayObject; public var topMargin:Number; public var uiMgr:UIManager; public var progress_mc:DisplayObject; public var rightMargin:Number; public var ctrl:DisplayObject; public var origScaleX:Number; public var origScaleY:Number; public function ControlData(_arg1:UIManager, _arg2:DisplayObject, _arg3:DisplayObject, _arg4:int){ var uiMgr = _arg1; var ctrl = _arg2; var owner = _arg3; var index = _arg4; super(); this.uiMgr = uiMgr; this.index = index; this.ctrl = ctrl; this.owner = owner; try { ctrl["uiMgr"] = uiMgr; } catch(re:ReferenceError) { }; } } }//package fl.video
Section 209
//CuePointManager (fl.video.CuePointManager) package fl.video { public class CuePointManager { flvplayback_internal var _disabledCuePointsByNameOnly:Object; flvplayback_internal var navCuePoints:Array; flvplayback_internal var allCuePoints:Array; flvplayback_internal var _disabledCuePoints:Array; flvplayback_internal var _asCuePointTolerance:Number; flvplayback_internal var _linearSearchTolerance:Number; flvplayback_internal var _asCuePointIndex:int; flvplayback_internal var asCuePoints:Array; flvplayback_internal var flvCuePoints:Array; flvplayback_internal var _metadataLoaded:Boolean; flvplayback_internal var _id:uint; private var _owner:FLVPlayback; flvplayback_internal var eventCuePoints:Array; public static const SHORT_VERSION:String = "2.1"; public static const VERSION:String = "2.1.0.14"; flvplayback_internal static const DEFAULT_LINEAR_SEARCH_TOLERANCE:Number = 50; flvplayback_internal static var cuePointsReplace:Array = ["&quot;", "\"", "&#39;", "'", "&#44;", ",", "&amp;", "&"]; public function CuePointManager(_arg1:FLVPlayback, _arg2:uint){ _owner = _arg1; _id = _arg2; reset(); _asCuePointTolerance = (_owner.getVideoPlayer(_id).playheadUpdateInterval / 2000); _linearSearchTolerance = DEFAULT_LINEAR_SEARCH_TOLERANCE; } flvplayback_internal function getCuePoint(_arg1:Array, _arg2:Boolean, _arg3):Object{ var _local4:Object; var _local5:int; switch (typeof(_arg3)){ case "string": _local4 = {name:_arg3}; break; case "number": _local4 = {time:_arg3}; break; case "object": _local4 = _arg3; break; }; _local5 = getCuePointIndex(_arg1, _arg2, _local4.time, _local4.name); if (_local5 < 0){ return (null); }; _local4 = deepCopyObject(_arg1[_local5]); _local4.array = _arg1; _local4.index = _local5; return (_local4); } public function resetASCuePointIndex(_arg1:Number):void{ var _local2:int; if ((((_arg1 <= 0)) || ((asCuePoints == null)))){ _asCuePointIndex = 0; return; }; _local2 = getCuePointIndex(asCuePoints, true, _arg1); _asCuePointIndex = ((asCuePoints[_local2].time)<_arg1) ? (_local2 + 1) : _local2; } public function set playheadUpdateInterval(_arg1:Number):void{ _asCuePointTolerance = (_arg1 / 2000); } flvplayback_internal function addOrDisable(_arg1:Boolean, _arg2:Object):void{ if (_arg1){ if (_arg2.type == CuePointType.ACTIONSCRIPT){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "Cannot disable actionscript cue points")); }; setFLVCuePointEnabled(false, _arg2); } else { if (_arg2.type == CuePointType.ACTIONSCRIPT){ addASCuePoint(_arg2); }; }; } public function processFLVCuePoints(_arg1:Array):void{ var _local2:int; var _local3:Number; var _local4:Object; var _local5:Array; var _local6:Number; var _local7:int; _metadataLoaded = true; if ((((_arg1 == null)) || ((_arg1.length < 1)))){ flvCuePoints = null; navCuePoints = null; eventCuePoints = null; return; }; flvCuePoints = _arg1; navCuePoints = new Array(); eventCuePoints = new Array(); _local3 = -1; _local5 = _disabledCuePoints; _local6 = 0; _disabledCuePoints = new Array(); _local7 = 0; while ((_local4 = flvCuePoints[_local7++]) != undefined) { if ((((_local3 > 0)) && ((_local3 >= _local4.time)))){ flvCuePoints = null; navCuePoints = null; eventCuePoints = null; _disabledCuePoints = new Array(); _disabledCuePointsByNameOnly = new Object(); throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, ("Unsorted cuePoint found after time: " + _local3))); }; _local3 = _local4.time; while ((((_local6 < _local5.length)) && ((cuePointCompare(_local5[_local6].time, null, _local4) < 0)))) { _local6++; }; if (((!((_disabledCuePointsByNameOnly[_local4.name] == undefined))) || ((((_local6 < _local5.length)) && ((cuePointCompare(_local5[_local6].time, _local5[_local6].name, _local4) == 0)))))){ _disabledCuePoints.push({time:_local4.time, name:_local4.name}); }; if (_local4.type == CuePointType.NAVIGATION){ navCuePoints.push(_local4); } else { if (_local4.type == CuePointType.EVENT){ eventCuePoints.push(_local4); }; }; if ((((allCuePoints == null)) || ((allCuePoints.length < 1)))){ allCuePoints = new Array(); allCuePoints.push(_local4); } else { _local2 = getCuePointIndex(allCuePoints, true, _local4.time); _local2 = ((allCuePoints[_local2].time)>_local4.time) ? 0 : (_local2 + 1); allCuePoints.splice(_local2, 0, _local4); }; }; _disabledCuePointsByNameOnly = new Object(); } public function addASCuePoint(_arg1, _arg2:String=null, _arg3:Object=null):Object{ var _local4:Object; var _local5:Boolean; var _local6:Boolean; var _local7:int; var _local8:Number; var _local9:Object; var _local10:int; if (typeof(_arg1) == "object"){ _local4 = deepCopyObject(_arg1); } else { _local4 = {time:_arg1, name:_arg2, parameters:deepCopyObject(_arg3)}; }; if (_local4.parameters == null){ delete _local4.parameters; }; _local5 = ((isNaN(_local4.time)) || ((_local4.time < 0))); if (_local5){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "time must be number")); }; _local6 = (_local4.name == null); if (_local6){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "name cannot be undefined or null")); }; _local4.type = CuePointType.ACTIONSCRIPT; if ((((asCuePoints == null)) || ((asCuePoints.length < 1)))){ _local7 = 0; asCuePoints = new Array(); asCuePoints.push(_local4); } else { _local7 = getCuePointIndex(asCuePoints, true, _local4.time); _local7 = ((asCuePoints[_local7].time)>_local4.time) ? 0 : (_local7 + 1); asCuePoints.splice(_local7, 0, _local4); }; if ((((allCuePoints == null)) || ((allCuePoints.length < 1)))){ allCuePoints = new Array(); allCuePoints.push(_local4); } else { _local10 = getCuePointIndex(allCuePoints, true, _local4.time); _local10 = ((allCuePoints[_local10].time)>_local4.time) ? 0 : (_local10 + 1); allCuePoints.splice(_local10, 0, _local4); }; _local8 = _owner.getVideoPlayer(_id).playheadTime; if (_local8 > 0){ if (_asCuePointIndex == _local7){ if (_local8 > asCuePoints[_local7].time){ _asCuePointIndex++; }; } else { if (_asCuePointIndex > _local7){ _asCuePointIndex++; }; }; } else { _asCuePointIndex = 0; }; _local9 = deepCopyObject(asCuePoints[_local7]); _local9.array = asCuePoints; _local9.index = _local7; return (_local9); } public function get metadataLoaded():Boolean{ return (_metadataLoaded); } public function reset():void{ _metadataLoaded = false; allCuePoints = null; asCuePoints = null; _disabledCuePoints = new Array(); _disabledCuePointsByNameOnly = new Object(); flvCuePoints = null; navCuePoints = null; eventCuePoints = null; _asCuePointIndex = 0; } public function removeCuePoints(_arg1:Array, _arg2:Object):Number{ var _local3:int; var _local4:Object; var _local5:int; _local5 = 0; _local3 = getCuePointIndex(_arg1, true, -1, _arg2.name); while (_local3 >= 0) { _local4 = _arg1[_local3]; _arg1.splice(_local3, 1); _local3--; _local5++; _local3 = getNextCuePointIndexWithName(_local4.name, _arg1, _local3); }; return (_local5); } flvplayback_internal function unescape(_arg1:String):String{ var _local2:String; var _local3:int; _local2 = _arg1; _local3 = 0; while (_local3 < cuePointsReplace.length) { var _temp1 = _local3; _local3 = (_local3 + 1); var _temp2 = _local3; _local3 = (_local3 + 1); _local2 = _local2.replace(cuePointsReplace[_temp1], cuePointsReplace[_temp2]); }; return (_local2); } public function setFLVCuePointEnabled(_arg1:Boolean, _arg2):int{ var _local3:Object; var _local4:Boolean; var _local5:Boolean; var _local6:uint; var _local7:int; var _local8:int; var _local9:Object; switch (typeof(_arg2)){ case "string": _local3 = {name:_arg2}; break; case "number": _local3 = {time:_arg2}; break; case "object": _local3 = _arg2; break; }; _local4 = ((isNaN(_local3.time)) || ((_local3.time < 0))); _local5 = (_local3.name == null); if (((_local4) && (_local5))){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "time must be number and/or name must not be undefined or null")); }; _local6 = 0; if (_local4){ if (!_metadataLoaded){ if (_disabledCuePointsByNameOnly[_local3.name] == undefined){ if (!_arg1){ _disabledCuePointsByNameOnly[_local3.name] = new Array(); }; } else { if (_arg1){ delete _disabledCuePointsByNameOnly[_local3.name]; }; return (-1); }; removeCuePoints(_disabledCuePoints, _local3); return (-1); }; if (_arg1){ _local6 = removeCuePoints(_disabledCuePoints, _local3); } else { _local7 = getCuePointIndex(flvCuePoints, true, -1, _local3.name); while (_local7 >= 0) { _local9 = flvCuePoints[_local7]; _local8 = getCuePointIndex(_disabledCuePoints, true, _local9.time); if ((((_local8 < 0)) || (!((_disabledCuePoints[_local8].time == _local9.time))))){ _disabledCuePoints = insertCuePoint(_local8, _disabledCuePoints, {name:_local9.name, time:_local9.time}); _local6 = (_local6 + 1); }; _local7 = getNextCuePointIndexWithName(_local9.name, flvCuePoints, _local7); }; }; return (_local6); }; _local7 = getCuePointIndex(_disabledCuePoints, false, _local3.time, _local3.name); if (_local7 < 0){ if (_arg1){ if (!_metadataLoaded){ _local7 = getCuePointIndex(_disabledCuePoints, false, _local3.time); if (_local7 < 0){ _local8 = getCuePointIndex(_disabledCuePointsByNameOnly[_local3.name], true, _local3.time); if (cuePointCompare(_local3.time, null, _disabledCuePointsByNameOnly[_local3.name]) != 0){ _disabledCuePointsByNameOnly[_local3.name] = insertCuePoint(_local8, _disabledCuePointsByNameOnly[_local3.name], _local3); }; } else { _disabledCuePoints.splice(_local7, 1); }; }; return ((_metadataLoaded) ? 0 : -1); }; } else { if (_arg1){ _disabledCuePoints.splice(_local7, 1); _local6 = 1; } else { _local6 = 0; }; return ((_metadataLoaded) ? _local6 : -1); }; if (_metadataLoaded){ _local7 = getCuePointIndex(flvCuePoints, false, _local3.time, _local3.name); if (_local7 < 0){ return (0); }; if (_local5){ _local3.name = flvCuePoints[_local7].name; }; }; _local8 = getCuePointIndex(_disabledCuePoints, true, _local3.time); _disabledCuePoints = insertCuePoint(_local8, _disabledCuePoints, _local3); _local6 = 1; return ((_metadataLoaded) ? _local6 : -1); } public function isFLVCuePointEnabled(_arg1):Boolean{ var _local2:Object; var _local3:Boolean; var _local4:Boolean; var _local5:int; if (!_metadataLoaded){ return (true); }; switch (typeof(_arg1)){ case "string": _local2 = {name:_arg1}; break; case "number": _local2 = {time:_arg1}; break; case "object": _local2 = _arg1; break; }; _local3 = ((isNaN(_local2.time)) || ((_local2.time < 0))); _local4 = (_local2.name == null); if (((_local3) && (_local4))){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "time must be number and/or name must not be undefined or null")); }; if (_local3){ _local5 = getCuePointIndex(flvCuePoints, true, -1, _local2.name); if (_local5 < 0){ return (true); }; while (_local5 >= 0) { if (getCuePointIndex(_disabledCuePoints, false, flvCuePoints[_local5].time, flvCuePoints[_local5].name) < 0){ return (true); }; _local5 = getNextCuePointIndexWithName(_local2.name, flvCuePoints, _local5); }; return (false); }; return ((getCuePointIndex(_disabledCuePoints, false, _local2.time, _local2.name) < 0)); } public function removeASCuePoint(_arg1):Object{ var _local2:Object; var _local3:int; if ((((asCuePoints == null)) || ((asCuePoints.length < 1)))){ return (null); }; switch (typeof(_arg1)){ case "string": _local2 = {name:_arg1}; break; case "number": _local2 = {time:_arg1}; break; case "object": _local2 = _arg1; break; }; _local3 = getCuePointIndex(asCuePoints, false, _local2.time, _local2.name); if (_local3 < 0){ return (null); }; _local2 = asCuePoints[_local3]; asCuePoints.splice(_local3, 1); _local3 = getCuePointIndex(allCuePoints, false, _local2.time, _local2.name); if (_local3 > 0){ allCuePoints.splice(_local3, 1); }; if (_owner.getVideoPlayer(_id).playheadTime > 0){ if (_asCuePointIndex > _local3){ _asCuePointIndex--; }; } else { _asCuePointIndex = 0; }; return (_local2); } public function get id():uint{ return (_id); } public function processCuePointsProperty(_arg1:Array):void{ var _local2:uint; var _local3:uint; var _local4:String; var _local5:String; var _local6:Object; var _local7:Boolean; var _local8:int; if ((((_arg1 == null)) || ((_arg1.length == 0)))){ return; }; _local2 = 0; _local8 = 0; while (_local8 < (_arg1.length - 1)) { switch (_local2){ case 6: addOrDisable(_local7, _local6); _local2 = 0; case 0: var _temp1 = _local8; _local8 = (_local8 + 1); if (_arg1[_temp1] != "t"){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "unexpected cuePoint parameter format")); }; if (isNaN(_arg1[_local8])){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "time must be number")); }; _local6 = new Object(); _local6.time = (_arg1[_local8] / 1000); _local2++; break; case 1: var _temp2 = _local8; _local8 = (_local8 + 1); if (_arg1[_temp2] != "n"){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "unexpected cuePoint parameter format")); }; if (_arg1[_local8] == undefined){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "name cannot be null or undefined")); }; _local6.name = unescape(_arg1[_local8]); _local2++; break; case 2: var _temp3 = _local8; _local8 = (_local8 + 1); if (_arg1[_temp3] != "t"){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "unexpected cuePoint parameter format")); }; if (isNaN(_arg1[_local8])){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "type must be number")); }; switch (_arg1[_local8]){ case 0: _local6.type = CuePointType.EVENT; break; case 1: _local6.type = CuePointType.NAVIGATION; break; case 2: _local6.type = CuePointType.ACTIONSCRIPT; break; default: throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "type must be 0, 1 or 2")); }; _local2++; break; case 3: var _temp4 = _local8; _local8 = (_local8 + 1); if (_arg1[_temp4] != "d"){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "unexpected cuePoint parameter format")); }; if (isNaN(_arg1[_local8])){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "disabled must be number")); }; _local7 = !((_arg1[_local8] == 0)); _local2++; break; case 4: var _temp5 = _local8; _local8 = (_local8 + 1); if (_arg1[_temp5] != "p"){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "unexpected cuePoint parameter format")); }; if (isNaN(_arg1[_local8])){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "num params must be number")); }; _local3 = _arg1[_local8]; _local2++; if (_local3 == 0){ _local2++; } else { _local6.parameters = new Object(); }; break; case 5: var _temp6 = _local8; _local8 = (_local8 + 1); _local4 = _arg1[_temp6]; _local5 = _arg1[_local8]; if ((_local4 is String)){ _local4 = unescape(_local4); }; if ((_local5 is String)){ _local5 = unescape(_local5); }; _local6.parameters[_local4] = _local5; _local3--; if (_local3 == 0){ _local2++; }; break; }; _local8++; }; if (_local2 == 6){ addOrDisable(_local7, _local6); } else { throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "unexpected end of cuePoint param string")); }; } flvplayback_internal function getNextCuePointIndexWithName(_arg1:String, _arg2:Array, _arg3:int):int{ var _local4:int; if (_arg1 == null){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "name cannot be undefined or null")); }; if (_arg2 == null){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "cuePoint.array undefined")); }; if (((((isNaN(_arg3)) || ((_arg3 < -1)))) || ((_arg3 >= _arg2.length)))){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "cuePoint.index must be number between -1 and cuePoint.array.length")); }; _local4 = (_arg3 + 1); while (_local4 < _arg2.length) { if (_arg2[_local4].name == _arg1){ break; }; _local4++; }; if (_local4 < _arg2.length){ return (_local4); }; return (-1); } public function dispatchASCuePoints():void{ var _local1:Number; _local1 = _owner.getVideoPlayer(_id).playheadTime; if (((_owner.getVideoPlayer(_id).stateResponsive) && (!((asCuePoints == null))))){ while ((((_asCuePointIndex < asCuePoints.length)) && ((asCuePoints[_asCuePointIndex].time <= (_local1 + _asCuePointTolerance))))) { _owner.dispatchEvent(new MetadataEvent(MetadataEvent.CUE_POINT, false, false, deepCopyObject(asCuePoints[_asCuePointIndex++]), _id)); }; }; } flvplayback_internal function getNextCuePointWithName(_arg1:Object):Object{ var _local2:int; var _local3:Object; if (_arg1 == null){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "cuePoint parameter undefined")); }; if (((isNaN(_arg1.time)) || ((_arg1.time < 0)))){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "time must be number")); }; _local2 = getNextCuePointIndexWithName(_arg1.name, _arg1.array, _arg1.index); if (_local2 < 0){ return (null); }; _local3 = deepCopyObject(_arg1.array[_local2]); _local3.array = _arg1.array; _local3.index = _local2; return (_local3); } public function insertCuePoint(_arg1:int, _arg2:Array, _arg3:Object):Array{ if (_arg1 < 0){ _arg2 = new Array(); _arg2.push(_arg3); } else { if (_arg2[_arg1].time > _arg3.time){ _arg1 = 0; } else { _arg1++; }; _arg2.splice(_arg1, 0, _arg3); }; return (_arg2); } flvplayback_internal function getCuePointIndex(_arg1:Array, _arg2:Boolean, _arg3:Number=NaN, _arg4:String=null, _arg5:int=-1, _arg6:int=-1):int{ var _local7:Boolean; var _local8:Boolean; var _local9:int; var _local10:int; var _local11:int; var _local12:int; var _local13:int; var _local14:int; var _local15:int; if ((((_arg1 == null)) || ((_arg1.length < 1)))){ return (-1); }; _local7 = ((isNaN(_arg3)) || ((_arg3 < 0))); _local8 = (_arg4 == null); if (((_local7) && (_local8))){ throw (new VideoError(VideoError.ILLEGAL_CUE_POINT, "time must be number and/or name must not be undefined or null")); }; if (_arg5 < 0){ _arg5 = 0; }; if (_arg6 < 0){ _arg6 = _arg1.length; }; if (((!(_local8)) && (((_arg2) || (_local7))))){ if (_local7){ _local12 = _arg5; } else { _local12 = getCuePointIndex(_arg1, _arg2, _arg3); }; _local13 = _local12; while (_local13 >= _arg5) { if (_arg1[_local13].name == _arg4){ break; }; _local13--; }; if (_local13 >= _arg5){ return (_local13); }; _local13 = (_local12 + 1); while (_local13 < _arg6) { if (_arg1[_local13].name == _arg4){ break; }; _local13++; }; if (_local13 < _arg6){ return (_local13); }; return (-1); }; if (_arg6 <= _linearSearchTolerance){ _local14 = (_arg5 + _arg6); _local15 = _arg5; while (_local15 < _local14) { _local9 = cuePointCompare(_arg3, _arg4, _arg1[_local15]); if (_local9 == 0){ return (_local15); }; if (_local9 < 0){ break; }; _local15++; }; if (_arg2){ if (_local15 > 0){ return ((_local15 - 1)); }; return (0); }; return (-1); }; _local10 = int((_arg6 / 2)); _local11 = (_arg5 + _local10); _local9 = cuePointCompare(_arg3, _arg4, _arg1[_local11]); if (_local9 < 0){ return (getCuePointIndex(_arg1, _arg2, _arg3, _arg4, _arg5, _local10)); }; if (_local9 > 0){ return (getCuePointIndex(_arg1, _arg2, _arg3, _arg4, (_local11 + 1), ((_local10 - 1) + (_arg6 % 2)))); }; return (_local11); } flvplayback_internal static function deepCopyObject(_arg1:Object, _arg2:uint=0):Object{ var _local3:Object; var _local4:*; if (_arg1 == null){ return (_arg1); }; _local3 = new Object(); for (_local4 in _arg1) { if ((((_arg2 == 0)) && ((((_local4 == "array")) || ((_local4 == "index")))))){ } else { if (typeof(_arg1[_local4]) == "object"){ _local3[_local4] = deepCopyObject(_arg1[_local4], (_arg2 + 1)); } else { _local3[_local4] = _arg1[_local4]; }; }; }; return (_local3); } flvplayback_internal static function cuePointCompare(_arg1:Number, _arg2:String, _arg3:Object):int{ var _local4:Number; var _local5:Number; _local4 = Math.round((_arg1 * 1000)); _local5 = Math.round((_arg3.time * 1000)); if (_local4 < _local5){ return (-1); }; if (_local4 > _local5){ return (1); }; if (_arg2 != null){ if (_arg2 == _arg3.name){ return (0); }; if (_arg2 < _arg3.name){ return (-1); }; return (1); }; return (0); } } }//package fl.video
Section 210
//CuePointType (fl.video.CuePointType) package fl.video { public final class CuePointType { public static const FLV:String = "flv"; public static const ALL:String = "all"; public static const ACTIONSCRIPT:String = "actionscript"; public static const EVENT:String = "event"; public static const NAVIGATION:String = "navigation"; } }//package fl.video
Section 211
//FLVPlayback (fl.video.FLVPlayback) package fl.video { import flash.events.*; import flash.display.*; import flash.media.*; import flash.net.*; import flash.geom.*; import flash.utils.*; public class FLVPlayback extends Sprite { private var _playheadUpdateInterval:Number; private var _align:String; flvplayback_internal var videoPlayerStateDict:Dictionary; flvplayback_internal var cuePointMgrs:Array; private var _volume:Number; private var _origHeight:Number; flvplayback_internal var videoPlayerStates:Array; private var _progressInterval:Number; private var _seekToPrevOffset:Number; private var _origWidth:Number; private var _scaleMode:String; flvplayback_internal var resizingNow:Boolean; flvplayback_internal var videoPlayers:Array; private var _bufferTime:Number; private var _aspectRatio:Boolean; private var _autoRewind:Boolean; flvplayback_internal var uiMgr:UIManager; private var previewImage_mc:Loader; private var _componentInspectorSetting:Boolean; flvplayback_internal var _firstStreamShown:Boolean; private var _visibleVP:uint; private var _idleTimeout:Number; private var _soundTransform:SoundTransform; public var boundingBox_mc:DisplayObject; flvplayback_internal var skinShowTimer:Timer; private var preview_mc:MovieClip; private var livePreviewHeight:Number; flvplayback_internal var _firstStreamReady:Boolean; private var _activeVP:uint; private var isLivePreview:Boolean; private var _topVP:uint; private var livePreviewWidth:Number; private var __forceNCMgr:NCManager; private var previewImageUrl:String; public static const SEEK_TO_PREV_OFFSET_DEFAULT:Number = 1; public static const SHORT_VERSION:String = "2.1"; flvplayback_internal static const skinShowTimerInterval:Number = 2000; public static const VERSION:String = "2.1.0.14"; flvplayback_internal static const DEFAULT_SKIN_SHOW_TIMER_INTERVAL:Number = 2000; public function FLVPlayback(){ var _local1:VideoPlayer; super(); mouseEnabled = false; isLivePreview = ((!((parent == null))) && ((getQualifiedClassName(parent) == "fl.livepreview::LivePreviewParent"))); _componentInspectorSetting = false; _origWidth = super.width; _origHeight = super.height; super.scaleX = 1; super.scaleY = 1; _local1 = new VideoPlayer(0, 0); _local1.setSize(_origWidth, _origHeight); videoPlayers = new Array(); videoPlayers[0] = _local1; _align = _local1.align; _autoRewind = _local1.autoRewind; _scaleMode = _local1.scaleMode; _bufferTime = _local1.bufferTime; _idleTimeout = _local1.idleTimeout; _playheadUpdateInterval = _local1.playheadUpdateInterval; _progressInterval = _local1.progressInterval; _soundTransform = _local1.soundTransform; _volume = _local1.volume; _seekToPrevOffset = SEEK_TO_PREV_OFFSET_DEFAULT; _firstStreamReady = false; _firstStreamShown = false; resizingNow = false; uiMgr = new UIManager(this); if (isLivePreview){ uiMgr.visible = true; }; _activeVP = 0; _visibleVP = 0; _topVP = 0; videoPlayerStates = new Array(); videoPlayerStateDict = new Dictionary(true); cuePointMgrs = new Array(); createVideoPlayer(0); boundingBox_mc.visible = false; removeChild(boundingBox_mc); boundingBox_mc = null; if (isLivePreview){ previewImageUrl = ""; createLivePreviewMovieClip(); setSize(_origWidth, _origHeight); }; } public function set fullScreenTakeOver(_arg1:Boolean):void{ uiMgr.fullScreenTakeOver = _arg1; } public function pause():void{ var _local1:VideoPlayerState; var _local2:VideoPlayer; if (!_firstStreamShown){ _local1 = videoPlayerStates[_activeVP]; queueCmd(_local1, QueuedCommand.PAUSE); } else { _local2 = videoPlayers[_activeVP]; _local2.pause(); }; } public function setScale(_arg1:Number, _arg2:Number):void{ var _local3:Rectangle; var _local4:Rectangle; var _local5:int; var _local6:VideoPlayer; _local3 = new Rectangle(x, y, width, height); _local4 = new Rectangle(registrationX, registrationY, registrationWidth, registrationHeight); resizingNow = true; _local5 = 0; while (_local5 < videoPlayers.length) { _local6 = videoPlayers[_local5]; if (_local6 !== null){ _local6.setSize((_origWidth * _arg1), (_origWidth * _arg2)); }; _local5++; }; resizingNow = false; dispatchEvent(new LayoutEvent(LayoutEvent.LAYOUT, false, false, _local3, _local4)); } public function stop():void{ var _local1:VideoPlayerState; var _local2:VideoPlayer; if (!_firstStreamShown){ _local1 = videoPlayerStates[_activeVP]; queueCmd(_local1, QueuedCommand.STOP); } else { _local2 = videoPlayers[_activeVP]; _local2.stop(); }; } public function set align(_arg1:String):void{ var _local2:VideoPlayer; if (_activeVP == 0){ _align = _arg1; }; _local2 = videoPlayers[_activeVP]; _local2.align = _arg1; } public function getVideoPlayer(_arg1:Number):VideoPlayer{ return (videoPlayers[_arg1]); } public function get playheadTime():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.playheadTime); } public function get progressInterval():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.progressInterval); } public function set skinFadeTime(_arg1:int):void{ uiMgr.skinFadeTime = _arg1; } public function get seekToPrevOffset():Number{ return (_seekToPrevOffset); } public function set playheadTime(_arg1:Number):void{ seek(_arg1); } public function get source():String{ var _local1:VideoPlayerState; var _local2:VideoPlayer; _local1 = videoPlayerStates[_activeVP]; if (_local1.isWaiting){ return (_local1.url); }; _local2 = videoPlayers[_activeVP]; return (_local2.source); } public function get activeVideoPlayerIndex():uint{ return (_activeVP); } public function get skinFadeTime():int{ return (uiMgr.skinFadeTime); } public function set scaleMode(_arg1:String):void{ var _local2:VideoPlayer; if (_activeVP == 0){ _scaleMode = _arg1; }; _local2 = videoPlayers[_activeVP]; _local2.scaleMode = _arg1; } public function set bufferingBar(_arg1:Sprite):void{ uiMgr.setControl(UIManager.BUFFERING_BAR, _arg1); } public function get metadataLoaded():Boolean{ var _local1:CuePointManager; _local1 = cuePointMgrs[_activeVP]; return (_local1.metadataLoaded); } public function closeVideoPlayer(_arg1:uint):void{ var _local2:VideoPlayer; if (_arg1 == 0){ throw (new VideoError(VideoError.DELETE_DEFAULT_PLAYER)); }; if (videoPlayers[_arg1] == undefined){ return; }; _local2 = videoPlayers[_arg1]; if (_visibleVP == _arg1){ visibleVideoPlayerIndex = 0; }; if (_activeVP == _arg1){ activeVideoPlayerIndex = 0; }; removeChild(_local2); _local2.close(); delete videoPlayers[_arg1]; delete videoPlayerStates[_arg1]; delete videoPlayerStateDict[_local2]; } public function get scaleMode():String{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.scaleMode); } public function set progressInterval(_arg1:Number):void{ var _local2:VideoPlayer; if (_activeVP == 0){ _progressInterval = _arg1; }; _local2 = videoPlayers[_activeVP]; _local2.progressInterval = _arg1; } public function get playing():Boolean{ return ((state == VideoState.PLAYING)); } public function get totalTime():Number{ var _local1:VideoPlayerState; var _local2:VideoPlayer; if (isLivePreview){ return (1); }; _local1 = videoPlayerStates[_activeVP]; if (_local1.totalTimeSet){ return (_local1.totalTime); }; _local2 = videoPlayers[_activeVP]; return (_local2.totalTime); } public function get ncMgr():INCManager{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.ncMgr); } public function set volume(_arg1:Number):void{ var _local2:VideoPlayer; if (_volume == _arg1){ return; }; _volume = _arg1; if (!scrubbing){ _local2 = videoPlayers[_visibleVP]; _local2.volume = _volume; }; dispatchEvent(new SoundEvent(SoundEvent.SOUND_UPDATE, false, false, _local2.soundTransform)); } public function get skinAutoHide():Boolean{ return (uiMgr.skinAutoHide); } public function set source(_arg1:String):void{ var _local2:VideoPlayerState; var _local3:CuePointManager; if (isLivePreview){ return; }; if (_arg1 == null){ _arg1 = ""; }; if (_componentInspectorSetting){ _local2 = videoPlayerStates[_activeVP]; _local2.url = _arg1; if (_arg1.length > 0){ _local2.isWaiting = true; addEventListener(Event.ENTER_FRAME, doContentPathConnect); }; } else { if (source == _arg1){ return; }; _local3 = cuePointMgrs[_activeVP]; _local3.reset(); _local2 = videoPlayerStates[_activeVP]; _local2.url = _arg1; _local2.isWaiting = true; doContentPathConnect(_activeVP); }; } public function set activeVideoPlayerIndex(_arg1:uint):void{ if (_activeVP == _arg1){ return; }; _activeVP = _arg1; if (videoPlayers[_activeVP] == undefined){ createVideoPlayer(_activeVP); }; } override public function set soundTransform(_arg1:SoundTransform):void{ var _local2:VideoPlayer; if (_arg1 == null){ return; }; _volume = _arg1.volume; _soundTransform.volume = (scrubbing) ? 0 : _arg1.volume; _soundTransform.leftToLeft = _arg1.leftToLeft; _soundTransform.leftToRight = _arg1.leftToRight; _soundTransform.rightToLeft = _arg1.rightToLeft; _soundTransform.rightToRight = _arg1.rightToRight; _local2 = videoPlayers[_activeVP]; _local2.soundTransform = _soundTransform; dispatchEvent(new SoundEvent(SoundEvent.SOUND_UPDATE, false, false, _local2.soundTransform)); } public function set seekToPrevOffset(_arg1:Number):void{ _seekToPrevOffset = _arg1; } public function set seekBarScrubTolerance(_arg1:Number):void{ uiMgr.seekBarScrubTolerance = _arg1; } override public function get scaleX():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_visibleVP]; return ((_local1.width / _origWidth)); } override public function get scaleY():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_visibleVP]; return ((_local1.height / _origHeight)); } public function get bytesLoaded():uint{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.bytesLoaded); } override public function set height(_arg1:Number):void{ var _local2:Rectangle; var _local3:Rectangle; var _local4:int; var _local5:VideoPlayer; if (isLivePreview){ setSize(this.width, _arg1); return; }; _local2 = new Rectangle(x, y, width, height); _local3 = new Rectangle(registrationX, registrationY, registrationWidth, registrationHeight); resizingNow = true; _local4 = 0; while (_local4 < videoPlayers.length) { _local5 = videoPlayers[_local4]; if (_local5 != null){ _local5.height = _arg1; }; _local4++; }; resizingNow = false; dispatchEvent(new LayoutEvent(LayoutEvent.LAYOUT, false, false, _local2, _local3)); } public function get forwardButton():Sprite{ return (uiMgr.getControl(UIManager.FORWARD_BUTTON)); } public function get seekBarInterval():Number{ return (uiMgr.seekBarInterval); } public function set totalTime(_arg1:Number):void{ var _local2:VideoPlayerState; _local2 = videoPlayerStates[_activeVP]; _local2.totalTime = _arg1; _local2.totalTimeSet = true; } public function set skinAutoHide(_arg1:Boolean):void{ if (isLivePreview){ return; }; uiMgr.skinAutoHide = _arg1; } public function set bufferTime(_arg1:Number):void{ var _local2:VideoPlayer; _local2 = videoPlayers[_activeVP]; _local2.bufferTime = _arg1; } public function get fullScreenSkinDelay():int{ return (uiMgr.fullScreenSkinDelay); } public function seekToNavCuePoint(_arg1):void{ var _local2:Object; var _local3:Object; if ((_arg1 is String)){ _local2 = {name:String(_arg1)}; } else { if ((_arg1 is Number)){ _local2 = {time:Number(_arg1)}; } else { _local2 = _arg1; }; }; if (_local2.name == undefined){ seekToNextNavCuePoint(_local2.time); return; }; if (isNaN(_local2.time)){ _local2.time = 0; }; _local3 = findNearestCuePoint(_arg1, CuePointType.NAVIGATION); while (((!((_local3 == null))) && ((((_local3.time < _local2.time)) || (!(isFLVCuePointEnabled(_local3))))))) { _local3 = findNextCuePointWithName(_local3); }; if (_local3 == null){ throw (new VideoError(VideoError.INVALID_SEEK)); }; seek(_local3.time); } private function onCompletePreview(_arg1:Event):void{ var e = _arg1; try { previewImage_mc.width = livePreviewWidth; previewImage_mc.height = livePreviewHeight; } catch(e:Error) { }; } public function set isLive(_arg1:Boolean):void{ var _local2:VideoPlayerState; _local2 = videoPlayerStates[_activeVP]; _local2.isLive = _arg1; _local2.isLiveSet = true; } flvplayback_internal function showSkinNow(_arg1:TimerEvent):void{ skinShowTimer = null; uiMgr.visible = true; } override public function get x():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_visibleVP]; return ((super.x + _local1.x)); } override public function get y():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_visibleVP]; return ((super.y + _local1.y)); } public function get seekBar():Sprite{ return (uiMgr.getControl(UIManager.SEEK_BAR)); } public function get volumeBarInterval():Number{ return (uiMgr.volumeBarInterval); } public function set registrationHeight(_arg1:Number):void{ height = _arg1; } public function get bufferingBarHidesAndDisablesOthers():Boolean{ return (uiMgr.bufferingBarHidesAndDisablesOthers); } public function seek(_arg1:Number):void{ var _local2:VideoPlayerState; var _local3:VideoPlayer; _local2 = videoPlayerStates[_activeVP]; if (!_firstStreamShown){ _local2.preSeekTime = 0; queueCmd(_local2, QueuedCommand.SEEK, _arg1); } else { _local2.preSeekTime = playheadTime; _local3 = videoPlayers[_activeVP]; _local3.seek(_arg1); }; } public function get state():String{ var _local1:VideoPlayer; var _local2:String; var _local3:VideoPlayerState; if (isLivePreview){ return (VideoState.STOPPED); }; _local1 = videoPlayers[_activeVP]; if ((((_activeVP == _visibleVP)) && (scrubbing))){ return (VideoState.SEEKING); }; _local2 = _local1.state; if (_local2 == VideoState.RESIZING){ return (VideoState.LOADING); }; _local3 = videoPlayerStates[_activeVP]; if ((((((_local3.prevState == VideoState.LOADING)) && (_local3.autoPlay))) && ((_local2 == VideoState.STOPPED)))){ return (VideoState.LOADING); }; return (_local2); } public function set autoRewind(_arg1:Boolean):void{ var _local2:VideoPlayer; if (_activeVP == 0){ _autoRewind = _arg1; }; _local2 = videoPlayers[_activeVP]; _local2.autoRewind = _arg1; } public function get volumeBar():Sprite{ return (uiMgr.getControl(UIManager.VOLUME_BAR)); } flvplayback_internal function skinError(_arg1:String):void{ if (isLivePreview){ return; }; if (((_firstStreamReady) && (!(_firstStreamShown)))){ showFirstStream(); }; dispatchEvent(new SkinErrorEvent(SkinErrorEvent.SKIN_ERROR, false, false, _arg1)); } override public function set scaleX(_arg1:Number):void{ var _local2:Rectangle; var _local3:Rectangle; var _local4:int; var _local5:VideoPlayer; _local2 = new Rectangle(x, y, width, height); _local3 = new Rectangle(registrationX, registrationY, registrationWidth, registrationHeight); resizingNow = true; _local4 = 0; while (_local4 < videoPlayers.length) { _local5 = videoPlayers[_local4]; if (_local5 !== null){ _local5.width = (_origWidth * _arg1); }; _local4++; }; resizingNow = false; dispatchEvent(new LayoutEvent(LayoutEvent.LAYOUT, false, false, _local2, _local3)); } override public function set scaleY(_arg1:Number):void{ var _local2:Rectangle; var _local3:Rectangle; var _local4:int; var _local5:VideoPlayer; _local2 = new Rectangle(x, y, width, height); _local3 = new Rectangle(registrationX, registrationY, registrationWidth, registrationHeight); resizingNow = true; _local4 = 0; while (_local4 < videoPlayers.length) { _local5 = videoPlayers[_local4]; if (_local5 !== null){ _local5.height = (_origHeight * _arg1); }; _local4++; }; resizingNow = false; dispatchEvent(new LayoutEvent(LayoutEvent.LAYOUT, false, false, _local2, _local3)); } flvplayback_internal function createVideoPlayer(_arg1:Number):void{ var vp:VideoPlayer; var added:Boolean; var vpState:VideoPlayerState; var cpMgr:CuePointManager; var skinDepth:int; var index = _arg1; if (isLivePreview){ return; }; vp = videoPlayers[index]; if (vp == null){ var _local3 = new VideoPlayer(0, 0); vp = _local3; videoPlayers[index] = _local3; vp.setSize(registrationWidth, registrationHeight); }; vp.visible = false; vp.volume = 0; vp.name = String(index); added = false; if (uiMgr.skin_mc != null){ try { skinDepth = getChildIndex(uiMgr.skin_mc); if (skinDepth > 0){ addChildAt(vp, skinDepth); added = true; }; } catch(err:Error) { }; }; if (!added){ addChild(vp); }; _topVP = index; vp.autoRewind = _autoRewind; vp.scaleMode = _scaleMode; vp.bufferTime = _bufferTime; vp.idleTimeout = _idleTimeout; vp.playheadUpdateInterval = _playheadUpdateInterval; vp.progressInterval = _progressInterval; vp.soundTransform = _soundTransform; vpState = new VideoPlayerState(vp, index); videoPlayerStates[index] = vpState; videoPlayerStateDict[vp] = vpState; vp.addEventListener(AutoLayoutEvent.AUTO_LAYOUT, handleAutoLayoutEvent); vp.addEventListener(MetadataEvent.CUE_POINT, handleMetadataEvent); vp.addEventListener(MetadataEvent.METADATA_RECEIVED, handleMetadataEvent); vp.addEventListener(VideoProgressEvent.PROGRESS, handleVideoProgressEvent); vp.addEventListener(VideoEvent.AUTO_REWOUND, handleVideoEvent); vp.addEventListener(VideoEvent.CLOSE, handleVideoEvent); vp.addEventListener(VideoEvent.COMPLETE, handleVideoEvent); vp.addEventListener(VideoEvent.PLAYHEAD_UPDATE, handleVideoEvent); vp.addEventListener(VideoEvent.STATE_CHANGE, handleVideoEvent); vp.addEventListener(VideoEvent.READY, handleVideoEvent); cpMgr = new CuePointManager(this, index); cuePointMgrs[index] = cpMgr; cpMgr.playheadUpdateInterval = _playheadUpdateInterval; } public function findNearestCuePoint(_arg1, _arg2:String="all"):Object{ var _local3:CuePointManager; _local3 = cuePointMgrs[_activeVP]; switch (_arg2){ case "event": return (_local3.getCuePoint(_local3.eventCuePoints, true, _arg1)); case "navigation": return (_local3.getCuePoint(_local3.navCuePoints, true, _arg1)); case "flv": return (_local3.getCuePoint(_local3.flvCuePoints, true, _arg1)); case "actionscript": return (_local3.getCuePoint(_local3.asCuePoints, true, _arg1)); case "all": default: return (_local3.getCuePoint(_local3.allCuePoints, true, _arg1)); }; } public function get muteButton():Sprite{ return (uiMgr.getControl(UIManager.MUTE_BUTTON)); } public function seekPercent(_arg1:Number):void{ var _local2:VideoPlayer; _local2 = videoPlayers[_activeVP]; if (((((((((isNaN(_arg1)) || ((_arg1 < 0)))) || ((_arg1 > 100)))) || (isNaN(_local2.totalTime)))) || ((_local2.totalTime <= 0)))){ throw (new VideoError(VideoError.INVALID_SEEK)); }; seek(((_local2.totalTime * _arg1) / 100)); } public function set forwardButton(_arg1:Sprite):void{ uiMgr.setControl(UIManager.FORWARD_BUTTON, _arg1); } public function get registrationWidth():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_visibleVP]; return (_local1.registrationWidth); } flvplayback_internal function queueCmd(_arg1:VideoPlayerState, _arg2:Number, _arg3:Number=NaN):void{ if (_arg1.cmdQueue == null){ _arg1.cmdQueue = new Array(); }; _arg1.cmdQueue.push(new QueuedCommand(_arg2, null, false, _arg3)); } private function doContentPathConnect(_arg1):void{ var _local2:int; var _local3:VideoPlayer; var _local4:VideoPlayerState; if (isLivePreview){ return; }; _local2 = 0; if ((_arg1 is int)){ _local2 = int(_arg1); } else { removeEventListener(Event.ENTER_FRAME, doContentPathConnect); }; _local3 = videoPlayers[_local2]; _local4 = videoPlayerStates[_local2]; if (!_local4.isWaiting){ return; }; if (((_local4.autoPlay) && (_firstStreamShown))){ _local3.play(_local4.url, _local4.totalTime, _local4.isLive); } else { _local3.load(_local4.url, _local4.totalTime, _local4.isLive); }; _local4.isLiveSet = false; _local4.totalTimeSet = false; _local4.isWaiting = false; } public function get registrationX():Number{ return (super.x); } public function bringVideoPlayerToFront(_arg1:uint):void{ var vp:VideoPlayer; var moved:Boolean; var skinDepth:int; var index = _arg1; if (index == _topVP){ return; }; vp = videoPlayers[index]; if (vp == null){ createVideoPlayer(index); vp = videoPlayers[index]; }; moved = false; if (uiMgr.skin_mc != null){ try { skinDepth = getChildIndex(uiMgr.skin_mc); if (skinDepth > 0){ setChildIndex(vp, (skinDepth - 1)); moved = true; }; } catch(err:Error) { }; }; if (!moved){ setChildIndex(vp, (numChildren - 1)); }; _topVP = index; } public function get registrationY():Number{ return (super.y); } public function get pauseButton():Sprite{ return (uiMgr.getControl(UIManager.PAUSE_BUTTON)); } public function set seekBarInterval(_arg1:Number):void{ uiMgr.seekBarInterval = _arg1; } public function addASCuePoint(_arg1, _arg2:String=null, _arg3:Object=null):Object{ var _local4:CuePointManager; _local4 = cuePointMgrs[_activeVP]; return (_local4.addASCuePoint(_arg1, _arg2, _arg3)); } public function get playheadPercentage():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; if (isNaN(_local1.totalTime)){ return (NaN); }; return (((_local1.playheadTime / _local1.totalTime) * 100)); } public function setFLVCuePointEnabled(_arg1:Boolean, _arg2):Number{ var _local3:CuePointManager; _local3 = cuePointMgrs[_activeVP]; return (_local3.setFLVCuePointEnabled(_arg1, _arg2)); } public function set fullScreenSkinDelay(_arg1:int):void{ uiMgr.fullScreenSkinDelay = _arg1; } public function seekToNextNavCuePoint(_arg1:Number=NaN):void{ var _local2:VideoPlayer; var _local3:Object; var _local4:Number; _local2 = videoPlayers[_activeVP]; if (((isNaN(_arg1)) || ((_arg1 < 0)))){ _arg1 = (_local2.playheadTime + 0.001); }; _local3 = findNearestCuePoint(_arg1, CuePointType.NAVIGATION); if (_local3 == null){ seek(_local2.totalTime); return; }; _local4 = _local3.index; if (_local3.time < _arg1){ _local4++; }; while ((((_local4 < _local3.array.length)) && (!(isFLVCuePointEnabled(_local3.array[_local4]))))) { _local4++; }; if (_local4 >= _local3.array.length){ _arg1 = _local2.totalTime; if (_local3.array[(_local3.array.length - 1)].time > _arg1){ _arg1 = _local3.array[(_local3.array.length - 1)]; }; seek(_arg1); } else { seek(_local3.array[_local4].time); }; } public function load(_arg1:String, _arg2:Number=NaN, _arg3:Boolean=false):void{ if ((((_arg1 == null)) || ((_arg1.length == 0)))){ return; }; if (_arg1 == this.source){ return; }; this.autoPlay = false; this.totalTime = _arg2; this.isLive = _arg3; this.source = _arg1; } public function seekSeconds(_arg1:Number):void{ seek(_arg1); } public function get fullScreenButton():Sprite{ return (uiMgr.getControl(UIManager.FULL_SCREEN_BUTTON)); } public function get scrubbing():Boolean{ var _local1:Sprite; var _local2:ControlData; _local1 = seekBar; if (_local1 != null){ _local2 = uiMgr.ctrlDataDict[_local1]; return (_local2.isDragging); }; return (false); } override public function set y(_arg1:Number):void{ var _local2:VideoPlayer; _local2 = videoPlayers[_visibleVP]; super.y = (_arg1 - _local2.y); } public function removeASCuePoint(_arg1):Object{ var _local2:CuePointManager; _local2 = cuePointMgrs[_activeVP]; return (_local2.removeASCuePoint(_arg1)); } public function get fullScreenTakeOver():Boolean{ return (uiMgr.fullScreenTakeOver); } override public function set x(_arg1:Number):void{ var _local2:VideoPlayer; _local2 = videoPlayers[_visibleVP]; super.x = (_arg1 - _local2.x); } public function get backButton():Sprite{ return (uiMgr.getControl(UIManager.BACK_BUTTON)); } public function set seekBar(_arg1:Sprite):void{ uiMgr.setControl(UIManager.SEEK_BAR, _arg1); } public function set skin(_arg1:String):void{ uiMgr.skin = _arg1; } public function set componentInspectorSetting(_arg1:Boolean):void{ _componentInspectorSetting = _arg1; } public function get preferredHeight():int{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.videoHeight); } public function set volumeBarInterval(_arg1:Number):void{ uiMgr.volumeBarInterval = _arg1; } public function set autoPlay(_arg1:Boolean):void{ var _local2:VideoPlayerState; _local2 = videoPlayerStates[_activeVP]; _local2.autoPlay = _arg1; } public function set visibleVideoPlayerIndex(_arg1:uint):void{ var _local2:VideoPlayer; var _local3:VideoPlayer; var _local4:uint; var _local5:Rectangle; var _local6:Rectangle; if (_visibleVP == _arg1){ return; }; if (videoPlayers[_arg1] == undefined){ createVideoPlayer(_arg1); }; _local2 = videoPlayers[_arg1]; _local3 = videoPlayers[_visibleVP]; _local3.visible = false; _local3.volume = 0; _visibleVP = _arg1; if (_firstStreamShown){ uiMgr.setupSkinAutoHide(false); _local2.visible = true; _soundTransform.volume = (scrubbing) ? _volume : 0; _local2.soundTransform = _soundTransform; } else { if (((((((_local2.stateResponsive) || ((_local2.state == VideoState.CONNECTION_ERROR)))) || ((_local2.state == VideoState.DISCONNECTED)))) && (uiMgr.skinReady))){ uiMgr.visible = true; uiMgr.setupSkinAutoHide(false); _firstStreamReady = true; if (uiMgr.skin == ""){ uiMgr.hookUpCustomComponents(); }; showFirstStream(); }; }; if (((!((_local2.height == _local3.height))) || (!((_local2.width == _local3.width))))){ _local5 = new Rectangle((_local3.x + super.x), (_local3.y + super.y), _local3.width, _local3.height); _local6 = new Rectangle((_local3.registrationX + super.x), (_local3.registrationY + super.y), _local3.registrationWidth, _local3.registrationHeight); dispatchEvent(new LayoutEvent(LayoutEvent.LAYOUT, false, false, _local5, _local6)); }; _local4 = _activeVP; _activeVP = _visibleVP; uiMgr.handleIVPEvent(new VideoEvent(VideoEvent.STATE_CHANGE, false, false, state, playheadTime, _visibleVP)); uiMgr.handleIVPEvent(new VideoEvent(VideoEvent.PLAYHEAD_UPDATE, false, false, state, playheadTime, _visibleVP)); if (_local2.isRTMP){ uiMgr.handleIVPEvent(new VideoEvent(VideoEvent.READY, false, false, state, playheadTime, _visibleVP)); } else { uiMgr.handleIVPEvent(new VideoProgressEvent(VideoProgressEvent.PROGRESS, false, false, bytesLoaded, bytesTotal, _visibleVP)); }; _activeVP = _local4; } public function get bufferingBar():Sprite{ return (uiMgr.getControl(UIManager.BUFFERING_BAR)); } flvplayback_internal function _scrubStart():void{ var _local1:Number; var _local2:VideoPlayer; _local1 = playheadTime; _local2 = videoPlayers[_visibleVP]; _volume = _local2.volume; _local2.volume = 0; dispatchEvent(new VideoEvent(VideoEvent.STATE_CHANGE, false, false, VideoState.SEEKING, _local1, _visibleVP)); dispatchEvent(new VideoEvent(VideoEvent.SCRUB_START, false, false, VideoState.SEEKING, _local1, _visibleVP)); } public function get align():String{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.align); } flvplayback_internal function handleAutoLayoutEvent(_arg1:AutoLayoutEvent):void{ var _local2:VideoPlayerState; var _local3:AutoLayoutEvent; var _local4:Rectangle; var _local5:Rectangle; _local2 = videoPlayerStateDict[_arg1.currentTarget]; _local3 = AutoLayoutEvent(_arg1.clone()); _local3.oldBounds.x = (_local3.oldBounds.x + super.x); _local3.oldBounds.y = (_local3.oldBounds.y + super.y); _local3.oldRegistrationBounds.x = (_local3.oldRegistrationBounds.x + super.y); _local3.oldRegistrationBounds.y = (_local3.oldRegistrationBounds.y + super.y); _local3.vp = _local2.index; dispatchEvent(_local3); if (((!(resizingNow)) && ((_local2.index == _visibleVP)))){ _local4 = Rectangle(_arg1.oldBounds.clone()); _local5 = Rectangle(_arg1.oldRegistrationBounds.clone()); _local4.x = (_local4.x + super.x); _local4.y = (_local4.y + super.y); _local5.x = (_local5.x + super.y); _local5.y = (_local5.y + super.y); dispatchEvent(new LayoutEvent(LayoutEvent.LAYOUT, false, false, _local4, _local5)); }; } public function findNextCuePointWithName(_arg1:Object):Object{ var _local2:CuePointManager; _local2 = cuePointMgrs[_activeVP]; return (_local2.getNextCuePointWithName(_arg1)); } public function set playButton(_arg1:Sprite):void{ uiMgr.setControl(UIManager.PLAY_BUTTON, _arg1); } public function set bitrate(_arg1:Number):void{ ncMgr.bitrate = _arg1; } public function set bufferingBarHidesAndDisablesOthers(_arg1:Boolean):void{ uiMgr.bufferingBarHidesAndDisablesOthers = _arg1; } override public function get soundTransform():SoundTransform{ var _local1:VideoPlayer; var _local2:SoundTransform; _local1 = videoPlayers[_visibleVP]; _local2 = _local1.soundTransform; if (scrubbing){ _local2.volume = _volume; }; return (_local2); } public function get stateResponsive():Boolean{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.stateResponsive); } public function get idleTimeout():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.idleTimeout); } override public function get height():Number{ var _local1:VideoPlayer; if (isLivePreview){ return (livePreviewHeight); }; _local1 = videoPlayers[_visibleVP]; return (_local1.height); } public function set registrationWidth(_arg1:Number):void{ width = _arg1; } public function get metadata():Object{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.metadata); } public function set skinBackgroundColor(_arg1:uint):void{ uiMgr.skinBackgroundColor = _arg1; } public function get volume():Number{ return (_volume); } public function play(_arg1:String=null, _arg2:Number=NaN, _arg3:Boolean=false):void{ var _local4:VideoPlayerState; var _local5:VideoPlayer; if (_arg1 == null){ if (!_firstStreamShown){ _local4 = videoPlayerStates[_activeVP]; queueCmd(_local4, QueuedCommand.PLAY); } else { _local5 = videoPlayers[_activeVP]; _local5.play(); }; } else { if (_arg1 == this.source){ return; }; this.autoPlay = true; this.totalTime = _arg2; this.isLive = _arg3; this.source = _arg1; }; } public function get paused():Boolean{ return ((state == VideoState.PAUSED)); } flvplayback_internal function handleVideoEvent(_arg1:VideoEvent):void{ var _local2:VideoPlayerState; var _local3:CuePointManager; var _local4:VideoEvent; var _local5:String; var _local6:Number; _local2 = videoPlayerStateDict[_arg1.currentTarget]; _local3 = cuePointMgrs[_local2.index]; _local4 = VideoEvent(_arg1.clone()); _local4.vp = _local2.index; _local5 = ((((_local2.index == _visibleVP)) && (scrubbing))) ? VideoState.SEEKING : _arg1.state; switch (_arg1.type){ case VideoEvent.AUTO_REWOUND: dispatchEvent(_local4); dispatchEvent(new VideoEvent(VideoEvent.REWIND, false, false, _local5, _arg1.playheadTime, _local2.index)); _local3.resetASCuePointIndex(_arg1.playheadTime); break; case VideoEvent.PLAYHEAD_UPDATE: _local4.state = _local5; dispatchEvent(_local4); if (((!(isNaN(_local2.preSeekTime))) && (!((_arg1.state == VideoState.SEEKING))))){ _local6 = _local2.preSeekTime; _local2.preSeekTime = NaN; _local3.resetASCuePointIndex(_arg1.playheadTime); dispatchEvent(new VideoEvent(VideoEvent.SEEKED, false, false, _arg1.state, _arg1.playheadTime, _local2.index)); if (_local6 < _arg1.playheadTime){ dispatchEvent(new VideoEvent(VideoEvent.FAST_FORWARD, false, false, _arg1.state, _arg1.playheadTime, _local2.index)); } else { if (_local6 > _arg1.playheadTime){ dispatchEvent(new VideoEvent(VideoEvent.REWIND, false, false, _arg1.state, _arg1.playheadTime, _local2.index)); }; }; }; _local3.dispatchASCuePoints(); break; case VideoEvent.STATE_CHANGE: if ((((_local2.index == _visibleVP)) && (scrubbing))){ break; }; if (_arg1.state == VideoState.RESIZING){ break; }; if ((((((_local2.prevState == VideoState.LOADING)) && (_local2.autoPlay))) && ((_arg1.state == VideoState.STOPPED)))){ return; }; if ((((((((_arg1.state == VideoState.CONNECTION_ERROR)) && ((_arg1.vp == _visibleVP)))) && (!(_firstStreamShown)))) && (uiMgr.skinReady))){ showFirstStream(); uiMgr.visible = true; if (uiMgr.skin == ""){ uiMgr.hookUpCustomComponents(); }; if (skinShowTimer != null){ skinShowTimer.reset(); skinShowTimer = null; }; }; _local2.prevState = _arg1.state; _local4.state = _local5; dispatchEvent(_local4); if (_local2.owner.state != _arg1.state){ return; }; switch (_arg1.state){ case VideoState.BUFFERING: dispatchEvent(new VideoEvent(VideoEvent.BUFFERING_STATE_ENTERED, false, false, _local5, _arg1.playheadTime, _local2.index)); break; case VideoState.PAUSED: dispatchEvent(new VideoEvent(VideoEvent.PAUSED_STATE_ENTERED, false, false, _local5, _arg1.playheadTime, _local2.index)); break; case VideoState.PLAYING: dispatchEvent(new VideoEvent(VideoEvent.PLAYING_STATE_ENTERED, false, false, _local5, _arg1.playheadTime, _local2.index)); break; case VideoState.STOPPED: dispatchEvent(new VideoEvent(VideoEvent.STOPPED_STATE_ENTERED, false, false, _local5, _arg1.playheadTime, _local2.index)); break; }; break; case VideoEvent.READY: if (!_firstStreamReady){ if (_local2.index == _visibleVP){ _firstStreamReady = true; if (((uiMgr.skinReady) && (!(_firstStreamShown)))){ uiMgr.visible = true; if (uiMgr.skin == ""){ uiMgr.hookUpCustomComponents(); }; showFirstStream(); }; }; } else { if (((((_firstStreamShown) && ((_arg1.state == VideoState.STOPPED)))) && (_local2.autoPlay))){ if (_local2.owner.isRTMP){ _local2.owner.play(); } else { _local2.prevState = VideoState.STOPPED; _local2.owner.playWhenEnoughDownloaded(); }; }; }; _local4.state = _local5; dispatchEvent(_local4); break; case VideoEvent.CLOSE: case VideoEvent.COMPLETE: _local4.state = _local5; dispatchEvent(_local4); break; }; } public function set volumeBar(_arg1:Sprite):void{ uiMgr.setControl(UIManager.VOLUME_BAR, _arg1); } public function set fullScreenBackgroundColor(_arg1:uint):void{ uiMgr.fullScreenBackgroundColor = _arg1; } public function get isLive():Boolean{ var _local1:VideoPlayerState; var _local2:VideoPlayer; _local1 = videoPlayerStates[_activeVP]; if (_local1.isLiveSet){ return (_local1.isLive); }; _local2 = videoPlayers[_activeVP]; return (_local2.isLive); } public function get bufferTime():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.bufferTime); } public function get registrationHeight():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_visibleVP]; return (_local1.registrationHeight); } public function get playPauseButton():Sprite{ return (uiMgr.getControl(UIManager.PLAY_PAUSE_BUTTON)); } flvplayback_internal function showFirstStream():void{ var _local1:VideoPlayer; var _local2:int; var _local3:VideoPlayerState; var _local4:int; _firstStreamShown = true; _local1 = videoPlayers[_visibleVP]; _local1.visible = true; if (!scrubbing){ _soundTransform.volume = _volume; _local1.soundTransform = _soundTransform; }; _local2 = 0; while (_local2 < videoPlayers.length) { _local1 = videoPlayers[_local2]; if (_local1 != null){ _local3 = videoPlayerStates[_local2]; if ((((_local1.state == VideoState.STOPPED)) && (_local3.autoPlay))){ if (_local1.isRTMP){ _local1.play(); } else { _local3.prevState = VideoState.STOPPED; _local1.playWhenEnoughDownloaded(); }; }; if (_local3.cmdQueue != null){ _local4 = 0; while (_local4 < _local3.cmdQueue.length) { switch (_local3.cmdQueue[_local4].type){ case QueuedCommand.PLAY: _local1.play(); break; case QueuedCommand.PAUSE: _local1.pause(); break; case QueuedCommand.STOP: _local1.stop(); break; case QueuedCommand.SEEK: _local1.seek(_local3.cmdQueue[_local4].time); break; case QueuedCommand.PLAY_WHEN_ENOUGH: _local1.playWhenEnoughDownloaded(); break; }; _local4++; }; _local3.cmdQueue = null; }; }; _local2++; }; } public function set volumeBarScrubTolerance(_arg1:Number):void{ uiMgr.volumeBarScrubTolerance = _arg1; } public function set skinBackgroundAlpha(_arg1:Number):void{ uiMgr.skinBackgroundAlpha = _arg1; } public function get playheadUpdateInterval():Number{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.playheadUpdateInterval); } public function set muteButton(_arg1:Sprite):void{ uiMgr.setControl(UIManager.MUTE_BUTTON, _arg1); } public function set skinScaleMaximum(_arg1:Number){ uiMgr.skinScaleMaximum = _arg1; } public function enterFullScreenDisplayState():void{ uiMgr.enterFullScreenDisplayState(); } flvplayback_internal function handleMetadataEvent(_arg1:MetadataEvent):void{ var _local2:VideoPlayerState; var _local3:CuePointManager; var _local4:MetadataEvent; _local2 = videoPlayerStateDict[_arg1.currentTarget]; _local3 = cuePointMgrs[_local2.index]; switch (_arg1.type){ case MetadataEvent.METADATA_RECEIVED: _local3.processFLVCuePoints(_arg1.info.cuePoints); break; case MetadataEvent.CUE_POINT: if (!_local3.isFLVCuePointEnabled(_arg1.info)){ return; }; break; }; _local4 = MetadataEvent(_arg1.clone()); _local4.vp = _local2.index; dispatchEvent(_local4); } public function playWhenEnoughDownloaded():void{ var _local1:VideoPlayerState; var _local2:VideoPlayer; if (!_firstStreamShown){ _local1 = videoPlayerStates[_activeVP]; queueCmd(_local1, QueuedCommand.PLAY_WHEN_ENOUGH); } else { _local2 = videoPlayers[_activeVP]; _local2.playWhenEnoughDownloaded(); }; } public function get bitrate():Number{ return (ncMgr.bitrate); } public function get autoRewind():Boolean{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.autoRewind); } public function get fullScreenBackgroundColor():uint{ return (uiMgr.fullScreenBackgroundColor); } public function get skin():String{ return (uiMgr.skin); } public function set registrationX(_arg1:Number):void{ super.x = _arg1; } public function set registrationY(_arg1:Number):void{ super.y = _arg1; } public function setSize(_arg1:Number, _arg2:Number):void{ var _local3:Rectangle; var _local4:Rectangle; var _local5:int; var _local6:VideoPlayer; _local3 = new Rectangle(x, y, this.width, this.height); _local4 = new Rectangle(registrationX, registrationY, registrationWidth, registrationHeight); if (isLivePreview){ livePreviewWidth = _arg1; livePreviewHeight = _arg2; if (previewImage_mc != null){ previewImage_mc.width = _arg1; previewImage_mc.height = _arg2; }; preview_mc.box_mc.width = _arg1; preview_mc.box_mc.height = _arg2; if ((((preview_mc.box_mc.width < preview_mc.icon_mc.width)) || ((preview_mc.box_mc.height < preview_mc.icon_mc.height)))){ preview_mc.icon_mc.visible = false; } else { preview_mc.icon_mc.visible = true; preview_mc.icon_mc.x = ((preview_mc.box_mc.width - preview_mc.icon_mc.width) / 2); preview_mc.icon_mc.y = ((preview_mc.box_mc.height - preview_mc.icon_mc.height) / 2); }; dispatchEvent(new LayoutEvent(LayoutEvent.LAYOUT, false, false, _local3, _local4)); return; }; resizingNow = true; _local5 = 0; while (_local5 < videoPlayers.length) { _local6 = videoPlayers[_local5]; if (_local6 != null){ _local6.setSize(_arg1, _arg2); }; _local5++; }; resizingNow = false; dispatchEvent(new LayoutEvent(LayoutEvent.LAYOUT, false, false, _local3, _local4)); } public function get isRTMP():Boolean{ var _local1:VideoPlayer; if (isLivePreview){ return (true); }; _local1 = videoPlayers[_activeVP]; return (_local1.isRTMP); } public function set preview(_arg1:String):void{ var filename = _arg1; if (!isLivePreview){ return; }; previewImageUrl = filename; if (previewImage_mc != null){ removeChild(previewImage_mc); }; previewImage_mc = new Loader(); previewImage_mc.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompletePreview); previewImage_mc.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (_arg1:IOErrorEvent):void{ }); previewImage_mc.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function (_arg1:SecurityErrorEvent):void{ }); addChildAt(previewImage_mc, 1); previewImage_mc.load(new URLRequest(previewImageUrl)); } override public function set width(_arg1:Number):void{ var _local2:Rectangle; var _local3:Rectangle; var _local4:int; var _local5:VideoPlayer; if (isLivePreview){ setSize(_arg1, this.height); return; }; _local2 = new Rectangle(x, y, width, height); _local3 = new Rectangle(registrationX, registrationY, registrationWidth, registrationHeight); resizingNow = true; _local4 = 0; while (_local4 < videoPlayers.length) { _local5 = videoPlayers[_local4]; if (_local5 != null){ _local5.width = _arg1; }; _local4++; }; resizingNow = false; dispatchEvent(new LayoutEvent(LayoutEvent.LAYOUT, false, false, _local2, _local3)); } public function get playButton():Sprite{ return (uiMgr.getControl(UIManager.PLAY_BUTTON)); } public function set pauseButton(_arg1:Sprite):void{ uiMgr.setControl(UIManager.PAUSE_BUTTON, _arg1); } public function get bytesTotal():uint{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.bytesTotal); } public function seekToPrevNavCuePoint(_arg1:Number=NaN):void{ var _local2:Object; var _local3:Number; var _local4:VideoPlayer; if (((isNaN(_arg1)) || ((_arg1 < 0)))){ _local4 = videoPlayers[_activeVP]; _arg1 = _local4.playheadTime; }; _local2 = findNearestCuePoint(_arg1, CuePointType.NAVIGATION); if (_local2 == null){ seek(0); return; }; _local3 = _local2.index; while ((((_local3 >= 0)) && (((!(isFLVCuePointEnabled(_local2.array[_local3]))) || ((_local2.array[_local3].time >= (_arg1 - _seekToPrevOffset))))))) { _local3--; }; if (_local3 < 0){ seek(0); } else { seek(_local2.array[_local3].time); }; } public function get autoPlay():Boolean{ var _local1:VideoPlayerState; _local1 = videoPlayerStates[_activeVP]; return (_local1.autoPlay); } public function set playheadPercentage(_arg1:Number):void{ seekPercent(_arg1); } public function isFLVCuePointEnabled(_arg1):Boolean{ var _local2:CuePointManager; _local2 = cuePointMgrs[_activeVP]; return (_local2.isFLVCuePointEnabled(_arg1)); } public function get buffering():Boolean{ return ((state == VideoState.BUFFERING)); } public function get volumeBarScrubTolerance():Number{ return (uiMgr.volumeBarScrubTolerance); } public function get skinBackgroundColor():uint{ return (uiMgr.skinBackgroundColor); } public function get visibleVideoPlayerIndex():uint{ return (_visibleVP); } public function set stopButton(_arg1:Sprite):void{ uiMgr.setControl(UIManager.STOP_BUTTON, _arg1); } public function get skinBackgroundAlpha():Number{ return (uiMgr.skinBackgroundAlpha); } public function get skinScaleMaximum():Number{ return (uiMgr.skinScaleMaximum); } public function get preferredWidth():int{ var _local1:VideoPlayer; _local1 = videoPlayers[_activeVP]; return (_local1.videoWidth); } override public function get width():Number{ var _local1:VideoPlayer; if (isLivePreview){ return (livePreviewWidth); }; _local1 = videoPlayers[_visibleVP]; return (_local1.width); } public function get stopped():Boolean{ return ((state == VideoState.STOPPED)); } public function set fullScreenButton(_arg1:Sprite):void{ uiMgr.setControl(UIManager.FULL_SCREEN_BUTTON, _arg1); } public function get stopButton():Sprite{ return (uiMgr.getControl(UIManager.STOP_BUTTON)); } public function set playheadUpdateInterval(_arg1:Number):void{ var _local2:CuePointManager; var _local3:VideoPlayer; if (_activeVP == 0){ _playheadUpdateInterval = _arg1; }; _local2 = cuePointMgrs[_activeVP]; _local2.playheadUpdateInterval = _arg1; _local3 = videoPlayers[_activeVP]; _local3.playheadUpdateInterval = _arg1; } private function createLivePreviewMovieClip():void{ preview_mc = new MovieClip(); preview_mc.name = "preview_mc"; preview_mc.box_mc = new MovieClip(); preview_mc.box_mc.name = "box_mc"; preview_mc.box_mc.graphics.beginFill(0); preview_mc.box_mc.graphics.moveTo(0, 0); preview_mc.box_mc.graphics.lineTo(0, 100); preview_mc.box_mc.graphics.lineTo(100, 100); preview_mc.box_mc.graphics.lineTo(100, 0); preview_mc.box_mc.graphics.lineTo(0, 0); preview_mc.box_mc.graphics.endFill(); preview_mc.addChild(preview_mc.box_mc); preview_mc.icon_mc = new Icon(); preview_mc.icon_mc.name = "icon_mc"; preview_mc.addChild(preview_mc.icon_mc); addChild(preview_mc); } public function set idleTimeout(_arg1:Number):void{ var _local2:VideoPlayer; if (_activeVP == 0){ _idleTimeout = _arg1; }; _local2 = videoPlayers[_activeVP]; _local2.idleTimeout = _arg1; } flvplayback_internal function skinLoaded():void{ var _local1:VideoPlayer; if (isLivePreview){ return; }; _local1 = videoPlayers[_visibleVP]; if (((((_firstStreamReady) || ((_local1.state == VideoState.CONNECTION_ERROR)))) || ((_local1.state == VideoState.DISCONNECTED)))){ uiMgr.visible = true; if (!_firstStreamShown){ showFirstStream(); }; } else { if (skinShowTimer != null){ skinShowTimer.reset(); skinShowTimer = null; }; skinShowTimer = new Timer(DEFAULT_SKIN_SHOW_TIMER_INTERVAL, 1); skinShowTimer.addEventListener(TimerEvent.TIMER, showSkinNow); skinShowTimer.start(); }; dispatchEvent(new VideoEvent(VideoEvent.SKIN_LOADED, false, false, state, playheadTime, _visibleVP)); } flvplayback_internal function _scrubFinish():void{ var _local1:Number; var _local2:String; var _local3:VideoPlayer; _local1 = playheadTime; _local2 = state; _local3 = videoPlayers[_visibleVP]; _soundTransform.volume = _volume; _local3.soundTransform = _soundTransform; if (_local2 != VideoState.SEEKING){ dispatchEvent(new VideoEvent(VideoEvent.STATE_CHANGE, false, false, _local2, _local1, _visibleVP)); }; dispatchEvent(new VideoEvent(VideoEvent.SCRUB_FINISH, false, false, _local2, _local1, _visibleVP)); } public function set playPauseButton(_arg1:Sprite):void{ uiMgr.setControl(UIManager.PLAY_PAUSE_BUTTON, _arg1); } public function set backButton(_arg1:Sprite):void{ uiMgr.setControl(UIManager.BACK_BUTTON, _arg1); } public function set cuePoints(_arg1:Array):void{ if (!_componentInspectorSetting){ return; }; cuePointMgrs[0].processCuePointsProperty(_arg1); } public function findCuePoint(_arg1, _arg2:String="all"):Object{ var _local3:CuePointManager; _local3 = cuePointMgrs[_activeVP]; switch (_arg2){ case "event": return (_local3.getCuePoint(_local3.eventCuePoints, false, _arg1)); case "navigation": return (_local3.getCuePoint(_local3.navCuePoints, false, _arg1)); case "flv": return (_local3.getCuePoint(_local3.flvCuePoints, false, _arg1)); case "actionscript": return (_local3.getCuePoint(_local3.asCuePoints, false, _arg1)); case "all": default: return (_local3.getCuePoint(_local3.allCuePoints, false, _arg1)); }; } public function get seekBarScrubTolerance():Number{ return (uiMgr.seekBarScrubTolerance); } flvplayback_internal function handleVideoProgressEvent(_arg1:VideoProgressEvent):void{ var _local2:VideoPlayerState; var _local3:VideoProgressEvent; _local2 = videoPlayerStateDict[_arg1.currentTarget]; _local3 = VideoProgressEvent(_arg1.clone()); _local3.vp = _local2.index; dispatchEvent(_local3); } } }//package fl.video
Section 212
//flvplayback_internal (fl.video.flvplayback_internal) package fl.video { public namespace flvplayback_internal = "http://www.adobe.com/2007/flash/flvplayback/internal"; }//package fl.video
Section 213
//FPADManager (fl.video.FPADManager) package fl.video { import flash.events.*; import flash.net.*; public class FPADManager { flvplayback_internal var _parseResults:ParseResults; flvplayback_internal var rtmpURL:String; flvplayback_internal var _url:String; flvplayback_internal var xmlLoader:URLLoader; flvplayback_internal var xml:XML; flvplayback_internal var _uriParam:String; private var _owner:INCManager; public static const VERSION:String = "2.1.0.14"; public static const SHORT_VERSION:String = "2.1"; public function FPADManager(_arg1:INCManager){ _owner = _arg1; } flvplayback_internal function connectXML(_arg1:String, _arg2:String, _arg3:String, _arg4:ParseResults):Boolean{ _uriParam = _arg2; _parseResults = _arg4; _url = ((_arg1 + "uri=") + _parseResults.protocol); if (_parseResults.serverName != null){ _url = (_url + ("/" + _parseResults.serverName)); }; if (_parseResults.portNumber != null){ _url = (_url + (":" + _parseResults.portNumber)); }; if (_parseResults.wrappedURL != null){ _url = (_url + ("/?" + _parseResults.wrappedURL)); }; _url = (_url + ("/" + _parseResults.appName)); _url = (_url + _arg3); xml = new XML(); xmlLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE, xmlLoadEventHandler); xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, xmlLoadEventHandler); xmlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, xmlLoadEventHandler); xmlLoader.load(new URLRequest(_url)); return (false); } flvplayback_internal function xmlLoadEventHandler(_arg1:Event):void{ var proxy:String; var e = _arg1; try { if (e.type != Event.COMPLETE){ _owner.helperDone(this, false); } else { xml = new XML(xmlLoader.data); if ((((xml == null)) || ((xml.localName() == null)))){ throw (new VideoError(VideoError.INVALID_XML, (("URL: \"" + _url) + "\" No root node found; if url is for an flv it must have .flv extension and take no parameters"))); } else { if (xml.localName() != "fpad"){ throw (new VideoError(VideoError.INVALID_XML, (("URL: \"" + _url) + "\" Root node not fpad"))); }; }; proxy = null; if ((((((xml.proxy.length() > 0)) && (xml.proxy.hasSimpleContent()))) && ((xml.proxy.*[0].nodeKind() == "text")))){ proxy = xml.proxy.*[0].toString(); }; if (proxy == null){ throw (new VideoError(VideoError.INVALID_XML, (("URL: \"" + _url) + "\" fpad xml requires proxy tag."))); }; rtmpURL = ((((_parseResults.protocol + "/") + proxy) + "/?") + _uriParam); _owner.helperDone(this, true); }; } catch(err:Error) { _owner.helperDone(this, false); throw (err); }; } } }//package fl.video
Section 214
//Icon (fl.video.Icon) package fl.video { import flash.display.*; public dynamic class Icon extends MovieClip { } }//package fl.video
Section 215
//INCManager (fl.video.INCManager) package fl.video { import flash.net.*; public interface INCManager { function set timeout(_arg1:uint):void; function get streamLength():Number; function get timeout():uint; function connectToURL(_arg1:String):Boolean; function get streamName():String; function get bitrate():Number; function get streamHeight():int; function helperDone(_arg1:Object, _arg2:Boolean):void; function getProperty(_arg1:String); function get streamWidth():int; function connectAgain():Boolean; function reconnect():void; function set videoPlayer(_arg1:VideoPlayer):void; function setProperty(_arg1:String, _arg2):void; function set bitrate(_arg1:Number):void; function get netConnection():NetConnection; function get videoPlayer():VideoPlayer; function get isRTMP():Boolean; function close():void; } }//package fl.video
Section 216
//IVPEvent (fl.video.IVPEvent) package fl.video { public interface IVPEvent { function set vp(_arg1:uint):void; function get vp():uint; function get type():String; } }//package fl.video
Section 217
//LayoutEvent (fl.video.LayoutEvent) package fl.video { import flash.events.*; import flash.geom.*; public class LayoutEvent extends Event { private var _oldBounds:Rectangle; private var _oldRegistrationBounds:Rectangle; public static const LAYOUT:String = "layout"; public function LayoutEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Rectangle=null, _arg5:Rectangle=null){ super(_arg1, _arg2, _arg3); _oldBounds = _arg4; _oldRegistrationBounds = _arg5; } public function get oldRegistrationBounds():Rectangle{ return (_oldRegistrationBounds); } override public function clone():Event{ return (new LayoutEvent(type, bubbles, cancelable, Rectangle(oldBounds.clone()), Rectangle(oldRegistrationBounds.clone()))); } public function set oldRegistrationBounds(_arg1:Rectangle):void{ _oldRegistrationBounds = _arg1; } public function set oldBounds(_arg1:Rectangle):void{ _oldBounds = _arg1; } public function get oldBounds():Rectangle{ return (_oldBounds); } } }//package fl.video
Section 218
//MetadataEvent (fl.video.MetadataEvent) package fl.video { import flash.events.*; public class MetadataEvent extends Event implements IVPEvent { private var _info:Object; private var _vp:uint; public static const METADATA_RECEIVED:String = "metadataReceived"; public static const CUE_POINT:String = "cuePoint"; public function MetadataEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:Object=null, _arg5:uint=0){ super(_arg1, _arg2, _arg3); _info = _arg4; _vp = _arg5; } public function get vp():uint{ return (_vp); } public function set info(_arg1:Object):void{ _info = _arg1; } override public function clone():Event{ return (new MetadataEvent(type, bubbles, cancelable, info, vp)); } public function get info():Object{ return (_info); } public function set vp(_arg1:uint):void{ _vp = _arg1; } } }//package fl.video
Section 219
//NCManager (fl.video.NCManager) package fl.video { import flash.events.*; import flash.net.*; import flash.utils.*; public class NCManager implements INCManager { public const DEFAULT_TIMEOUT:uint = 60000; flvplayback_internal var _serverName:String; flvplayback_internal var _tryNCTimer:Timer; flvplayback_internal var _autoSenseBW:Boolean; flvplayback_internal var _fpadZone:Number; flvplayback_internal var _appName:String; flvplayback_internal var _ncConnected:Boolean; flvplayback_internal var _fpadMgr:FPADManager; flvplayback_internal var _bitrate:Number; flvplayback_internal var _timeoutTimer:Timer; flvplayback_internal var _wrappedURL:String; flvplayback_internal var _payload:Number; flvplayback_internal var _proxyType:String; flvplayback_internal var _nc:NetConnection; flvplayback_internal var _streamLength:Number; flvplayback_internal var _connTypeCounter:uint; flvplayback_internal var _streamWidth:int; flvplayback_internal var _ncUri:String; flvplayback_internal var _contentPath:String; flvplayback_internal var _smilMgr:SMILManager; flvplayback_internal var _streamHeight:int; flvplayback_internal var _isRTMP:Boolean; flvplayback_internal var _tryNC:Array; flvplayback_internal var _owner:VideoPlayer; flvplayback_internal var _streams:Array; flvplayback_internal var _portNumber:String; flvplayback_internal var _streamName:String; flvplayback_internal var _objectEncoding:uint; public var fallbackServerName:String; flvplayback_internal var _protocol:String; public static const VERSION:String = "2.1.0.14"; public static const SHORT_VERSION:String = "2.1"; public function NCManager(){ _fpadZone = NaN; _objectEncoding = ObjectEncoding.AMF0; _proxyType = "best"; _timeoutTimer = new Timer(DEFAULT_TIMEOUT); _timeoutTimer.addEventListener(TimerEvent.TIMER, this._onFMSConnectTimeOut); _tryNCTimer = new Timer(1500, 1); _tryNCTimer.addEventListener(TimerEvent.TIMER, this.nextConnect); initNCInfo(); initOtherInfo(); _nc = null; _ncConnected = false; } flvplayback_internal function initNCInfo():void{ _isRTMP = false; _serverName = null; _wrappedURL = null; _portNumber = null; _appName = null; } flvplayback_internal function cleanConns():void{ var _local1:uint; _tryNCTimer.reset(); if (_tryNC != null){ _local1 = 0; while (_local1 < _tryNC.length) { if (_tryNC[_local1] != null){ _tryNC[_local1].removeEventListener(NetStatusEvent.NET_STATUS, connectOnStatus); if (_tryNC[_local1].client.pending){ _tryNC[_local1].addEventListener(NetStatusEvent.NET_STATUS, disconnectOnStatus); } else { _tryNC[_local1].close(); }; }; _tryNC[_local1] = null; _local1++; }; _tryNC = null; }; } public function get streamWidth():int{ return (_streamWidth); } public function connectToURL(_arg1:String):Boolean{ var parseResults:ParseResults; var canReuse:Boolean; var name:String; var url = _arg1; initOtherInfo(); _contentPath = url; if ((((_contentPath == null)) || ((_contentPath == "")))){ throw (new VideoError(VideoError.INVALID_SOURCE)); }; parseResults = parseURL(_contentPath); if ((((parseResults.streamName == null)) || ((parseResults.streamName == "")))){ throw (new VideoError(VideoError.INVALID_SOURCE, url)); }; if (parseResults.isRTMP){ canReuse = canReuseOldConnection(parseResults); _isRTMP = true; _protocol = parseResults.protocol; _streamName = parseResults.streamName; _serverName = parseResults.serverName; _wrappedURL = parseResults.wrappedURL; _portNumber = parseResults.portNumber; _appName = parseResults.appName; if ((((((((_appName == null)) || ((_appName == "")))) || ((_streamName == null)))) || ((_streamName == "")))){ throw (new VideoError(VideoError.INVALID_SOURCE, url)); }; _autoSenseBW = (_streamName.indexOf(",") >= 0); return (((canReuse) || (connectRTMP()))); //unresolved jump }; name = parseResults.streamName; if ((((((((name.indexOf("?") < 0)) && ((((name.length < 4)) || (!((name.slice(-4).toLowerCase() == ".txt"))))))) && ((((name.length < 4)) || (!((name.slice(-4).toLowerCase() == ".xml"))))))) && ((((name.length < 5)) || (!((name.slice(-5).toLowerCase() == ".smil"))))))){ canReuse = canReuseOldConnection(parseResults); _isRTMP = false; _streamName = name; return (((canReuse) || (connectHTTP()))); }; if (name.indexOf("/fms/fpad") >= 0){ try { return (connectFPAD(name)); } catch(err:Error) { }; }; _smilMgr = new SMILManager(this); return (_smilMgr.connectXML(name)); } public function get streamName():String{ return (_streamName); } flvplayback_internal function reconnectOnStatus(_arg1:NetStatusEvent):void{ if ((((_arg1.info.code == "NetConnection.Connect.Failed")) || ((_arg1.info.code == "NetConnection.Connect.Rejected")))){ _nc = null; _ncConnected = false; _owner.ncReconnected(); }; } public function get videoPlayer():VideoPlayer{ return (_owner); } flvplayback_internal function getStreamLengthResult(_arg1:Number):void{ if (_arg1 > 0){ _streamLength = _arg1; }; _owner.ncConnected(); } flvplayback_internal function canReuseOldConnection(_arg1:ParseResults):Boolean{ if ((((_nc == null)) || (!(_ncConnected)))){ return (false); }; if (!_arg1.isRTMP){ if (!_isRTMP){ return (true); }; _owner.close(); _nc = null; _ncConnected = false; initNCInfo(); return (false); }; if (_isRTMP){ if ((((((((((_arg1.serverName == _serverName)) && ((_arg1.appName == _appName)))) && ((_arg1.protocol == _protocol)))) && ((_arg1.portNumber == _portNumber)))) && ((_arg1.wrappedURL == _wrappedURL)))){ return (true); }; _owner.close(); _nc = null; _ncConnected = false; }; initNCInfo(); return (false); } public function getProperty(_arg1:String){ switch (_arg1){ case "fallbackServerName": return (fallbackServerName); case "fpadZone": return (_fpadZone); case "objectEncoding": return (_objectEncoding); case "proxyType": return (_proxyType); default: throw (new VideoError(VideoError.UNSUPPORTED_PROPERTY, _arg1)); }; } flvplayback_internal function connectRTMP():Boolean{ var _local1:int; var _local2:uint; _timeoutTimer.stop(); _timeoutTimer.start(); _tryNC = new Array(); _local1 = ((((_protocol == "rtmp:/")) || ((_protocol == "rtmpe:/")))) ? 2 : 1; _local2 = 0; while (_local2 < _local1) { _tryNC[_local2] = new NetConnection(); _tryNC[_local2].objectEncoding = _objectEncoding; _tryNC[_local2].proxyType = _proxyType; if (!isNaN(_fpadZone)){ _tryNC[_local2].fpadZone = _fpadZone; }; _tryNC[_local2].client = new ConnectClient(this, _tryNC[_local2], _local2); _tryNC[_local2].addEventListener(NetStatusEvent.NET_STATUS, connectOnStatus); _local2++; }; nextConnect(); return (false); } public function reconnect():void{ if (!_isRTMP){ throw (new Error("Cannot call reconnect on an http connection")); }; _nc.client = new ReconnectClient(this); _nc.addEventListener(NetStatusEvent.NET_STATUS, reconnectOnStatus); _nc.connect(_ncUri, false); } public function helperDone(_arg1:Object, _arg2:Boolean):void{ var _local3:ParseResults; var _local4:String; var _local5:Boolean; var _local6:uint; var _local7:Number; if (!_arg2){ _nc = null; _ncConnected = false; _owner.ncConnected(); _smilMgr = null; _fpadMgr = null; return; }; _local5 = false; if (_arg1 == _fpadMgr){ _local4 = _fpadMgr.rtmpURL; _fpadMgr = null; _local3 = parseURL(_local4); _isRTMP = _local3.isRTMP; _protocol = _local3.protocol; _serverName = _local3.serverName; _portNumber = _local3.portNumber; _wrappedURL = _local3.wrappedURL; _appName = _local3.appName; _streamName = _local3.streamName; _local7 = _fpadZone; _fpadZone = NaN; connectRTMP(); _fpadZone = _local7; return; }; if (_arg1 != _smilMgr){ return; }; _streamWidth = _smilMgr.width; _streamHeight = _smilMgr.height; _local4 = _smilMgr.baseURLAttr[0]; if (((!((_local4 == null))) && (!((_local4 == ""))))){ if (_local4.charAt((_local4.length - 1)) != "/"){ _local4 = (_local4 + "/"); }; _local3 = parseURL(_local4); _isRTMP = _local3.isRTMP; _local5 = true; _streamName = _local3.streamName; if (_isRTMP){ _protocol = _local3.protocol; _serverName = _local3.serverName; _portNumber = _local3.portNumber; _wrappedURL = _local3.wrappedURL; _appName = _local3.appName; if ((((_appName == null)) || ((_appName == "")))){ _smilMgr = null; throw (new VideoError(VideoError.INVALID_XML, ("Base RTMP URL must include application name: " + _local4))); }; if (_smilMgr.baseURLAttr.length > 1){ _local3 = parseURL(_smilMgr.baseURLAttr[1]); if (_local3.serverName != null){ fallbackServerName = _local3.serverName; }; }; }; }; _streams = _smilMgr.videoTags; _smilMgr = null; _local6 = 0; while (_local6 < _streams.length) { _local4 = _streams[_local6].src; _local3 = parseURL(_local4); if (!_local5){ _isRTMP = _local3.isRTMP; _local5 = true; if (_isRTMP){ _protocol = _local3.protocol; if (_streams.length > 1){ throw (new VideoError(VideoError.INVALID_XML, "Cannot switch between multiple absolute RTMP URLs, must use meta tag base attribute.")); }; _serverName = _local3.serverName; _portNumber = _local3.portNumber; _wrappedURL = _local3.wrappedURL; _appName = _local3.appName; if ((((_appName == null)) || ((_appName == "")))){ throw (new VideoError(VideoError.INVALID_XML, ("Base RTMP URL must include application name: " + _local4))); }; } else { if ((((_local3.streamName.indexOf("/fms/fpad") >= 0)) && ((_streams.length > 1)))){ throw (new VideoError(VideoError.INVALID_XML, "Cannot switch between multiple absolute fpad URLs, must use meta tag base attribute.")); }; }; } else { if (((((((!((_streamName == null))) && (!((_streamName == ""))))) && (!(_local3.isRelative)))) && ((_streams.length > 1)))){ throw (new VideoError(VideoError.INVALID_XML, "When using meta tag base attribute, cannot use absolute URLs for video or ref tag src attributes.")); }; }; _streams[_local6].parseResults = _local3; _local6++; }; _autoSenseBW = (_streams.length > 1); if (!_autoSenseBW){ if (_streamName != null){ _streamName = (_streamName + _streams[0].parseResults.streamName); } else { _streamName = _streams[0].parseResults.streamName; }; if (((_isRTMP) && ((_streamName.substr(-4).toLowerCase() == ".flv")))){ _streamName = _streamName.substr(0, (_streamName.length - 4)); }; _streamLength = _streams[0].dur; }; if (_isRTMP){ connectRTMP(); } else { if (((!((_streamName == null))) && ((_streamName.indexOf("/fms/fpad") >= 0)))){ connectFPAD(_streamName); } else { if (_autoSenseBW){ bitrateMatch(); }; connectHTTP(); _owner.ncConnected(); }; }; } public function get netConnection():NetConnection{ return (_nc); } public function get bitrate():Number{ return (_bitrate); } public function setProperty(_arg1:String, _arg2):void{ switch (_arg1){ case "fallbackServerName": fallbackServerName = String(_arg2); break; case "fpadZone": _fpadZone = Number(_arg2); break; case "objectEncoding": _objectEncoding = uint(_arg2); break; case "proxyType": _proxyType = String(_arg2); break; default: throw (new VideoError(VideoError.UNSUPPORTED_PROPERTY, _arg1)); }; } public function get timeout():uint{ return (_timeoutTimer.delay); } public function set videoPlayer(_arg1:VideoPlayer):void{ _owner = _arg1; } flvplayback_internal function bitrateMatch():void{ var _local1:Number; var _local2:uint; var _local3:uint; _local1 = _bitrate; if (isNaN(_local1)){ _local1 = 0; }; _local2 = _streams.length; _local3 = 0; while (_local3 < _streams.length) { if (((isNaN(_streams[_local3].bitrate)) || ((_local1 >= _streams[_local3].bitrate)))){ _local2 = _local3; break; }; _local3++; }; if (_local2 == _streams.length){ throw (new VideoError(VideoError.NO_BITRATE_MATCH)); }; if (_streamName != null){ _streamName = (_streamName + _streams[_local2].src); } else { _streamName = _streams[_local2].src; }; if (((_isRTMP) && ((_streamName.substr(-4).toLowerCase() == ".flv")))){ _streamName = _streamName.substr(0, (_streamName.length - 4)); }; _streamLength = _streams[_local2].dur; } flvplayback_internal function disconnectOnStatus(_arg1:NetStatusEvent):void{ if (_arg1.info.code == "NetConnection.Connect.Success"){ _arg1.target.removeEventListener(NetStatusEvent.NET_STATUS, disconnectOnStatus); _arg1.target.close(); }; } flvplayback_internal function nextConnect(_arg1:TimerEvent=null):void{ var _local2:String; var _local3:String; var _local4:String; if (_connTypeCounter == 0){ _local2 = _protocol; _local3 = _portNumber; } else { _local3 = null; if (_protocol == "rtmp:/"){ _local2 = "rtmpt:/"; } else { if (_protocol == "rtmpe:/"){ _local2 = "rtmpte:/"; } else { _tryNC.pop(); return; }; }; }; _local4 = (((_local2 + ((_serverName)==null) ? "" : ((("/" + _serverName) + ((_local3)==null) ? "" : (":" + _local3)) + "/")) + ((_wrappedURL)==null) ? "" : (_wrappedURL + "/")) + _appName); _tryNC[_connTypeCounter].client.pending = true; _tryNC[_connTypeCounter].connect(_local4, _autoSenseBW); if (_connTypeCounter < (_tryNC.length - 1)){ _connTypeCounter++; _tryNCTimer.reset(); _tryNCTimer.start(); }; } flvplayback_internal function connectFPAD(_arg1:String):Boolean{ var _local2:Object; var _local3:String; var _local4:String; var _local5:String; var _local6:ParseResults; _local2 = /^(.+)(\?|\&)(uri=)([^&]+)(\&.*)?$/.exec(_arg1); if (_local2 == null){ throw (new VideoError(VideoError.INVALID_SOURCE, ("fpad url must include uri parameter: " + _arg1))); }; _local3 = (_local2[1] + _local2[2]); _local4 = _local2[4]; _local5 = ((_local2[5])==undefined) ? "" : _local2[5]; _local6 = parseURL(_local4); if (!_local6.isRTMP){ throw (new VideoError(VideoError.INVALID_SOURCE, ("fpad url uri parameter must be rtmp url: " + _arg1))); }; _fpadMgr = new FPADManager(this); return (_fpadMgr.connectXML(_local3, _local4, _local5, _local6)); } flvplayback_internal function connectHTTP():Boolean{ _nc = new NetConnection(); _nc.connect(null); _ncConnected = true; return (true); } public function get isRTMP():Boolean{ return (_isRTMP); } public function get streamLength():Number{ return (_streamLength); } public function connectAgain():Boolean{ var _local1:int; var _local2:String; _local1 = _appName.indexOf("/"); if (_local1 < 0){ _local1 = _streamName.indexOf("/"); if (_local1 >= 0){ _appName = (_appName + "/"); _appName = (_appName + _streamName.slice(0, _local1)); _streamName = _streamName.slice((_local1 + 1)); }; return (false); }; _local2 = _appName.slice((_local1 + 1)); _local2 = (_local2 + "/"); _local2 = (_local2 + _streamName); _streamName = _local2; _appName = _appName.slice(0, _local1); close(); _payload = 0; _connTypeCounter = 0; cleanConns(); connectRTMP(); return (true); } flvplayback_internal function parseURL(_arg1:String):ParseResults{ var _local2:ParseResults; var _local3:int; var _local4:int; var _local5:int; var _local6:int; var _local7:String; var _local8:ParseResults; _local2 = new ParseResults(); _local3 = 0; _local4 = _arg1.indexOf(":/", _local3); if (_local4 >= 0){ _local4 = (_local4 + 2); _local2.protocol = _arg1.slice(_local3, _local4).toLowerCase(); _local2.isRelative = false; } else { _local2.isRelative = true; }; if (((!((_local2.protocol == null))) && ((((((((((_local2.protocol == "rtmp:/")) || ((_local2.protocol == "rtmpt:/")))) || ((_local2.protocol == "rtmps:/")))) || ((_local2.protocol == "rtmpe:/")))) || ((_local2.protocol == "rtmpte:/")))))){ _local2.isRTMP = true; _local3 = _local4; if (_arg1.charAt(_local3) == "/"){ _local3++; _local5 = _arg1.indexOf(":", _local3); _local6 = _arg1.indexOf("/", _local3); if (_local6 < 0){ if (_local5 < 0){ _local2.serverName = _arg1.slice(_local3); } else { _local4 = _local5; _local2.portNumber = _arg1.slice(_local3, _local4); _local3 = (_local4 + 1); _local2.serverName = _arg1.slice(_local3); }; return (_local2); }; if ((((_local5 >= 0)) && ((_local5 < _local6)))){ _local4 = _local5; _local2.serverName = _arg1.slice(_local3, _local4); _local3 = (_local4 + 1); _local4 = _local6; _local2.portNumber = _arg1.slice(_local3, _local4); } else { _local4 = _local6; _local2.serverName = _arg1.slice(_local3, _local4); }; _local3 = (_local4 + 1); }; if (_arg1.charAt(_local3) == "?"){ _local7 = _arg1.slice((_local3 + 1)); _local8 = parseURL(_local7); if ((((_local8.protocol == null)) || (!(_local8.isRTMP)))){ throw (new VideoError(VideoError.INVALID_SOURCE, _arg1)); }; _local2.wrappedURL = "?"; _local2.wrappedURL = (_local2.wrappedURL + _local8.protocol); if (_local8.serverName != null){ _local2.wrappedURL = (_local2.wrappedURL + "/"); _local2.wrappedURL = (_local2.wrappedURL + _local8.serverName); }; if (_local8.portNumber != null){ _local2.wrappedURL = (_local2.wrappedURL + (":" + _local8.portNumber)); }; if (_local8.wrappedURL != null){ _local2.wrappedURL = (_local2.wrappedURL + "/"); _local2.wrappedURL = (_local2.wrappedURL + _local8.wrappedURL); }; _local2.appName = _local8.appName; _local2.streamName = _local8.streamName; return (_local2); }; _local4 = _arg1.indexOf("/", _local3); if (_local4 < 0){ _local2.appName = _arg1.slice(_local3); return (_local2); }; _local2.appName = _arg1.slice(_local3, _local4); _local3 = (_local4 + 1); _local4 = _arg1.indexOf("/", _local3); if (_local4 < 0){ _local2.streamName = _arg1.slice(_local3); if (_local2.streamName.slice(-4).toLowerCase() == ".flv"){ _local2.streamName = _local2.streamName.slice(0, -4); }; return (_local2); }; _local2.appName = (_local2.appName + "/"); _local2.appName = (_local2.appName + _arg1.slice(_local3, _local4)); _local3 = (_local4 + 1); _local2.streamName = _arg1.slice(_local3); if (_local2.streamName.slice(-4).toLowerCase() == ".flv"){ _local2.streamName = _local2.streamName.slice(0, -4); }; } else { _local2.isRTMP = false; _local2.streamName = _arg1; }; return (_local2); } flvplayback_internal function initOtherInfo():void{ _contentPath = null; _streamName = null; _streamWidth = -1; _streamHeight = -1; _streamLength = NaN; _streams = null; _autoSenseBW = false; _payload = 0; _connTypeCounter = 0; cleanConns(); } public function set timeout(_arg1:uint):void{ _timeoutTimer.delay = _arg1; } flvplayback_internal function _onFMSConnectTimeOut(_arg1:TimerEvent=null):void{ cleanConns(); _nc = null; _ncConnected = false; if (!connectAgain()){ _owner.ncConnected(); }; } public function get streamHeight():int{ return (_streamHeight); } flvplayback_internal function connectOnStatus(_arg1:NetStatusEvent):void{ var _local2:ParseResults; _arg1.target.client.pending = false; if (_arg1.info.code == "NetConnection.Connect.Success"){ _nc = _tryNC[_arg1.target.client.connIndex]; cleanConns(); } else { if ((((((_arg1.info.code == "NetConnection.Connect.Rejected")) && (!((_arg1.info.ex == null))))) && ((_arg1.info.ex.code == 302)))){ _connTypeCounter = 0; cleanConns(); _local2 = parseURL(_arg1.info.ex.redirect); if (_local2.isRTMP){ _protocol = _local2.protocol; _serverName = _local2.serverName; _wrappedURL = _local2.wrappedURL; _portNumber = _local2.portNumber; _appName = _local2.appName; if (_local2.streamName != null){ _appName = (_appName + ("/" + _local2.streamName)); }; connectRTMP(); } else { tryFallBack(); }; } else { if ((((((_arg1.info.code == "NetConnection.Connect.Failed")) || ((_arg1.info.code == "NetConnection.Connect.Rejected")))) && ((_arg1.target.client.connIndex == (_tryNC.length - 1))))){ if (!connectAgain()){ tryFallBack(); }; }; }; }; } flvplayback_internal function onReconnected():void{ _ncConnected = true; _owner.ncReconnected(); } flvplayback_internal function tryFallBack():void{ if ((((_serverName == fallbackServerName)) || ((fallbackServerName == null)))){ _nc = null; _ncConnected = false; _owner.ncConnected(); } else { _connTypeCounter = 0; cleanConns(); _serverName = fallbackServerName; connectRTMP(); }; } public function set bitrate(_arg1:Number):void{ if (!_isRTMP){ _bitrate = _arg1; }; } flvplayback_internal function onConnected(_arg1:NetConnection, _arg2:Number):void{ var _local3:Array; var _local4:uint; var _local5:String; _timeoutTimer.stop(); _arg1.removeEventListener(NetStatusEvent.NET_STATUS, connectOnStatus); _nc = _arg1; _ncUri = _nc.uri; _ncConnected = true; if (_autoSenseBW){ _bitrate = (_arg2 * 0x0400); if (_streams != null){ bitrateMatch(); } else { _local3 = _streamName.split(","); _local4 = 0; while (_local4 < _local3.length) { _local5 = stripFrontAndBackWhiteSpace(_local3[_local4]); if ((_local4 + 1) < _local3.length){ if (_arg2 <= Number(_local3[(_local4 + 1)])){ _streamName = _local5; break; }; } else { _streamName = _local5; break; }; _local4 = (_local4 + 2); }; if (_streamName.slice(-4).toLowerCase() == ".flv"){ _streamName = _streamName.slice(0, -4); }; }; }; if (((!(_owner.isLive)) && (isNaN(_streamLength)))){ _nc.call("getStreamLength", new Responder(getStreamLengthResult), _streamName); } else { _owner.ncConnected(); }; } public function close():void{ if (_nc){ _nc.close(); _ncConnected = false; }; } flvplayback_internal static function stripFrontAndBackWhiteSpace(_arg1:String):String{ var _local2:uint; var _local3:uint; var _local4:int; var _local5:int; _local3 = _arg1.length; _local4 = 0; _local5 = _local3; _local2 = 0; for (;_local2 < _local3;_local2++) { switch (_arg1.charCodeAt(_local2)){ case 9: case 10: case 13: case 32: continue; }; _local4 = _local2; break; }; _local2 = _local3; for (;_local2 >= 0;_local2--) { switch (_arg1.charCodeAt(_local2)){ case 9: case 10: case 13: case 32: continue; }; _local5 = (_local2 + 1); break; }; if (_local5 <= _local4){ return (""); }; return (_arg1.slice(_local4, _local5)); } } }//package fl.video
Section 220
//ParseResults (fl.video.ParseResults) package fl.video { public class ParseResults { public var portNumber:String; public var streamName:String; public var serverName:String; public var isRTMP:Boolean; public var appName:String; public var isRelative:Boolean; public var protocol:String; public var wrappedURL:String; } }//package fl.video
Section 221
//QueuedCommand (fl.video.QueuedCommand) package fl.video { public class QueuedCommand { public var type:uint; public var time:Number; public var url:String; public var isLive:Boolean; public static const LOAD:uint = 1; public static const STOP:uint = 3; public static const PLAY_WHEN_ENOUGH:uint = 5; public static const PLAY:uint = 0; public static const PAUSE:uint = 2; public static const SEEK:uint = 4; public function QueuedCommand(_arg1:uint, _arg2:String, _arg3:Boolean, _arg4:Number){ this.type = _arg1; this.url = _arg2; this.isLive = _arg3; this.time = _arg4; } } }//package fl.video
Section 222
//ReconnectClient (fl.video.ReconnectClient) package fl.video { public class ReconnectClient { public var owner:NCManager; public function ReconnectClient(_arg1:NCManager){ this.owner = _arg1; } public function close():void{ } public function onBWDone(... _args):void{ owner.onReconnected(); } } }//package fl.video
Section 223
//SkinErrorEvent (fl.video.SkinErrorEvent) package fl.video { import flash.events.*; public class SkinErrorEvent extends ErrorEvent { public static const SKIN_ERROR:String = "skinError"; public function SkinErrorEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:String=""){ super(_arg1, _arg2, _arg3, _arg4); } override public function clone():Event{ return (new SkinErrorEvent(type, bubbles, cancelable, text)); } } }//package fl.video
Section 224
//SMILManager (fl.video.SMILManager) package fl.video { import flash.events.*; import flash.net.*; public class SMILManager { flvplayback_internal var width:int; flvplayback_internal var xmlLoader:URLLoader; flvplayback_internal var xml:XML; flvplayback_internal var height:int; private var _url:String; flvplayback_internal var videoTags:Array; flvplayback_internal var baseURLAttr:Array; private var _owner:INCManager; public static const VERSION:String = "2.1.0.14"; public static const SHORT_VERSION:String = "2.1"; public function SMILManager(_arg1:INCManager){ _owner = _arg1; width = -1; height = -1; } flvplayback_internal function parseVideo(_arg1:XML):Object{ var _local2:Object; _local2 = new Object(); if (_arg1.@src.length() > 0){ _local2.src = _arg1.@src.toString(); }; if (_arg1.@["system-bitrate"].length() > 0){ _local2.bitrate = int(_arg1.@["system-bitrate"].toString()); }; if (_arg1.@dur.length() > 0){ _local2.dur = parseTime(_arg1.@dur.toString()); }; return (_local2); } flvplayback_internal function connectXML(_arg1:String):Boolean{ _url = fixURL(_arg1); xmlLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE, xmlLoadEventHandler); xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, xmlLoadEventHandler); xmlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, xmlLoadEventHandler); xmlLoader.load(new URLRequest(_url)); return (false); } flvplayback_internal function parseSwitch(_arg1:XML):void{ var _local2:String; var _local3:XML; for (_local2 in _arg1.*) { _local3 = _arg1.*[_local2]; if (_local3.nodeKind() != "element"){ } else { switch (_local3.localName()){ case "video": case "ref": videoTags.push(parseVideo(_local3)); break; default: break; }; }; }; } flvplayback_internal function fixURL(_arg1:String):String{ var _local2:String; if (/^(http:|https:)/i.test(_arg1)){ _local2 = ((_arg1.indexOf("?"))>=0) ? "&" : "?"; return ((((_arg1 + _local2) + "FLVPlaybackVersion=") + SHORT_VERSION)); }; return (_arg1); } flvplayback_internal function xmlLoadEventHandler(_arg1:Event):void{ var e = _arg1; try { if (e.type != Event.COMPLETE){ _owner.helperDone(this, false); } else { baseURLAttr = new Array(); videoTags = new Array(); xml = new XML(xmlLoader.data); if ((((xml == null)) || ((xml.localName() == null)))){ throw (new VideoError(VideoError.INVALID_XML, (("URL: \"" + _url) + "\" No root node found; if url is for an flv it must have .flv extension and take no parameters"))); } else { if (xml.localName() != "smil"){ throw (new VideoError(VideoError.INVALID_XML, (("URL: \"" + _url) + "\" Root node not smil"))); }; }; checkForIllegalNodes(xml, "element", ["head", "body"]); if (xml.head.length() > 0){ parseHead(xml.head[0]); }; if (xml.body.length() < 1){ throw (new VideoError(VideoError.INVALID_XML, (("URL: \"" + _url) + "\" Tag body is required."))); } else { parseBody(xml.body[0]); }; _owner.helperDone(this, true); }; } catch(err:Error) { _owner.helperDone(this, false); throw (err); } finally { xmlLoader.removeEventListener(Event.COMPLETE, xmlLoadEventHandler); xmlLoader.removeEventListener(IOErrorEvent.IO_ERROR, xmlLoadEventHandler); xmlLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, xmlLoadEventHandler); xmlLoader = null; }; } flvplayback_internal function checkForIllegalNodes(_arg1:XML, _arg2:String, _arg3:Array):void{ var _local4:String; var _local5:Boolean; var _local6:XML; var _local7:String; var _local8:String; for (_local4 in _arg1.*) { _local5 = false; _local6 = _arg1.*[_local4]; if (_local6.nodeKind() != _arg2){ } else { _local7 = _local6.localName(); for (_local8 in _arg3) { if (_arg3[_local8] == _local7){ _local5 = true; break; }; }; if (!_local5){ throw (new VideoError(VideoError.INVALID_XML, (((((((("URL: \"" + _url) + "\" ") + _arg2) + " ") + _local7) + " not supported in ") + _arg1.localName()) + " tag."))); }; }; }; } flvplayback_internal function parseHead(_arg1:XML):void{ checkForIllegalNodes(_arg1, "element", ["meta", "layout"]); if (_arg1.meta.length() > 0){ checkForIllegalNodes(_arg1.meta[0], "element", []); checkForIllegalNodes(_arg1.meta[0], "attribute", ["base"]); if (_arg1.meta.@base.length() > 0){ baseURLAttr.push(_arg1.meta.@base.toString()); }; }; if (_arg1.layout.length() > 0){ parseLayout(_arg1.layout[0]); }; } flvplayback_internal function parseBody(_arg1:XML):void{ var _local2:XML; var _local3:String; var _local4:Object; if (((!((_arg1.*.length() == 1))) || (!((_arg1.*[0].nodeKind() == "element"))))){ throw (new VideoError(VideoError.INVALID_XML, (((("URL: \"" + _url) + "\" Tag ") + _arg1.localName()) + " is required to contain exactly one tag."))); }; _local2 = _arg1.*[0]; _local3 = _local2.localName(); switch (_local3){ case "switch": parseSwitch(_local2); break; case "video": case "ref": _local4 = parseVideo(_local2); videoTags.push(_local4); break; default: throw (new VideoError(VideoError.INVALID_XML, (((((("URL: \"" + _url) + "\" Tag ") + _local3) + " not supported in ") + _arg1.localName()) + " tag."))); }; if (videoTags.length < 1){ throw (new VideoError(VideoError.INVALID_XML, (("URL: \"" + _url) + "\" At least one video of ref tag is required."))); }; } flvplayback_internal function parseTime(_arg1:String):Number{ var _local2:Object; var _local3:Number; var _local4:Number; _local2 = /^((\d+):)?(\d+):((\d+)(.\d+)?)$/.exec(_arg1); if (_local2 == null){ _local3 = Number(_arg1); if (((isNaN(_local3)) || ((_local3 < 0)))){ throw (new VideoError(VideoError.INVALID_XML, ("Invalid dur value: " + _arg1))); }; return (_local3); //unresolved jump }; _local4 = 0; _local4 = (_local4 + ((uint(_local2[2]) * 60) * 60)); _local4 = (_local4 + (uint(_local2[3]) * 60)); _local4 = (_local4 + Number(_local2[4])); return (_local4); } flvplayback_internal function parseLayout(_arg1:XML):void{ var _local2:XML; var _local3:Number; var _local4:Number; checkForIllegalNodes(_arg1, "element", ["root-layout"]); if (_arg1["root-layout"].length() > 1){ throw (new VideoError(VideoError.INVALID_XML, (("URL: \"" + _url) + "\" Only one base attribute supported in meta tag."))); }; if (_arg1["root-layout"].length() > 0){ _local2 = _arg1["root-layout"][0]; if (_local2.@width.length() > 0){ _local3 = Number(_local2.@width[0]); }; if (_local2.@height.length() > 0){ _local4 = Number(_local2.@height[0]); }; if (((((((isNaN(_local3)) || ((_local3 < 0)))) || (isNaN(_local4)))) || ((_local4 < 0)))){ throw (new VideoError(VideoError.INVALID_XML, (((("URL: \"" + _url) + "\" Tag ") + _arg1.localName()) + " requires attributes width and height. Width and height must be numbers greater than or equal to 0."))); }; width = Math.round(_local3); height = Math.round(_local4); }; } } }//package fl.video
Section 225
//SoundEvent (fl.video.SoundEvent) package fl.video { import flash.events.*; import flash.media.*; public class SoundEvent extends Event { private var _soundTransform:SoundTransform; public static const SOUND_UPDATE:String = "soundUpdate"; public function SoundEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:SoundTransform=null){ super(_arg1, _arg2, _arg3); _soundTransform = _arg4; } public function get soundTransform():SoundTransform{ return (_soundTransform); } override public function clone():Event{ return (new SoundEvent(type, bubbles, cancelable, soundTransform)); } } }//package fl.video
Section 226
//UIManager (fl.video.UIManager) package fl.video { import flash.events.*; import flash.display.*; import flash.net.*; import flash.geom.*; import flash.utils.*; public class UIManager { flvplayback_internal var cacheStageBGColor:uint; flvplayback_internal var _bufferingDelayTimer:Timer; public var ctrlDataDict:Dictionary; flvplayback_internal var _skinAutoHide:Boolean; flvplayback_internal var placeholderLeft:Number; flvplayback_internal var _playAfterScrub:Boolean; public var customClips:Array; flvplayback_internal var _skinFadeStartTime:int; flvplayback_internal var delayedControls:Array; flvplayback_internal var _lastScrubPos:Number; flvplayback_internal var _skinAutoHideLastMotionTime:int; flvplayback_internal var _volumeBarTimer:Timer; flvplayback_internal var cacheFLVPlaybackScaleMode:Array; flvplayback_internal var borderScale9Rects:Array; flvplayback_internal var _volumeBarScrubTolerance:Number; flvplayback_internal var fullScreenSourceRectMinAspectRatio:Number; flvplayback_internal var _skin:String; flvplayback_internal var fullScreenSourceRectMinHeight:uint; flvplayback_internal var videoRight:Number; flvplayback_internal var _bufferingBarHides:Boolean; flvplayback_internal var placeholderRight:Number; flvplayback_internal var cachedSoundLevel:Number; flvplayback_internal var videoBottom:Number; flvplayback_internal var border_mc:DisplayObject; flvplayback_internal var borderAlpha:Number; flvplayback_internal var borderColorTransform:ColorTransform; flvplayback_internal var _skinFadingTimer:Timer; flvplayback_internal var __visible:Boolean; flvplayback_internal var borderColor:uint; flvplayback_internal var cacheFLVPlaybackIndex:int; flvplayback_internal var cacheFLVPlaybackLocation:Rectangle; flvplayback_internal var _skinReady:Boolean; flvplayback_internal var controls:Array; flvplayback_internal var cacheFLVPlaybackAlign:Array; flvplayback_internal var _skinAutoHideMouseX:Number; flvplayback_internal var _skinAutoHideMouseY:Number; flvplayback_internal var layout_mc:Sprite; flvplayback_internal var cacheSkinAutoHide:Boolean; flvplayback_internal var cacheStageScaleMode:String; flvplayback_internal var videoTop:Number; flvplayback_internal var _skinFadingMaxTime:int; flvplayback_internal var placeholderTop:Number; flvplayback_internal var _lastVolumePos:Number; flvplayback_internal var mouseCaptureCtrl:int; flvplayback_internal var _seekBarScrubTolerance:Number; flvplayback_internal var borderPrevRect:Rectangle; flvplayback_internal var skinTemplate:Sprite; flvplayback_internal var _progressPercent:Number; flvplayback_internal var videoLeft:Number; flvplayback_internal var _fullScreenVideoWidth:Number; flvplayback_internal var _isMuted:Boolean; flvplayback_internal var _skinAutoHideTimer:Timer; flvplayback_internal var _fullScreenBgColor:uint; flvplayback_internal var _vc:FLVPlayback; flvplayback_internal var _bufferingOn:Boolean; flvplayback_internal var _seekBarTimer:Timer; flvplayback_internal var _controlsEnabled:Boolean; flvplayback_internal var _fullScreen:Boolean; flvplayback_internal var placeholderBottom:Number; flvplayback_internal var fullScreenSourceRectMinWidth:uint; flvplayback_internal var _fullScreenTakeOver:Boolean; flvplayback_internal var skin_mc:Sprite; flvplayback_internal var _fullScreenAccel:Boolean; flvplayback_internal var _fullScreenVideoHeight:Number; flvplayback_internal var skinLoadDelayCount:uint; flvplayback_internal var _skinFadingIn:Boolean; flvplayback_internal var _skinAutoHideMotionTimeout:int; flvplayback_internal var borderCopy:Sprite; flvplayback_internal var cacheStageAlign:String; flvplayback_internal var cacheFLVPlaybackParent:DisplayObjectContainer; flvplayback_internal var skinLoader:Loader; flvplayback_internal var _skinScaleMaximum:Number; public static const VOLUME_BAR_HIT:int = 12; public static const MUTE_OFF_BUTTON:int = 10; public static const BACK_BUTTON:int = 5; public static const FORWARD_BUTTON:int = 6; public static const STOP_BUTTON:int = 2; public static const NUM_BUTTONS:int = 13; public static const NORMAL_STATE:uint = 0; public static const SEEK_BAR_HANDLE:int = 3; public static const PLAY_BUTTON:int = 1; public static const MUTE_BUTTON:int = 15; public static const DOWN_STATE:uint = 2; public static const SEEK_BAR_SCRUB_TOLERANCE_DEFAULT:Number = 5; public static const FULL_SCREEN_OFF_BUTTON:int = 8; flvplayback_internal static const SKIN_AUTO_HIDE_MOTION_TIMEOUT_DEFAULT:Number = 3000; public static const SEEK_BAR:int = 17; public static const VOLUME_BAR_SCRUB_TOLERANCE_DEFAULT:Number = 0; public static const FULL_SCREEN_ON_BUTTON:int = 7; public static const FULL_SCREEN_BUTTON:int = 14; public static const BUFFERING_BAR:int = 16; public static const VERSION:String = "2.1.0.14"; public static const VOLUME_BAR_HANDLE:int = 11; public static const PAUSE_BUTTON:int = 0; flvplayback_internal static const SKIN_AUTO_HIDE_INTERVAL:Number = 200; public static const OVER_STATE:uint = 1; flvplayback_internal static const SKIN_FADING_INTERVAL:Number = 100; public static const VOLUME_BAR:int = 18; public static const SHORT_VERSION:String = "2.1"; public static const SEEK_BAR_INTERVAL_DEFAULT:Number = 250; flvplayback_internal static const SKIN_FADING_MAX_TIME_DEFAULT:Number = 500; public static const SEEK_BAR_HIT:int = 4; public static const PLAY_PAUSE_BUTTON:int = 13; public static const BUFFERING_DELAY_INTERVAL_DEFAULT:Number = 1000; public static const MUTE_ON_BUTTON:int = 9; public static const FULL_SCREEN_SOURCE_RECT_MIN_HEIGHT:uint = 240; public static const NUM_CONTROLS:int = 19; public static const VOLUME_BAR_INTERVAL_DEFAULT:Number = 250; public static const FULL_SCREEN_SOURCE_RECT_MIN_WIDTH:uint = 320; flvplayback_internal static var layoutNameToIndexMappings:Object = null; flvplayback_internal static var buttonSkinLinkageIDs:Array = ["upLinkageID", "overLinkageID", "downLinkageID"]; flvplayback_internal static var layoutNameArray:Array = ["pause_mc", "play_mc", "stop_mc", null, null, "back_mc", "forward_mc", null, null, null, null, null, null, "playpause_mc", "fullScreenToggle_mc", "volumeMute_mc", "bufferingBar_mc", "seekBar_mc", "volumeBar_mc", "seekBarHandle_mc", "seekBarHit_mc", "seekBarProgress_mc", "seekBarFullness_mc", "volumeBarHandle_mc", "volumeBarHit_mc", "volumeBarProgress_mc", "volumeBarFullness_mc", "progressFill_mc"]; flvplayback_internal static var skinClassPrefixes:Array = ["pauseButton", "playButton", "stopButton", null, null, "backButton", "forwardButton", "fullScreenButtonOn", "fullScreenButtonOff", "muteButtonOn", "muteButtonOff", null, null, null, null, null, "bufferingBar", "seekBar", "volumeBar"]; flvplayback_internal static var customComponentClassNames:Array = ["PauseButton", "PlayButton", "StopButton", null, null, "BackButton", "ForwardButton", null, null, null, null, null, null, "PlayPauseButton", "FullScreenButton", "MuteButton", "BufferingBar", "SeekBar", "VolumeBar"]; public function UIManager(_arg1:FLVPlayback){ var vc = _arg1; super(); _vc = vc; _skin = null; _skinAutoHide = false; cacheSkinAutoHide = _skinAutoHide; _skinFadingMaxTime = SKIN_FADING_MAX_TIME_DEFAULT; _skinAutoHideMotionTimeout = SKIN_AUTO_HIDE_MOTION_TIMEOUT_DEFAULT; _skinReady = true; __visible = false; _bufferingBarHides = false; _controlsEnabled = true; _lastScrubPos = 0; _lastVolumePos = 0; cachedSoundLevel = _vc.volume; _isMuted = false; controls = new Array(); customClips = null; ctrlDataDict = new Dictionary(true); skin_mc = null; skinLoader = null; skinTemplate = null; layout_mc = null; border_mc = null; borderCopy = null; borderPrevRect = null; borderScale9Rects = null; borderAlpha = 0.85; borderColor = 4697035; borderColorTransform = new ColorTransform(0, 0, 0, 0, 71, 171, 203, (0xFF * borderAlpha)); _seekBarScrubTolerance = SEEK_BAR_SCRUB_TOLERANCE_DEFAULT; _volumeBarScrubTolerance = VOLUME_BAR_SCRUB_TOLERANCE_DEFAULT; _bufferingOn = false; mouseCaptureCtrl = -1; _seekBarTimer = new Timer(SEEK_BAR_INTERVAL_DEFAULT); _seekBarTimer.addEventListener(TimerEvent.TIMER, seekBarListener); _volumeBarTimer = new Timer(VOLUME_BAR_INTERVAL_DEFAULT); _volumeBarTimer.addEventListener(TimerEvent.TIMER, volumeBarListener); _bufferingDelayTimer = new Timer(BUFFERING_DELAY_INTERVAL_DEFAULT, 1); _bufferingDelayTimer.addEventListener(TimerEvent.TIMER, doBufferingDelay); _skinAutoHideTimer = new Timer(SKIN_AUTO_HIDE_INTERVAL); _skinAutoHideTimer.addEventListener(TimerEvent.TIMER, skinAutoHideHitTest); _skinFadingTimer = new Timer(SKIN_FADING_INTERVAL); _skinFadingTimer.addEventListener(TimerEvent.TIMER, skinFadeMore); _vc.addEventListener(MetadataEvent.METADATA_RECEIVED, handleIVPEvent); _vc.addEventListener(VideoEvent.PLAYHEAD_UPDATE, handleIVPEvent); _vc.addEventListener(VideoProgressEvent.PROGRESS, handleIVPEvent); _vc.addEventListener(VideoEvent.STATE_CHANGE, handleIVPEvent); _vc.addEventListener(VideoEvent.READY, handleIVPEvent); _vc.addEventListener(LayoutEvent.LAYOUT, handleLayoutEvent); _vc.addEventListener(AutoLayoutEvent.AUTO_LAYOUT, handleLayoutEvent); _vc.addEventListener(SoundEvent.SOUND_UPDATE, handleSoundEvent); _vc.addEventListener(Event.ADDED_TO_STAGE, handleEvent); _vc.addEventListener(Event.REMOVED_FROM_STAGE, handleEvent); fullScreenSourceRectMinWidth = FULL_SCREEN_SOURCE_RECT_MIN_WIDTH; fullScreenSourceRectMinHeight = FULL_SCREEN_SOURCE_RECT_MIN_HEIGHT; fullScreenSourceRectMinAspectRatio = (FULL_SCREEN_SOURCE_RECT_MIN_WIDTH / FULL_SCREEN_SOURCE_RECT_MIN_HEIGHT); _fullScreen = false; _fullScreenTakeOver = true; _fullScreenBgColor = 0; _fullScreenAccel = false; if (_vc.stage != null){ try { _fullScreen = (_vc.stage.displayState == StageDisplayState.FULL_SCREEN); _vc.stage.addEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreenEvent); } catch(se:SecurityError) { }; }; if (layoutNameToIndexMappings == null){ initLayoutNameToIndexMappings(); }; } public function get seekBarScrubTolerance():Number{ return (_seekBarScrubTolerance); } flvplayback_internal function removeButtonListeners(_arg1:Sprite):void{ if (_arg1 == null){ return; }; _arg1.removeEventListener(MouseEvent.ROLL_OVER, handleButtonEvent); _arg1.removeEventListener(MouseEvent.ROLL_OUT, handleButtonEvent); _arg1.removeEventListener(MouseEvent.MOUSE_DOWN, handleButtonEvent); _arg1.removeEventListener(MouseEvent.CLICK, handleButtonEvent); _arg1.removeEventListener(Event.ENTER_FRAME, skinButtonControl); } public function set skinFadeTime(_arg1:int):void{ _skinFadingMaxTime = _arg1; } public function get skinFadeTime():int{ return (_skinFadingMaxTime); } flvplayback_internal function finishLoad(_arg1:Event):void{ var i:int; var cachedActivePlayerIndex:int; var state:String; var j:int; var e = _arg1; try { skinLoadDelayCount++; if (skinLoadDelayCount < 2){ return; } else { _vc.removeEventListener(Event.ENTER_FRAME, finishLoad); }; i = 0; while (i < NUM_CONTROLS) { if (delayedControls[i] != undefined){ setControl(i, delayedControls[i]); }; i = (i + 1); }; if (_fullScreenTakeOver){ enterFullScreenTakeOver(); } else { exitFullScreenTakeOver(); }; layoutSkin(); setupSkinAutoHide(false); skin_mc.visible = __visible; _vc.addChild(skin_mc); _skinReady = true; _vc.skinLoaded(); cachedActivePlayerIndex = _vc.activeVideoPlayerIndex; _vc.activeVideoPlayerIndex = _vc.visibleVideoPlayerIndex; state = _vc.state; j = 0; while (j < NUM_CONTROLS) { if (controls[j] == undefined){ } else { setEnabledAndVisibleForState(j, state); if (j < NUM_BUTTONS){ skinButtonControl(controls[j]); }; }; j = (j + 1); }; _vc.activeVideoPlayerIndex = cachedActivePlayerIndex; } catch(err:Error) { _vc.skinError(err.message); removeSkin(); }; } flvplayback_internal function downloadSkin():void{ if (skinLoader == null){ skinLoader = new Loader(); skinLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoad); skinLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleLoadErrorEvent); skinLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleLoadErrorEvent); }; skinLoader.load(new URLRequest(_skin)); } flvplayback_internal function removeSkin():void{ var i:int; if (skinLoader != null){ try { skinLoader.close(); } catch(e1:Error) { }; skinLoader = null; }; if (skin_mc != null){ i = 0; while (i < NUM_CONTROLS) { if (controls[i] == undefined){ } else { if (i < NUM_BUTTONS){ removeButtonListeners(controls[i]); }; delete ctrlDataDict[controls[i]]; delete controls[i]; }; i = (i + 1); }; try { skin_mc.parent.removeChild(skin_mc); } catch(e2:Error) { }; skin_mc = null; }; skinTemplate = null; layout_mc = null; border_mc = null; borderCopy = null; borderPrevRect = null; borderScale9Rects = null; } flvplayback_internal function positionBar(_arg1:Sprite, _arg2:String, _arg3:Number):void{ var ctrlData:ControlData; var bar:DisplayObject; var barData:ControlData; var ctrl = _arg1; var type = _arg2; var percent = _arg3; try { if ((((ctrl["positionBar"] is Function)) && (ctrl["positionBar"](type, percent)))){ return; }; } catch(re2:ReferenceError) { }; ctrlData = ctrlDataDict[ctrl]; bar = ctrlData[(type + "_mc")]; if (bar == null){ return; }; barData = ctrlDataDict[bar]; if (bar.parent == ctrl){ if (barData.fill_mc == null){ bar.scaleX = ((barData.origScaleX * percent) / 100); } else { positionMaskedFill(bar, percent); }; } else { bar.x = (ctrl.x + barData.leftMargin); bar.y = (ctrl.y + barData.origY); if (barData.fill_mc == null){ bar.width = ((((ctrl.width - barData.leftMargin) - barData.rightMargin) * percent) / 100); } else { positionMaskedFill(bar, percent); }; }; } flvplayback_internal function setupButtonSkin(_arg1:int):Sprite{ var _local2:String; var _local3:Sprite; var _local4:ControlData; _local2 = skinClassPrefixes[_arg1]; if (_local2 == null){ return (null); }; _local3 = new Sprite(); _local4 = new ControlData(this, _local3, null, _arg1); ctrlDataDict[_local3] = _local4; _local4.state_mc = new Array(); _local4.state_mc[NORMAL_STATE] = setupButtonSkinState(_local3, skinTemplate, (_local2 + "NormalState")); _local4.state_mc[NORMAL_STATE].visible = true; _local4.state_mc[OVER_STATE] = setupButtonSkinState(_local3, skinTemplate, (_local2 + "OverState"), _local4.state_mc[NORMAL_STATE]); _local4.state_mc[DOWN_STATE] = setupButtonSkinState(_local3, skinTemplate, (_local2 + "DownState"), _local4.state_mc[NORMAL_STATE]); _local4.disabled_mc = setupButtonSkinState(_local3, skinTemplate, (_local2 + "DisabledState"), _local4.state_mc[NORMAL_STATE]); return (_local3); } public function get skinReady():Boolean{ return (_skinReady); } public function get skinAutoHide():Boolean{ return (_skinAutoHide); } flvplayback_internal function dispatchMessage(_arg1:int):void{ var cachedActivePlayerIndex:int; var ctrl:Sprite; var ctrlData:ControlData; var handle:Sprite; var index = _arg1; if ((((index == SEEK_BAR_HANDLE)) || ((index == SEEK_BAR_HIT)))){ _vc._scrubStart(); }; cachedActivePlayerIndex = _vc.activeVideoPlayerIndex; _vc.activeVideoPlayerIndex = _vc.visibleVideoPlayerIndex; switch (index){ case PAUSE_BUTTON: _vc.pause(); break; case PLAY_BUTTON: _vc.play(); break; case STOP_BUTTON: _vc.stop(); break; case SEEK_BAR_HIT: case SEEK_BAR_HANDLE: ctrl = controls[SEEK_BAR]; ctrlData = ctrlDataDict[ctrl]; calcPercentageFromHandle(ctrl); _lastScrubPos = ctrlData.percentage; if (index == SEEK_BAR_HIT){ handle = controls[SEEK_BAR_HANDLE]; handle.x = handle.parent.mouseX; handle.y = handle.parent.mouseY; }; _vc.removeEventListener(VideoEvent.PLAYHEAD_UPDATE, handleIVPEvent); if (((_vc.playing) || (_vc.buffering))){ _playAfterScrub = true; } else { if (_vc.state != VideoState.SEEKING){ _playAfterScrub = false; }; }; _seekBarTimer.start(); startHandleDrag(ctrl); _vc.pause(); break; case VOLUME_BAR_HIT: case VOLUME_BAR_HANDLE: ctrl = controls[VOLUME_BAR]; ctrlData = ctrlDataDict[ctrl]; calcPercentageFromHandle(ctrl); _lastVolumePos = ctrlData.percentage; if (index == VOLUME_BAR_HIT){ handle = controls[VOLUME_BAR_HANDLE]; handle.x = handle.parent.mouseX; handle.y = handle.parent.mouseY; }; _vc.removeEventListener(SoundEvent.SOUND_UPDATE, handleSoundEvent); _volumeBarTimer.start(); startHandleDrag(ctrl); break; case BACK_BUTTON: _vc.seekToPrevNavCuePoint(); break; case FORWARD_BUTTON: _vc.seekToNextNavCuePoint(); break; case MUTE_ON_BUTTON: if (!_isMuted){ _isMuted = true; cachedSoundLevel = _vc.volume; _vc.volume = 0; setEnabledAndVisibleForState(MUTE_OFF_BUTTON, VideoState.PLAYING); skinButtonControl(controls[MUTE_OFF_BUTTON]); setEnabledAndVisibleForState(MUTE_ON_BUTTON, VideoState.PLAYING); skinButtonControl(controls[MUTE_ON_BUTTON]); }; break; case MUTE_OFF_BUTTON: if (_isMuted){ _isMuted = false; _vc.volume = cachedSoundLevel; setEnabledAndVisibleForState(MUTE_OFF_BUTTON, VideoState.PLAYING); skinButtonControl(controls[MUTE_OFF_BUTTON]); setEnabledAndVisibleForState(MUTE_ON_BUTTON, VideoState.PLAYING); skinButtonControl(controls[MUTE_ON_BUTTON]); }; break; case FULL_SCREEN_ON_BUTTON: if (((!(_fullScreen)) && (!((_vc.stage == null))))){ enterFullScreenDisplayState(); setEnabledAndVisibleForState(FULL_SCREEN_OFF_BUTTON, VideoState.PLAYING); skinButtonControl(controls[FULL_SCREEN_OFF_BUTTON]); setEnabledAndVisibleForState(FULL_SCREEN_ON_BUTTON, VideoState.PLAYING); skinButtonControl(controls[FULL_SCREEN_ON_BUTTON]); }; break; case FULL_SCREEN_OFF_BUTTON: if (((_fullScreen) && (!((_vc.stage == null))))){ try { _vc.stage.displayState = StageDisplayState.NORMAL; } catch(se:SecurityError) { }; setEnabledAndVisibleForState(FULL_SCREEN_OFF_BUTTON, VideoState.PLAYING); skinButtonControl(controls[FULL_SCREEN_OFF_BUTTON]); setEnabledAndVisibleForState(FULL_SCREEN_ON_BUTTON, VideoState.PLAYING); skinButtonControl(controls[FULL_SCREEN_ON_BUTTON]); }; break; default: throw (new Error("Unknown ButtonControl")); }; _vc.activeVideoPlayerIndex = cachedActivePlayerIndex; } flvplayback_internal function handleFullScreenEvent(_arg1:FullScreenEvent):void{ _fullScreen = _arg1.fullScreen; setEnabledAndVisibleForState(FULL_SCREEN_OFF_BUTTON, VideoState.PLAYING); skinButtonControl(controls[FULL_SCREEN_OFF_BUTTON]); setEnabledAndVisibleForState(FULL_SCREEN_ON_BUTTON, VideoState.PLAYING); skinButtonControl(controls[FULL_SCREEN_ON_BUTTON]); if (((_fullScreen) && (_fullScreenTakeOver))){ enterFullScreenTakeOver(); } else { if (!_fullScreen){ exitFullScreenTakeOver(); }; }; } flvplayback_internal function handleLayoutEvent(_arg1:LayoutEvent):void{ var _local2:int; if (((((((_fullScreen) && (_fullScreenTakeOver))) && (_fullScreenAccel))) && (!((_vc.stage == null))))){ if (((((((((!((_vc.registrationX == 0))) || (!((_vc.registrationY == 0))))) || (!((_vc.parent == _vc.stage))))) || (!((_vc.registrationWidth == _vc.stage.stageWidth))))) || (!((_vc.registrationHeight == _vc.stage.stageHeight))))){ _vc.stage.displayState = StageDisplayState.NORMAL; return; }; _local2 = _vc.activeVideoPlayerIndex; _vc.activeVideoPlayerIndex = _vc.visibleVideoPlayerIndex; if (_vc.align != VideoAlign.CENTER){ cacheFLVPlaybackAlign[_vc.visibleVideoPlayerIndex] = _vc.align; _vc.align = VideoAlign.CENTER; }; if (_vc.scaleMode != VideoScaleMode.MAINTAIN_ASPECT_RATIO){ cacheFLVPlaybackScaleMode[_vc.visibleVideoPlayerIndex] = _vc.scaleMode; _vc.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO; _vc.activeVideoPlayerIndex = _local2; return; }; _vc.activeVideoPlayerIndex = _local2; }; layoutSkin(); setupSkinAutoHide(false); } flvplayback_internal function seekBarListener(_arg1:TimerEvent):void{ var _local2:int; var _local3:Sprite; var _local4:ControlData; var _local5:Number; _local2 = _vc.activeVideoPlayerIndex; _vc.activeVideoPlayerIndex = _vc.visibleVideoPlayerIndex; _local3 = controls[SEEK_BAR]; if (_local3 == null){ return; }; _local4 = ctrlDataDict[_local3]; calcPercentageFromHandle(_local3); _local5 = _local4.percentage; if (_arg1 == null){ _seekBarTimer.stop(); if (_local5 != _lastScrubPos){ _vc.seekPercent(_local5); }; _vc.addEventListener(VideoEvent.PLAYHEAD_UPDATE, handleIVPEvent); if (_playAfterScrub){ _vc.play(); }; } else { if (_vc.getVideoPlayer(_vc.visibleVideoPlayerIndex).state == VideoState.SEEKING){ } else { if ((((((((_seekBarScrubTolerance <= 0)) || ((Math.abs((_local5 - _lastScrubPos)) > _seekBarScrubTolerance)))) || ((_local5 < _seekBarScrubTolerance)))) || ((_local5 > (100 - _seekBarScrubTolerance))))){ if (_local5 != _lastScrubPos){ _lastScrubPos = _local5; _vc.seekPercent(_local5); }; }; }; }; _vc.activeVideoPlayerIndex = _local2; } public function get seekBarInterval():Number{ return (_seekBarTimer.delay); } public function set skinAutoHide(_arg1:Boolean):void{ if (_arg1 == _skinAutoHide){ return; }; _skinAutoHide = _arg1; cacheSkinAutoHide = _arg1; setupSkinAutoHide(true); } flvplayback_internal function setCustomClip(_arg1:DisplayObject):void{ var dCopy:DisplayObject; var ctrlData:ControlData; var scale9Grid:Rectangle; var diff:Number; var numBorderBitmaps:int; var i:int; var lastXDim:Number; var floorLastXDim:Number; var lastYDim:Number; var floorLastYDim:Number; var newRect:Rectangle; var dispObj = _arg1; dCopy = new (dispObj["constructor"]); skin_mc.addChild(dCopy); ctrlData = new ControlData(this, dCopy, null, -1); ctrlDataDict[dCopy] = ctrlData; ctrlData.avatar = dispObj; customClips.push(dCopy); if (dispObj.name == "border_mc"){ border_mc = dCopy; try { borderCopy = (ctrlData.avatar["colorMe"]) ? new Sprite() : null; } catch(re:ReferenceError) { borderCopy = null; }; if (borderCopy != null){ border_mc.visible = false; scale9Grid = border_mc.scale9Grid; scale9Grid.x = Math.round(scale9Grid.x); scale9Grid.y = Math.round(scale9Grid.y); scale9Grid.width = Math.round(scale9Grid.width); diff = ((scale9Grid.x + scale9Grid.width) - border_mc.scale9Grid.right); if (diff > 0.5){ scale9Grid.width--; } else { if (diff < -0.5){ scale9Grid.width++; }; }; scale9Grid.height = Math.round(scale9Grid.height); diff = ((scale9Grid.y + scale9Grid.height) - border_mc.scale9Grid.bottom); if (diff > 0.5){ scale9Grid.height--; } else { if (diff < -0.5){ scale9Grid.height++; }; }; if (scale9Grid != null){ borderScale9Rects = new Array(); lastXDim = (border_mc.width - (scale9Grid.x + scale9Grid.width)); floorLastXDim = Math.floor(lastXDim); if ((lastXDim - floorLastXDim) < 0.05){ lastXDim = floorLastXDim; } else { lastXDim = (floorLastXDim + 1); }; lastYDim = (border_mc.height - (scale9Grid.y + scale9Grid.height)); floorLastYDim = Math.floor(lastYDim); if ((lastYDim - floorLastYDim) < 0.05){ lastYDim = floorLastYDim; } else { lastYDim = (floorLastYDim + 1); }; newRect = new Rectangle(0, 0, scale9Grid.x, scale9Grid.y); borderScale9Rects.push(((((newRect.width < 1)) || ((newRect.height < 1)))) ? null : newRect); newRect = new Rectangle(scale9Grid.x, 0, scale9Grid.width, scale9Grid.y); borderScale9Rects.push(((((newRect.width < 1)) || ((newRect.height < 1)))) ? null : newRect); newRect = new Rectangle((scale9Grid.x + scale9Grid.width), 0, lastXDim, scale9Grid.y); borderScale9Rects.push(((((newRect.width < 1)) || ((newRect.height < 1)))) ? null : newRect); newRect = new Rectangle(0, scale9Grid.y, scale9Grid.x, scale9Grid.height); borderScale9Rects.push(((((newRect.width < 1)) || ((newRect.height < 1)))) ? null : newRect); newRect = new Rectangle(scale9Grid.x, scale9Grid.y, scale9Grid.width, scale9Grid.height); borderScale9Rects.push(((((newRect.width < 1)) || ((newRect.height < 1)))) ? null : newRect); newRect = new Rectangle((scale9Grid.x + scale9Grid.width), scale9Grid.y, lastXDim, scale9Grid.height); borderScale9Rects.push(((((newRect.width < 1)) || ((newRect.height < 1)))) ? null : newRect); newRect = new Rectangle(0, (scale9Grid.y + scale9Grid.height), scale9Grid.x, lastYDim); borderScale9Rects.push(((((newRect.width < 1)) || ((newRect.height < 1)))) ? null : newRect); newRect = new Rectangle(scale9Grid.x, (scale9Grid.y + scale9Grid.height), scale9Grid.width, lastYDim); borderScale9Rects.push(((((newRect.width < 1)) || ((newRect.height < 1)))) ? null : newRect); newRect = new Rectangle((scale9Grid.x + scale9Grid.width), (scale9Grid.y + scale9Grid.height), lastXDim, lastYDim); borderScale9Rects.push(((((newRect.width < 1)) || ((newRect.height < 1)))) ? null : newRect); i = 0; while (i < borderScale9Rects.length) { if (borderScale9Rects[i] != null){ break; }; i = (i + 1); }; if (i >= borderScale9Rects.length){ borderScale9Rects = null; }; }; numBorderBitmaps = ((borderScale9Rects)==null) ? 1 : 9; i = 0; while (i < numBorderBitmaps) { if ((((borderScale9Rects == null)) || (!((borderScale9Rects[i] == null))))){ borderCopy.addChild(new Bitmap()); }; i = (i + 1); }; skin_mc.addChild(borderCopy); borderPrevRect = null; }; }; } public function get fullScreenSkinDelay():int{ return (_skinAutoHideMotionTimeout); } flvplayback_internal function doBufferingDelay(_arg1:TimerEvent):void{ var _local2:int; _bufferingDelayTimer.reset(); _local2 = _vc.activeVideoPlayerIndex; _vc.activeVideoPlayerIndex = _vc.visibleVideoPlayerIndex; if (_vc.state == VideoState.BUFFERING){ _bufferingOn = true; handleIVPEvent(new VideoEvent(VideoEvent.STATE_CHANGE, false, false, VideoState.BUFFERING, NaN, _vc.visibleVideoPlayerIndex)); }; _vc.activeVideoPlayerIndex = _local2; } flvplayback_internal function volumeBarListener(_arg1:TimerEvent):void{ var _local2:Sprite; var _local3:ControlData; var _local4:Number; var _local5:Boolean; _local2 = controls[VOLUME_BAR]; if (_local2 == null){ return; }; _local3 = ctrlDataDict[_local2]; calcPercentageFromHandle(_local2); _local4 = _local3.percentage; _local5 = (_arg1 == null); if (_local5){ _volumeBarTimer.stop(); _vc.addEventListener(SoundEvent.SOUND_UPDATE, handleSoundEvent); }; if (((((((((_local5) || ((_volumeBarScrubTolerance <= 0)))) || ((Math.abs((_local4 - _lastVolumePos)) > _volumeBarScrubTolerance)))) || ((_local4 < _volumeBarScrubTolerance)))) || ((_local4 > (100 - _volumeBarScrubTolerance))))){ if (_local4 != _lastVolumePos){ if (_isMuted){ cachedSoundLevel = (_local4 / 100); } else { _vc.volume = (_local4 / 100); }; _lastVolumePos = _local4; }; }; } public function get visible():Boolean{ return (__visible); } flvplayback_internal function fixUpBar(_arg1:DisplayObject, _arg2:String, _arg3:DisplayObject, _arg4:String):void{ var ctrlData:ControlData; var bar:DisplayObject; var barData:ControlData; var definitionHolder = _arg1; var propPrefix = _arg2; var ctrl = _arg3; var name = _arg4; ctrlData = ctrlDataDict[ctrl]; if (ctrlData[name] != null){ return; }; try { bar = ctrl[name]; } catch(re:ReferenceError) { bar = null; }; if (bar == null){ try { bar = createSkin(definitionHolder, (propPrefix + "LinkageID")); } catch(ve:VideoError) { bar = null; }; if (bar == null){ return; }; if (ctrl.parent != null){ if (getBooleanPropSafe(ctrl, (propPrefix + "Below"))){ ctrl.parent.addChildAt(bar, ctrl.parent.getChildIndex(ctrl)); } else { ctrl.parent.addChild(bar); }; }; }; ctrlData[name] = bar; barData = ctrlDataDict[bar]; if (barData == null){ barData = new ControlData(this, bar, ctrl, -1); ctrlDataDict[bar] = barData; }; } public function get volumeBarInterval():Number{ return (_volumeBarTimer.delay); } public function get bufferingBarHidesAndDisablesOthers():Boolean{ return (_bufferingBarHides); } flvplayback_internal function calcLayoutControl(_arg1:DisplayObject):Rectangle{ var rect:Rectangle; var ctrlData:ControlData; var anchorRight:Boolean; var anchorLeft:Boolean; var anchorTop:Boolean; var anchorBottom:Boolean; var ctrl = _arg1; rect = new Rectangle(); if (ctrl == null){ return (rect); }; ctrlData = ctrlDataDict[ctrl]; if (ctrlData == null){ return (rect); }; if (ctrlData.avatar == null){ return (rect); }; anchorRight = false; anchorLeft = true; anchorTop = false; anchorBottom = true; try { anchorRight = ctrlData.avatar["anchorRight"]; } catch(re1:ReferenceError) { anchorRight = false; }; try { anchorLeft = ctrlData.avatar["anchorLeft"]; } catch(re1:ReferenceError) { anchorLeft = true; }; try { anchorTop = ctrlData.avatar["anchorTop"]; } catch(re1:ReferenceError) { anchorTop = false; }; try { anchorBottom = ctrlData.avatar["anchorBottom"]; } catch(re1:ReferenceError) { anchorBottom = true; }; if (anchorRight){ if (anchorLeft){ rect.x = ((ctrlData.avatar.x - placeholderLeft) + videoLeft); rect.width = ((((ctrlData.avatar.x + ctrlData.avatar.width) - placeholderRight) + videoRight) - rect.x); ctrlData.origWidth = NaN; } else { rect.x = ((ctrlData.avatar.x - placeholderRight) + videoRight); rect.width = ctrl.width; }; } else { rect.x = ((ctrlData.avatar.x - placeholderLeft) + videoLeft); rect.width = ctrl.width; }; if (anchorTop){ if (anchorBottom){ rect.y = ((ctrlData.avatar.y - placeholderTop) + videoTop); rect.height = ((((ctrlData.avatar.y + ctrlData.avatar.height) - placeholderBottom) + videoBottom) - rect.y); ctrlData.origHeight = NaN; } else { rect.y = ((ctrlData.avatar.y - placeholderTop) + videoTop); rect.height = ctrl.height; }; } else { rect.y = ((ctrlData.avatar.y - placeholderBottom) + videoBottom); rect.height = ctrl.height; }; try { if ((ctrl["layoutSelf"] is Function)){ rect = ctrl["layoutSelf"](rect); }; } catch(re3:ReferenceError) { }; return (rect); } flvplayback_internal function skinFadeMore(_arg1:TimerEvent):void{ var _local2:Number; if (((((!(_skinFadingIn)) && ((skin_mc.alpha <= 0.5)))) || (((_skinFadingIn) && ((skin_mc.alpha >= 0.95)))))){ skin_mc.visible = _skinFadingIn; skin_mc.alpha = 1; _skinFadingTimer.stop(); } else { _local2 = ((getTimer() - _skinFadeStartTime) / _skinFadingMaxTime); if (!_skinFadingIn){ _local2 = (1 - _local2); }; if (_local2 < 0){ _local2 = 0; } else { if (_local2 > 1){ _local2 = 1; }; }; skin_mc.alpha = _local2; }; } flvplayback_internal function bitmapCopyBorder():void{ var _local1:Rectangle; var _local2:BitmapData; var _local3:Matrix; var _local4:Number; var _local5:Number; var _local6:Rectangle; var _local7:int; var _local8:Number; var _local9:Number; var _local10:int; var _local11:Bitmap; var _local12:Number; var _local13:Number; if ((((border_mc == null)) || ((borderCopy == null)))){ return; }; _local1 = border_mc.getBounds(skin_mc); if ((((borderPrevRect == null)) || (!(borderPrevRect.equals(_local1))))){ borderCopy.x = _local1.x; borderCopy.y = _local1.y; _local3 = new Matrix(border_mc.scaleX, 0, 0, border_mc.scaleY, 0, 0); if (borderScale9Rects == null){ _local2 = new BitmapData(_local1.width, _local1.height, true, 0); _local2.draw(border_mc, _local3, borderColorTransform); Bitmap(borderCopy.getChildAt(0)).bitmapData = _local2; } else { _local4 = 0; _local5 = 0; _local6 = new Rectangle(0, 0, 0, 0); _local7 = 0; _local8 = 0; if (borderScale9Rects[3] != null){ _local8 = (_local8 + borderScale9Rects[3].width); }; if (borderScale9Rects[5] != null){ _local8 = (_local8 + borderScale9Rects[5].width); }; _local9 = 0; if (borderScale9Rects[1] != null){ _local9 = (_local9 + borderScale9Rects[1].height); }; if (borderScale9Rects[7] != null){ _local9 = (_local9 + borderScale9Rects[7].height); }; _local10 = 0; while (_local10 < borderScale9Rects.length) { if ((_local10 % 3) == 0){ _local4 = 0; _local5 = (_local5 + _local6.height); }; if (borderScale9Rects[_local10] == null){ } else { _local6 = Rectangle(borderScale9Rects[_local10]).clone(); _local3.a = 1; if ((((((_local10 == 1)) || ((_local10 == 4)))) || ((_local10 == 7)))){ _local12 = ((_local1.width - _local8) / _local6.width); _local6.x = (_local6.x * _local12); _local6.width = (_local6.width * _local12); _local6.width = Math.round(_local6.width); _local3.a = (_local3.a * _local12); }; _local3.tx = -(_local6.x); _local6.x = 0; _local3.d = 1; if ((((_local10 >= 3)) && ((_local10 <= 5)))){ _local13 = ((_local1.height - _local9) / _local6.height); _local6.y = (_local6.y * _local13); _local6.height = (_local6.height * _local13); _local6.height = Math.round(_local6.height); _local3.d = (_local3.d * _local13); }; _local3.ty = -(_local6.y); _local6.y = 0; _local2 = new BitmapData(_local6.width, _local6.height, true, 0); _local2.draw(border_mc, _local3, borderColorTransform, null, _local6, false); _local11 = Bitmap(borderCopy.getChildAt(_local7)); _local7++; _local11.bitmapData = _local2; _local11.x = _local4; _local11.y = _local5; _local4 = (_local4 + _local6.width); }; _local10++; }; }; borderPrevRect = _local1; }; } flvplayback_internal function resetPlayPause():void{ var _local1:int; if (controls[PLAY_PAUSE_BUTTON] == undefined){ return; }; _local1 = PAUSE_BUTTON; while (_local1 <= PLAY_BUTTON) { removeButtonListeners(controls[_local1]); delete ctrlDataDict[controls[_local1]]; delete controls[_local1]; _local1++; }; delete ctrlDataDict[controls[PLAY_PAUSE_BUTTON]]; delete controls[PLAY_PAUSE_BUTTON]; } public function setControl(_arg1:int, _arg2:Sprite):void{ var ctrlData:ControlData; var index = _arg1; var ctrl = _arg2; if (ctrl == controls[index]){ return; }; switch (index){ case PAUSE_BUTTON: case PLAY_BUTTON: resetPlayPause(); break; case PLAY_PAUSE_BUTTON: if ((((ctrl == null)) || (!((ctrl.parent == skin_mc))))){ resetPlayPause(); }; if (ctrl != null){ setControl(PAUSE_BUTTON, Sprite(ctrl.getChildByName("pause_mc"))); setControl(PLAY_BUTTON, Sprite(ctrl.getChildByName("play_mc"))); }; break; case FULL_SCREEN_BUTTON: if (ctrl != null){ setControl(FULL_SCREEN_ON_BUTTON, Sprite(ctrl.getChildByName("on_mc"))); setControl(FULL_SCREEN_OFF_BUTTON, Sprite(ctrl.getChildByName("off_mc"))); }; break; case MUTE_BUTTON: if (ctrl != null){ setControl(MUTE_ON_BUTTON, Sprite(ctrl.getChildByName("on_mc"))); setControl(MUTE_OFF_BUTTON, Sprite(ctrl.getChildByName("off_mc"))); }; break; }; if (controls[index] != null){ try { delete controls[index]["uiMgr"]; } catch(re:ReferenceError) { }; if (index < NUM_BUTTONS){ removeButtonListeners(controls[index]); }; delete ctrlDataDict[controls[index]]; delete controls[index]; }; if (ctrl == null){ return; }; ctrlData = ctrlDataDict[ctrl]; if (ctrlData == null){ ctrlData = new ControlData(this, ctrl, null, index); ctrlDataDict[ctrl] = ctrlData; } else { ctrlData.index = index; }; if (index >= NUM_BUTTONS){ controls[index] = ctrl; switch (index){ case SEEK_BAR: addBarControl(ctrl); break; case VOLUME_BAR: addBarControl(ctrl); ctrlData.percentage = (_vc.volume * 100); break; case BUFFERING_BAR: if (ctrl.parent == skin_mc){ finishAddBufferingBar(); } else { ctrl.addEventListener(Event.ENTER_FRAME, finishAddBufferingBar); }; break; }; setEnabledAndVisibleForState(index, _vc.state); } else { controls[index] = ctrl; addButtonControl(ctrl); }; } flvplayback_internal function createSkin(_arg1:DisplayObject, _arg2:String):DisplayObject{ var stateSkinDesc:*; var theClass:Class; var definitionHolder = _arg1; var skinName = _arg2; try { stateSkinDesc = definitionHolder[skinName]; if ((stateSkinDesc is String)){ try { theClass = Class(definitionHolder.loaderInfo.applicationDomain.getDefinition(stateSkinDesc)); } catch(err1:Error) { theClass = Class(getDefinitionByName(stateSkinDesc)); }; return (DisplayObject(new (theClass))); } else { if ((stateSkinDesc is Class)){ return (new (stateSkinDesc)); } else { if ((stateSkinDesc is DisplayObject)){ return (stateSkinDesc); }; }; }; } catch(err2:Error) { throw (new VideoError(VideoError.MISSING_SKIN_STYLE, skinName)); }; return (null); } flvplayback_internal function addButtonControl(_arg1:Sprite):void{ var _local2:ControlData; var _local3:int; if (_arg1 == null){ return; }; _local2 = ctrlDataDict[_arg1]; _arg1.mouseChildren = false; _local3 = _vc.activeVideoPlayerIndex; _vc.activeVideoPlayerIndex = _vc.visibleVideoPlayerIndex; _local2.state = NORMAL_STATE; setEnabledAndVisibleForState(_local2.index, _vc.state); _arg1.addEventListener(MouseEvent.ROLL_OVER, handleButtonEvent); _arg1.addEventListener(MouseEvent.ROLL_OUT, handleButtonEvent); _arg1.addEventListener(MouseEvent.MOUSE_DOWN, handleButtonEvent); _arg1.addEventListener(MouseEvent.CLICK, handleButtonEvent); if (_arg1.parent == skin_mc){ skinButtonControl(_arg1); } else { _arg1.addEventListener(Event.ENTER_FRAME, skinButtonControl); }; _vc.activeVideoPlayerIndex = _local3; } flvplayback_internal function hookUpCustomComponents():void{ var searchHash:Object; var doTheSearch:Boolean; var i:int; var dispObj:DisplayObject; var name:String; var index:int; var ctrl:Sprite; searchHash = new Object(); doTheSearch = false; i = 0; while (i < NUM_CONTROLS) { if (controls[i] == null){ searchHash[customComponentClassNames[i]] = i; doTheSearch = true; }; i = (i + 1); }; if (!doTheSearch){ return; }; i = 0; while (i < _vc.parent.numChildren) { dispObj = _vc.parent.getChildAt(i); name = getQualifiedClassName(dispObj); if (searchHash[name] != undefined){ if (typeof(searchHash[name]) == "number"){ index = int(searchHash[name]); try { ctrl = Sprite(dispObj); if ((((((index >= NUM_BUTTONS)) || ((ctrl["placeholder_mc"] is DisplayObject)))) && ((ctrl["uiMgr"] == null)))){ setControl(index, ctrl); searchHash[name] = ctrl; }; } catch(err:Error) { }; }; }; i = (i + 1); }; } flvplayback_internal function positionHandle(_arg1:Sprite):void{ var _local2:ControlData; var _local3:Sprite; var _local4:ControlData; var _local5:Number; var _local6:Number; if (_arg1 == null){ return; }; if ((((_arg1["positionHandle"] is Function)) && (_arg1["positionHandle"]()))){ return; }; _local2 = ctrlDataDict[_arg1]; _local3 = _local2.handle_mc; if (_local3 == null){ return; }; _local4 = ctrlDataDict[_local3]; _local5 = (isNaN(_local2.origWidth)) ? _arg1.width : _local2.origWidth; _local6 = ((_local5 - _local4.rightMargin) - _local4.leftMargin); _local3.x = ((_arg1.x + _local4.leftMargin) + ((_local6 * _local2.percentage) / 100)); _local3.y = (_arg1.y + _local4.origY); if (_local2.fullness_mc != null){ positionBar(_arg1, "fullness", _local2.percentage); }; } flvplayback_internal function exitFullScreenTakeOver():void{ var fullScreenBG:Sprite; var cacheActiveIndex:int; var i:int; var vp:VideoPlayer; if (cacheFLVPlaybackParent == null){ return; }; _vc.removeEventListener(Event.ADDED_TO_STAGE, handleEvent); _vc.stage.removeEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreenEvent); try { if (_fullScreenAccel){ _vc.stage.fullScreenSourceRect = new Rectangle(0, 0, -1, -1); } else { _vc.stage.align = cacheStageAlign; _vc.stage.scaleMode = cacheStageScaleMode; }; fullScreenBG = Sprite(_vc.getChildByName("fullScreenBG")); if (fullScreenBG != null){ _vc.removeChild(fullScreenBG); }; if (_vc.parent != cacheFLVPlaybackParent){ cacheFLVPlaybackParent.addChildAt(_vc, cacheFLVPlaybackIndex); } else { cacheFLVPlaybackParent.setChildIndex(_vc, cacheFLVPlaybackIndex); }; cacheActiveIndex = _vc.activeVideoPlayerIndex; i = 0; while (i < _vc.videoPlayers.length) { vp = (_vc.videoPlayers[i] as VideoPlayer); if (vp != null){ _vc.activeVideoPlayerIndex = i; if (cacheFLVPlaybackScaleMode[i] != undefined){ _vc.scaleMode = cacheFLVPlaybackScaleMode[i]; }; if (cacheFLVPlaybackAlign[i]){ _vc.align = cacheFLVPlaybackAlign[i]; }; }; i = (i + 1); }; _vc.activeVideoPlayerIndex = cacheActiveIndex; _vc.registrationX = cacheFLVPlaybackLocation.x; _vc.registrationY = cacheFLVPlaybackLocation.y; _vc.setSize(cacheFLVPlaybackLocation.width, cacheFLVPlaybackLocation.height); } catch(err:Error) { }; _vc.addEventListener(Event.ADDED_TO_STAGE, handleEvent); _vc.stage.addEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreenEvent); _fullScreen = false; _fullScreenAccel = false; cacheStageAlign = null; cacheStageScaleMode = null; cacheFLVPlaybackParent = null; cacheFLVPlaybackIndex = 0; cacheFLVPlaybackLocation = null; cacheFLVPlaybackScaleMode = null; cacheFLVPlaybackAlign = null; if (_skinAutoHide != cacheSkinAutoHide){ _skinAutoHide = cacheSkinAutoHide; setupSkinAutoHide(false); }; } flvplayback_internal function positionMaskedFill(_arg1:DisplayObject, _arg2:Number):void{ var ctrlData:ControlData; var fill:DisplayObject; var mask:DisplayObject; var fillData:ControlData; var maskData:ControlData; var slideReveal:Boolean; var maskSprite:Sprite; var barData:ControlData; var ctrl = _arg1; var percent = _arg2; if (ctrl == null){ return; }; ctrlData = ctrlDataDict[ctrl]; fill = ctrlData.fill_mc; if (fill == null){ return; }; mask = ctrlData.mask_mc; if (ctrlData.mask_mc == null){ try { var _local4 = ctrl["mask_mc"]; mask = _local4; ctrlData.mask_mc = _local4; } catch(re:ReferenceError) { ctrlData.mask_mc = null; }; if (ctrlData.mask_mc == null){ maskSprite = new Sprite(); _local4 = maskSprite; mask = _local4; ctrlData.mask_mc = _local4; maskSprite.graphics.beginFill(0xFFFFFF); maskSprite.graphics.drawRect(0, 0, 1, 1); maskSprite.graphics.endFill(); barData = ctrlDataDict[fill]; maskSprite.x = barData.origX; maskSprite.y = barData.origY; maskSprite.width = barData.origWidth; maskSprite.height = barData.origHeight; maskSprite.visible = false; fill.parent.addChild(maskSprite); fill.mask = maskSprite; }; if (ctrlData.mask_mc != null){ calcBarMargins(ctrl, "mask", true); }; }; fillData = ctrlDataDict[fill]; maskData = ctrlDataDict[mask]; try { slideReveal = fill["slideReveal"]; } catch(re:ReferenceError) { slideReveal = false; }; if (fill.parent == ctrl){ if (slideReveal){ fill.x = ((maskData.origX - fillData.origWidth) + ((fillData.origWidth * percent) / 100)); } else { mask.width = ((fillData.origWidth * percent) / 100); }; } else { if (fill.parent == ctrl.parent){ if (slideReveal){ mask.x = (ctrl.x + maskData.leftMargin); mask.y = (ctrl.y + maskData.topMargin); mask.width = ((ctrl.width - maskData.rightMargin) - maskData.leftMargin); mask.height = ((ctrl.height - maskData.topMargin) - maskData.bottomMargin); fill.x = ((mask.x - fillData.origWidth) + ((maskData.origWidth * percent) / 100)); fill.y = (ctrl.y + fillData.topMargin); } else { fill.x = (ctrl.x + fillData.leftMargin); fill.y = (ctrl.y + fillData.topMargin); mask.x = fill.x; mask.y = fill.y; mask.width = ((((ctrl.width - fillData.rightMargin) - fillData.leftMargin) * percent) / 100); mask.height = ((ctrl.height - fillData.topMargin) - fillData.bottomMargin); }; }; }; } flvplayback_internal function calcPercentageFromHandle(_arg1:Sprite):void{ var _local2:ControlData; var _local3:Sprite; var _local4:ControlData; var _local5:Number; var _local6:Number; var _local7:Number; if (_arg1 == null){ return; }; _local2 = ctrlDataDict[_arg1]; if ((((_arg1["calcPercentageFromHandle"] is Function)) && (_arg1["calcPercentageFromHandle"]()))){ if (_local2.percentage < 0){ _local2.percentage = 0; }; if (_local2.percentage > 100){ _local2.percentage = 100; }; return; }; _local3 = _local2.handle_mc; if (_local3 == null){ return; }; _local4 = ctrlDataDict[_local3]; _local5 = (isNaN(_local2.origWidth)) ? _arg1.width : _local2.origWidth; _local6 = ((_local5 - _local4.rightMargin) - _local4.leftMargin); _local7 = (_local3.x - (_arg1.x + _local4.leftMargin)); _local2.percentage = ((_local7 / _local6) * 100); if (_local2.percentage < 0){ _local2.percentage = 0; }; if (_local2.percentage > 100){ _local2.percentage = 100; }; if (_local2.fullness_mc != null){ positionBar(_arg1, "fullness", _local2.percentage); }; } flvplayback_internal function handleRelease(_arg1:int):void{ var _local2:int; _local2 = _vc.activeVideoPlayerIndex; _vc.activeVideoPlayerIndex = _vc.visibleVideoPlayerIndex; if (_arg1 == SEEK_BAR){ seekBarListener(null); } else { if (_arg1 == VOLUME_BAR){ volumeBarListener(null); }; }; stopHandleDrag(controls[_arg1]); _vc.activeVideoPlayerIndex = _local2; if (_arg1 == SEEK_BAR){ _vc._scrubFinish(); }; } flvplayback_internal function setTwoButtonHolderSkin(_arg1:int, _arg2:int, _arg3:String, _arg4:int, _arg5:String):Sprite{ var _local6:Sprite; var _local7:Sprite; var _local8:ControlData; _local7 = new Sprite(); _local8 = new ControlData(this, _local7, null, _arg1); ctrlDataDict[_local7] = _local8; skin_mc.addChild(_local7); _local6 = setupButtonSkin(_arg2); _local6.name = _arg3; _local6.visible = true; _local7.addChild(_local6); _local6 = setupButtonSkin(_arg4); _local6.name = _arg5; _local6.visible = false; _local7.addChild(_local6); return (_local7); } flvplayback_internal function skinAutoHideHitTest(_arg1:TimerEvent, _arg2:Boolean=true):void{ var visibleVP:VideoPlayer; var hit:Boolean; var e = _arg1; var doFade = _arg2; try { if (!__visible){ skin_mc.visible = false; } else { if (_vc.stage != null){ visibleVP = _vc.getVideoPlayer(_vc.visibleVideoPlayerIndex); hit = visibleVP.hitTestPoint(_vc.stage.mouseX, _vc.stage.mouseY, true); if (((((_fullScreen) && (_fullScreenTakeOver))) && (!((e == null))))){ if ((((_vc.stage.mouseX == _skinAutoHideMouseX)) && ((_vc.stage.mouseY == _skinAutoHideMouseY)))){ if ((getTimer() - _skinAutoHideLastMotionTime) > _skinAutoHideMotionTimeout){ hit = false; }; } else { _skinAutoHideLastMotionTime = getTimer(); _skinAutoHideMouseX = _vc.stage.mouseX; _skinAutoHideMouseY = _vc.stage.mouseY; }; }; if (((!(hit)) && (!((border_mc == null))))){ hit = border_mc.hitTestPoint(_vc.stage.mouseX, _vc.stage.mouseY, true); if (((((hit) && (_fullScreen))) && (_fullScreenTakeOver))){ _skinAutoHideLastMotionTime = getTimer(); }; }; if (((!(doFade)) || ((_skinFadingMaxTime <= 0)))){ _skinFadingTimer.stop(); skin_mc.visible = hit; skin_mc.alpha = 1; } else { if (((((((hit) && (skin_mc.visible))) && (((!(_skinFadingTimer.running)) || (_skinFadingIn))))) || (((!(hit)) && (((!(skin_mc.visible)) || (((_skinFadingTimer.running) && (!(_skinFadingIn)))))))))){ } else { _skinFadingTimer.stop(); _skinFadingIn = hit; if (((_skinFadingIn) && ((skin_mc.alpha == 1)))){ skin_mc.alpha = 0; }; _skinFadeStartTime = getTimer(); _skinFadingTimer.start(); skin_mc.visible = true; }; }; }; }; } catch(se:SecurityError) { _skinAutoHideTimer.stop(); _skinFadingTimer.stop(); skin_mc.visible = __visible; skin_mc.alpha = 1; }; } public function set seekBarInterval(_arg1:Number):void{ if (_seekBarTimer.delay == _arg1){ return; }; _seekBarTimer.delay = _arg1; } flvplayback_internal function layoutControl(_arg1:DisplayObject):void{ var _local2:ControlData; var _local3:Rectangle; var _local4:Sprite; var _local5:Rectangle; if (_arg1 == null){ return; }; _local2 = ctrlDataDict[_arg1]; if (_local2 == null){ return; }; if (_local2.avatar == null){ return; }; _local3 = calcLayoutControl(_arg1); _arg1.x = _local3.x; _arg1.y = _local3.y; _arg1.width = _local3.width; _arg1.height = _local3.height; switch (_local2.index){ case SEEK_BAR: case VOLUME_BAR: if (((!((_local2.hit_mc == null))) && ((_local2.hit_mc.parent == skin_mc)))){ _local4 = _local2.hit_mc; _local5 = calcLayoutControl(_local4); _local4.x = _local5.x; _local4.y = _local5.y; _local4.width = _local5.width; _local4.height = _local5.height; }; if (_local2.progress_mc != null){ if (isNaN(_progressPercent)){ _progressPercent = (_vc.isRTMP) ? 100 : 0; }; positionBar(Sprite(_arg1), "progress", _progressPercent); }; positionHandle(Sprite(_arg1)); break; case BUFFERING_BAR: positionMaskedFill(_arg1, 100); break; }; } public function set fullScreenSkinDelay(_arg1:int):void{ _skinAutoHideMotionTimeout = _arg1; } flvplayback_internal function captureMouseEvent(_arg1:MouseEvent):void{ _arg1.stopPropagation(); } flvplayback_internal function handleMouseUp(_arg1:MouseEvent):void{ var _local2:Sprite; var _local3:ControlData; _local2 = controls[mouseCaptureCtrl]; if (_local2 != null){ _local3 = ctrlDataDict[_local2]; _local3.state = (_local2.hitTestPoint(_arg1.stageX, _arg1.stageY, true)) ? OVER_STATE : NORMAL_STATE; skinButtonControl(_local2); switch (mouseCaptureCtrl){ case SEEK_BAR_HANDLE: case SEEK_BAR_HIT: handleRelease(SEEK_BAR); break; case VOLUME_BAR_HANDLE: case VOLUME_BAR_HIT: handleRelease(VOLUME_BAR); break; }; }; _arg1.currentTarget.removeEventListener(MouseEvent.MOUSE_DOWN, captureMouseEvent, true); _arg1.currentTarget.removeEventListener(MouseEvent.MOUSE_OUT, captureMouseEvent, true); _arg1.currentTarget.removeEventListener(MouseEvent.MOUSE_OVER, captureMouseEvent, true); _arg1.currentTarget.removeEventListener(MouseEvent.MOUSE_UP, handleMouseUp); _arg1.currentTarget.removeEventListener(MouseEvent.ROLL_OUT, captureMouseEvent, true); _arg1.currentTarget.removeEventListener(MouseEvent.ROLL_OVER, captureMouseEvent, true); } public function set visible(_arg1:Boolean):void{ if (__visible == _arg1){ return; }; __visible = _arg1; if (!__visible){ skin_mc.visible = false; } else { setupSkinAutoHide(false); }; } public function get bufferingDelayInterval():Number{ return (_bufferingDelayTimer.delay); } public function set fullScreenBackgroundColor(_arg1:uint):void{ if (_fullScreenBgColor != _arg1){ _fullScreenBgColor = _arg1; if (_vc){ }; }; } public function get fullScreenTakeOver():Boolean{ return (_fullScreenTakeOver); } public function set skin(_arg1:String):void{ var _local2:String; if (_arg1 == null){ removeSkin(); _skin = null; _skinReady = true; } else { _local2 = String(_arg1); if (_arg1 == _skin){ return; }; removeSkin(); _skin = String(_arg1); _skinReady = (_skin == ""); if (!_skinReady){ downloadSkin(); }; }; } public function set volumeBarInterval(_arg1:Number):void{ if (_volumeBarTimer.delay == _arg1){ return; }; _volumeBarTimer.delay = _arg1; } flvplayback_internal function setSkin(_arg1:int, _arg2:DisplayObject):void{ var _local3:Sprite; var _local4:ControlData; var _local5:String; if (_arg1 >= NUM_CONTROLS){ return; }; if (_arg1 < NUM_BUTTONS){ _local3 = setupButtonSkin(_arg1); skin_mc.addChild(_local3); _local4 = ctrlDataDict[_local3]; } else { switch (_arg1){ case PLAY_PAUSE_BUTTON: _local3 = setTwoButtonHolderSkin(_arg1, PLAY_BUTTON, "play_mc", PAUSE_BUTTON, "pause_mc"); _local4 = ctrlDataDict[_local3]; break; case FULL_SCREEN_BUTTON: _local3 = setTwoButtonHolderSkin(_arg1, FULL_SCREEN_ON_BUTTON, "on_mc", FULL_SCREEN_OFF_BUTTON, "off_mc"); _local4 = ctrlDataDict[_local3]; break; case MUTE_BUTTON: _local3 = setTwoButtonHolderSkin(_arg1, MUTE_ON_BUTTON, "on_mc", MUTE_OFF_BUTTON, "off_mc"); _local4 = ctrlDataDict[_local3]; break; case SEEK_BAR: case VOLUME_BAR: _local5 = skinClassPrefixes[_arg1]; _local3 = Sprite(createSkin(skinTemplate, _local5)); if (_local3 != null){ skin_mc.addChild(_local3); _local4 = new ControlData(this, _local3, null, _arg1); ctrlDataDict[_local3] = _local4; _local4.progress_mc = setupBarSkinPart(_local3, _arg2, skinTemplate, (_local5 + "Progress"), "progress_mc"); _local4.fullness_mc = setupBarSkinPart(_local3, _arg2, skinTemplate, (_local5 + "Fullness"), "fullness_mc"); _local4.hit_mc = Sprite(setupBarSkinPart(_local3, _arg2, skinTemplate, (_local5 + "Hit"), "hit_mc")); _local4.handle_mc = Sprite(setupBarSkinPart(_local3, _arg2, skinTemplate, (_local5 + "Handle"), "handle_mc", true)); _local3.width = _arg2.width; _local3.height = _arg2.height; }; break; case BUFFERING_BAR: _local5 = skinClassPrefixes[_arg1]; _local3 = Sprite(createSkin(skinTemplate, _local5)); if (_local3 != null){ skin_mc.addChild(_local3); _local4 = new ControlData(this, _local3, null, _arg1); ctrlDataDict[_local3] = _local4; _local4.fill_mc = setupBarSkinPart(_local3, _arg2, skinTemplate, (_local5 + "Fill"), "fill_mc"); _local3.width = _arg2.width; _local3.height = _arg2.height; }; break; }; }; _local4.avatar = _arg2; ctrlDataDict[_local3] = _local4; delayedControls[_arg1] = _local3; } public function set bufferingBarHidesAndDisablesOthers(_arg1:Boolean):void{ _bufferingBarHides = _arg1; } flvplayback_internal function handleSoundEvent(_arg1:SoundEvent):void{ var _local2:Sprite; var _local3:ControlData; if (((_isMuted) && ((_arg1.soundTransform.volume > 0)))){ _isMuted = false; setEnabledAndVisibleForState(MUTE_OFF_BUTTON, VideoState.PLAYING); skinButtonControl(controls[MUTE_OFF_BUTTON]); setEnabledAndVisibleForState(MUTE_ON_BUTTON, VideoState.PLAYING); skinButtonControl(controls[MUTE_ON_BUTTON]); }; _local2 = controls[VOLUME_BAR]; if (_local2 != null){ _local3 = ctrlDataDict[_local2]; _local3.percentage = ((_isMuted) ? cachedSoundLevel : _arg1.soundTransform.volume * 100); if (_local3.percentage < 0){ _local3.percentage = 0; } else { if (_local3.percentage > 100){ _local3.percentage = 100; }; }; positionHandle(_local2); }; } flvplayback_internal function stopHandleDrag(_arg1:Sprite):void{ var ctrlData:ControlData; var handle:Sprite; var ctrl = _arg1; if (ctrl == null){ return; }; ctrlData = ctrlDataDict[ctrl]; try { if ((((ctrl["stopHandleDrag"] is Function)) && (ctrl["stopHandleDrag"]()))){ ctrlData.isDragging = false; return; }; } catch(re:ReferenceError) { }; handle = ctrlData.handle_mc; if (handle == null){ return; }; handle.stopDrag(); ctrlData.isDragging = false; } public function set skinBackgroundAlpha(_arg1:Number):void{ if (borderAlpha != _arg1){ borderAlpha = _arg1; borderColorTransform.alphaOffset = (0xFF * _arg1); borderPrevRect = null; layoutSkin(); }; } public function getControl(_arg1:int):Sprite{ return (controls[_arg1]); } public function set skinScaleMaximum(_arg1:Number):void{ _skinScaleMaximum = _arg1; } flvplayback_internal function handleLoad(_arg1:Event):void{ var i:int; var dispObj:DisplayObject; var index:Number; var e = _arg1; try { skin_mc = new Sprite(); if (e != null){ skinTemplate = Sprite(skinLoader.content); }; layout_mc = skinTemplate; customClips = new Array(); delayedControls = new Array(); i = 0; while (i < layout_mc.numChildren) { dispObj = layout_mc.getChildAt(i); index = layoutNameToIndexMappings[dispObj.name]; if (!isNaN(index)){ setSkin(int(index), dispObj); } else { if (dispObj.name != "video_mc"){ setCustomClip(dispObj); }; }; i = (i + 1); }; skinLoadDelayCount = 0; _vc.addEventListener(Event.ENTER_FRAME, finishLoad); } catch(err:Error) { _vc.skinError(err.message); removeSkin(); }; } flvplayback_internal function calcBarMargins(_arg1:DisplayObject, _arg2:String, _arg3:Boolean):void{ var ctrlData:ControlData; var bar:DisplayObject; var barData:ControlData; var ctrl = _arg1; var type = _arg2; var symmetricMargins = _arg3; if (ctrl == null){ return; }; ctrlData = ctrlDataDict[ctrl]; bar = ctrlData[(type + "_mc")]; if (bar == null){ try { bar = ctrl[(type + "_mc")]; } catch(re:ReferenceError) { bar = null; }; if (bar == null){ return; }; ctrlData[(type + "_mc")] = bar; }; barData = ctrlDataDict[bar]; if (barData == null){ barData = new ControlData(this, bar, ctrl, -1); ctrlDataDict[bar] = barData; }; barData.leftMargin = getNumberPropSafe(ctrl, (type + "LeftMargin")); if (((isNaN(barData.leftMargin)) && ((bar.parent == ctrl.parent)))){ barData.leftMargin = (bar.x - ctrl.x); }; barData.rightMargin = getNumberPropSafe(ctrl, (type + "RightMargin")); if (isNaN(barData.rightMargin)){ if (symmetricMargins){ barData.rightMargin = barData.leftMargin; } else { if (bar.parent == ctrl.parent){ barData.rightMargin = (((ctrl.width - bar.width) - bar.x) + ctrl.x); }; }; }; barData.topMargin = getNumberPropSafe(ctrl, (type + "TopMargin")); if (((isNaN(barData.topMargin)) && ((bar.parent == ctrl.parent)))){ barData.topMargin = (bar.y - ctrl.y); }; barData.bottomMargin = getNumberPropSafe(ctrl, (type + "BottomMargin")); if (isNaN(barData.bottomMargin)){ if (symmetricMargins){ barData.bottomMargin = barData.topMargin; } else { if (bar.parent == ctrl.parent){ barData.bottomMargin = (((ctrl.height - bar.height) - bar.y) + ctrl.y); }; }; }; barData.origX = getNumberPropSafe(ctrl, (type + "X")); if (isNaN(barData.origX)){ if (bar.parent == ctrl.parent){ barData.origX = (bar.x - ctrl.x); } else { if (bar.parent == ctrl){ barData.origX = bar.x; }; }; }; barData.origY = getNumberPropSafe(ctrl, (type + "Y")); if (isNaN(barData.origY)){ if (bar.parent == ctrl.parent){ barData.origY = (bar.y - ctrl.y); } else { if (bar.parent == ctrl){ barData.origY = bar.y; }; }; }; barData.origWidth = bar.width; barData.origHeight = bar.height; barData.origScaleX = bar.scaleX; barData.origScaleY = bar.scaleY; } public function set skinBackgroundColor(_arg1:uint):void{ if (borderColor != _arg1){ borderColor = _arg1; borderColorTransform.redOffset = ((borderColor >> 16) & 0xFF); borderColorTransform.greenOffset = ((borderColor >> 8) & 0xFF); borderColorTransform.blueOffset = (borderColor & 0xFF); borderPrevRect = null; layoutSkin(); }; } public function set volumeBarScrubTolerance(_arg1:Number):void{ _volumeBarScrubTolerance = _arg1; } flvplayback_internal function finishAddBufferingBar(_arg1:Event=null):void{ var _local2:Sprite; if (_arg1 != null){ _arg1.currentTarget.removeEventListener(Event.ENTER_FRAME, finishAddBufferingBar); }; _local2 = controls[BUFFERING_BAR]; calcBarMargins(_local2, "fill", true); fixUpBar(_local2, "fill", _local2, "fill_mc"); positionMaskedFill(_local2, 100); } flvplayback_internal function handleButtonEvent(_arg1:MouseEvent):void{ var ctrlData:ControlData; var topLevel:DisplayObject; var e = _arg1; ctrlData = ctrlDataDict[e.currentTarget]; switch (e.type){ case MouseEvent.ROLL_OVER: ctrlData.state = OVER_STATE; break; case MouseEvent.ROLL_OUT: ctrlData.state = NORMAL_STATE; break; case MouseEvent.MOUSE_DOWN: ctrlData.state = DOWN_STATE; mouseCaptureCtrl = ctrlData.index; switch (mouseCaptureCtrl){ case SEEK_BAR_HANDLE: case SEEK_BAR_HIT: case VOLUME_BAR_HANDLE: case VOLUME_BAR_HIT: dispatchMessage(ctrlData.index); break; }; topLevel = _vc.stage; try { topLevel.addEventListener(MouseEvent.MOUSE_DOWN, captureMouseEvent, true); } catch(se:SecurityError) { topLevel = _vc.root; topLevel.addEventListener(MouseEvent.MOUSE_DOWN, captureMouseEvent, true); }; topLevel.addEventListener(MouseEvent.MOUSE_OUT, captureMouseEvent, true); topLevel.addEventListener(MouseEvent.MOUSE_OVER, captureMouseEvent, true); topLevel.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp); topLevel.addEventListener(MouseEvent.ROLL_OUT, captureMouseEvent, true); topLevel.addEventListener(MouseEvent.ROLL_OVER, captureMouseEvent, true); break; case MouseEvent.CLICK: switch (mouseCaptureCtrl){ case SEEK_BAR_HANDLE: case SEEK_BAR_HIT: case VOLUME_BAR_HANDLE: case VOLUME_BAR_HIT: break; default: dispatchMessage(ctrlData.index); break; }; return; }; skinButtonControl(e.currentTarget); } flvplayback_internal function applySkinState(_arg1:ControlData, _arg2:DisplayObject):void{ if (_arg2 != _arg1.currentState_mc){ if (_arg1.currentState_mc != null){ _arg1.currentState_mc.visible = false; }; _arg1.currentState_mc = _arg2; _arg1.currentState_mc.visible = true; }; } flvplayback_internal function handleLoadErrorEvent(_arg1:ErrorEvent):void{ _skinReady = true; _vc.skinError(_arg1.toString()); } flvplayback_internal function addBarControl(_arg1:Sprite):void{ var _local2:ControlData; _local2 = ctrlDataDict[_arg1]; _local2.isDragging = false; _local2.percentage = 0; if ((((_arg1.parent == skin_mc)) && (!((skin_mc == null))))){ finishAddBarControl(_arg1); } else { _arg1.addEventListener(Event.REMOVED_FROM_STAGE, cleanupHandle); _arg1.addEventListener(Event.ENTER_FRAME, finishAddBarControl); }; } flvplayback_internal function handleEvent(_arg1:Event):void{ var e = _arg1; switch (e.type){ case Event.ADDED_TO_STAGE: _fullScreen = false; if (_vc.stage != null){ try { _fullScreen = (_vc.stage.displayState == StageDisplayState.FULL_SCREEN); _vc.stage.addEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreenEvent); } catch(se:SecurityError) { }; }; if (!_fullScreen){ _fullScreenAccel = false; }; setEnabledAndVisibleForState(FULL_SCREEN_OFF_BUTTON, VideoState.PLAYING); skinButtonControl(controls[FULL_SCREEN_OFF_BUTTON]); setEnabledAndVisibleForState(FULL_SCREEN_ON_BUTTON, VideoState.PLAYING); skinButtonControl(controls[FULL_SCREEN_ON_BUTTON]); if (((_fullScreen) && (_fullScreenTakeOver))){ enterFullScreenTakeOver(); } else { if (!_fullScreen){ exitFullScreenTakeOver(); }; }; layoutSkin(); setupSkinAutoHide(false); break; case Event.REMOVED_FROM_STAGE: _vc.stage.removeEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreenEvent); break; }; } flvplayback_internal function skinButtonControl(_arg1:Object):void{ var ctrl:Sprite; var ctrlData:ControlData; var e:Event; var ctrlOrEvent = _arg1; if (ctrlOrEvent == null){ return; }; if ((ctrlOrEvent is Event)){ e = Event(ctrlOrEvent); ctrl = Sprite(e.currentTarget); ctrl.removeEventListener(Event.ENTER_FRAME, skinButtonControl); } else { ctrl = Sprite(ctrlOrEvent); }; ctrlData = ctrlDataDict[ctrl]; if (ctrlData == null){ return; }; try { if (ctrl["placeholder_mc"] != undefined){ ctrl.removeChild(ctrl["placeholder_mc"]); ctrl["placeholder_mc"] = null; }; } catch(re:ReferenceError) { }; if (ctrlData.state_mc == null){ ctrlData.state_mc = new Array(); }; if (ctrlData.state_mc[NORMAL_STATE] == undefined){ ctrlData.state_mc[NORMAL_STATE] = setupButtonSkinState(ctrl, ctrl, buttonSkinLinkageIDs[NORMAL_STATE], null); }; if (((ctrlData.enabled) && (_controlsEnabled))){ if (ctrlData.state_mc[ctrlData.state] == undefined){ ctrlData.state_mc[ctrlData.state] = setupButtonSkinState(ctrl, ctrl, buttonSkinLinkageIDs[ctrlData.state], ctrlData.state_mc[NORMAL_STATE]); }; if (ctrlData.state_mc[ctrlData.state] != ctrlData.currentState_mc){ if (ctrlData.currentState_mc != null){ ctrlData.currentState_mc.visible = false; }; ctrlData.currentState_mc = ctrlData.state_mc[ctrlData.state]; ctrlData.currentState_mc.visible = true; }; applySkinState(ctrlData, ctrlData.state_mc[ctrlData.state]); } else { ctrlData.state = NORMAL_STATE; if (ctrlData.disabled_mc == null){ ctrlData.disabled_mc = setupButtonSkinState(ctrl, ctrl, "disabledLinkageID", ctrlData.state_mc[NORMAL_STATE]); }; applySkinState(ctrlData, ctrlData.disabled_mc); }; } public function set controlsEnabled(_arg1:Boolean):void{ var _local2:int; if (_controlsEnabled == _arg1){ return; }; _controlsEnabled = _arg1; _local2 = 0; while (_local2 < NUM_BUTTONS) { skinButtonControl(controls[_local2]); _local2++; }; } flvplayback_internal function setupSkinAutoHide(_arg1:Boolean):void{ if (((_skinAutoHide) && (!((skin_mc == null))))){ skinAutoHideHitTest(null, _arg1); _skinAutoHideTimer.start(); } else { if (skin_mc != null){ if (((((((_arg1) && ((_skinFadingMaxTime > 0)))) && (((!(skin_mc.visible)) || ((skin_mc.alpha < 1)))))) && (__visible))){ _skinFadingTimer.stop(); _skinFadeStartTime = getTimer(); _skinFadingIn = true; if (skin_mc.alpha == 1){ skin_mc.alpha = 0; }; _skinFadingTimer.start(); } else { if (_skinFadingMaxTime <= 0){ _skinFadingTimer.stop(); skin_mc.alpha = 1; }; }; skin_mc.visible = __visible; }; _skinAutoHideTimer.stop(); }; } public function enterFullScreenDisplayState():void{ var theRect:Rectangle; var vp:VideoPlayer; var effectiveWidth:int; var effectiveHeight:int; var videoAspectRatio:Number; var screenAspectRatio:Number; var effectiveMinWidth:int; var effectiveMinHeight:int; var skinScaleMinWidth:int; var skinScaleMinHeight:int; if (((!(_fullScreen)) && (!((_vc.stage == null))))){ if (_fullScreenTakeOver){ try { theRect = _vc.stage.fullScreenSourceRect; _fullScreenAccel = true; vp = _vc.getVideoPlayer(_vc.visibleVideoPlayerIndex); effectiveWidth = vp.videoWidth; effectiveHeight = vp.videoHeight; videoAspectRatio = (effectiveWidth / effectiveHeight); screenAspectRatio = (_vc.stage.fullScreenWidth / _vc.stage.fullScreenHeight); if (videoAspectRatio > screenAspectRatio){ effectiveHeight = (effectiveWidth / screenAspectRatio); } else { if (videoAspectRatio < screenAspectRatio){ effectiveWidth = (effectiveHeight * screenAspectRatio); }; }; effectiveMinWidth = fullScreenSourceRectMinWidth; effectiveMinHeight = fullScreenSourceRectMinHeight; if (fullScreenSourceRectMinAspectRatio > screenAspectRatio){ effectiveMinHeight = (effectiveMinWidth / screenAspectRatio); } else { if (fullScreenSourceRectMinAspectRatio < screenAspectRatio){ effectiveMinWidth = (effectiveMinHeight * screenAspectRatio); }; }; skinScaleMinWidth = (_vc.stage.fullScreenWidth / _skinScaleMaximum); skinScaleMinHeight = (_vc.stage.fullScreenHeight / _skinScaleMaximum); if ((((effectiveMinWidth < skinScaleMinWidth)) || ((effectiveMinHeight < skinScaleMinHeight)))){ effectiveMinWidth = skinScaleMinWidth; effectiveMinHeight = skinScaleMinHeight; }; if ((((effectiveWidth < effectiveMinWidth)) || ((effectiveHeight < effectiveMinHeight)))){ effectiveWidth = effectiveMinWidth; effectiveHeight = effectiveMinHeight; }; _vc.stage.fullScreenSourceRect = new Rectangle(0, 0, effectiveWidth, effectiveHeight); _vc.stage.displayState = StageDisplayState.FULL_SCREEN; } catch(re:ReferenceError) { _fullScreenAccel = false; } catch(re:SecurityError) { _fullScreenAccel = false; }; }; try { _vc.stage.displayState = StageDisplayState.FULL_SCREEN; } catch(se:SecurityError) { }; }; } public function get skin():String{ return (_skin); } flvplayback_internal function finishAddBarControl(_arg1:Object):void{ var ctrl:Sprite; var ctrlData:ControlData; var e:Event; var ctrlOrEvent = _arg1; if (ctrlOrEvent == null){ return; }; if ((ctrlOrEvent is Event)){ e = Event(ctrlOrEvent); ctrl = Sprite(e.currentTarget); ctrl.removeEventListener(Event.ENTER_FRAME, finishAddBarControl); } else { ctrl = Sprite(ctrlOrEvent); }; ctrlData = ctrlDataDict[ctrl]; try { if ((ctrl["addBarControl"] is Function)){ var _local3 = ctrl; _local3["addBarControl"](); }; } catch(re:ReferenceError) { }; ctrlData.origWidth = ctrl.width; ctrlData.origHeight = ctrl.height; fixUpBar(ctrl, "progress", ctrl, "progress_mc"); calcBarMargins(ctrl, "progress", false); if (ctrlData.progress_mc != null){ fixUpBar(ctrl, "progressBarFill", ctrlData.progress_mc, "fill_mc"); calcBarMargins(ctrlData.progress_mc, "fill", false); calcBarMargins(ctrlData.progress_mc, "mask", false); if (isNaN(_progressPercent)){ _progressPercent = (_vc.isRTMP) ? 100 : 0; }; positionBar(ctrl, "progress", _progressPercent); }; fixUpBar(ctrl, "fullness", ctrl, "fullness_mc"); calcBarMargins(ctrl, "fullness", false); if (ctrlData.fullness_mc != null){ fixUpBar(ctrl, "fullnessBarFill", ctrlData.fullness_mc, "fill_mc"); calcBarMargins(ctrlData.fullness_mc, "fill", false); calcBarMargins(ctrlData.fullness_mc, "mask", false); }; fixUpBar(ctrl, "hit", ctrl, "hit_mc"); fixUpBar(ctrl, "handle", ctrl, "handle_mc"); calcBarMargins(ctrl, "handle", true); switch (ctrlData.index){ case SEEK_BAR: setControl(SEEK_BAR_HANDLE, ctrlData.handle_mc); if (ctrlData.hit_mc != null){ setControl(SEEK_BAR_HIT, ctrlData.hit_mc); }; break; case VOLUME_BAR: setControl(VOLUME_BAR_HANDLE, ctrlData.handle_mc); if (ctrlData.hit_mc != null){ setControl(VOLUME_BAR_HIT, ctrlData.hit_mc); }; break; }; positionHandle(ctrl); } public function get fullScreenBackgroundColor():uint{ return (_fullScreenBgColor); } flvplayback_internal function startHandleDrag(_arg1:Sprite):void{ var ctrlData:ControlData; var handle:Sprite; var handleData:ControlData; var theY:Number; var theWidth:Number; var bounds:Rectangle; var ctrl = _arg1; if (ctrl == null){ return; }; ctrlData = ctrlDataDict[ctrl]; try { if ((((ctrl["startHandleDrag"] is Function)) && (ctrl["startHandleDrag"]()))){ ctrlData.isDragging = true; return; }; } catch(re:ReferenceError) { }; handle = ctrlData.handle_mc; if (handle == null){ return; }; handleData = ctrlDataDict[handle]; theY = (ctrl.y + handleData.origY); theWidth = (isNaN(ctrlData.origWidth)) ? ctrl.width : ctrlData.origWidth; bounds = new Rectangle((ctrl.x + handleData.leftMargin), theY, (theWidth - handleData.rightMargin), 0); handle.startDrag(false, bounds); ctrlData.isDragging = true; } flvplayback_internal function setupBarSkinPart(_arg1:Sprite, _arg2:DisplayObject, _arg3:Sprite, _arg4:String, _arg5:String, _arg6:Boolean=false):DisplayObject{ var part:DisplayObject; var partAvatar:DisplayObject; var ctrlData:ControlData; var partData:ControlData; var ctrl = _arg1; var avatar = _arg2; var definitionHolder = _arg3; var skinName = _arg4; var partName = _arg5; var required = _arg6; try { part = ctrl[partName]; } catch(re:ReferenceError) { part = null; }; if (part == null){ try { part = createSkin(definitionHolder, skinName); } catch(ve:VideoError) { if (required){ throw (ve); }; }; if (part != null){ skin_mc.addChild(part); part.x = ctrl.x; part.y = ctrl.y; partAvatar = layout_mc.getChildByName((skinName + "_mc")); if (partAvatar != null){ if (partName == "hit_mc"){ ctrlData = ctrlDataDict[ctrl]; partData = new ControlData(this, part, controls[ctrlData.index], -1); partData.avatar = partAvatar; ctrlDataDict[part] = partData; } else { part.x = (part.x + (partAvatar.x - avatar.x)); part.y = (part.y + (partAvatar.y - avatar.y)); part.width = partAvatar.width; part.height = partAvatar.height; }; }; }; }; if (((required) && ((part == null)))){ throw (new VideoError(VideoError.MISSING_SKIN_STYLE, skinName)); }; return (part); } public function get skinBackgroundAlpha():Number{ return (borderAlpha); } public function get volumeBarScrubTolerance():Number{ return (_volumeBarScrubTolerance); } public function get skinScaleMaximum():Number{ return (_skinScaleMaximum); } public function get skinBackgroundColor():uint{ return (borderColor); } public function get controlsEnabled():Boolean{ return (_controlsEnabled); } flvplayback_internal function handleIVPEvent(_arg1:IVPEvent):void{ var _local2:uint; var _local3:int; var _local4:VideoEvent; var _local5:Sprite; var _local6:ControlData; var _local7:VideoProgressEvent; var _local8:VideoPlayerState; var _local9:Number; var _local10:Number; var _local11:Number; if (_arg1.vp != _vc.visibleVideoPlayerIndex){ return; }; _local2 = _vc.activeVideoPlayerIndex; _vc.activeVideoPlayerIndex = _vc.visibleVideoPlayerIndex; switch (_arg1.type){ case VideoEvent.STATE_CHANGE: _local4 = VideoEvent(_arg1); if (_local4.state == VideoState.BUFFERING){ if (!_bufferingOn){ _bufferingDelayTimer.reset(); _bufferingDelayTimer.start(); }; } else { _bufferingDelayTimer.reset(); _bufferingOn = false; }; if (_local4.state == VideoState.LOADING){ _progressPercent = (_vc.getVideoPlayer(_arg1.vp).isRTMP) ? 100 : 0; _local3 = SEEK_BAR; while (_local3 <= VOLUME_BAR) { _local5 = controls[_local3]; if (controls[_local3] == null){ } else { _local6 = ctrlDataDict[_local5]; if (_local6.progress_mc != null){ positionBar(_local5, "progress", _progressPercent); }; }; _local3++; }; }; _local3 = 0; while (_local3 < NUM_CONTROLS) { if (controls[_local3] == undefined){ } else { setEnabledAndVisibleForState(_local3, _local4.state); if (_local3 < NUM_BUTTONS){ skinButtonControl(controls[_local3]); }; }; _local3++; }; break; case VideoEvent.READY: case MetadataEvent.METADATA_RECEIVED: _local3 = 0; while (_local3 < NUM_CONTROLS) { if (controls[_local3] == undefined){ } else { setEnabledAndVisibleForState(_local3, _vc.state); if (_local3 < NUM_BUTTONS){ skinButtonControl(controls[_local3]); }; }; _local3++; }; if (_vc.getVideoPlayer(_arg1.vp).isRTMP){ _progressPercent = 100; _local3 = SEEK_BAR; while (_local3 <= VOLUME_BAR) { _local5 = controls[_local3]; if (_local5 == null){ } else { _local6 = ctrlDataDict[_local5]; if (_local6.progress_mc != null){ positionBar(_local5, "progress", _progressPercent); }; }; _local3++; }; }; break; case VideoEvent.PLAYHEAD_UPDATE: if (((((((!((controls[SEEK_BAR] == undefined))) && (!(_vc.isLive)))) && (!(isNaN(_vc.totalTime))))) && (!((_vc.getVideoPlayer(_vc.visibleVideoPlayerIndex).state == VideoState.SEEKING))))){ _local4 = VideoEvent(_arg1); _local10 = ((_local4.playheadTime / _vc.totalTime) * 100); if (_local10 < 0){ _local10 = 0; } else { if (_local10 > 100){ _local10 = 100; }; }; _local5 = controls[SEEK_BAR]; _local6 = ctrlDataDict[_local5]; _local6.percentage = _local10; positionHandle(_local5); }; break; case VideoProgressEvent.PROGRESS: _local7 = VideoProgressEvent(_arg1); _progressPercent = ((_local7.bytesTotal)<=0) ? 100 : ((_local7.bytesLoaded / _local7.bytesTotal) * 100); _local8 = _vc.videoPlayerStates[_arg1.vp]; _local9 = _local8.minProgressPercent; if (((!(isNaN(_local9))) && ((_local9 > _progressPercent)))){ _progressPercent = _local9; }; if (!isNaN(_vc.totalTime)){ _local11 = ((_vc.playheadTime / _vc.totalTime) * 100); if (_local11 > _progressPercent){ _progressPercent = _local11; _local8.minProgressPercent = _progressPercent; }; }; _local3 = SEEK_BAR; while (_local3 <= VOLUME_BAR) { _local5 = controls[_local3]; if (_local5 == null){ } else { _local6 = ctrlDataDict[_local5]; if (_local6.progress_mc != null){ positionBar(_local5, "progress", _progressPercent); }; }; _local3++; }; break; }; _vc.activeVideoPlayerIndex = _local2; } flvplayback_internal function setupButtonSkinState(_arg1:Sprite, _arg2:Sprite, _arg3:String, _arg4:DisplayObject=null):DisplayObject{ var stateSkin:DisplayObject; var ctrl = _arg1; var definitionHolder = _arg2; var skinName = _arg3; var defaultSkin = _arg4; try { stateSkin = createSkin(definitionHolder, skinName); } catch(ve:VideoError) { if (defaultSkin != null){ stateSkin = null; } else { throw (ve); }; }; if (stateSkin != null){ stateSkin.visible = false; ctrl.addChild(stateSkin); } else { if (defaultSkin != null){ stateSkin = defaultSkin; }; }; return (stateSkin); } flvplayback_internal function layoutSkin():void{ var video_mc:DisplayObject; var i:int; var borderRect:Rectangle; var forceSkinAutoHide:Boolean; var minWidth:Number; var vidWidth:Number; var minHeight:Number; var vidHeight:Number; if (layout_mc == null){ return; }; if (skinLoadDelayCount < 2){ return; }; video_mc = layout_mc["video_mc"]; if (video_mc == null){ throw (new Error("No layout_mc.video_mc")); }; placeholderLeft = video_mc.x; placeholderRight = (video_mc.x + video_mc.width); placeholderTop = video_mc.y; placeholderBottom = (video_mc.y + video_mc.height); videoLeft = (_vc.x - _vc.registrationX); videoRight = (videoLeft + _vc.width); videoTop = (_vc.y - _vc.registrationY); videoBottom = (videoTop + _vc.height); if (((((_fullScreen) && (_fullScreenTakeOver))) && (!((border_mc == null))))){ borderRect = calcLayoutControl(border_mc); forceSkinAutoHide = false; if ((((borderRect.width > 0)) && ((borderRect.height > 0)))){ if (borderRect.x < 0){ placeholderLeft = (placeholderLeft + (videoLeft - borderRect.x)); forceSkinAutoHide = true; }; if ((borderRect.x + borderRect.width) > _vc.registrationWidth){ placeholderRight = (placeholderRight + ((borderRect.x + borderRect.width) - videoRight)); forceSkinAutoHide = true; }; if (borderRect.y < 0){ placeholderTop = (placeholderTop + (videoTop - borderRect.y)); forceSkinAutoHide = true; }; if ((borderRect.y + borderRect.height) > _vc.registrationHeight){ placeholderBottom = (placeholderBottom + ((borderRect.y + borderRect.height) - videoBottom)); forceSkinAutoHide = true; }; if (forceSkinAutoHide){ _skinAutoHide = true; setupSkinAutoHide(true); }; }; }; try { if (!isNaN(layout_mc["minWidth"])){ minWidth = layout_mc["minWidth"]; vidWidth = (videoRight - videoLeft); if ((((minWidth > 0)) && ((minWidth > vidWidth)))){ videoLeft = (videoLeft - ((minWidth - vidWidth) / 2)); videoRight = (minWidth + videoLeft); }; }; } catch(re1:ReferenceError) { }; try { if (!isNaN(layout_mc["minHeight"])){ minHeight = layout_mc["minHeight"]; vidHeight = (videoBottom - videoTop); if ((((minHeight > 0)) && ((minHeight > vidHeight)))){ videoTop = (videoTop - ((minHeight - vidHeight) / 2)); videoBottom = (minHeight + videoTop); }; }; } catch(re2:ReferenceError) { }; i = 0; while (i < customClips.length) { layoutControl(customClips[i]); if (customClips[i] == border_mc){ bitmapCopyBorder(); }; i = (i + 1); }; i = 0; while (i < NUM_CONTROLS) { layoutControl(controls[i]); i = (i + 1); }; } public function set bufferingDelayInterval(_arg1:Number):void{ if (_bufferingDelayTimer.delay == _arg1){ return; }; _bufferingDelayTimer.delay = _arg1; } flvplayback_internal function setEnabledAndVisibleForState(_arg1:int, _arg2:String):void{ var _local3:int; var _local4:String; var _local5:Sprite; var _local6:ControlData; var _local7:Boolean; var _local8:ControlData; var _local9:ControlData; var _local10:ControlData; var _local11:ControlData; _local3 = _vc.activeVideoPlayerIndex; _vc.activeVideoPlayerIndex = _vc.visibleVideoPlayerIndex; _local4 = _arg2; if ((((_local4 == VideoState.BUFFERING)) && (!(_bufferingOn)))){ _local4 = VideoState.PLAYING; }; _local5 = controls[_arg1]; if (_local5 == null){ return; }; _local6 = ctrlDataDict[_local5]; if (_local6 == null){ return; }; switch (_arg1){ case VOLUME_BAR: case VOLUME_BAR_HANDLE: case VOLUME_BAR_HIT: _local6.enabled = true; break; case FULL_SCREEN_ON_BUTTON: _local6.enabled = !(_fullScreen); if (controls[FULL_SCREEN_BUTTON] != undefined){ _local5.visible = _local6.enabled; }; break; case FULL_SCREEN_OFF_BUTTON: _local6.enabled = _fullScreen; if (controls[FULL_SCREEN_BUTTON] != undefined){ _local5.visible = _local6.enabled; }; break; case MUTE_ON_BUTTON: _local6.enabled = !(_isMuted); if (controls[MUTE_BUTTON] != undefined){ _local5.visible = _local6.enabled; }; break; case MUTE_OFF_BUTTON: _local6.enabled = _isMuted; if (controls[MUTE_BUTTON] != undefined){ _local5.visible = _local6.enabled; }; break; default: switch (_local4){ case VideoState.LOADING: case VideoState.CONNECTION_ERROR: _local6.enabled = false; break; case VideoState.DISCONNECTED: _local6.enabled = ((!((_vc.source == null))) && (!((_vc.source == "")))); break; case VideoState.SEEKING: break; default: _local6.enabled = true; break; }; break; }; switch (_arg1){ case SEEK_BAR: switch (_local4){ case VideoState.STOPPED: case VideoState.PLAYING: case VideoState.PAUSED: case VideoState.REWINDING: case VideoState.SEEKING: _local6.enabled = true; break; case VideoState.BUFFERING: _local6.enabled = ((!(_bufferingBarHides)) || ((controls[BUFFERING_BAR] == undefined))); break; default: _local6.enabled = false; break; }; if (_local6.enabled){ _local6.enabled = !(isNaN(_vc.totalTime)); }; if (_local6.handle_mc != null){ _local8 = ctrlDataDict[_local6.handle_mc]; _local8.enabled = _local6.enabled; _local6.handle_mc.visible = _local8.enabled; }; if (_local6.hit_mc != null){ _local9 = ctrlDataDict[_local6.hit_mc]; _local9.enabled = _local6.enabled; _local6.hit_mc.visible = _local9.enabled; }; _local7 = ((((((!(_bufferingBarHides)) || (_local6.enabled))) || ((controls[BUFFERING_BAR] == undefined)))) || (!(controls[BUFFERING_BAR].visible))); _local5.visible = _local7; if (_local6.progress_mc != null){ _local6.progress_mc.visible = _local7; _local10 = ctrlDataDict[_local6.progress_mc]; if (_local10.fill_mc != null){ _local10.fill_mc.visible = _local7; }; }; if (_local6.fullness_mc != null){ _local6.fullness_mc.visible = _local7; _local11 = ctrlDataDict[_local6.fullness_mc]; if (_local11.fill_mc != null){ _local11.fill_mc.visible = _local7; }; }; break; case BUFFERING_BAR: switch (_local4){ case VideoState.STOPPED: case VideoState.PLAYING: case VideoState.PAUSED: case VideoState.REWINDING: case VideoState.SEEKING: _local6.enabled = false; break; default: _local6.enabled = true; break; }; _local5.visible = _local6.enabled; if (_local6.fill_mc != null){ _local6.fill_mc.visible = _local6.enabled; }; break; case PAUSE_BUTTON: switch (_local4){ case VideoState.DISCONNECTED: case VideoState.STOPPED: case VideoState.PAUSED: case VideoState.REWINDING: _local6.enabled = false; break; case VideoState.PLAYING: _local6.enabled = true; break; case VideoState.BUFFERING: _local6.enabled = ((!(_bufferingBarHides)) || ((controls[BUFFERING_BAR] == undefined))); break; }; if (controls[PLAY_PAUSE_BUTTON] != undefined){ _local5.visible = _local6.enabled; }; break; case PLAY_BUTTON: switch (_local4){ case VideoState.PLAYING: _local6.enabled = false; break; case VideoState.STOPPED: case VideoState.PAUSED: _local6.enabled = true; break; case VideoState.BUFFERING: _local6.enabled = ((!(_bufferingBarHides)) || ((controls[BUFFERING_BAR] == undefined))); break; }; if (controls[PLAY_PAUSE_BUTTON] != undefined){ _local5.visible = !(controls[PAUSE_BUTTON].visible); }; break; case STOP_BUTTON: switch (_local4){ case VideoState.DISCONNECTED: case VideoState.STOPPED: _local6.enabled = false; break; case VideoState.PAUSED: case VideoState.PLAYING: case VideoState.BUFFERING: _local6.enabled = true; break; }; break; case BACK_BUTTON: case FORWARD_BUTTON: switch (_local4){ case VideoState.BUFFERING: _local6.enabled = ((!(_bufferingBarHides)) || ((controls[BUFFERING_BAR] == undefined))); break; }; }; _local5.mouseEnabled = _local6.enabled; _vc.activeVideoPlayerIndex = _local3; } public function set fullScreenTakeOver(_arg1:Boolean):void{ var v = _arg1; if (_fullScreenTakeOver != v){ _fullScreenTakeOver = v; if (_fullScreenTakeOver){ enterFullScreenTakeOver(); } else { if (((((!((_vc.stage == null))) && (_fullScreen))) && (_fullScreenAccel))){ try { _vc.stage.displayState = StageDisplayState.NORMAL; } catch(se:SecurityError) { }; }; exitFullScreenTakeOver(); }; }; } flvplayback_internal function enterFullScreenTakeOver():void{ var i:int; var fullScreenBG:Sprite; var vp:VideoPlayer; if (((!(_fullScreen)) || (!((cacheFLVPlaybackParent == null))))){ return; }; _vc.removeEventListener(LayoutEvent.LAYOUT, handleLayoutEvent); _vc.removeEventListener(AutoLayoutEvent.AUTO_LAYOUT, handleLayoutEvent); _vc.removeEventListener(Event.ADDED_TO_STAGE, handleEvent); _vc.stage.removeEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreenEvent); try { cacheFLVPlaybackScaleMode = new Array(); cacheFLVPlaybackAlign = new Array(); i = 0; while (i < _vc.videoPlayers.length) { vp = (_vc.videoPlayers[i] as VideoPlayer); if (vp != null){ cacheFLVPlaybackScaleMode[i] = vp.scaleMode; cacheFLVPlaybackAlign[i] = vp.align; }; i = (i + 1); }; cacheFLVPlaybackParent = _vc.parent; cacheFLVPlaybackIndex = _vc.parent.getChildIndex(_vc); cacheFLVPlaybackLocation = new Rectangle(_vc.registrationX, _vc.registrationY, _vc.registrationWidth, _vc.registrationHeight); if (!_fullScreenAccel){ cacheStageAlign = _vc.stage.align; cacheStageScaleMode = _vc.stage.scaleMode; _vc.stage.align = StageAlign.TOP_LEFT; _vc.stage.scaleMode = StageScaleMode.NO_SCALE; }; _vc.align = VideoAlign.CENTER; _vc.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO; _vc.registrationX = 0; _vc.registrationY = 0; _vc.setSize(_vc.stage.stageWidth, _vc.stage.stageHeight); if (_vc.stage != _vc.parent){ _vc.stage.addChild(_vc); } else { _vc.stage.setChildIndex(_vc, (_vc.stage.numChildren - 1)); }; fullScreenBG = Sprite(_vc.getChildByName("fullScreenBG")); if (fullScreenBG == null){ fullScreenBG = new Sprite(); fullScreenBG.name = "fullScreenBG"; _vc.addChildAt(fullScreenBG, 0); } else { _vc.setChildIndex(fullScreenBG, 0); }; fullScreenBG.graphics.beginFill(_fullScreenBgColor); fullScreenBG.graphics.drawRect(0, 0, _vc.stage.stageWidth, _vc.stage.stageHeight); layoutSkin(); setupSkinAutoHide(false); } catch(err:Error) { cacheFLVPlaybackParent = null; }; _vc.addEventListener(LayoutEvent.LAYOUT, handleLayoutEvent); _vc.addEventListener(AutoLayoutEvent.AUTO_LAYOUT, handleLayoutEvent); _vc.addEventListener(Event.ADDED_TO_STAGE, handleEvent); _vc.stage.addEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreenEvent); } public function set seekBarScrubTolerance(_arg1:Number):void{ _seekBarScrubTolerance = _arg1; } flvplayback_internal function cleanupHandle(_arg1:Object):void{ var e:Event; var ctrl:Sprite; var ctrlData:ControlData; var ctrlOrEvent = _arg1; try { if ((ctrlOrEvent is Event)){ e = Event(ctrlOrEvent); }; ctrl = ((e == null)) ? Sprite(ctrlOrEvent) : Sprite(e.currentTarget); ctrlData = ctrlDataDict[ctrl]; if ((((ctrlData == null)) || ((e == null)))){ ctrl.removeEventListener(Event.REMOVED_FROM_STAGE, cleanupHandle, false); if (ctrlData == null){ return; }; }; ctrl.removeEventListener(Event.ENTER_FRAME, finishAddBarControl); if (ctrlData.handle_mc != null){ if (ctrlData.handle_mc.parent != null){ ctrlData.handle_mc.parent.removeChild(ctrlData.handle_mc); }; delete ctrlDataDict[ctrlData.handle_mc]; ctrlData.handle_mc = null; }; if (ctrlData.hit_mc != null){ if (ctrlData.hit_mc.parent != null){ ctrlData.hit_mc.parent.removeChild(ctrlData.hit_mc); }; delete ctrlDataDict[ctrlData.hit_mc]; ctrlData.hit_mc = null; }; } catch(err:Error) { }; } flvplayback_internal static function getNumberPropSafe(_arg1:Object, _arg2:String):Number{ var numProp:*; var obj = _arg1; var propName = _arg2; try { numProp = obj[propName]; return (Number(numProp)); } catch(re:ReferenceError) { }; return (NaN); } flvplayback_internal static function getBooleanPropSafe(_arg1:Object, _arg2:String):Boolean{ var boolProp:*; var obj = _arg1; var propName = _arg2; try { boolProp = obj[propName]; return (Boolean(boolProp)); } catch(re:ReferenceError) { }; return (false); } flvplayback_internal static function initLayoutNameToIndexMappings():void{ var _local1:int; layoutNameToIndexMappings = new Object(); _local1 = 0; while (_local1 < layoutNameArray.length) { if (layoutNameArray[_local1] != null){ layoutNameToIndexMappings[layoutNameArray[_local1]] = _local1; }; _local1++; }; } } }//package fl.video
Section 227
//VideoAlign (fl.video.VideoAlign) package fl.video { public final class VideoAlign { public static const CENTER:String = "center"; public static const LEFT:String = "left"; public static const BOTTOM_RIGHT:String = "bottomRight"; public static const BOTTOM:String = "bottom"; public static const TOP_LEFT:String = "topLeft"; public static const TOP_RIGHT:String = "topRight"; public static const TOP:String = "top"; public static const BOTTOM_LEFT:String = "bottomLeft"; public static const RIGHT:String = "right"; } }//package fl.video
Section 228
//VideoError (fl.video.VideoError) package fl.video { public class VideoError extends Error { private var _code:uint; public static const INVALID_SOURCE:uint = 1004; flvplayback_internal static const ERROR_MSG:Array = ["Unable to make connection to server or to find FLV on server", "No matching cue point found", "Illegal cue point", "Invalid seek", "Invalid source", "Invalid xml", "No bitrate match, must be no default flv", "Cannot delete default VideoPlayer", "VideoPlayer.iNCManagerClass has not been set or its value is invalid", "Null url parameter sent to load()", "Skin is missing a required style definition or its value is invalid", "Unsupported property", "VideoPlayer.netStreamClientClass has not been set or its value is invalid"]; public static const NULL_URL_LOAD:uint = 1009; public static const INVALID_XML:uint = 1005; flvplayback_internal static const BASE_ERROR_CODE:uint = 1000; public static const DELETE_DEFAULT_PLAYER:uint = 1007; public static const SHORT_VERSION:String = "2.1"; public static const UNSUPPORTED_PROPERTY:uint = 1011; public static const ILLEGAL_CUE_POINT:uint = 1002; public static const INVALID_SEEK:uint = 1003; public static const NO_CONNECTION:uint = 1000; public static const MISSING_SKIN_STYLE:uint = 1010; public static const INCMANAGER_CLASS_UNSET:uint = 1008; public static const NO_BITRATE_MATCH:uint = 1006; public static const NETSTREAM_CLIENT_CLASS_UNSET:uint = 1012; public static const VERSION:String = "2.1.0.14"; public function VideoError(_arg1:uint, _arg2:String=null){ super((((("" + _arg1) + ": ") + ERROR_MSG[(_arg1 - BASE_ERROR_CODE)]) + ((_arg2)==null) ? "" : (": " + _arg2))); name = "VideoError"; _code = _arg1; } public function get code():uint{ return (_code); } } }//package fl.video
Section 229
//VideoEvent (fl.video.VideoEvent) package fl.video { import flash.events.*; public class VideoEvent extends Event implements IVPEvent { private var _vp:uint; private var _playheadTime:Number; private var _state:String; public static const FAST_FORWARD:String = "fastForward"; public static const READY:String = "ready"; public static const SKIN_LOADED:String = "skinLoaded"; public static const SCRUB_FINISH:String = "scrubFinish"; public static const BUFFERING_STATE_ENTERED:String = "bufferingStateEntered"; public static const STOPPED_STATE_ENTERED:String = "stoppedStateEntered"; public static const AUTO_REWOUND:String = "autoRewound"; public static const SCRUB_START:String = "scrubStart"; public static const PLAYHEAD_UPDATE:String = "playheadUpdate"; public static const SEEKED:String = "seeked"; public static const PLAYING_STATE_ENTERED:String = "playingStateEntered"; public static const CLOSE:String = "close"; public static const PAUSED_STATE_ENTERED:String = "pausedStateEntered"; public static const COMPLETE:String = "complete"; public static const REWIND:String = "rewind"; public static const STATE_CHANGE:String = "stateChange"; public function VideoEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:String=null, _arg5:Number=NaN, _arg6:uint=0){ super(_arg1, _arg2, _arg3); _state = _arg4; _playheadTime = _arg5; _vp = _arg6; } public function set playheadTime(_arg1:Number):void{ _playheadTime = _arg1; } public function get playheadTime():Number{ return (_playheadTime); } public function get state():String{ return (_state); } public function get vp():uint{ return (_vp); } override public function clone():Event{ return (new VideoEvent(type, bubbles, cancelable, state, playheadTime, vp)); } public function set state(_arg1:String):void{ _state = _arg1; } public function set vp(_arg1:uint):void{ _vp = _arg1; } } }//package fl.video
Section 230
//VideoPlayer (fl.video.VideoPlayer) package fl.video { import flash.events.*; import flash.media.*; import flash.net.*; import flash.geom.*; import flash.utils.*; public class VideoPlayer extends Video { protected var _align:String; protected var _registrationWidth:Number; flvplayback_internal var _updateProgressTimer:Timer; flvplayback_internal var _atEndCheckPlayhead:Number; flvplayback_internal var _hiddenForResize:Boolean; flvplayback_internal var startProgressTime:Number; protected var _volume:Number; flvplayback_internal var _invalidSeekTime:Boolean; flvplayback_internal var _readyDispatched:Boolean; flvplayback_internal var lastUpdateTimeStuckCount:Number; protected var _ns:NetStream; protected var _isLive:Boolean; flvplayback_internal var _bufferState:String; protected var _streamLength:Number; flvplayback_internal var _rtmpDoSeekTimer:Timer; protected var _contentPath:String; flvplayback_internal var lastUpdateTimeStuckCountMax:int;// = 10 protected var _metadata:Object; protected var __visible:Boolean; flvplayback_internal var autoResizeMetadataDelayMax:Number;// = 5 protected var _scaleMode:String; flvplayback_internal var _lastUpdateTime:Number; flvplayback_internal var _sawPlayStop:Boolean; flvplayback_internal var _atEnd:Boolean; flvplayback_internal var _sawSeekNotify:Boolean; flvplayback_internal var _idleTimeoutTimer:Timer; flvplayback_internal var _prevVideoWidth:int; protected var _registrationX:Number; protected var _registrationY:Number; protected var _bufferTime:Number; flvplayback_internal var _cachedState:String; flvplayback_internal var totalDownloadTime:Number; flvplayback_internal var _cachedPlayheadTime:Number; protected var _autoPlay:Boolean; protected var _autoRewind:Boolean; flvplayback_internal var _invalidSeekRecovery:Boolean; flvplayback_internal var _hiddenRewindPlayheadTime:Number; flvplayback_internal var _prevVideoHeight:int; protected var _ncMgr:INCManager; protected var _soundTransform:SoundTransform; flvplayback_internal var _httpDoSeekCount:Number; flvplayback_internal var oldRegistrationBounds:Rectangle; flvplayback_internal var _cmdQueue:Array; flvplayback_internal var _updateTimeTimer:Timer; flvplayback_internal var httpDoSeekMaxCount:Number;// = 4 flvplayback_internal var _startingPlay:Boolean; flvplayback_internal var baselineProgressTime:Number; flvplayback_internal var _autoResizeTimer:Timer; flvplayback_internal var _autoResizeDone:Boolean; flvplayback_internal var _httpDoSeekTimer:Timer; protected var _state:String; protected var _videoWidth:int; flvplayback_internal var _finishAutoResizeTimer:Timer; flvplayback_internal var _resizeImmediatelyOnMetadata:Boolean; flvplayback_internal var _currentPos:Number; flvplayback_internal var oldBounds:Rectangle; protected var _videoHeight:int; flvplayback_internal var waitingForEnough:Boolean; flvplayback_internal var _delayedBufferingTimer:Timer; protected var _registrationHeight:Number; flvplayback_internal var _hiddenForResizeMetadataDelay:Number; flvplayback_internal var autoResizePlayheadTimeout:Number;// = 0.5 flvplayback_internal var _rtmpDoStopAtEndTimer:Timer; flvplayback_internal var _lastSeekTime:Number; flvplayback_internal var totalProgressTime:Number; flvplayback_internal static const FINISH_AUTO_RESIZE_INTERVAL:Number = 250; flvplayback_internal static const DEFAULT_AUTO_RESIZE_PLAYHEAD_TIMEOUT:Number = 0.5; flvplayback_internal static const DEFAULT_AUTO_RESIZE_METADATA_DELAY_MAX:Number = 5; public static const SHORT_VERSION:String = "2.1"; flvplayback_internal static const HTTP_DO_SEEK_INTERVAL:Number = 250; flvplayback_internal static const DEFAULT_HTTP_DO_SEEK_MAX_COUNT:Number = 4; flvplayback_internal static const RTMP_DO_SEEK_INTERVAL:Number = 100; flvplayback_internal static const HTTP_DELAYED_BUFFERING_INTERVAL:Number = 100; public static const DEFAULT_UPDATE_TIME_INTERVAL:Number = 250; flvplayback_internal static const AUTO_RESIZE_INTERVAL:Number = 100; public static const DEFAULT_IDLE_TIMEOUT_INTERVAL:Number = 300000; flvplayback_internal static const DEFAULT_LAST_UPDATE_TIME_STUCK_COUNT_MAX:int = 10; flvplayback_internal static const RTMP_DO_STOP_AT_END_INTERVAL:Number = 500; public static const VERSION:String = "2.1.0.14"; public static const DEFAULT_UPDATE_PROGRESS_INTERVAL:Number = 250; public static var netStreamClientClass:Object = VideoPlayerClient; public static var iNCManagerClass:Object = "fl.video.NCManager"; flvplayback_internal static var BUFFER_FLUSH:String = "bufferFlush"; flvplayback_internal static var BUFFER_FULL:String = "bufferFull"; flvplayback_internal static var BUFFER_EMPTY:String = "bufferEmpty"; public function VideoPlayer(_arg1:int=320, _arg2:int=240){ autoResizePlayheadTimeout = DEFAULT_AUTO_RESIZE_PLAYHEAD_TIMEOUT; autoResizeMetadataDelayMax = DEFAULT_AUTO_RESIZE_METADATA_DELAY_MAX; httpDoSeekMaxCount = DEFAULT_HTTP_DO_SEEK_MAX_COUNT; lastUpdateTimeStuckCountMax = DEFAULT_LAST_UPDATE_TIME_STUCK_COUNT_MAX; super(_arg1, _arg2); _registrationX = x; _registrationY = y; _registrationWidth = _arg1; _registrationHeight = _arg2; _state = VideoState.DISCONNECTED; _cachedState = _state; _bufferState = BUFFER_EMPTY; _sawPlayStop = false; _cachedPlayheadTime = 0; _metadata = null; _startingPlay = false; _invalidSeekTime = false; _invalidSeekRecovery = false; _currentPos = 0; _atEnd = false; _streamLength = 0; _cmdQueue = new Array(); _readyDispatched = false; _autoResizeDone = false; _lastUpdateTime = NaN; lastUpdateTimeStuckCount = 0; _sawSeekNotify = false; _hiddenForResize = false; _hiddenForResizeMetadataDelay = 0; _resizeImmediatelyOnMetadata = false; _videoWidth = -1; _videoHeight = -1; _prevVideoWidth = 0; _prevVideoHeight = 0; _updateTimeTimer = new Timer(DEFAULT_UPDATE_TIME_INTERVAL); _updateTimeTimer.addEventListener(TimerEvent.TIMER, doUpdateTime); _updateProgressTimer = new Timer(DEFAULT_UPDATE_PROGRESS_INTERVAL); _updateProgressTimer.addEventListener(TimerEvent.TIMER, doUpdateProgress); _idleTimeoutTimer = new Timer(DEFAULT_IDLE_TIMEOUT_INTERVAL, 1); _idleTimeoutTimer.addEventListener(TimerEvent.TIMER, doIdleTimeout); _autoResizeTimer = new Timer(AUTO_RESIZE_INTERVAL); _autoResizeTimer.addEventListener(TimerEvent.TIMER, doAutoResize); _rtmpDoStopAtEndTimer = new Timer(RTMP_DO_STOP_AT_END_INTERVAL); _rtmpDoStopAtEndTimer.addEventListener(TimerEvent.TIMER, rtmpDoStopAtEnd); _rtmpDoSeekTimer = new Timer(RTMP_DO_SEEK_INTERVAL); _rtmpDoSeekTimer.addEventListener(TimerEvent.TIMER, rtmpDoSeek); _httpDoSeekTimer = new Timer(HTTP_DO_SEEK_INTERVAL); _httpDoSeekTimer.addEventListener(TimerEvent.TIMER, httpDoSeek); _httpDoSeekCount = 0; _finishAutoResizeTimer = new Timer(FINISH_AUTO_RESIZE_INTERVAL, 1); _finishAutoResizeTimer.addEventListener(TimerEvent.TIMER, finishAutoResize); _delayedBufferingTimer = new Timer(HTTP_DELAYED_BUFFERING_INTERVAL); _delayedBufferingTimer.addEventListener(TimerEvent.TIMER, doDelayedBuffering); _isLive = false; _align = VideoAlign.CENTER; _scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO; _autoPlay = true; _autoRewind = false; _bufferTime = 0.1; _soundTransform = new SoundTransform(); _volume = _soundTransform.volume; __visible = true; _contentPath = ""; waitingForEnough = false; baselineProgressTime = NaN; startProgressTime = NaN; totalDownloadTime = NaN; totalProgressTime = NaN; } public function get playheadTime():Number{ var _local1:Number; _local1 = ((_ns)==null) ? _currentPos : _ns.time; if (((!((_metadata == null))) && (!((_metadata.audiodelay == undefined))))){ _local1 = (_local1 - _metadata.audiodelay); if (_local1 < 0){ _local1 = 0; }; }; return (_local1); } public function stop():void{ if (!isXnOK()){ if ((((((_state == VideoState.CONNECTION_ERROR)) || ((_ncMgr == null)))) || ((_ncMgr.netConnection == null)))){ throw (new VideoError(VideoError.NO_CONNECTION)); }; return; } else { if (_state == VideoState.EXEC_QUEUED_CMD){ _state = _cachedState; } else { if (!stateResponsive){ queueCmd(QueuedCommand.STOP); return; }; execQueuedCmds(); }; }; if ((((_state == VideoState.STOPPED)) || ((_ns == null)))){ return; }; if (_ncMgr.isRTMP){ if (((_autoRewind) && (!(_isLive)))){ _currentPos = 0; _play(0, 0); _state = VideoState.STOPPED; setState(VideoState.REWINDING); } else { closeNS(true); setState(VideoState.STOPPED); }; } else { _pause(true); if (_autoRewind){ _seek(0); _state = VideoState.STOPPED; setState(VideoState.REWINDING); } else { setState(VideoState.STOPPED); }; }; } flvplayback_internal function execQueuedCmds():void{ var nextCmd:Object; while ((((((_cmdQueue.length > 0)) && (((((stateResponsive) || ((_state == VideoState.DISCONNECTED)))) || ((_state == VideoState.CONNECTION_ERROR)))))) && (((!((_cmdQueue[0].url == null))) || (((!((_state == VideoState.DISCONNECTED))) && (!((_state == VideoState.CONNECTION_ERROR))))))))) { try { nextCmd = _cmdQueue.shift(); _cachedState = _state; _state = VideoState.EXEC_QUEUED_CMD; switch (nextCmd.type){ case QueuedCommand.PLAY: play(nextCmd.url, nextCmd.time, nextCmd.isLive); break; case QueuedCommand.LOAD: load(nextCmd.url, nextCmd.time, nextCmd.isLive); break; case QueuedCommand.PAUSE: pause(); break; case QueuedCommand.STOP: stop(); break; case QueuedCommand.SEEK: seek(nextCmd.time); break; case QueuedCommand.PLAY_WHEN_ENOUGH: playWhenEnoughDownloaded(); break; }; } finally { if (_state == VideoState.EXEC_QUEUED_CMD){ _state = _cachedState; }; }; }; } public function setScale(_arg1:Number, _arg2:Number):void{ super.scaleX = _arg1; super.scaleY = _arg2; _registrationWidth = width; _registrationHeight = height; switch (_scaleMode){ case VideoScaleMode.MAINTAIN_ASPECT_RATIO: case VideoScaleMode.NO_SCALE: startAutoResize(); break; default: super.x = _registrationX; super.y = _registrationY; break; }; } public function set playheadTime(_arg1:Number):void{ seek(_arg1); } override public function get videoWidth():int{ if (_videoWidth > 0){ return (_videoWidth); }; if (((((!((_metadata == null))) && (!(isNaN(_metadata.width))))) && (!(isNaN(_metadata.height))))){ if ((((_metadata.width == _metadata.height)) && (_readyDispatched))){ return (super.videoWidth); }; return (int(_metadata.width)); }; if (_readyDispatched){ return (super.videoWidth); }; return (-1); } public function get scaleMode():String{ return (_scaleMode); } public function get progressInterval():Number{ return (_updateProgressTimer.delay); } public function set align(_arg1:String):void{ if (_align != _arg1){ switch (_arg1){ case VideoAlign.CENTER: case VideoAlign.TOP: case VideoAlign.LEFT: case VideoAlign.BOTTOM: case VideoAlign.RIGHT: case VideoAlign.TOP_LEFT: case VideoAlign.TOP_RIGHT: case VideoAlign.BOTTOM_LEFT: case VideoAlign.BOTTOM_RIGHT: break; default: return; }; _align = _arg1; switch (_scaleMode){ case VideoScaleMode.MAINTAIN_ASPECT_RATIO: case VideoScaleMode.NO_SCALE: startAutoResize(); break; }; }; } public function set scaleMode(_arg1:String):void{ if (_scaleMode != _arg1){ switch (_arg1){ case VideoScaleMode.MAINTAIN_ASPECT_RATIO: case VideoScaleMode.NO_SCALE: case VideoScaleMode.EXACT_FIT: break; default: return; }; if ((((((_scaleMode == VideoScaleMode.EXACT_FIT)) && (_resizeImmediatelyOnMetadata))) && ((((_videoWidth < 0)) || ((_videoHeight < 0)))))){ _resizeImmediatelyOnMetadata = false; }; _scaleMode = _arg1; startAutoResize(); }; } public function get source():String{ return (_contentPath); } flvplayback_internal function doUpdateTime(_arg1:TimerEvent=null):void{ var _local2:Number; _local2 = playheadTime; if (_local2 != _atEndCheckPlayhead){ _atEndCheckPlayhead = NaN; }; switch (_state){ case VideoState.STOPPED: case VideoState.PAUSED: case VideoState.DISCONNECTED: case VideoState.CONNECTION_ERROR: _updateTimeTimer.stop(); break; case VideoState.PLAYING: case VideoState.BUFFERING: if (((((((((!((_ncMgr == null))) && (!(_ncMgr.isRTMP)))) && ((_lastUpdateTime == _local2)))) && (!((_ns == null))))) && ((_ns.bytesLoaded == _ns.bytesTotal)))){ if (lastUpdateTimeStuckCount > lastUpdateTimeStuckCountMax){ lastUpdateTimeStuckCount = 0; httpDoStopAtEnd(); } else { lastUpdateTimeStuckCount++; }; }; }; if (_lastUpdateTime != _local2){ dispatchEvent(new VideoEvent(VideoEvent.PLAYHEAD_UPDATE, false, false, _state, _local2)); _lastUpdateTime = _local2; lastUpdateTimeStuckCount = 0; }; } flvplayback_internal function rtmpNetStatus(_arg1:NetStatusEvent):void{ if (_state == VideoState.CONNECTION_ERROR){ return; }; switch (_arg1.info.code){ case "NetStream.Play.Stop": if (_startingPlay){ return; }; switch (_state){ case VideoState.RESIZING: if (_hiddenForResize){ finishAutoResize(); }; break; case VideoState.LOADING: case VideoState.STOPPED: case VideoState.PAUSED: break; default: _sawPlayStop = true; if (((!(_rtmpDoStopAtEndTimer.running)) && ((((_bufferState == BUFFER_FLUSH)) || ((((_ns.bufferTime <= 0.1)) && ((_ns.bufferLength <= 0.1)))))))){ _cachedPlayheadTime = playheadTime; _rtmpDoStopAtEndTimer.reset(); _rtmpDoStopAtEndTimer.start(); }; break; }; break; case "NetStream.Buffer.Empty": switch (_bufferState){ case BUFFER_FULL: if (_sawPlayStop){ rtmpDoStopAtEnd(); } else { if (_state == VideoState.PLAYING){ setState(VideoState.BUFFERING); }; }; break; }; _bufferState = BUFFER_EMPTY; _sawPlayStop = false; break; case "NetStream.Buffer.Flush": if (((_sawSeekNotify) && ((_state == VideoState.SEEKING)))){ _bufferState = BUFFER_EMPTY; _sawPlayStop = false; setStateFromCachedState(false); doUpdateTime(); execQueuedCmds(); }; if (((((!(_rtmpDoStopAtEndTimer.running)) && (_sawPlayStop))) && ((((_bufferState == BUFFER_EMPTY)) || ((((_ns.bufferTime <= 0.1)) && ((_ns.bufferLength <= 0.1)))))))){ _cachedPlayheadTime = playheadTime; _rtmpDoStopAtEndTimer.reset(); _rtmpDoStopAtEndTimer.start(); }; switch (_bufferState){ case BUFFER_EMPTY: if (!_hiddenForResize){ if ((((((_state == VideoState.LOADING)) && ((_cachedState == VideoState.PLAYING)))) || ((_state == VideoState.BUFFERING)))){ setState(VideoState.PLAYING); } else { if (_cachedState == VideoState.BUFFERING){ _cachedState = VideoState.PLAYING; }; }; }; _bufferState = BUFFER_FLUSH; break; default: if (_state == VideoState.BUFFERING){ setStateFromCachedState(); }; break; }; break; case "NetStream.Buffer.Full": if (((_sawSeekNotify) && ((_state == VideoState.SEEKING)))){ _bufferState = BUFFER_EMPTY; _sawPlayStop = false; setStateFromCachedState(false); doUpdateTime(); execQueuedCmds(); }; switch (_bufferState){ case BUFFER_EMPTY: _bufferState = BUFFER_FULL; if (!_hiddenForResize){ if ((((((_state == VideoState.LOADING)) && ((_cachedState == VideoState.PLAYING)))) || ((_state == VideoState.BUFFERING)))){ setState(VideoState.PLAYING); } else { if (_cachedState == VideoState.BUFFERING){ _cachedState = VideoState.PLAYING; }; }; if (_rtmpDoStopAtEndTimer.running){ _sawPlayStop = true; _rtmpDoStopAtEndTimer.reset(); }; }; break; case BUFFER_FLUSH: _bufferState = BUFFER_FULL; if (_rtmpDoStopAtEndTimer.running){ _sawPlayStop = true; _rtmpDoStopAtEndTimer.reset(); }; break; }; if (_state == VideoState.BUFFERING){ setStateFromCachedState(); }; break; case "NetStream.Pause.Notify": if ((((_state == VideoState.RESIZING)) && (_hiddenForResize))){ finishAutoResize(); }; break; case "NetStream.Unpause.Notify": if (_state == VideoState.PAUSED){ _state = VideoState.PLAYING; setState(VideoState.BUFFERING); } else { _cachedState = VideoState.PLAYING; }; break; case "NetStream.Play.Start": _rtmpDoStopAtEndTimer.reset(); _bufferState = BUFFER_EMPTY; _sawPlayStop = false; if (_startingPlay){ _startingPlay = false; _cachedPlayheadTime = playheadTime; } else { if (_state == VideoState.PLAYING){ setState(VideoState.BUFFERING); }; }; break; case "NetStream.Play.Reset": _rtmpDoStopAtEndTimer.reset(); if (_state == VideoState.REWINDING){ _rtmpDoSeekTimer.reset(); if ((((playheadTime == 0)) || ((playheadTime < _cachedPlayheadTime)))){ setStateFromCachedState(); } else { _cachedPlayheadTime = playheadTime; _rtmpDoSeekTimer.start(); }; }; break; case "NetStream.Seek.Notify": if (playheadTime != _cachedPlayheadTime){ setStateFromCachedState(false); doUpdateTime(); execQueuedCmds(); } else { _sawSeekNotify = true; _rtmpDoSeekTimer.start(); }; break; case "Netstream.Play.UnpublishNotify": break; case "Netstream.Play.PublishNotify": break; case "NetStream.Play.StreamNotFound": if (!_ncMgr.connectAgain()){ setState(VideoState.CONNECTION_ERROR); }; break; case "NetStream.Play.Failed": case "NetStream.Failed": case "NetStream.Play.FileStructureInvalid": case "NetStream.Play.NoSupportedTrackFound": setState(VideoState.CONNECTION_ERROR); break; }; } public function set progressInterval(_arg1:Number):void{ _updateProgressTimer.delay = _arg1; } flvplayback_internal function onCuePoint(_arg1:Object):void{ if (((!(_hiddenForResize)) || (((!(isNaN(_hiddenRewindPlayheadTime))) && ((playheadTime < _hiddenRewindPlayheadTime)))))){ dispatchEvent(new MetadataEvent(MetadataEvent.CUE_POINT, false, false, _arg1)); }; } flvplayback_internal function createINCManager():void{ var theClass:Class; theClass = null; try { if ((iNCManagerClass is String)){ theClass = Class(getDefinitionByName(String(iNCManagerClass))); } else { if ((iNCManagerClass is Class)){ theClass = Class(iNCManagerClass); }; }; } catch(e:Error) { theClass = null; }; if (theClass == null){ throw (new VideoError(VideoError.INCMANAGER_CLASS_UNSET, ((iNCManagerClass)==null) ? "null" : iNCManagerClass.toString())); }; _ncMgr = new (theClass); _ncMgr.videoPlayer = this; } flvplayback_internal function doAutoResize(_arg1:TimerEvent=null):void{ var _local2:Boolean; var _local3:int; var _local4:int; var _local5:Number; var _local6:Number; if (_autoResizeTimer.running){ switch (_state){ case VideoState.RESIZING: case VideoState.LOADING: break; case VideoState.DISCONNECTED: case VideoState.CONNECTION_ERROR: _autoResizeTimer.reset(); return; default: if (!stateResponsive){ return; }; }; if (((((((((!((super.videoWidth == _prevVideoWidth))) || (!((super.videoHeight == _prevVideoHeight))))) || ((_bufferState == BUFFER_FULL)))) || ((_bufferState == BUFFER_FLUSH)))) || ((_ns.time > autoResizePlayheadTimeout)))){ if (((((_hiddenForResize) && (!(_ns.client.ready)))) && ((_hiddenForResizeMetadataDelay < autoResizeMetadataDelayMax)))){ _hiddenForResizeMetadataDelay++; return; }; _autoResizeTimer.reset(); } else { return; }; }; if (_autoResizeDone){ setState(_cachedState); return; }; oldBounds = new Rectangle(x, y, width, height); oldRegistrationBounds = new Rectangle(registrationX, registrationY, registrationWidth, registrationHeight); _autoResizeDone = true; _local2 = _readyDispatched; _readyDispatched = true; _local3 = videoWidth; _local4 = videoHeight; _readyDispatched = _local2; switch (_scaleMode){ case VideoScaleMode.NO_SCALE: super.width = _local3; super.height = _local4; break; case VideoScaleMode.EXACT_FIT: super.width = registrationWidth; super.height = registrationHeight; break; case VideoScaleMode.MAINTAIN_ASPECT_RATIO: default: _local5 = ((_local3 * _registrationHeight) / _local4); _local6 = ((_local4 * _registrationWidth) / _local3); if (_local6 < _registrationHeight){ super.width = _registrationWidth; super.height = _local6; } else { if (_local5 < _registrationWidth){ super.width = _local5; super.height = _registrationHeight; } else { super.width = _registrationWidth; super.height = _registrationHeight; }; }; }; switch (_align){ case VideoAlign.CENTER: case VideoAlign.TOP: case VideoAlign.BOTTOM: default: super.x = (_registrationX + ((_registrationWidth - width) / 2)); break; case VideoAlign.LEFT: case VideoAlign.TOP_LEFT: case VideoAlign.BOTTOM_LEFT: super.x = _registrationX; break; case VideoAlign.RIGHT: case VideoAlign.TOP_RIGHT: case VideoAlign.BOTTOM_RIGHT: super.x = (_registrationX + (_registrationWidth - width)); break; }; switch (_align){ case VideoAlign.CENTER: case VideoAlign.LEFT: case VideoAlign.RIGHT: default: super.y = (_registrationY + ((_registrationHeight - height) / 2)); break; case VideoAlign.TOP: case VideoAlign.TOP_LEFT: case VideoAlign.TOP_RIGHT: super.y = _registrationY; break; case VideoAlign.BOTTOM: case VideoAlign.BOTTOM_LEFT: case VideoAlign.BOTTOM_RIGHT: super.y = (_registrationY + (_registrationHeight - height)); break; }; if (_hiddenForResize){ _hiddenRewindPlayheadTime = playheadTime; if (_state == VideoState.LOADING){ _cachedState = VideoState.PLAYING; }; if (!_ncMgr.isRTMP){ _pause(true); _seek(0); _finishAutoResizeTimer.reset(); _finishAutoResizeTimer.start(); } else { if (!_isLive){ _currentPos = 0; _play(0, 0); setState(VideoState.RESIZING); } else { if (_autoPlay){ _finishAutoResizeTimer.reset(); _finishAutoResizeTimer.start(); } else { finishAutoResize(); }; }; }; } else { dispatchEvent(new AutoLayoutEvent(AutoLayoutEvent.AUTO_LAYOUT, false, false, oldBounds, oldRegistrationBounds)); }; } public function get totalTime():Number{ return (_streamLength); } public function get ncMgr():INCManager{ if (_ncMgr == null){ createINCManager(); }; return (_ncMgr); } public function set volume(_arg1:Number):void{ var _local2:SoundTransform; _local2 = soundTransform; _local2.volume = _arg1; soundTransform = _local2; } flvplayback_internal function _play(_arg1:int=0, _arg2:int=-1):void{ waitingForEnough = false; _rtmpDoStopAtEndTimer.reset(); _startingPlay = true; _ns.play(_ncMgr.streamName, (_isLive) ? -1 : _arg1, _arg2); } flvplayback_internal function finishAutoResize(_arg1:TimerEvent=null):void{ if (stateResponsive){ return; }; _hiddenForResize = false; super.visible = __visible; volume = _volume; dispatchEvent(new AutoLayoutEvent(AutoLayoutEvent.AUTO_LAYOUT, false, false, oldBounds, oldRegistrationBounds)); if (_autoPlay){ if (_ncMgr.isRTMP){ if (!_isLive){ _currentPos = 0; _play(0); }; if (_state == VideoState.RESIZING){ setState(VideoState.LOADING); _cachedState = VideoState.PLAYING; }; } else { waitingForEnough = true; _cachedState = _state; _state = VideoState.PAUSED; checkReadyForPlay(bytesLoaded, bytesTotal); if (waitingForEnough){ _state = _cachedState; setState(VideoState.PAUSED); } else { _cachedState = VideoState.PLAYING; }; }; } else { setState(VideoState.STOPPED); }; } public function set soundTransform(_arg1:SoundTransform):void{ if (_arg1 == null){ return; }; if (_hiddenForResize){ _volume = _arg1.volume; }; _soundTransform = new SoundTransform(); _soundTransform.volume = (_hiddenForResize) ? 0 : _arg1.volume; _soundTransform.leftToLeft = _arg1.leftToLeft; _soundTransform.leftToRight = _arg1.leftToRight; _soundTransform.rightToLeft = _arg1.rightToLeft; _soundTransform.rightToRight = _arg1.rightToRight; if (_ns != null){ _ns.soundTransform = _soundTransform; }; } flvplayback_internal function httpDoSeek(_arg1:TimerEvent):void{ var _local2:Boolean; _local2 = (((_state == VideoState.REWINDING)) || ((_state == VideoState.SEEKING))); if (((((_local2) && ((_httpDoSeekCount < httpDoSeekMaxCount)))) && ((((_cachedPlayheadTime == playheadTime)) || (_invalidSeekTime))))){ _httpDoSeekCount++; return; }; _httpDoSeekCount = 0; _httpDoSeekTimer.reset(); if (!_local2){ return; }; setStateFromCachedState(false); if (_invalidSeekTime){ _invalidSeekTime = false; _invalidSeekRecovery = true; seek(playheadTime); } else { doUpdateTime(); _lastSeekTime = playheadTime; execQueuedCmds(); }; } public function get bytesLoaded():uint{ if ((((_ns == null)) || (_ncMgr.isRTMP))){ return (uint.MIN_VALUE); }; return (_ns.bytesLoaded); } override public function set height(_arg1:Number):void{ super.height = (_registrationHeight = _arg1); switch (_scaleMode){ case VideoScaleMode.MAINTAIN_ASPECT_RATIO: case VideoScaleMode.NO_SCALE: startAutoResize(); break; default: super.height = _arg1; break; }; } flvplayback_internal function httpNetStatus(_arg1:NetStatusEvent):void{ switch (_arg1.info.code){ case "NetStream.Play.Stop": _delayedBufferingTimer.reset(); if (_invalidSeekTime){ _invalidSeekTime = false; _invalidSeekRecovery = true; setState(_cachedState); seek(playheadTime); } else { switch (_state){ case VideoState.SEEKING: httpDoSeek(null); case VideoState.PLAYING: case VideoState.BUFFERING: httpDoStopAtEnd(); break; }; }; break; case "NetStream.Seek.InvalidTime": if (_invalidSeekRecovery){ _invalidSeekTime = false; _invalidSeekRecovery = false; setState(_cachedState); seek(0); } else { _invalidSeekTime = true; _httpDoSeekCount = 0; _httpDoSeekTimer.start(); }; break; case "NetStream.Buffer.Empty": _bufferState = BUFFER_EMPTY; if (_state == VideoState.PLAYING){ _delayedBufferingTimer.reset(); _delayedBufferingTimer.start(); }; break; case "NetStream.Buffer.Full": case "NetStream.Buffer.Flush": _delayedBufferingTimer.reset(); _bufferState = BUFFER_FULL; if (!_hiddenForResize){ if ((((((_state == VideoState.LOADING)) && ((_cachedState == VideoState.PLAYING)))) || ((_state == VideoState.BUFFERING)))){ setState(VideoState.PLAYING); } else { if (_cachedState == VideoState.BUFFERING){ _cachedState = VideoState.PLAYING; }; }; }; break; case "NetStream.Seek.Notify": _invalidSeekRecovery = false; switch (_state){ case VideoState.SEEKING: case VideoState.REWINDING: _httpDoSeekCount = 0; _httpDoSeekTimer.start(); break; }; break; case "NetStream.Play.StreamNotFound": case "NetStream.Play.FileStructureInvalid": case "NetStream.Play.NoSupportedTrackFound": setState(VideoState.CONNECTION_ERROR); break; }; } public function get netConnection():NetConnection{ if (_ncMgr != null){ return (_ncMgr.netConnection); }; return (null); } public function set bufferTime(_arg1:Number):void{ _bufferTime = _arg1; if (_ns != null){ _ns.bufferTime = _bufferTime; }; } flvplayback_internal function onMetaData(_arg1:Object):void{ if (_metadata != null){ return; }; _metadata = _arg1; if (isNaN(_streamLength)){ _streamLength = _arg1.duration; }; if (((_resizeImmediatelyOnMetadata) && (_ns.client.ready))){ _resizeImmediatelyOnMetadata = false; _autoResizeTimer.reset(); _autoResizeDone = false; doAutoResize(); }; dispatchEvent(new MetadataEvent(MetadataEvent.METADATA_RECEIVED, false, false, _arg1)); } flvplayback_internal function queueCmd(_arg1:Number, _arg2:String=null, _arg3:Boolean=false, _arg4:Number=NaN):void{ _cmdQueue.push(new QueuedCommand(_arg1, _arg2, _arg3, _arg4)); } public function set registrationHeight(_arg1:Number):void{ height = _arg1; } override public function get visible():Boolean{ if (!_hiddenForResize){ __visible = super.visible; }; return (__visible); } public function seek(_arg1:Number):void{ if (_invalidSeekTime){ return; }; if (((isNaN(_arg1)) || ((_arg1 < 0)))){ throw (new VideoError(VideoError.INVALID_SEEK)); }; if (!isXnOK()){ if ((((((_state == VideoState.CONNECTION_ERROR)) || ((_ncMgr == null)))) || ((_ncMgr.netConnection == null)))){ throw (new VideoError(VideoError.NO_CONNECTION)); }; flushQueuedCmds(); queueCmd(QueuedCommand.SEEK, null, false, _arg1); setState(VideoState.LOADING); _cachedState = VideoState.LOADING; _ncMgr.reconnect(); return; } else { if (_state == VideoState.EXEC_QUEUED_CMD){ _state = _cachedState; } else { if (!stateResponsive){ queueCmd(QueuedCommand.SEEK, null, false, _arg1); return; }; execQueuedCmds(); }; }; if (_ns == null){ _createStream(); }; if (((_atEnd) && ((_arg1 < playheadTime)))){ _atEnd = false; }; switch (_state){ case VideoState.PLAYING: _state = VideoState.BUFFERING; case VideoState.BUFFERING: case VideoState.PAUSED: _seek(_arg1); setState(VideoState.SEEKING); break; case VideoState.STOPPED: if (_ncMgr.isRTMP){ _play(0); _pause(true); }; _seek(_arg1); _state = VideoState.PAUSED; setState(VideoState.SEEKING); break; }; } public function get state():String{ return (_state); } public function set autoRewind(_arg1:Boolean):void{ _autoRewind = _arg1; } override public function set scaleX(_arg1:Number):void{ super.scaleX = _arg1; _registrationWidth = width; switch (_scaleMode){ case VideoScaleMode.MAINTAIN_ASPECT_RATIO: case VideoScaleMode.NO_SCALE: startAutoResize(); break; }; } override public function set scaleY(_arg1:Number):void{ super.scaleY = _arg1; _registrationHeight = height; switch (_scaleMode){ case VideoScaleMode.MAINTAIN_ASPECT_RATIO: case VideoScaleMode.NO_SCALE: startAutoResize(); break; }; } public function get registrationWidth():Number{ return (_registrationWidth); } flvplayback_internal function flushQueuedCmds():void{ while (_cmdQueue.length > 0) { _cmdQueue.pop(); }; } public function get registrationX():Number{ return (_registrationX); } flvplayback_internal function _setUpStream():void{ if (((!(isNaN(_ncMgr.streamLength))) && ((_ncMgr.streamLength >= 0)))){ _streamLength = _ncMgr.streamLength; }; _videoWidth = ((_ncMgr.streamWidth)>=0) ? _ncMgr.streamWidth : -1; _videoHeight = ((_ncMgr.streamHeight)>=0) ? _ncMgr.streamHeight : -1; _resizeImmediatelyOnMetadata = (((((_videoWidth >= 0)) && ((_videoHeight >= 0)))) || ((_scaleMode == VideoScaleMode.EXACT_FIT))); if (!_hiddenForResize){ __visible = super.visible; super.visible = false; _volume = volume; volume = 0; _hiddenForResize = true; }; _hiddenForResizeMetadataDelay = 0; _play(0); if (_currentPos > 0){ _seek(_currentPos); _currentPos = 0; }; _autoResizeTimer.reset(); _autoResizeTimer.start(); } public function get registrationY():Number{ return (_registrationY); } flvplayback_internal function httpDoStopAtEnd():void{ if ((((((_atEndCheckPlayhead == playheadTime)) && (!((_atEndCheckPlayhead == _lastUpdateTime))))) && (!((playheadTime == 0))))){ _atEnd = false; _seek(0); return; }; _atEndCheckPlayhead = NaN; _atEnd = true; if (isNaN(_streamLength)){ _streamLength = _ns.time; }; _pause(true); setState(VideoState.STOPPED); if (_state != VideoState.STOPPED){ return; }; doUpdateTime(); if (_state != VideoState.STOPPED){ return; }; dispatchEvent(new VideoEvent(VideoEvent.COMPLETE, false, false, _state, playheadTime)); if (_state != VideoState.STOPPED){ return; }; if (_autoRewind){ _atEnd = false; _pause(true); _seek(0); setState(VideoState.REWINDING); }; } public function ncConnected():void{ if ((((_ncMgr == null)) || ((_ncMgr.netConnection == null)))){ setState(VideoState.CONNECTION_ERROR); } else { if (_ns == null){ _createStream(); _setUpStream(); }; }; } override public function set visible(_arg1:Boolean):void{ __visible = _arg1; if (!_hiddenForResize){ super.visible = __visible; }; } public function load(_arg1:String, _arg2:Number=NaN, _arg3:Boolean=false):void{ if (_arg1 == null){ throw (new VideoError(VideoError.NULL_URL_LOAD)); }; if (_state == VideoState.EXEC_QUEUED_CMD){ _state = _cachedState; } else { if (((((!(stateResponsive)) && (!((_state == VideoState.DISCONNECTED))))) && (!((_state == VideoState.CONNECTION_ERROR))))){ queueCmd(QueuedCommand.LOAD, _arg1, _arg3, _arg2); return; }; execQueuedCmds(); }; _autoPlay = false; _load(_arg1, _arg2, _arg3); } override public function set x(_arg1:Number):void{ var _local2:Number; if (this.x != _arg1){ _local2 = (_arg1 - this.x); super.x = _arg1; _registrationX = (_registrationX + _local2); }; } override public function set y(_arg1:Number):void{ var _local2:Number; if (this.y != _arg1){ _local2 = (_arg1 - this.y); super.y = _arg1; _registrationY = (_registrationY + _local2); }; } flvplayback_internal function _pause(_arg1:Boolean):void{ _atEndCheckPlayhead = playheadTime; _rtmpDoStopAtEndTimer.reset(); if (_arg1){ _ns.pause(); } else { _ns.resume(); }; } public function get playheadUpdateInterval():Number{ return (_updateTimeTimer.delay); } flvplayback_internal function doDelayedBuffering(_arg1:TimerEvent):void{ switch (_state){ case VideoState.LOADING: case VideoState.RESIZING: break; case VideoState.PLAYING: _delayedBufferingTimer.reset(); if (((((((((!(isNaN(totalTime))) && ((totalTime > 0)))) && ((bytesLoaded > 0)))) && ((bytesLoaded < uint.MAX_VALUE)))) && ((bytesLoaded < bytesTotal)))){ pause(); if (_state == VideoState.PAUSED){ waitingForEnough = true; playWhenEnoughDownloaded(); }; } else { setState(VideoState.BUFFERING); }; break; default: _delayedBufferingTimer.reset(); break; }; } flvplayback_internal function createNetStreamClient():Object{ var theClass:Class; var theInst:Object; theClass = null; theInst = null; try { if ((netStreamClientClass is String)){ theClass = Class(getDefinitionByName(String(netStreamClientClass))); } else { if ((netStreamClientClass is Class)){ theClass = Class(netStreamClientClass); }; }; if (theClass != null){ theInst = new theClass(this); }; } catch(e:Error) { theClass = null; theInst = null; }; if (theInst == null){ throw (new VideoError(VideoError.NETSTREAM_CLIENT_CLASS_UNSET, ((netStreamClientClass)==null) ? "null" : netStreamClientClass.toString())); }; return (theInst); } public function get align():String{ return (_align); } public function set registrationWidth(_arg1:Number):void{ width = _arg1; } public function get stateResponsive():Boolean{ switch (_state){ case VideoState.STOPPED: case VideoState.PLAYING: case VideoState.PAUSED: case VideoState.BUFFERING: return (true); default: return (false); }; } public function get volume():Number{ return (soundTransform.volume); } public function get soundTransform():SoundTransform{ var _local1:SoundTransform; if (_ns != null){ _soundTransform = _ns.soundTransform; }; _local1 = new SoundTransform(); _local1.volume = (_hiddenForResize) ? _volume : _soundTransform.volume; _local1.leftToLeft = _soundTransform.leftToLeft; _local1.leftToRight = _soundTransform.leftToRight; _local1.rightToLeft = _soundTransform.rightToLeft; _local1.rightToRight = _soundTransform.rightToRight; return (_local1); } public function get bufferTime():Number{ if (_ns != null){ _bufferTime = _ns.bufferTime; }; return (_bufferTime); } public function get metadata():Object{ return (_metadata); } public function play(_arg1:String=null, _arg2:Number=NaN, _arg3:Boolean=false):void{ if (_arg1 != null){ if (_state == VideoState.EXEC_QUEUED_CMD){ _state = _cachedState; } else { if (((((!(stateResponsive)) && (!((_state == VideoState.DISCONNECTED))))) && (!((_state == VideoState.CONNECTION_ERROR))))){ queueCmd(QueuedCommand.PLAY, _arg1, _arg3, _arg2); return; }; execQueuedCmds(); }; _autoPlay = true; _load(_arg1, _arg2, _arg3); return; }; if (!isXnOK()){ if ((((((_state == VideoState.CONNECTION_ERROR)) || ((_ncMgr == null)))) || ((_ncMgr.netConnection == null)))){ throw (new VideoError(VideoError.NO_CONNECTION)); }; flushQueuedCmds(); queueCmd(QueuedCommand.PLAY); setState(VideoState.LOADING); _cachedState = VideoState.LOADING; _ncMgr.reconnect(); return; } else { if (_state == VideoState.EXEC_QUEUED_CMD){ _state = _cachedState; } else { if (!stateResponsive){ queueCmd(QueuedCommand.PLAY); return; }; execQueuedCmds(); }; }; if (_ns == null){ _createStream(); }; switch (_state){ case VideoState.BUFFERING: if (_ncMgr.isRTMP){ _play(0); if (_atEnd){ _atEnd = false; _currentPos = 0; setState(VideoState.REWINDING); } else { if (_currentPos > 0){ _seek(_currentPos); _currentPos = 0; }; }; }; case VideoState.PLAYING: return; case VideoState.STOPPED: if (_ncMgr.isRTMP){ if (_isLive){ _play(-1); setState(VideoState.BUFFERING); } else { _play(0); if (_atEnd){ _atEnd = false; _currentPos = 0; _state = VideoState.BUFFERING; setState(VideoState.REWINDING); } else { if (_currentPos > 0){ _seek(_currentPos); _currentPos = 0; setState(VideoState.BUFFERING); } else { setState(VideoState.BUFFERING); }; }; }; } else { _pause(false); if (_atEnd){ _atEnd = false; _seek(0); _state = VideoState.BUFFERING; setState(VideoState.REWINDING); } else { if (_bufferState == BUFFER_EMPTY){ setState(VideoState.BUFFERING); } else { setState(VideoState.PLAYING); }; }; }; break; case VideoState.PAUSED: _pause(false); if (!_ncMgr.isRTMP){ if (_bufferState == BUFFER_EMPTY){ setState(VideoState.BUFFERING); } else { setState(VideoState.PLAYING); }; } else { setState(VideoState.BUFFERING); }; break; }; } public function get isLive():Boolean{ return (_isLive); } flvplayback_internal function setStateFromCachedState(_arg1:Boolean=true):void{ switch (_cachedState){ case VideoState.PLAYING: case VideoState.PAUSED: case VideoState.BUFFERING: setState(_cachedState, _arg1); break; default: setState(VideoState.STOPPED, _arg1); break; }; } public function get idleTimeout():Number{ return (_idleTimeoutTimer.delay); } public function get registrationHeight():Number{ return (_registrationHeight); } public function ncReconnected():void{ if ((((_ncMgr == null)) || ((_ncMgr.netConnection == null)))){ setState(VideoState.CONNECTION_ERROR); } else { _ns = null; _state = VideoState.STOPPED; execQueuedCmds(); }; } flvplayback_internal function startAutoResize():void{ switch (_state){ case VideoState.DISCONNECTED: case VideoState.CONNECTION_ERROR: return; default: if (_ns == null){ return; }; _autoResizeDone = false; if (((stateResponsive) && (((((((((!((super.videoWidth == 0))) || (!((super.videoHeight == 0))))) || ((_bufferState == BUFFER_FULL)))) || ((_bufferState == BUFFER_FLUSH)))) || ((_ns.time > autoResizePlayheadTimeout)))))){ doAutoResize(); } else { _autoResizeTimer.reset(); _autoResizeTimer.start(); }; break; }; } flvplayback_internal function setState(_arg1:String, _arg2:Boolean=true):void{ var _local3:String; if (_arg1 == _state){ return; }; _hiddenRewindPlayheadTime = NaN; _cachedState = _state; _cachedPlayheadTime = playheadTime; _state = _arg1; _local3 = _state; dispatchEvent(new VideoEvent(VideoEvent.STATE_CHANGE, false, false, _local3, playheadTime)); if (!_readyDispatched){ switch (_local3){ case VideoState.STOPPED: case VideoState.PLAYING: case VideoState.PAUSED: case VideoState.BUFFERING: _readyDispatched = true; dispatchEvent(new VideoEvent(VideoEvent.READY, false, false, _local3, playheadTime)); break; }; }; switch (_cachedState){ case VideoState.REWINDING: dispatchEvent(new VideoEvent(VideoEvent.AUTO_REWOUND, false, false, _local3, playheadTime)); if (((_ncMgr.isRTMP) && ((_local3 == VideoState.STOPPED)))){ closeNS(); }; break; }; switch (_local3){ case VideoState.STOPPED: case VideoState.PAUSED: if (_ncMgr.isRTMP){ _idleTimeoutTimer.reset(); _idleTimeoutTimer.start(); }; break; case VideoState.SEEKING: case VideoState.REWINDING: _bufferState = BUFFER_EMPTY; _sawPlayStop = false; _idleTimeoutTimer.reset(); break; case VideoState.PLAYING: case VideoState.BUFFERING: _updateTimeTimer.start(); _idleTimeoutTimer.reset(); break; case VideoState.LOADING: case VideoState.RESIZING: _idleTimeoutTimer.reset(); break; }; if (_arg2){ execQueuedCmds(); }; } flvplayback_internal function _seek(_arg1:Number):void{ _rtmpDoStopAtEndTimer.reset(); if (((((!((_metadata == null))) && (!((_metadata.audiodelay == undefined))))) && (((isNaN(_streamLength)) || (((_arg1 + _metadata.audiodelay) < _streamLength)))))){ _arg1 = (_arg1 + _metadata.audiodelay); }; _ns.seek(_arg1); _lastSeekTime = _arg1; _invalidSeekTime = false; _bufferState = BUFFER_EMPTY; _sawPlayStop = false; _sawSeekNotify = false; } public function get autoRewind():Boolean{ return (_autoRewind); } flvplayback_internal function doIdleTimeout(_arg1:TimerEvent):void{ close(); } public function playWhenEnoughDownloaded():void{ if (((!((_ncMgr == null))) && (_ncMgr.isRTMP))){ play(); return; }; if (!isXnOK()){ throw (new VideoError(VideoError.NO_CONNECTION)); }; if (_state == VideoState.EXEC_QUEUED_CMD){ _state = _cachedState; } else { if (!stateResponsive){ queueCmd(QueuedCommand.PLAY_WHEN_ENOUGH); return; }; execQueuedCmds(); }; waitingForEnough = true; checkReadyForPlay(bytesLoaded, bytesTotal); } flvplayback_internal function rtmpDoSeek(_arg1:TimerEvent):void{ if (((!((_state == VideoState.REWINDING))) && (!((_state == VideoState.SEEKING))))){ _rtmpDoSeekTimer.reset(); _sawSeekNotify = false; } else { if (playheadTime != _cachedPlayheadTime){ _rtmpDoSeekTimer.reset(); _sawSeekNotify = false; setStateFromCachedState(false); doUpdateTime(); _lastSeekTime = playheadTime; execQueuedCmds(); }; }; } public function get netStream():NetStream{ return (_ns); } override public function get videoHeight():int{ if (_videoHeight > 0){ return (_videoHeight); }; if (((((!((_metadata == null))) && (!(isNaN(_metadata.width))))) && (!(isNaN(_metadata.height))))){ if ((((_metadata.width == _metadata.height)) && (_readyDispatched))){ return (super.videoHeight); }; return (int(_metadata.height)); }; if (_readyDispatched){ return (super.videoHeight); }; return (-1); } public function set registrationX(_arg1:Number):void{ var _local2:Number; if (_registrationX != _arg1){ _local2 = (_arg1 - _registrationX); _registrationX = _arg1; this.x = (this.x + _local2); }; } public function set registrationY(_arg1:Number):void{ var _local2:Number; if (_registrationY != _arg1){ _local2 = (_arg1 - _registrationY); _registrationY = _arg1; this.y = (this.y + _local2); }; } flvplayback_internal function doUpdateProgress(_arg1:TimerEvent):void{ var _local2:uint; var _local3:uint; if (_ns == null){ return; }; _local2 = _ns.bytesLoaded; _local3 = _ns.bytesTotal; if (_local3 < uint.MAX_VALUE){ dispatchEvent(new VideoProgressEvent(VideoProgressEvent.PROGRESS, false, false, _local2, _local3)); }; if ((((((_state == VideoState.DISCONNECTED)) || ((_state == VideoState.CONNECTION_ERROR)))) || ((_local2 >= _local3)))){ _updateProgressTimer.stop(); }; checkEnoughDownloaded(_local2, _local3); } override public function set width(_arg1:Number):void{ super.width = (_registrationWidth = _arg1); switch (_scaleMode){ case VideoScaleMode.MAINTAIN_ASPECT_RATIO: case VideoScaleMode.NO_SCALE: startAutoResize(); break; default: super.width = _arg1; break; }; } public function get isRTMP():Boolean{ if (_ncMgr == null){ return (false); }; return (_ncMgr.isRTMP); } public function get bytesTotal():uint{ if ((((_ns == null)) || (_ncMgr.isRTMP))){ return (uint.MAX_VALUE); }; return (_ns.bytesTotal); } public function setSize(_arg1:Number, _arg2:Number):void{ super.width = (_registrationWidth = _arg1); super.height = (_registrationHeight = _arg2); switch (_scaleMode){ case VideoScaleMode.MAINTAIN_ASPECT_RATIO: case VideoScaleMode.NO_SCALE: startAutoResize(); break; default: super.x = _registrationX; super.y = _registrationY; break; }; } flvplayback_internal function isXnOK():Boolean{ if (_state == VideoState.LOADING){ return (true); }; if (_state == VideoState.CONNECTION_ERROR){ return (false); }; if (_state != VideoState.DISCONNECTED){ if ((((((_ncMgr == null)) || ((_ncMgr.netConnection == null)))) || (((_ncMgr.isRTMP) && (!(_ncMgr.netConnection.connected)))))){ setState(VideoState.DISCONNECTED); return (false); }; return (true); }; return (false); } flvplayback_internal function _createStream():void{ var _local1:NetStream; _ns = null; _local1 = new NetStream(_ncMgr.netConnection); if (_ncMgr.isRTMP){ _local1.addEventListener(NetStatusEvent.NET_STATUS, rtmpNetStatus); } else { _local1.addEventListener(NetStatusEvent.NET_STATUS, httpNetStatus); }; _local1.client = createNetStreamClient(); _local1.bufferTime = _bufferTime; _local1.soundTransform = soundTransform; _ns = _local1; attachNetStream(_ns); } flvplayback_internal function checkReadyForPlay(_arg1:uint, _arg2:uint):void{ var _local3:Number; if (_arg1 >= _arg2){ waitingForEnough = false; _cachedState = _state; _state = VideoState.EXEC_QUEUED_CMD; play(); execQueuedCmds(); return; }; if (isNaN(baselineProgressTime)){ return; }; if (((isNaN(totalTime)) || ((totalTime < 0)))){ waitingForEnough = false; _cachedState = _state; _state = VideoState.EXEC_QUEUED_CMD; play(); execQueuedCmds(); } else { if (totalDownloadTime > 1.5){ _local3 = ((totalProgressTime - baselineProgressTime) / totalDownloadTime); if ((totalTime - playheadTime) > ((totalTime - totalProgressTime) / _local3)){ waitingForEnough = false; _cachedState = _state; _state = VideoState.EXEC_QUEUED_CMD; play(); execQueuedCmds(); }; }; }; } flvplayback_internal function closeNS(_arg1:Boolean=false):void{ if (_ns != null){ if (_arg1){ doUpdateTime(); _currentPos = _ns.time; }; _updateTimeTimer.reset(); _updateProgressTimer.reset(); _idleTimeoutTimer.reset(); _autoResizeTimer.reset(); _rtmpDoStopAtEndTimer.reset(); _rtmpDoSeekTimer.reset(); _httpDoSeekTimer.reset(); _finishAutoResizeTimer.reset(); _delayedBufferingTimer.reset(); _ns.removeEventListener(NetStatusEvent.NET_STATUS, rtmpNetStatus); _ns.removeEventListener(NetStatusEvent.NET_STATUS, httpNetStatus); _ns.close(); _ns = null; }; } flvplayback_internal function _load(_arg1:String, _arg2:Number, _arg3:Boolean):void{ var _local4:Boolean; _prevVideoWidth = super.videoWidth; _prevVideoHeight = super.videoHeight; _autoResizeDone = false; _cachedPlayheadTime = 0; _bufferState = BUFFER_EMPTY; _sawPlayStop = false; _metadata = null; _startingPlay = false; _invalidSeekTime = false; _invalidSeekRecovery = false; _isLive = _arg3; _contentPath = _arg1; _currentPos = 0; _streamLength = (((isNaN(_arg2)) || ((_arg2 <= 0)))) ? NaN : _arg2; _atEnd = false; _readyDispatched = false; _lastUpdateTime = NaN; lastUpdateTimeStuckCount = 0; _sawSeekNotify = false; waitingForEnough = false; baselineProgressTime = NaN; startProgressTime = NaN; totalDownloadTime = NaN; totalProgressTime = NaN; _httpDoSeekCount = 0; _updateTimeTimer.reset(); _updateProgressTimer.reset(); _idleTimeoutTimer.reset(); _autoResizeTimer.reset(); _rtmpDoStopAtEndTimer.reset(); _rtmpDoSeekTimer.reset(); _httpDoSeekTimer.reset(); _finishAutoResizeTimer.reset(); _delayedBufferingTimer.reset(); closeNS(false); if (_ncMgr == null){ createINCManager(); }; _local4 = _ncMgr.connectToURL(_contentPath); setState(VideoState.LOADING); _cachedState = VideoState.LOADING; if (_local4){ _createStream(); _setUpStream(); }; if (!_ncMgr.isRTMP){ _updateProgressTimer.start(); }; } flvplayback_internal function rtmpDoStopAtEnd(_arg1:TimerEvent=null):void{ if (_rtmpDoStopAtEndTimer.running){ switch (_state){ case VideoState.DISCONNECTED: case VideoState.CONNECTION_ERROR: _rtmpDoStopAtEndTimer.reset(); return; }; if ((((_arg1 == null)) || ((_cachedPlayheadTime == playheadTime)))){ _rtmpDoStopAtEndTimer.reset(); } else { _cachedPlayheadTime = playheadTime; return; }; }; if ((((((((_atEndCheckPlayhead == playheadTime)) && (!((_atEndCheckPlayhead == _lastSeekTime))))) && (!(_isLive)))) && (!((playheadTime == 0))))){ _atEnd = false; _currentPos = 0; _play(0); return; }; _atEndCheckPlayhead = NaN; _bufferState = BUFFER_EMPTY; _sawPlayStop = false; _atEnd = true; setState(VideoState.STOPPED); if (_state != VideoState.STOPPED){ return; }; doUpdateTime(); if (_state != VideoState.STOPPED){ return; }; dispatchEvent(new VideoEvent(VideoEvent.COMPLETE, false, false, _state, playheadTime)); if (_state != VideoState.STOPPED){ return; }; if (((((_autoRewind) && (!(_isLive)))) && (!((playheadTime == 0))))){ _atEnd = false; _currentPos = 0; _play(0, 0); setState(VideoState.REWINDING); } else { closeNS(); }; } public function set idleTimeout(_arg1:Number):void{ _idleTimeoutTimer.delay = _arg1; } public function set playheadUpdateInterval(_arg1:Number):void{ _updateTimeTimer.delay = _arg1; } flvplayback_internal function checkEnoughDownloaded(_arg1:uint, _arg2:uint):void{ if ((((_arg1 == 0)) || ((_arg2 == uint.MAX_VALUE)))){ return; }; if (((isNaN(totalTime)) || ((totalTime <= 0)))){ if (((waitingForEnough) && (stateResponsive))){ waitingForEnough = false; _cachedState = _state; _state = VideoState.EXEC_QUEUED_CMD; play(); execQueuedCmds(); }; return; }; if (_arg1 >= _arg2){ if (waitingForEnough){ waitingForEnough = false; _cachedState = _state; _state = VideoState.EXEC_QUEUED_CMD; play(); execQueuedCmds(); }; return; }; if (isNaN(baselineProgressTime)){ baselineProgressTime = ((_arg1 / _arg2) * totalTime); }; if (isNaN(startProgressTime)){ startProgressTime = getTimer(); } else { totalDownloadTime = ((getTimer() - startProgressTime) / 1000); totalProgressTime = ((_arg1 / _arg2) * totalTime); if (waitingForEnough){ checkReadyForPlay(_arg1, _arg2); }; }; } public function close():void{ closeNS(true); if (((!((_ncMgr == null))) && (_ncMgr.isRTMP))){ _ncMgr.close(); }; setState(VideoState.DISCONNECTED); dispatchEvent(new VideoEvent(VideoEvent.CLOSE, false, false, _state, playheadTime)); } public function pause():void{ if (!isXnOK()){ if ((((((_state == VideoState.CONNECTION_ERROR)) || ((_ncMgr == null)))) || ((_ncMgr.netConnection == null)))){ throw (new VideoError(VideoError.NO_CONNECTION)); }; return; } else { if (_state == VideoState.EXEC_QUEUED_CMD){ _state = _cachedState; } else { if (!stateResponsive){ queueCmd(QueuedCommand.PAUSE); return; }; execQueuedCmds(); }; }; if ((((((_state == VideoState.PAUSED)) || ((_state == VideoState.STOPPED)))) || ((_ns == null)))){ return; }; _pause(true); setState(VideoState.PAUSED); } } }//package fl.video
Section 231
//VideoPlayerClient (fl.video.VideoPlayerClient) package fl.video { public dynamic class VideoPlayerClient { protected var _owner:VideoPlayer; protected var gotMetadata:Boolean; public function VideoPlayerClient(_arg1:VideoPlayer){ _owner = _arg1; gotMetadata = false; } public function get ready():Boolean{ return (gotMetadata); } public function onMetaData(_arg1:Object, ... _args):void{ _arg1.duration; _arg1.width; _arg1.height; _owner.onMetaData(_arg1); gotMetadata = true; } public function get owner():VideoPlayer{ return (_owner); } public function onCuePoint(_arg1:Object, ... _args):void{ _arg1.name; _arg1.time; _arg1.type; _owner.onCuePoint(_arg1); } } }//package fl.video
Section 232
//VideoPlayerState (fl.video.VideoPlayerState) package fl.video { public class VideoPlayerState { public var autoPlay:Boolean; public var isWaiting:Boolean; public var isLiveSet:Boolean; public var index:int; public var prevState:String; public var preSeekTime:Number; public var minProgressPercent:Number; public var url:String; public var totalTime:Number; public var owner:VideoPlayer; public var isLive:Boolean; public var cmdQueue:Array; public var totalTimeSet:Boolean; public function VideoPlayerState(_arg1:VideoPlayer, _arg2:int){ this.owner = _arg1; this.index = _arg2; this.url = ""; this.isLive = false; this.isLiveSet = true; this.totalTime = NaN; this.totalTimeSet = true; this.autoPlay = (_arg2 == 0); this.isWaiting = false; this.preSeekTime = NaN; this.cmdQueue = null; } } }//package fl.video
Section 233
//VideoProgressEvent (fl.video.VideoProgressEvent) package fl.video { import flash.events.*; public class VideoProgressEvent extends ProgressEvent implements IVPEvent { private var _vp:uint; public static const PROGRESS:String = "progress"; public function VideoProgressEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:uint=0, _arg5:uint=0, _arg6:uint=0){ super(_arg1, _arg2, _arg3, _arg4, _arg5); _vp = _arg6; } override public function clone():Event{ return (new VideoProgressEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal, vp)); } public function set vp(_arg1:uint):void{ _vp = _arg1; } public function get vp():uint{ return (_vp); } } }//package fl.video
Section 234
//VideoScaleMode (fl.video.VideoScaleMode) package fl.video { public final class VideoScaleMode { public static const EXACT_FIT:String = "exactFit"; public static const MAINTAIN_ASPECT_RATIO:String = "maintainAspectRatio"; public static const NO_SCALE:String = "noScale"; } }//package fl.video
Section 235
//VideoState (fl.video.VideoState) package fl.video { public final class VideoState { public static const CONNECTION_ERROR:String = "connectionError"; public static const BUFFERING:String = "buffering"; public static const SEEKING:String = "seeking"; public static const STOPPED:String = "stopped"; public static const PAUSED:String = "paused"; public static const RESIZING:String = "resizing"; public static const PLAYING:String = "playing"; public static const DISCONNECTED:String = "disconnected"; public static const LOADING:String = "loading"; public static const REWINDING:String = "rewinding"; flvplayback_internal static var EXEC_QUEUED_CMD:String = "execQueuedCmd"; } }//package fl.video
Section 236
//ByteArrayAsset (mx.core.ByteArrayAsset) package mx.core { import flash.utils.*; public class ByteArrayAsset extends ByteArray { } }//package mx.core
Section 237
//Uncharted2 (Uncharted2) package { import flash.events.*; import flash.display.*; import com.kerb.uncharted.*; public class Uncharted2 extends Sprite { public function Uncharted2(){ addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } private function onAddedToStage(_arg1:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); var _local2:int = loaderInfo.width; var _local3:int = loaderInfo.height; var _local4:Sprite = new Sprite(); var _local5:Graphics = _local4.graphics; _local5.beginFill(0); _local5.drawRect(-1000, -1000, (2000 + _local2), 1000); _local5.drawRect(-1000, _local3, (2000 + _local2), 1000); _local5.drawRect(-1000, -1000, 1000, (1000 + _local3)); _local5.drawRect(_local2, -1000, 1000, (1000 + _local3)); _local5.endFill(); addChild(_local4); addChildAt(new Main(), 0); } } }//package

Library Items

Symbol 1 BinaryData {com.kerb.uncharted.Preload_SWFBytes}
Symbol 2 GraphicUsed by:3
Symbol 3 MovieClipUses:2Used by:7
Symbol 4 BitmapUsed by:5
Symbol 5 GraphicUses:4Used by:6
Symbol 6 MovieClip {fl.video.Icon} [fl.video.Icon]Uses:5Used by:7
Symbol 7 MovieClip {fl.video.FLVPlayback} [fl.video.FLVPlayback]Uses:3 6
Symbol 8 BinaryData {com.kerb.uncharted.game.levels.Level4_LevelData}
Symbol 9 BinaryData {com.kerb.uncharted.Main_text_en_IE}
Symbol 10 BinaryData {com.kerb.uncharted.Main_text_fr_FR}
Symbol 11 BinaryData {com.kerb.uncharted.Main_AvatarSWFBytes}
Symbol 12 BinaryData {com.kerb.uncharted.Main_text_es_ES}
Symbol 13 BinaryData {com.kerb.uncharted.Main_text_ru_RU}
Symbol 14 BinaryData {com.kerb.uncharted.Main_text_pl_PL}
Symbol 15 BinaryData {com.kerb.uncharted.game.levels.Level5_LevelData}
Symbol 16 BinaryData {com.kerb.uncharted.Main_SoundsSWFBytes}
Symbol 17 BinaryData {com.kerb.uncharted.game.levels.Level3_LevelData}
Symbol 18 BinaryData {com.kerb.uncharted.Main_text_it_IT}
Symbol 19 BinaryData {com.kerb.uncharted.Main_text_da_DK}
Symbol 20 BinaryData {com.kerb.uncharted.Main_text_de_DE}
Symbol 21 BinaryData {com.kerb.uncharted.Main_GraphicsSWFBytes}
Symbol 22 BinaryData {com.kerb.uncharted.Main_text_de_CH}
Symbol 23 BinaryData {com.kerb.uncharted.Main_text_nl_BE}
Symbol 24 BinaryData {com.kerb.uncharted.Main_EnemiesSWFBytes}
Symbol 25 BinaryData {com.kerb.uncharted.Main_InterfaceSWFBytes}
Symbol 26 BinaryData {com.kerb.uncharted.Main_text_sv_SE}
Symbol 27 BinaryData {com.kerb.uncharted.Main_text_fi_FI}
Symbol 28 BinaryData {com.kerb.uncharted.game.levels.Level2_LevelData}
Symbol 29 BinaryData {com.kerb.uncharted.Main_text_no_NO}
Symbol 30 BinaryData {com.kerb.uncharted.game.levels.Level1_LevelData}
Symbol 31 BinaryData {com.kerb.uncharted.Main_CutScenesSWFBytes}
Symbol 32 BinaryData {com.kerb.uncharted.Main_text_pt_PT}

Instance Names

"boundingBox_mc"Symbol 7 MovieClip {fl.video.FLVPlayback} [fl.video.FLVPlayback] Frame 1Symbol 3 MovieClip

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 7 as "fl.video.FLVPlayback"
ExportAssets (56)Timeline Frame 2Symbol 6 as "fl.video.Icon"
SerialNumber (41)Timeline Frame 1

Labels

"com_kerb_uncharted_Preload"Frame 1
"Uncharted2"Frame 2




http://swfchan.com/24/118267/info.shtml
Created: 7/3 -2019 08:16:57 Last modified: 7/3 -2019 08:16:57 Server time: 22/12 -2024 11:04:46