Section 1
//Camera3D (iriysoft.engine3d.Camera3D)
package iriysoft.engine3d {
import iriysoft.math.*;
import flash.display.*;
import flash.events.*;
public class Camera3D extends Bitmap {
protected var m_nFOV:Number;
protected var m_coordTarget:Coords3D;
public var coords:Coords3D;
protected var m_nLens:Number;
protected var m_uTargetMode:uint;
public var nDepth:Number;
private static const MIN_FOV:Number = 5;
private static const DEFAULT_DEPTH:Number = 5000;
private static const DEFAULT_WIDTH:Number = 550;
public static const MODE_REAR_VIEW:uint = 3;
private static const DEFAULT_HEIGHT:Number = 400;
private static const DEFAULT_FOV:Number = 45;
private static const MAX_FOV:Number = 175;
public static const MODE_TAIL:uint = 1;
public static const MODE_NONE:uint = 0;
public static const MODE_TRACK:uint = 2;
public function Camera3D(_arg1:uint=550, _arg2:uint=400){
super(new BitmapData(_arg1, _arg2), "auto", true);
this.coords = new Coords3D();
this.nFOV = Camera3D.DEFAULT_FOV;
this.nDepth = Camera3D.DEFAULT_DEPTH;
this.m_uTargetMode = Camera3D.MODE_NONE;
this.addEventListener(Event.ADDED_TO_STAGE, this.onAddToStage);
this.addEventListener(Event.REMOVED_FROM_STAGE, this.onRemoveFromStage);
}
public function get nLens():Number{
return (this.m_nLens);
}
public function set nLens(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = 0;
};
this.m_nLens = _arg1;
this.m_nFOV = ((360 * Math.atan(((2 * this.m_nLens) / this.bitmapData.width))) / Math.PI);
}
public function setTarget(_arg1:uint, _arg2:Coords3D):void{
this.m_uTargetMode = _arg1;
this.m_coordTarget = _arg2;
}
public function set nFOV(_arg1:Number):void{
if (_arg1 < Camera3D.MIN_FOV){
_arg1 = Camera3D.MIN_FOV;
};
if (_arg1 > Camera3D.MAX_FOV){
_arg1 = Camera3D.MAX_FOV;
};
this.m_nFOV = _arg1;
this.m_nLens = (this.bitmapData.width / (2 * Math.tan(((Math.PI * this.m_nFOV) / 360))));
}
protected function onAddToStage(_arg1:Event):void{
this.startRender();
}
protected function onEnterFrame(_arg1:Event):void{
var _local2:Coords3D;
this.dispatchEvent(new Event3D(Event3D.RENDER_QUERY));
if (this.m_uTargetMode == Camera3D.MODE_TAIL){
_local2 = this.m_coordTarget.findReverse();
_local2.copyTo(this.coords);
this.coords.rotateOnX((-(Math.PI) / 15));
this.coords.translate(new Point3D(0, 13, 32));
} else {
if (this.m_uTargetMode == Camera3D.MODE_REAR_VIEW){
_local2 = this.m_coordTarget.findReverse();
_local2.copyTo(this.coords);
this.coords.translate(new Point3D(0, 8, 10));
this.coords.rotateOnY(Math.PI);
};
};
}
public function stopRender():void{
this.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
}
public function startRender():void{
this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
}
protected function onRemoveFromStage(_arg1:Event):void{
this.stopRender();
}
public function get nFOV():Number{
return (this.m_nFOV);
}
}
}//package iriysoft.engine3d
Section 2
//Coords3D (iriysoft.engine3d.Coords3D)
package iriysoft.engine3d {
import iriysoft.math.*;
public class Coords3D {
protected var m_p3dXAxis:Point3D;
protected var m_p3dYAxis:Point3D;
protected var m_p3dZAxis:Point3D;
protected var m_p3dOrigin:Point3D;
public function Coords3D(_arg1:Point3D=null, _arg2:Point3D=null, _arg3:Point3D=null, _arg4:Point3D=null){
if (_arg1 == null){
_arg1 = new Point3D(0, 0, 0);
};
if (_arg2 == null){
_arg2 = new Point3D(1, 0, 0);
};
if (_arg3 == null){
_arg3 = new Point3D(0, 1, 0);
};
if (_arg4 == null){
_arg4 = new Point3D(0, 0, 1);
};
this.m_p3dOrigin = _arg1;
this.m_p3dXAxis = _arg2;
this.m_p3dYAxis = _arg3;
this.m_p3dZAxis = _arg4;
}
public function rotateOnZ(_arg1:Number):void{
var _local2:Coords3D;
_local2 = new Coords3D(new Point3D(0, 0, 0), new Point3D(Math.cos(_arg1), -(Math.sin(_arg1)), 0), new Point3D(Math.sin(_arg1), Math.cos(_arg1), 0), new Point3D(0, 0, 1));
this.transformToCoords(_local2.findReverse());
}
public function transformPoint(_arg1:Point3D):void{
_arg1.substract(this.m_p3dOrigin);
this.transformVector(_arg1);
}
public function transformToCoords(_arg1:Coords3D):void{
_arg1.transformPoint(this.m_p3dOrigin);
_arg1.transformVector(this.m_p3dXAxis);
_arg1.transformVector(this.m_p3dYAxis);
_arg1.transformVector(this.m_p3dZAxis);
}
public function rotateOnOwnY(_arg1:Number):void{
var _local2:Point3D;
_local2 = this.m_p3dOrigin.clone();
_local2.nLength = (_local2.nLength * -1);
this.translate(_local2);
this.rotateOnY(_arg1);
_local2.nLength = (_local2.nLength * -1);
this.translate(_local2);
}
public function translate(_arg1:Point3D):void{
this.m_p3dOrigin.add(_arg1);
}
public function copyTo(_arg1:Coords3D):void{
this.m_p3dOrigin.copyTo(_arg1.m_p3dOrigin);
this.m_p3dXAxis.copyTo(_arg1.m_p3dXAxis);
this.m_p3dYAxis.copyTo(_arg1.m_p3dYAxis);
this.m_p3dZAxis.copyTo(_arg1.m_p3dZAxis);
}
public function get p3dOrigin():Point3D{
return (this.m_p3dOrigin);
}
public function rotateOnAxis(_arg1:Point3D, _arg2:Number):void{
var _local3:Point3D;
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:Coords3D;
_local3 = _arg1.clone();
_local3.normalize();
_local4 = Math.cos((_arg2 * 0.5));
_local5 = Math.sin((_arg2 * 0.5));
_local6 = (_local3.nX * _local5);
_local7 = (_local3.nY * _local5);
_local8 = (_local3.nZ * _local5);
_local9 = _local4;
_local10 = (_local6 * _local6);
_local11 = (_local6 * _local7);
_local12 = (_local6 * _local8);
_local13 = (_local6 * _local9);
_local14 = (_local7 * _local7);
_local15 = (_local7 * _local8);
_local16 = (_local7 * _local9);
_local17 = (_local8 * _local8);
_local18 = (_local8 * _local9);
_local19 = new Coords3D(new Point3D(0, 0, 0), new Point3D((1 - (2 * (_local14 + _local17))), (2 * (_local11 - _local18)), (2 * (_local12 + _local16))), new Point3D((2 * (_local11 + _local18)), (1 - (2 * (_local10 + _local17))), (2 * (_local15 - _local13))), new Point3D((2 * (_local12 - _local16)), (2 * (_local15 + _local13)), (1 - (2 * (_local10 + _local14)))));
this.transformToCoords(_local19.findReverse());
}
public function transformVector(_arg1:Point3D):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = _arg1.findScalar(this.m_p3dXAxis);
_local3 = _arg1.findScalar(this.m_p3dYAxis);
_local4 = _arg1.findScalar(this.m_p3dZAxis);
_arg1.nX = _local2;
_arg1.nY = _local3;
_arg1.nZ = _local4;
}
public function clone():Coords3D{
var _local1:Coords3D;
_local1 = new Coords3D();
_local1.m_p3dOrigin = this.m_p3dOrigin.clone();
_local1.m_p3dXAxis = this.m_p3dXAxis.clone();
_local1.m_p3dYAxis = this.m_p3dYAxis.clone();
_local1.m_p3dZAxis = this.m_p3dZAxis.clone();
return (_local1);
}
public function findReverse():Coords3D{
var _local1:Coords3D;
_local1 = new Coords3D();
_local1.transformToCoords(this);
return (_local1);
}
public function get p3dZAxis():Point3D{
return (this.m_p3dZAxis);
}
public function rotateOnX(_arg1:Number):void{
var _local2:Coords3D;
_local2 = new Coords3D(new Point3D(0, 0, 0), new Point3D(1, 0, 0), new Point3D(0, Math.cos(_arg1), -(Math.sin(_arg1))), new Point3D(0, Math.sin(_arg1), Math.cos(_arg1)));
this.transformToCoords(_local2.findReverse());
}
public function rotateOnY(_arg1:Number):void{
var _local2:Coords3D;
_local2 = new Coords3D(new Point3D(0, 0, 0), new Point3D(Math.cos(_arg1), 0, Math.sin(_arg1)), new Point3D(0, 1, 0), new Point3D(-(Math.sin(_arg1)), 0, Math.cos(_arg1)));
this.transformToCoords(_local2.findReverse());
}
}
}//package iriysoft.engine3d
Section 3
//Event3D (iriysoft.engine3d.Event3D)
package iriysoft.engine3d {
import flash.events.*;
public class Event3D extends Event {
public var op3dSource2:ObjectPseudo3D;
public var op3dSource1:ObjectPseudo3D;
public static const PHYSICS_HIT:String = "physicsHit";
public static const RENDER_QUERY:String = "renderQuery";
public function Event3D(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
}
}//package iriysoft.engine3d
Section 4
//Object3D (iriysoft.engine3d.Object3D)
package iriysoft.engine3d {
import iriysoft.math.*;
import flash.utils.*;
public class Object3D {
public var nZAtCamera:Number;
public var nCameraZ:Number;
private var m_dictPolygons:Dictionary;
public var coordObjectToCamera:Coords3D;
public var coords:Coords3D;
public function Object3D(_arg1:Point3D=null){
this.coords = new Coords3D(_arg1);
this.coordObjectToCamera = new Coords3D();
this.m_dictPolygons = new Dictionary();
}
public function get dictPolygons():Dictionary{
return (this.m_dictPolygons);
}
public function addPolygon(_arg1:Polygon3D):void{
this.m_dictPolygons[_arg1] = true;
}
public function removePolygon(_arg1:Polygon3D):void{
delete this.m_dictPolygons[_arg1];
}
}
}//package iriysoft.engine3d
Section 5
//ObjectPseudo3D (iriysoft.engine3d.ObjectPseudo3D)
package iriysoft.engine3d {
import iriysoft.math.*;
import flash.display.*;
public class ObjectPseudo3D extends MovieClip {
public var coords:Coords3D;
public var p3dCenterAtCamera:Point3D;
public var coordObjectToCamera:Coords3D;
public var nCameraZ:Number;
public function ObjectPseudo3D(_arg1:Point3D=null){
this.coords = new Coords3D(_arg1);
this.coordObjectToCamera = new Coords3D();
this.p3dCenterAtCamera = new Point3D();
}
public function get nZAtCamera():Number{
return (this.p3dCenterAtCamera.nZ);
}
}
}//package iriysoft.engine3d
Section 6
//Physics3D (iriysoft.engine3d.Physics3D)
package iriysoft.engine3d {
import iriysoft.math.*;
import flash.utils.*;
import flash.events.*;
public class Physics3D extends EventDispatcher {
private var m_dictObjects:Dictionary;
public static const MASS_INFINITE:Number = 1000000;
public function Physics3D(){
this.m_dictObjects = new Dictionary();
}
public function addObject(_arg1:ObjectPseudo3D, _arg2:Number, _arg3:Number=1000000, _arg4:Boolean=true):void{
this.m_dictObjects[_arg1] = {radius:_arg2, mass:_arg3, test:_arg4};
}
public function removeObject(_arg1:ObjectPseudo3D):void{
delete this.m_dictObjects[_arg1];
}
public function process():void{
var _local1:Dictionary;
var _local2:ObjectPseudo3D;
var _local3:ObjectPseudo3D;
var _local4:Number;
var _local5:Point3D;
var _local6:Point3D;
var _local7:Number;
var _local8:Point3D;
var _local9:Point3D;
var _local10:Point3D;
var _local11:Number;
var _local12:*;
var _local13:*;
var _local14:Event3D;
_local1 = new Dictionary();
_local5 = new Point3D();
_local6 = new Point3D();
_local8 = new Point3D();
_local9 = new Point3D();
_local10 = new Point3D();
for (_local12 in this.m_dictObjects) {
_local2 = (_local12 as ObjectPseudo3D);
if (this.m_dictObjects[_local2].test){
for (_local13 in this.m_dictObjects) {
if (_local1[_local13] == null){
_local3 = (_local13 as ObjectPseudo3D);
if (_local2 != _local3){
_local4 = Point3D.distance(_local2.coords.p3dOrigin, _local3.coords.p3dOrigin);
if (_local4 < (this.m_dictObjects[_local2].radius + this.m_dictObjects[_local3].radius)){
_local7 = ((this.m_dictObjects[_local2].radius + this.m_dictObjects[_local3].radius) - _local4);
_local3.coords.p3dOrigin.copyTo(_local5);
_local5.substract(_local2.coords.p3dOrigin);
_local5.nLength = (_local7 * (1 - (this.m_dictObjects[_local3].mass / (this.m_dictObjects[_local2].mass + this.m_dictObjects[_local3].mass))));
_local3.coords.translate(_local5);
_local5.copyTo(_local6);
_local6.nLength = (_local6.nLength * -1);
_local6.nLength = (_local7 - _local6.nLength);
_local2.coords.translate(_local6);
if ((_local2 is Car3D)){
(_local2 as Car3D).m_p3dSpeed.copyTo(_local8);
} else {
_local8.nLength = 0;
};
if ((_local3 is Car3D)){
(_local3 as Car3D).m_p3dSpeed.copyTo(_local9);
} else {
_local9.nLength = 0;
};
if ((_local2 is Car3D)){
_local9.copyTo(_local10);
_local10.nLength = (_local10.nLength * (this.m_dictObjects[_local3].mass / this.m_dictObjects[_local2].mass));
_local10.nLength = (_local10.nLength * -1);
_local10.add(_local8);
_local6.normalize();
_local11 = _local6.findScalar(_local10);
_local6.nLength = ((-4 * _local11) / Car3D.SCALE_FACTOR);
(_local2 as Car3D).m_p3dSpeed.add(_local6);
};
if ((_local3 is Car3D)){
_local8.copyTo(_local10);
_local10.nLength = (_local10.nLength * (this.m_dictObjects[_local2].mass / this.m_dictObjects[_local3].mass));
_local10.nLength = (_local10.nLength * -1);
_local10.add(_local9);
_local5.normalize();
_local11 = _local5.findScalar(_local10);
_local5.nLength = ((-4 * _local11) / Car3D.SCALE_FACTOR);
(_local3 as Car3D).m_p3dSpeed.add(_local5);
};
_local14 = new Event3D(Event3D.PHYSICS_HIT);
_local14.op3dSource1 = _local2;
_local14.op3dSource2 = _local3;
this.dispatchEvent(_local14);
};
};
};
};
_local1[_local2] = true;
};
};
}
}
}//package iriysoft.engine3d
Section 7
//Polygon3D (iriysoft.engine3d.Polygon3D)
package iriysoft.engine3d {
import iriysoft.math.*;
import flash.display.*;
import flash.geom.*;
public class Polygon3D {
public var aProcVertexes:Array;
public var aTexels:Array;
public var aVertexes:Array;
public var bdTexture:BitmapData;
public var iColor:int;
public var aProcTexels:Array;
public function Polygon3D(... _args){
var _local2:int;
var _local3:Point3D;
var _local4:int;
super();
this.aVertexes = new Array();
_local2 = _args.length;
_local4 = 0;
while (_local4 < _local2) {
_local3 = (_args[_local4] as Point3D);
this.aVertexes.push(_local3.clone());
_local4++;
};
this.setColor(4285579318);
}
public function applyTexture(_arg1:BitmapData, ... _args):void{
var _local3:int;
var _local4:Point;
var _local5:int;
this.bdTexture = _arg1;
this.aTexels = new Array();
_local3 = _args.length;
_local5 = 0;
while (_local5 < _local3) {
_local4 = (_args[_local5] as Point);
this.aTexels.push(_local4.clone());
_local5++;
};
}
public function setColor(_arg1:int):void{
this.iColor = _arg1;
}
public function transformTo(_arg1:Coords3D):void{
var _local2:*;
for each (_local2 in this.aProcVertexes) {
_arg1.transformPoint((_local2 as Point3D));
};
}
public function beginNewProcessing():void{
var _local1:int;
var _local2:int;
var _local3:int;
this.aProcVertexes = new Array();
_local1 = this.aVertexes.length;
_local2 = 0;
while (_local2 < _local1) {
this.aProcVertexes[_local2] = (this.aVertexes[_local2] as Point3D).clone();
_local2++;
};
if (this.bdTexture != null){
this.aProcTexels = new Array();
_local1 = this.aTexels.length;
_local3 = 0;
while (_local3 < _local1) {
this.aProcTexels[_local3] = (this.aTexels[_local3] as Point).clone();
_local3++;
};
};
}
public function clipByPlane(_arg1:Point3D, _arg2:Point3D):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:Point3D;
var _local7:Point3D;
var _local8:Point3D;
var _local9:Point3D;
var _local10:Point3D;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Point3D;
var _local15:int;
var _local16:Point;
var _local17:Point;
var _local18:Point;
_local3 = 0;
_local5 = this.aProcVertexes.length;
_local6 = (this.aProcVertexes[0] as Point3D);
if (this.bdTexture != null){
_local16 = (this.aProcTexels[0] as Point);
};
_local9 = new Point3D();
_local10 = new Point3D();
_local15 = 0;
while (_local15 < _local5) {
_local4 = 0;
_local7 = (this.aProcVertexes[(_local15 + _local3)] as Point3D);
if (this.bdTexture != null){
_local17 = (this.aProcTexels[(_local15 + _local3)] as Point);
};
if (_local15 < (_local5 - 1)){
_local8 = (this.aProcVertexes[((_local15 + _local3) + 1)] as Point3D);
if (this.bdTexture != null){
_local18 = (this.aProcTexels[((_local15 + _local3) + 1)] as Point);
};
} else {
_local8 = _local6;
if (this.bdTexture != null){
_local18 = _local16;
};
};
_local7.copyTo(_local9);
_local9.substract(_arg2);
_local11 = _local9.findScalar(_arg1);
_local8.copyTo(_local10);
_local10.substract(_arg2);
_local12 = _local10.findScalar(_arg1);
if ((((((_local11 > 0)) && ((_local12 < 0)))) || ((((_local12 >= 0)) && ((_local11 < 0)))))){
_local13 = ((_arg2.findScalar(_arg1) - _local7.findScalar(_arg1)) / (_local8.findScalar(_arg1) - _local7.findScalar(_arg1)));
this.aProcVertexes.splice(((_local15 + _local3) + 1), 0, new Point3D((_local7.nX + (_local13 * (_local8.nX - _local7.nX))), (_local7.nY + (_local13 * (_local8.nY - _local7.nY))), (_local7.nZ + (_local13 * (_local8.nZ - _local7.nZ)))));
if (this.bdTexture != null){
this.aProcTexels.splice(((_local15 + _local3) + 1), 0, new Point((_local17.x + (_local13 * (_local18.x - _local17.x))), (_local17.y + (_local13 * (_local18.y - _local17.y)))));
};
_local4++;
};
if (_local11 < 0){
this.aProcVertexes.splice((_local15 + _local3), 1);
if (this.bdTexture != null){
this.aProcTexels.splice((_local15 + _local3), 1);
};
_local4--;
};
_local3 = (_local3 + _local4);
_local15++;
};
}
}
}//package iriysoft.engine3d
Section 8
//Scene3D (iriysoft.engine3d.Scene3D)
package iriysoft.engine3d {
import iriysoft.math.*;
import flash.utils.*;
import flash.geom.*;
public class Scene3D {
protected var m_aObjects:Array;
protected var m_dictCameras:Dictionary;
public var coords:Coords3D;
private static const TEXTURE_PERSPECTIVE:Boolean = true;
private static const TEXTURE_SPAN:int = 16;
public function Scene3D(){
this.coords = new Coords3D();
this.m_dictCameras = new Dictionary();
this.m_aObjects = new Array();
}
public function addObject(_arg1:Object):void{
this.m_aObjects.push(_arg1);
}
public function removeObject(_arg1:Object):void{
var _local2:String;
for (_local2 in this.m_aObjects) {
if (this.m_aObjects[_local2] == _arg1){
this.m_aObjects.splice(_local2, 1);
break;
};
};
}
public function removeCamera(_arg1:Camera3D):void{
_arg1.removeEventListener(Event3D.RENDER_QUERY, this.onCameraRenderQuery);
delete this.m_dictCameras[_arg1];
}
public function addCamera(_arg1:Camera3D):void{
if (this.m_dictCameras[_arg1] == null){
this.m_dictCameras[_arg1] = true;
_arg1.addEventListener(Event3D.RENDER_QUERY, this.onCameraRenderQuery);
};
}
protected function onCameraRenderQuery(_arg1:Event3D):void{
var _local2:Camera3D;
var _local3:Coords3D;
var _local4:Object3D;
var _local5:ObjectPseudo3D;
var _local6:Coords3D;
var _local7:Coords3D;
var _local8:int;
var _local9:int;
var _local10:Point3D;
var _local11:Point3D;
var _local12:Point3D;
var _local13:Point3D;
var _local14:Point3D;
var _local15:Point3D;
var _local16:Point3D;
var _local17:Point3D;
var _local18:Point3D;
var _local19:Point3D;
var _local20:Point3D;
var _local21:Point3D;
var _local22:Polygon3D;
var _local23:int;
var _local24:Point3D;
var _local25:VertexInfo;
var _local26:VertexInfo;
var _local27:VertexInfo;
var _local28:Array;
var _local29:int;
var _local30:int;
var _local31:int;
var _local32:int;
var _local33:int;
var _local34:Number;
var _local35:Rectangle;
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:Number;
var _local47:Number;
var _local48:Number;
var _local49:Number;
var _local50:Number;
var _local51:Number;
var _local52:Number;
var _local53:int;
var _local54:Number;
var _local55:Number;
var _local56:Number;
var _local57:Number;
var _local58:Number;
var _local59:Number;
var _local60:Number;
var _local61:Number;
var _local62:Number;
var _local63:Number;
var _local64:int;
var _local65:int;
var _local66:Number;
var _local67:Point3D;
var _local68:Number;
var _local69:Matrix;
var _local70:*;
var _local71:int;
var _local72:*;
var _local73:int;
_local2 = (_arg1.target as Camera3D);
_local2.bitmapData.fillRect(new Rectangle(0, 0, _local2.bitmapData.width, _local2.bitmapData.height), 4288269567);
_local3 = this.coords.clone();
_local3.transformToCoords(_local2.coords);
_local6 = new Coords3D();
_local8 = this.m_aObjects.length;
_local9 = 0;
while (_local9 < _local8) {
if ((this.m_aObjects[_local9] is Object3D)){
_local4 = (this.m_aObjects[_local9] as Object3D);
this.coords.copyTo(_local6);
_local6.transformToCoords(_local4.coords);
_local7 = _local6.findReverse();
_local3.copyTo(_local4.coordObjectToCamera);
_local4.coordObjectToCamera.transformToCoords(_local7);
} else {
if ((this.m_aObjects[_local9] is ObjectPseudo3D)){
_local5 = (this.m_aObjects[_local9] as ObjectPseudo3D);
this.coords.copyTo(_local6);
_local6.transformToCoords(_local5.coords);
_local7 = _local6.findReverse();
_local3.copyTo(_local5.coordObjectToCamera);
_local5.coordObjectToCamera.transformToCoords(_local7);
_local5.p3dCenterAtCamera.nX = 0;
_local5.p3dCenterAtCamera.nY = 0;
_local5.p3dCenterAtCamera.nZ = 0;
_local5.coordObjectToCamera.transformPoint(_local5.p3dCenterAtCamera);
};
};
_local9++;
};
this.m_aObjects.sortOn("nZAtCamera", (Array.NUMERIC | Array.DESCENDING));
_local10 = new Point3D(0, 0, 1);
_local11 = new Point3D(0, 0, 1);
_local12 = new Point3D(0, 0, -1);
_local13 = new Point3D(0, 0, _local2.nDepth);
_local14 = new Point3D(0, (-(_local2.bitmapData.height) / 2), ((_local2.bitmapData.height * _local2.bitmapData.height) / (4 * _local2.nLens)));
_local15 = new Point3D(0, 0, 0);
_local16 = new Point3D(0, (_local2.bitmapData.height / 2), ((_local2.bitmapData.height * _local2.bitmapData.height) / (4 * _local2.nLens)));
_local17 = new Point3D(0, 0, 0);
_local18 = new Point3D((-(_local2.bitmapData.width) / 2), 0, ((_local2.bitmapData.width * _local2.bitmapData.width) / (4 * _local2.nLens)));
_local19 = new Point3D(0, 0, 0);
_local20 = new Point3D((_local2.bitmapData.width / 2), 0, ((_local2.bitmapData.width * _local2.bitmapData.width) / (4 * _local2.nLens)));
_local21 = new Point3D(0, 0, 0);
_local24 = new Point3D();
_local25 = new VertexInfo();
_local26 = new VertexInfo();
_local27 = new VertexInfo();
_local28 = new Array(_local25, _local26, _local27);
_local35 = new Rectangle();
_local67 = new Point3D();
_local69 = new Matrix();
_local9 = 0;
while (_local9 < _local8) {
if ((this.m_aObjects[_local9] is Object3D)){
_local4 = (this.m_aObjects[_local9] as Object3D);
for (_local70 in _local4.dictPolygons) {
_local22 = (_local70 as Polygon3D);
_local22.beginNewProcessing();
_local22.transformTo(_local4.coordObjectToCamera);
_local22.clipByPlane(_local10, _local11);
_local22.clipByPlane(_local12, _local13);
_local22.clipByPlane(_local14, _local15);
_local22.clipByPlane(_local16, _local17);
_local22.clipByPlane(_local18, _local19);
_local22.clipByPlane(_local20, _local21);
_local23 = _local22.aProcVertexes.length;
_local71 = 1;
while (_local71 < (_local23 - 1)) {
_local22.aProcVertexes[0].copyTo(_local24);
_local25.m_iX = Math.round((((_local24.nX * _local2.nLens) / _local24.nZ) + (_local2.bitmapData.width / 2)));
_local25.m_iY = Math.round((((_local24.nY * _local2.nLens) / _local24.nZ) + (_local2.bitmapData.height / 2)));
if (_local22.bdTexture != null){
if (Scene3D.TEXTURE_PERSPECTIVE){
_local25.m_nWZ = (1 / _local24.nZ);
_local25.m_nUZ = (_local22.aProcTexels[0].x * _local25.m_nWZ);
_local25.m_nVZ = (_local22.aProcTexels[0].y * _local25.m_nWZ);
} else {
_local25.m_nU = _local22.aProcTexels[0].x;
_local25.m_nV = _local22.aProcTexels[0].y;
};
};
_local22.aProcVertexes[_local71].copyTo(_local24);
_local26.m_iX = Math.round((((_local24.nX * _local2.nLens) / _local24.nZ) + (_local2.bitmapData.width / 2)));
_local26.m_iY = Math.round((((_local24.nY * _local2.nLens) / _local24.nZ) + (_local2.bitmapData.height / 2)));
if (_local22.bdTexture != null){
if (Scene3D.TEXTURE_PERSPECTIVE){
_local26.m_nWZ = (1 / _local24.nZ);
_local26.m_nUZ = (_local22.aProcTexels[_local71].x * _local26.m_nWZ);
_local26.m_nVZ = (_local22.aProcTexels[_local71].y * _local26.m_nWZ);
} else {
_local26.m_nU = _local22.aProcTexels[_local71].x;
_local26.m_nV = _local22.aProcTexels[_local71].y;
};
};
_local22.aProcVertexes[(_local71 + 1)].copyTo(_local24);
_local27.m_iX = Math.round((((_local24.nX * _local2.nLens) / _local24.nZ) + (_local2.bitmapData.width / 2)));
_local27.m_iY = Math.round((((_local24.nY * _local2.nLens) / _local24.nZ) + (_local2.bitmapData.height / 2)));
if (_local22.bdTexture != null){
if (Scene3D.TEXTURE_PERSPECTIVE){
_local27.m_nWZ = (1 / _local24.nZ);
_local27.m_nUZ = (_local22.aProcTexels[(_local71 + 1)].x * _local27.m_nWZ);
_local27.m_nVZ = (_local22.aProcTexels[(_local71 + 1)].y * _local27.m_nWZ);
} else {
_local27.m_nU = _local22.aProcTexels[(_local71 + 1)].x;
_local27.m_nV = _local22.aProcTexels[(_local71 + 1)].y;
};
};
_local28.sortOn("m_iY", Array.NUMERIC);
_local25 = (_local28[0] as VertexInfo);
_local26 = (_local28[1] as VertexInfo);
_local27 = (_local28[2] as VertexInfo);
if (_local22.bdTexture != null){
if (Scene3D.TEXTURE_PERSPECTIVE){
_local29 = (_local25.m_iX + (((_local26.m_iY - _local25.m_iY) * (_local27.m_iX - _local25.m_iX)) / (_local27.m_iY - _local25.m_iY)));
_local44 = (_local25.m_nWZ + (((_local26.m_iY - _local25.m_iY) * (_local27.m_nWZ - _local25.m_nWZ)) / (_local27.m_iY - _local25.m_iY)));
_local47 = (_local25.m_nUZ + (((_local26.m_iY - _local25.m_iY) * (_local27.m_nUZ - _local25.m_nUZ)) / (_local27.m_iY - _local25.m_iY)));
_local50 = (_local25.m_nVZ + (((_local26.m_iY - _local25.m_iY) * (_local27.m_nVZ - _local25.m_nVZ)) / (_local27.m_iY - _local25.m_iY)));
_local31 = _local26.m_iX;
_local45 = _local26.m_nWZ;
_local48 = _local26.m_nUZ;
_local51 = _local26.m_nVZ;
_local46 = ((_local44 - _local45) / (_local29 - _local31));
_local49 = ((_local47 - _local48) / (_local29 - _local31));
_local52 = ((_local50 - _local51) / (_local29 - _local31));
} else {
_local29 = (_local25.m_iX + (((_local26.m_iY - _local25.m_iY) * (_local27.m_iX - _local25.m_iX)) / (_local27.m_iY - _local25.m_iY)));
_local36 = (_local25.m_nU + (((_local26.m_iY - _local25.m_iY) * (_local27.m_nU - _local25.m_nU)) / (_local27.m_iY - _local25.m_iY)));
_local39 = (_local25.m_nV + (((_local26.m_iY - _local25.m_iY) * (_local27.m_nV - _local25.m_nV)) / (_local27.m_iY - _local25.m_iY)));
_local31 = _local26.m_iX;
_local37 = _local26.m_nU;
_local40 = _local26.m_nV;
_local38 = ((_local36 - _local37) / (_local29 - _local31));
_local41 = ((_local39 - _local40) / (_local39 - _local40));
};
};
_local72 = _local25.m_iY;
while (_local72 <= _local27.m_iY) {
_local29 = (_local25.m_iX + (((_local72 - _local25.m_iY) * (_local27.m_iX - _local25.m_iX)) / (_local27.m_iY - _local25.m_iY)));
if (_local22.bdTexture != null){
if (Scene3D.TEXTURE_PERSPECTIVE){
_local44 = (_local25.m_nWZ + (((_local72 - _local25.m_iY) * (_local27.m_nWZ - _local25.m_nWZ)) / (_local27.m_iY - _local25.m_iY)));
_local47 = (_local25.m_nUZ + (((_local72 - _local25.m_iY) * (_local27.m_nUZ - _local25.m_nUZ)) / (_local27.m_iY - _local25.m_iY)));
_local50 = (_local25.m_nVZ + (((_local72 - _local25.m_iY) * (_local27.m_nVZ - _local25.m_nVZ)) / (_local27.m_iY - _local25.m_iY)));
} else {
_local36 = (_local25.m_nU + (((_local72 - _local25.m_iY) * (_local27.m_nU - _local25.m_nU)) / (_local27.m_iY - _local25.m_iY)));
_local39 = (_local25.m_nV + (((_local72 - _local25.m_iY) * (_local27.m_nV - _local25.m_nV)) / (_local27.m_iY - _local25.m_iY)));
};
};
if (_local72 < _local26.m_iY){
_local31 = (_local25.m_iX + (((_local72 - _local25.m_iY) * (_local26.m_iX - _local25.m_iX)) / (_local26.m_iY - _local25.m_iY)));
if (_local22.bdTexture != null){
if (Scene3D.TEXTURE_PERSPECTIVE){
_local45 = (_local25.m_nWZ + (((_local72 - _local25.m_iY) * (_local26.m_nWZ - _local25.m_nWZ)) / (_local26.m_iY - _local25.m_iY)));
_local48 = (_local25.m_nUZ + (((_local72 - _local25.m_iY) * (_local26.m_nUZ - _local25.m_nUZ)) / (_local26.m_iY - _local25.m_iY)));
_local51 = (_local25.m_nVZ + (((_local72 - _local25.m_iY) * (_local26.m_nVZ - _local25.m_nVZ)) / (_local26.m_iY - _local25.m_iY)));
} else {
_local37 = (_local25.m_nU + (((_local72 - _local25.m_iY) * (_local26.m_nU - _local25.m_nU)) / (_local26.m_iY - _local25.m_iY)));
_local40 = (_local25.m_nV + (((_local72 - _local25.m_iY) * (_local26.m_nV - _local25.m_nV)) / (_local26.m_iY - _local25.m_iY)));
};
};
} else {
if (_local27.m_iY == _local26.m_iY){
_local31 = _local26.m_iX;
if (_local22.bdTexture != null){
if (Scene3D.TEXTURE_PERSPECTIVE){
_local45 = _local26.m_nWZ;
_local48 = _local26.m_nUZ;
_local51 = _local26.m_nVZ;
} else {
_local37 = _local26.m_nU;
_local40 = _local26.m_nV;
};
};
} else {
_local31 = (_local26.m_iX + (((_local72 - _local26.m_iY) * (_local27.m_iX - _local26.m_iX)) / (_local27.m_iY - _local26.m_iY)));
if (_local22.bdTexture != null){
if (Scene3D.TEXTURE_PERSPECTIVE){
_local45 = (_local26.m_nWZ + (((_local72 - _local26.m_iY) * (_local27.m_nWZ - _local26.m_nWZ)) / (_local27.m_iY - _local26.m_iY)));
_local48 = (_local26.m_nUZ + (((_local72 - _local26.m_iY) * (_local27.m_nUZ - _local26.m_nUZ)) / (_local27.m_iY - _local26.m_iY)));
_local51 = (_local26.m_nVZ + (((_local72 - _local26.m_iY) * (_local27.m_nVZ - _local26.m_nVZ)) / (_local27.m_iY - _local26.m_iY)));
} else {
_local37 = (_local26.m_nU + (((_local72 - _local26.m_iY) * (_local27.m_nU - _local26.m_nU)) / (_local27.m_iY - _local26.m_iY)));
_local40 = (_local26.m_nV + (((_local72 - _local26.m_iY) * (_local27.m_nV - _local26.m_nV)) / (_local27.m_iY - _local26.m_iY)));
};
};
};
};
if (_local29 > _local31){
_local33 = _local29;
_local29 = _local31;
_local31 = _local33;
if (_local22.bdTexture != null){
if (Scene3D.TEXTURE_PERSPECTIVE){
_local34 = _local44;
_local44 = _local45;
_local45 = _local34;
_local34 = _local47;
_local47 = _local48;
_local48 = _local34;
_local34 = _local50;
_local50 = _local51;
_local51 = _local34;
} else {
_local34 = _local36;
_local36 = _local37;
_local37 = _local34;
_local34 = _local39;
_local39 = _local40;
_local40 = _local34;
};
};
};
if (_local22.bdTexture == null){
_local35.x = _local29;
_local35.width = (_local31 - _local29);
_local35.y = _local72;
_local35.height = 1;
_local2.bitmapData.fillRect(_local35, _local22.iColor);
} else {
if (!Scene3D.TEXTURE_PERSPECTIVE){
_local42 = _local36;
_local43 = _local39;
_local2.bitmapData.lock();
_local73 = _local29;
while (_local73 < _local31) {
_local2.bitmapData.setPixel(_local73, _local72, _local22.bdTexture.getPixel(_local42, _local43));
_local42 = (_local42 + _local38);
_local43 = (_local43 + _local41);
_local73++;
};
_local2.bitmapData.unlock();
} else {
_local64 = _local29;
_local53 = (_local31 - _local29);
_local54 = _local44;
_local55 = _local47;
_local56 = _local50;
_local60 = (_local55 / _local54);
_local61 = (_local56 / _local54);
_local2.bitmapData.lock();
while (_local53 >= Scene3D.TEXTURE_SPAN) {
_local57 = (_local54 + (Scene3D.TEXTURE_SPAN * _local46));
_local58 = (_local55 + (Scene3D.TEXTURE_SPAN * _local49));
_local59 = (_local56 + (Scene3D.TEXTURE_SPAN * _local52));
_local62 = (_local58 / _local57);
_local63 = (_local59 / _local57);
_local42 = _local60;
_local43 = _local61;
_local38 = ((_local62 - _local60) / Scene3D.TEXTURE_SPAN);
_local41 = ((_local63 - _local61) / Scene3D.TEXTURE_SPAN);
_local65 = Scene3D.TEXTURE_SPAN;
while (_local65--) {
_local2.bitmapData.setPixel(_local64, _local72, _local22.bdTexture.getPixel(_local42, _local43));
_local64++;
_local42 = (_local42 + _local38);
_local43 = (_local43 + _local41);
};
_local53 = (_local53 - Scene3D.TEXTURE_SPAN);
_local54 = _local57;
_local55 = _local58;
_local56 = _local59;
_local60 = _local62;
_local61 = _local63;
};
if (_local53 != 0){
_local57 = (_local54 + (_local53 * _local46));
_local58 = (_local55 + (_local53 * _local49));
_local59 = (_local56 + (_local53 * _local52));
_local62 = (_local58 / _local57);
_local63 = (_local59 / _local57);
_local42 = _local60;
_local43 = _local61;
_local38 = ((_local62 - _local60) / _local53);
_local41 = ((_local63 - _local61) / _local53);
while (_local53--) {
_local2.bitmapData.setPixel(_local64, _local72, _local22.bdTexture.getPixel(_local42, _local43));
_local64++;
_local42 = (_local42 + _local38);
_local43 = (_local43 + _local41);
};
};
_local2.bitmapData.unlock();
};
};
_local72++;
};
_local71++;
};
};
} else {
if ((this.m_aObjects[_local9] is ObjectPseudo3D)){
_local5 = (this.m_aObjects[_local9] as ObjectPseudo3D);
_local67.nX = 0;
_local67.nY = 0;
_local67.nZ = 1;
_local5.coordObjectToCamera.transformVector(_local67);
if (((((((((((!(pointIsClippedByPlane(_local5.p3dCenterAtCamera, _local10, _local11))) && (!(pointIsClippedByPlane(_local5.p3dCenterAtCamera, _local12, _local13))))) && (!(pointIsClippedByPlane(_local5.p3dCenterAtCamera, _local14, _local15))))) && (!(pointIsClippedByPlane(_local5.p3dCenterAtCamera, _local16, _local17))))) && (!(pointIsClippedByPlane(_local5.p3dCenterAtCamera, _local18, _local19))))) && (!(pointIsClippedByPlane(_local5.p3dCenterAtCamera, _local20, _local21))))){
_local66 = Math.acos((_local67.nZ / Math.sqrt(((_local67.nX * _local67.nX) + (_local67.nZ * _local67.nZ)))));
if (_local67.nX < 0){
_local66 = ((2 * Math.PI) - _local66);
};
_local68 = ((_local5.p3dCenterAtCamera.nX * _local2.nLens) / _local5.p3dCenterAtCamera.nZ);
_local66 = (_local66 - (0.003 * _local68));
while (_local66 < 0) {
_local66 = (_local66 + (2 * Math.PI));
};
while (_local66 >= (2 * Math.PI)) {
_local66 = (_local66 - (2 * Math.PI));
};
_local5.gotoAndStop((Math.round(((_local66 * 180) / Math.PI)) + 1));
_local69.tx = Math.round((_local68 + (_local2.bitmapData.width / 2)));
_local69.ty = Math.round((((_local5.p3dCenterAtCamera.nY * _local2.nLens) / _local5.p3dCenterAtCamera.nZ) + (_local2.bitmapData.height / 2)));
_local69.a = ((0.1 * _local2.nLens) / _local5.p3dCenterAtCamera.nZ);
_local69.d = _local69.a;
_local2.bitmapData.draw(_local5, _local69);
};
};
};
_local9++;
};
}
protected function pointIsClippedByPlane(_arg1:Point3D, _arg2:Point3D, _arg3:Point3D):Boolean{
var _local4:Point3D;
var _local5:Number;
_local4 = _arg1.clone();
_local4.substract(_arg3);
_local5 = _local4.findScalar(_arg2);
return ((_local5 < 0));
}
}
}//package iriysoft.engine3d
Section 9
//VertexInfo (iriysoft.engine3d.VertexInfo)
package iriysoft.engine3d {
class VertexInfo {
public var m_nVZ:Number;
public var m_iX:int;
public var m_iY:int;
public var m_nUZ:Number;
public var m_nU:Number;
public var m_nV:Number;
public var m_nWZ:Number;
}
}//package iriysoft.engine3d
Section 10
//Point3D (iriysoft.math.Point3D)
package iriysoft.math {
public class Point3D {
public var nX:Number;
public var nY:Number;
public var nZ:Number;
public function Point3D(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
this.nX = _arg1;
this.nY = _arg2;
this.nZ = _arg3;
}
public function rotateOnZ(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
_local2 = ((this.nX * Math.cos(_arg1)) - (this.nY * Math.sin(_arg1)));
_local3 = ((this.nX * Math.sin(_arg1)) + (this.nY * Math.cos(_arg1)));
this.nX = _local2;
this.nY = _local3;
}
public function rotateOnAxis(_arg1:Point3D, _arg2:Number):void{
}
public function substract(_arg1:Point3D):void{
this.nX = (this.nX - _arg1.nX);
this.nY = (this.nY - _arg1.nY);
this.nZ = (this.nZ - _arg1.nZ);
}
public function toString():String{
return ((((((("(x=" + this.nX) + ", y=") + this.nY) + ", z=") + this.nZ) + ")"));
}
public function findScalar(_arg1:Point3D):Number{
return ((((this.nX * _arg1.nX) + (this.nY * _arg1.nY)) + (this.nZ * _arg1.nZ)));
}
public function set nLength(_arg1:Number):void{
var _local2:Number;
_local2 = (_arg1 / this.nLength);
if (this.nLength == 0){
_local2 = 0;
};
this.nX = (this.nX * _local2);
this.nY = (this.nY * _local2);
this.nZ = (this.nZ * _local2);
}
public function normalize():void{
this.nLength = 1;
}
public function copyTo(_arg1:Point3D):void{
_arg1.nX = this.nX;
_arg1.nY = this.nY;
_arg1.nZ = this.nZ;
}
public function get nLength():Number{
return (Math.sqrt(this.findScalar(this)));
}
public function add(_arg1:Point3D):void{
this.nX = (this.nX + _arg1.nX);
this.nY = (this.nY + _arg1.nY);
this.nZ = (this.nZ + _arg1.nZ);
}
public function clone():Point3D{
return (new Point3D(this.nX, this.nY, this.nZ));
}
public function rotateOnX(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
_local2 = ((this.nY * Math.cos(_arg1)) - (this.nZ * Math.sin(_arg1)));
_local3 = ((this.nY * Math.sin(_arg1)) + (this.nZ * Math.cos(_arg1)));
this.nY = _local2;
this.nZ = _local3;
}
public function rotateOnY(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
_local2 = ((this.nX * Math.cos(_arg1)) + (this.nZ * Math.sin(_arg1)));
_local3 = ((-(this.nX) * Math.sin(_arg1)) + (this.nZ * Math.cos(_arg1)));
this.nX = _local2;
this.nZ = _local3;
}
public static function distance(_arg1:Point3D, _arg2:Point3D):Number{
return (Math.sqrt(((((_arg1.nX - _arg2.nX) * (_arg1.nX - _arg2.nX)) + ((_arg1.nY - _arg2.nY) * (_arg1.nY - _arg2.nY))) + ((_arg1.nZ - _arg2.nZ) * (_arg1.nZ - _arg2.nZ)))));
}
}
}//package iriysoft.math
Section 11
//SoundManager (iriysoft.sound.SoundManager)
package iriysoft.sound {
import flash.media.*;
import flash.utils.*;
import flash.system.*;
public class SoundManager {
private var m_sBackSoundID:String;
private var m_schBackSound:SoundChannel;
private var m_dictSounds:Dictionary;
private var m_soundOn:Boolean;
public function SoundManager(){
this.m_dictSounds = new Dictionary();
this.soundOn = true;
this.m_sBackSoundID = null;
}
public function set soundOn(_arg1:Boolean):void{
this.m_soundOn = _arg1;
if (!this.m_soundOn){
this.stopBackSound();
SoundMixer.stopAll();
} else {
if (this.m_sBackSoundID != null){
this.playBackSound(this.m_sBackSoundID);
};
};
}
public function stopBackSound():void{
if (this.m_schBackSound != null){
this.m_schBackSound.stop();
this.m_schBackSound = null;
};
}
public function setTransform(_arg1:String, _arg2:SoundTransform):void{
(this.m_dictSounds[_arg1] as SoundObject).m_transform = _arg2;
}
public function get soundOn():Boolean{
return (this.m_soundOn);
}
public function removeSound(_arg1:String):void{
delete this.m_dictSounds[_arg1];
}
public function setVolume(_arg1:String, _arg2:Number):void{
(this.m_dictSounds[_arg1] as SoundObject).m_transform.volume = _arg2;
}
public function addSound(_arg1:String, _arg2:String=null):void{
var _local3:Class;
var _local4:SoundObject;
if (_arg2 == null){
_arg2 = _arg1;
};
_local3 = (ApplicationDomain.currentDomain.getDefinition(_arg1) as Class);
_local4 = new SoundObject(new (_local3));
this.m_dictSounds[_arg2] = _local4;
}
public function playBackSound(_arg1:String):SoundChannel{
if (((!((this.m_schBackSound == null))) && (!((this.m_sBackSoundID == _arg1))))){
this.m_schBackSound.stop();
this.m_schBackSound = null;
};
if (this.m_schBackSound == null){
this.m_schBackSound = this.playSound(_arg1, 0, int.MAX_VALUE);
};
this.m_sBackSoundID = _arg1;
return (this.m_schBackSound);
}
public function playSound(_arg1:String, _arg2:Number=0, _arg3:int=0):SoundChannel{
if (this.soundOn){
return ((this.m_dictSounds[_arg1] as SoundObject).play(_arg2, _arg3));
};
return (null);
}
}
}//package iriysoft.sound
Section 12
//SoundObject (iriysoft.sound.SoundObject)
package iriysoft.sound {
import flash.media.*;
class SoundObject {
public var m_transform:SoundTransform;
public var m_sound:Sound;
function SoundObject(_arg1:Sound){
this.m_sound = _arg1;
this.m_transform = new SoundTransform();
}
public function play(_arg1:Number=0, _arg2:int=0):SoundChannel{
return (this.m_sound.play(_arg1, _arg2, this.m_transform));
}
}
}//package iriysoft.sound
Section 13
//FrameTimer (iriysoft.utils.FrameTimer)
package iriysoft.utils {
import flash.display.*;
import flash.events.*;
public class FrameTimer extends EventDispatcher {
private var m_nTransparentTime:Number;
private var m_nTimer:Number;
private var m_nDelay:Number;
private var m_uRepeatCount:uint;
private var m_uCurrentCount:uint;
private var m_doEnterFrameSource:DisplayObject;
public static const CHRONOMETER:Number = -1;
public function FrameTimer(_arg1:DisplayObject, _arg2:Number=-1, _arg3:uint=0){
this.m_nDelay = _arg2;
this.m_uRepeatCount = _arg3;
this.m_nTransparentTime = 0;
this.reset();
this.m_doEnterFrameSource = _arg1;
}
public function stop():void{
this.m_doEnterFrameSource.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
}
private function onEnterFrame(_arg1:Event):void{
var _local2:Number;
_local2 = (1000 / (_arg1.target as DisplayObject).stage.frameRate);
this.m_nTimer = (this.m_nTimer + _local2);
this.m_nTransparentTime = (this.m_nTransparentTime + _local2);
if ((((this.m_nDelay >= 0)) && ((this.m_nTimer >= this.m_nDelay)))){
this.dispatchEvent(new TimerEvent(TimerEvent.TIMER));
this.m_nTimer = 0;
this.m_uCurrentCount++;
if (this.m_uCurrentCount == this.m_uRepeatCount){
this.dispatchEvent(new TimerEvent(TimerEvent.TIMER_COMPLETE));
this.stop();
};
};
}
public function reset():void{
this.m_uCurrentCount = 0;
this.m_nTimer = 0;
}
public function get nTime():Number{
return (this.m_nTransparentTime);
}
public function start():void{
if ((((this.m_uCurrentCount < this.m_uRepeatCount)) || ((this.m_uRepeatCount == 0)))){
this.m_nTimer = 0;
this.m_doEnterFrameSource.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
};
}
public function set nDelay(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = 0;
};
this.m_nDelay = _arg1;
}
public function get uCurrentCount():uint{
return (this.m_uCurrentCount);
}
public function get nDelay():Number{
return (this.m_nDelay);
}
public function resume():void{
if ((((this.m_uCurrentCount < this.m_uRepeatCount)) || ((this.m_uRepeatCount == 0)))){
this.m_doEnterFrameSource.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
};
}
public function set uRepeatCount(_arg1:uint):void{
this.m_uRepeatCount = _arg1;
if (this.m_uRepeatCount <= this.m_uCurrentCount){
this.stop();
};
}
public function get uRepeatCount():uint{
return (this.m_uCurrentCount);
}
public static function convertTime(_arg1:uint):Object{
var _local2:uint;
var _local3:uint;
var _local4:uint;
var _local5:uint;
_local2 = (_arg1 / ((60 * 60) * 1000));
_arg1 = (_arg1 - (_local2 * ((60 * 60) * 1000)));
_local3 = (_arg1 / (60 * 1000));
_arg1 = (_arg1 - (_local3 * (60 * 1000)));
_local4 = (_arg1 / 1000);
_arg1 = (_arg1 - (_local4 * 1000));
_local5 = _arg1;
return ({hours:_local2, minutes:_local3, seconds:_local4, milliseconds:_local5});
}
}
}//package iriysoft.utils
Section 14
//_back_wheel_2w_12 (Race3D_fla._back_wheel_2w_12)
package Race3D_fla {
import flash.display.*;
public dynamic class _back_wheel_2w_12 extends MovieClip {
public var mc:MovieClip;
}
}//package Race3D_fla
Section 15
//_back_wheel2w_13 (Race3D_fla._back_wheel2w_13)
package Race3D_fla {
import flash.display.*;
public dynamic class _back_wheel2w_13 extends MovieClip {
public var mc_rim:MovieClip;
}
}//package Race3D_fla
Section 16
//_bike_body_22 (Race3D_fla._bike_body_22)
package Race3D_fla {
import flash.display.*;
public dynamic class _bike_body_22 extends MovieClip {
public var mc:MovieClip;
}
}//package Race3D_fla
Section 17
//_bike_body_wx_16 (Race3D_fla._bike_body_wx_16)
package Race3D_fla {
import flash.display.*;
public dynamic class _bike_body_wx_16 extends MovieClip {
public var mc:MovieClip;
}
}//package Race3D_fla
Section 18
//_bike_bodyw_17 (Race3D_fla._bike_bodyw_17)
package Race3D_fla {
import flash.display.*;
public dynamic class _bike_bodyw_17 extends MovieClip {
public var mc_b_spring:MovieClip;
public var mc_s_wheel_forward:MovieClip;
public var mc_f_spring:MovieClip;
public var mc_s_wheel_back:MovieClip;
public var mc_body_man:MovieClip;
public var mc_f_point:MovieClip;
}
}//package Race3D_fla
Section 19
//_bike_f_springw_18 (Race3D_fla._bike_f_springw_18)
package Race3D_fla {
import flash.display.*;
public dynamic class _bike_f_springw_18 extends MovieClip {
public var mc_spring:MovieClip;
}
}//package Race3D_fla
Section 20
//_forward_wheel_w_6 (Race3D_fla._forward_wheel_w_6)
package Race3D_fla {
import flash.display.*;
public dynamic class _forward_wheel_w_6 extends MovieClip {
public var mc:MovieClip;
}
}//package Race3D_fla
Section 21
//_forward_wheelw_7 (Race3D_fla._forward_wheelw_7)
package Race3D_fla {
import flash.display.*;
public dynamic class _forward_wheelw_7 extends MovieClip {
public var mc_rim:MovieClip;
}
}//package Race3D_fla
Section 22
//_man_allw_26 (Race3D_fla._man_allw_26)
package Race3D_fla {
import flash.display.*;
public dynamic class _man_allw_26 extends MovieClip {
public var b:MovieClip;
public var h:MovieClip;
public var l:MovieClip;
}
}//package Race3D_fla
Section 23
//bodyw_31 (Race3D_fla.bodyw_31)
package Race3D_fla {
import flash.display.*;
public dynamic class bodyw_31 extends MovieClip {
public var p:MovieClip;
}
}//package Race3D_fla
Section 24
//Countdown_72 (Race3D_fla.Countdown_72)
package Race3D_fla {
import flash.display.*;
public dynamic class Countdown_72 extends MovieClip {
public function Countdown_72(){
addFrameScript(12, frame13);
}
function frame13(){
stop();
}
}
}//package Race3D_fla
Section 25
//Countdown_74 (Race3D_fla.Countdown_74)
package Race3D_fla {
import flash.display.*;
public dynamic class Countdown_74 extends MovieClip {
public function Countdown_74(){
addFrameScript(12, frame13);
}
function frame13(){
stop();
}
}
}//package Race3D_fla
Section 26
//Countdown_76 (Race3D_fla.Countdown_76)
package Race3D_fla {
import flash.display.*;
public dynamic class Countdown_76 extends MovieClip {
public function Countdown_76(){
addFrameScript(12, frame13);
}
function frame13(){
stop();
}
}
}//package Race3D_fla
Section 27
//Countdown_78 (Race3D_fla.Countdown_78)
package Race3D_fla {
import flash.display.*;
public dynamic class Countdown_78 extends MovieClip {
public function Countdown_78(){
addFrameScript(12, frame13);
}
function frame13(){
stop();
}
}
}//package Race3D_fla
Section 28
//FinalLap_Title_81 (Race3D_fla.FinalLap_Title_81)
package Race3D_fla {
import flash.display.*;
import flash.text.*;
public dynamic class FinalLap_Title_81 extends MovieClip {
public var tfMessage2:TextField;
public var tfMessage1:TextField;
public var tfMessage3:TextField;
}
}//package Race3D_fla
Section 29
//headw_30 (Race3D_fla.headw_30)
package Race3D_fla {
import flash.display.*;
public dynamic class headw_30 extends MovieClip {
public var p:MovieClip;
}
}//package Race3D_fla
Section 30
//legw_32 (Race3D_fla.legw_32)
package Race3D_fla {
import flash.display.*;
public dynamic class legw_32 extends MovieClip {
public var p:MovieClip;
}
}//package Race3D_fla
Section 31
//Loader_34 (Race3D_fla.Loader_34)
package Race3D_fla {
import flash.display.*;
import flash.text.*;
public dynamic class Loader_34 extends MovieClip {
public var btStart:SimpleButton;
public var mcStripe:MovieClip;
public var tfPercents:TextField;
public function Loader_34(){
addFrameScript(0, frame1, 1, frame2);
}
function frame1(){
stop();
}
function frame2(){
stop();
}
}
}//package Race3D_fla
Section 32
//logoaniinit_1 (Race3D_fla.logoaniinit_1)
package Race3D_fla {
import flash.display.*;
public dynamic class logoaniinit_1 extends MovieClip {
public var prebut:SimpleButton;
public function logoaniinit_1(){
addFrameScript(5766, frame5767);
}
function frame5767(){
stop();
}
}
}//package Race3D_fla
Section 33
//logocharacters_2 (Race3D_fla.logocharacters_2)
package Race3D_fla {
import flash.display.*;
public dynamic class logocharacters_2 extends MovieClip {
public var num;
public function logocharacters_2(){
addFrameScript(0, frame1);
}
function frame1(){
num = (Math.floor((Math.random() * 3)) + 1);
MovieClip(this).gotoAndStop(num);
}
}
}//package Race3D_fla
Section 34
//spring_backw_21 (Race3D_fla.spring_backw_21)
package Race3D_fla {
import flash.display.*;
public dynamic class spring_backw_21 extends MovieClip {
public var mc_top:MovieClip;
}
}//package Race3D_fla
Section 35
//Tachometer_70 (Race3D_fla.Tachometer_70)
package Race3D_fla {
import flash.display.*;
public dynamic class Tachometer_70 extends MovieClip {
public function Tachometer_70(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Race3D_fla
Section 36
//TrainingResult_91 (Race3D_fla.TrainingResult_91)
package Race3D_fla {
import flash.display.*;
import flash.text.*;
public dynamic class TrainingResult_91 extends MovieClip {
public var tfMinutes:TextField;
public var tfMilliSeconds:TextField;
public var tfSeconds:TextField;
}
}//package Race3D_fla
Section 37
//TransmissionBar_69 (Race3D_fla.TransmissionBar_69)
package Race3D_fla {
import flash.display.*;
public dynamic class TransmissionBar_69 extends MovieClip {
public function TransmissionBar_69(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package Race3D_fla
Section 38
//Arrow3D (Arrow3D)
package {
import iriysoft.engine3d.*;
public dynamic class Arrow3D extends ObjectPseudo3D {
}
}//package
Section 39
//Beacon3D (Beacon3D)
package {
import iriysoft.engine3d.*;
public dynamic class Beacon3D extends ObjectPseudo3D {
}
}//package
Section 40
//ButtonOverSound (ButtonOverSound)
package {
import flash.media.*;
public dynamic class ButtonOverSound extends Sound {
}
}//package
Section 41
//ButtonSound (ButtonSound)
package {
import flash.media.*;
public dynamic class ButtonSound extends Sound {
}
}//package
Section 42
//Car3D (Car3D)
package {
import iriysoft.engine3d.*;
import iriysoft.math.*;
import flash.display.*;
import flash.events.*;
import flash.ui.*;
public class Car3D extends ObjectPseudo3D {
private var m_nSteer:Number;
private var m_nSteerSpeed:Number;
private var m_iWheelRadius:int;
public var iCurrentCheck:int;
public var m_iRPM:int;
private var m_bAutoTransmission:Boolean;
private var m_iHP:int;
public var m_p3dSpeed:Point3D;
public var iSkill:int;
public var m_iGear:int;
public var iNextCheck:int;
public var bOutOfTrack:Boolean;
public var p3dTarget2:Point3D;
private var m_iGearTimer:int;
public var m_iMass:int;
public var iCurrentLap:int;
public var iDriver:int;
public var p3dTarget:Point3D;
private static const STEER_SPEED_UP:Number = 0.02;
public static const DRIVER_USER:int = 1;
private static const ROLL_FRICTION:Number = 0.02;
private static const GEAR_TOP:int = 8;
private static const GRAVITY:Number = 9.8;
private static const BRAKE_SLIP_FRICTION:Number = 50000;
private static const MIN_RPM:int = 800;
private static const SLIP_OUT_FRICTION:Number = 11;
private static const GEAR_NEUTRAL:int = 1;
private static const MAX_RPM:int = 8000;
private static const GEAR_REAR:int = 0;
private static const SLIP_FRICTION:Number = 15;
private static const BACK_THROTTLE:int = 100;
private static const MAX_STEER_SPEED:Number = 0.135;
public static const DRIVER_AI:int = 2;
private static const GEAR_SWITCH_COOLDOWN:int = 8;
private static const THROTTLE:int = 100;
public static const EVENT_UPDATE:String = "update";
private static const TRANSMISSIONS:Array = [5.11, 0, 3.42, 2.11, 1.43, 1.09, 1.1, 0.91];
public static const SCALE_FACTOR:int = 12;
private static const ROLL_OUT_FRICTION:Number = 100;
private static const AIR_RESISTANCE:Number = 0.2;
public static const DRIVER_NONE:int = 0;
private static const MAX_STEER:Number = 1.8;
public function Car3D(){
this.iDriver = Car3D.DRIVER_NONE;
this.m_iGear = Car3D.GEAR_NEUTRAL;
this.m_iRPM = Car3D.MIN_RPM;
this.m_nSteer = 0;
this.m_iMass = 1520;
this.m_iHP = 220;
this.m_iWheelRadius = 26;
this.m_bAutoTransmission = true;
this.m_iGearTimer = 0;
this.m_p3dSpeed = new Point3D();
this.m_nSteerSpeed = 0;
this.iSkill = 0;
}
public function process(_arg1:Object=null):void{
var _local2:Number;
var _local3:Boolean;
var _local4:Boolean;
var _local5:Boolean;
var _local6:Boolean;
var _local7:Boolean;
var _local8:Boolean;
var _local9:Boolean;
var _local10:Point3D;
var _local11:Point3D;
var _local12:Number;
var _local13:Number;
var _local14:Point3D;
var _local15:Point3D;
var _local16:Point3D;
var _local17:Point3D;
var _local18:Point3D;
var _local19:Number;
var _local20:Number;
var _local21:Point3D;
var _local22:Point3D;
var _local23:*;
var _local24:Point3D;
var _local25:Point3D;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Point3D;
var _local31:Number;
var _local32:Number;
_local2 = this.m_p3dSpeed.nLength;
_local3 = false;
_local4 = false;
_local5 = false;
_local6 = false;
_local7 = false;
_local8 = false;
_local9 = false;
if (this.iDriver == Car3D.DRIVER_USER){
for (_local23 in _arg1) {
switch (_local23){
case Keyboard.UP:
_local5 = true;
break;
case Keyboard.DOWN:
_local6 = true;
break;
case Keyboard.LEFT:
_local8 = true;
break;
case Keyboard.RIGHT:
_local9 = true;
break;
};
};
} else {
if (this.iDriver == Car3D.DRIVER_AI){
_local24 = this.p3dTarget.clone();
_local24.substract(this.coords.p3dOrigin);
_local25 = this.p3dTarget2.clone();
_local25.substract(this.coords.p3dOrigin);
_local26 = Math.acos((_local24.findScalar(this.coords.p3dZAxis) / (_local24.nLength * this.coords.p3dZAxis.nLength)));
_local27 = Math.acos((_local25.findScalar(this.coords.p3dZAxis) / (_local25.nLength * this.coords.p3dZAxis.nLength)));
_local28 = _local24.nLength;
_local29 = (_local26 / _local28);
if ((((_local26 > ((Math.PI / 350) - ((this.iSkill * Math.PI) / 2000)))) && ((_local28 > 200)))){
_local30 = _local24.clone();
} else {
if (_local27 > ((Math.PI / 350) - ((this.iSkill * Math.PI) / 2000))){
_local30 = _local25.clone();
};
};
if (_local30 != null){
_local30.rotateOnY((Math.PI / 2));
_local31 = (_local30.findScalar(this.coords.p3dZAxis) / (_local30.nLength * this.coords.p3dZAxis.nLength));
if (_local31 > 0){
_local8 = true;
} else {
_local9 = true;
};
};
if (_local2 > (160 + (this.iSkill * 5))){
} else {
if ((((_local29 < ((Math.PI / 900) + ((this.iSkill * Math.PI) / 4000)))) || ((_local2 < (80 + (this.iSkill * 10)))))){
_local5 = true;
};
};
};
};
_local10 = this.coords.p3dZAxis.clone();
_local10.normalize();
_local11 = _local10.clone();
_local11.rotateOnY((Math.PI / 2));
_local12 = this.m_p3dSpeed.findScalar(_local10);
_local13 = this.m_p3dSpeed.findScalar(_local11);
if (_local13 < 0){
_local13 = (_local13 * -1);
_local11.nLength = (_local11.nLength * -1);
};
if (!this.m_bAutoTransmission){
if (((((_local4) && ((this.m_iGearTimer <= 0)))) && ((this.m_iGear < Car3D.GEAR_TOP)))){
this.m_iGear++;
this.m_iGearTimer = Car3D.GEAR_SWITCH_COOLDOWN;
};
if (((((_local3) && ((this.m_iGearTimer <= 0)))) && ((this.m_iGear > Car3D.GEAR_REAR)))){
this.m_iGear--;
this.m_iGearTimer = Car3D.GEAR_SWITCH_COOLDOWN;
};
} else {
if ((((((this.m_iGear == Car3D.GEAR_NEUTRAL)) && (_local5))) && ((this.m_iGearTimer <= 0)))){
this.m_iGear = (Car3D.GEAR_NEUTRAL + 1);
this.m_iGearTimer = Car3D.GEAR_SWITCH_COOLDOWN;
};
if ((((((this.m_iGear == Car3D.GEAR_NEUTRAL)) && (_local6))) && ((this.m_iGearTimer <= 0)))){
this.m_iGear = Car3D.GEAR_REAR;
this.m_iGearTimer = Car3D.GEAR_SWITCH_COOLDOWN;
};
if ((((((((((_local12 > 0)) && ((_local12 < 3)))) && (!(_local5)))) || ((((((_local12 < 0)) && ((_local12 > -3)))) && (!(_local6)))))) && ((this.m_iGearTimer <= 0)))){
this.m_iGear = Car3D.GEAR_NEUTRAL;
this.m_iGearTimer = Car3D.GEAR_SWITCH_COOLDOWN;
};
if (this.m_iGear > Car3D.GEAR_NEUTRAL){
if ((((((_local12 > ((0.025 * 7000) / Car3D.TRANSMISSIONS[this.m_iGear]))) && ((this.m_iGear < Car3D.GEAR_TOP)))) && ((this.m_iGearTimer <= 0)))){
this.m_iGear++;
this.m_iGearTimer = Car3D.GEAR_SWITCH_COOLDOWN;
};
if ((((((_local12 < ((0.025 * 7000) / Car3D.TRANSMISSIONS[(this.m_iGear - 1)]))) && ((this.m_iGear > (Car3D.GEAR_NEUTRAL + 1))))) && ((this.m_iGearTimer <= 0)))){
this.m_iGear--;
this.m_iGearTimer = Car3D.GEAR_SWITCH_COOLDOWN;
};
};
};
if (((_local5) && ((this.m_iGear > Car3D.GEAR_NEUTRAL)))){
this.m_iRPM = (this.m_iRPM + Car3D.THROTTLE);
} else {
if (((_local6) && ((this.m_iGear == Car3D.GEAR_REAR)))){
this.m_iRPM = (this.m_iRPM + Car3D.BACK_THROTTLE);
} else {
if (this.m_iGear == Car3D.GEAR_REAR){
this.m_iRPM = (this.m_iRPM - (3 * Car3D.THROTTLE));
} else {
this.m_iRPM = (this.m_iRPM - Car3D.THROTTLE);
};
};
};
if (this.m_iRPM > Car3D.MAX_RPM){
this.m_iRPM = Car3D.MAX_RPM;
};
if (this.m_iRPM < Car3D.MIN_RPM){
this.m_iRPM = Car3D.MIN_RPM;
};
_local14 = new Point3D();
_local15 = new Point3D();
_local16 = new Point3D();
_local17 = new Point3D();
_local18 = new Point3D();
_local11.copyTo(_local15);
if (_local13 != 0){
_local15.nLength = (_local15.nLength * -1);
_local15.nLength = (((this.bOutOfTrack) ? Car3D.SLIP_OUT_FRICTION : Car3D.SLIP_FRICTION * this.m_iMass) * Car3D.GRAVITY);
_local32 = ((_local13 * this.m_iMass) * Car3D.SCALE_FACTOR);
if (_local15.nLength > _local32){
_local15.nLength = _local32;
};
} else {
_local15.nLength = 0;
};
this.m_p3dSpeed.copyTo(_local18);
_local18.normalize();
_local18.nLength = (_local18.nLength * ((-(Car3D.AIR_RESISTANCE) * _local2) * _local2));
_local10.copyTo(_local14);
if (this.m_iGear == Car3D.GEAR_NEUTRAL){
_local14.nLength = 0;
} else {
if (this.m_iGear == Car3D.GEAR_REAR){
_local14.nLength = (_local14.nLength * -1);
};
};
_local10.copyTo(_local16);
_local10.copyTo(_local17);
if (_local12 == 0){
_local16.nLength = 0;
_local17.nLength = 0;
} else {
if (_local12 > 0){
_local16.nLength = (_local16.nLength * -1);
_local17.nLength = (_local17.nLength * -1);
};
};
if (_local7){
_local16.nLength = 0;
_local17.nLength = (((this.bOutOfTrack) ? Car3D.SLIP_OUT_FRICTION : Car3D.SLIP_FRICTION * this.m_iMass) * Car3D.GRAVITY);
_local32 = ((Math.abs(_local12) * this.m_iMass) * Car3D.SCALE_FACTOR);
if (_local17.nLength > _local32){
_local17.nLength = _local32;
};
} else {
_local16.nLength = ((((this.bOutOfTrack) ? Car3D.ROLL_OUT_FRICTION : Car3D.ROLL_FRICTION * this.m_iMass) * Car3D.GRAVITY) / this.m_iWheelRadius);
_local32 = ((Math.abs(_local12) * this.m_iMass) * Car3D.SCALE_FACTOR);
if (_local16.nLength > _local32){
_local16.nLength = _local32;
};
if (((((_local6) && ((_local12 > 0)))) || (((_local5) && ((_local12 < 0)))))){
_local14.nLength = 0;
_local17.nLength = Car3D.BRAKE_SLIP_FRICTION;
} else {
if (((!((this.m_iGear == Car3D.GEAR_NEUTRAL))) && ((Math.abs(_local12) < (((0.025 * 2) * this.m_iRPM) / Car3D.TRANSMISSIONS[this.m_iGear]))))){
_local14.nLength = (((this.m_iHP * this.m_iRPM) * Car3D.TRANSMISSIONS[this.m_iGear]) / 50);
this.m_iRPM = (this.m_iRPM - (((1.25 * Math.abs(_local12)) * Car3D.TRANSMISSIONS[this.m_iGear]) / 3));
_local17.nLength = 0;
};
};
};
_local19 = ((Car3D.MAX_STEER * 200) / Math.abs(_local12));
if (((_local8) && ((this.m_nSteer > -(_local19))))){
this.m_nSteerSpeed = (this.m_nSteerSpeed + Car3D.STEER_SPEED_UP);
if (this.m_nSteerSpeed > Car3D.MAX_STEER_SPEED){
this.m_nSteerSpeed = Car3D.MAX_STEER_SPEED;
};
if (this.m_nSteer > 0){
this.m_nSteer = (this.m_nSteer - (3 * Car3D.MAX_STEER_SPEED));
};
this.m_nSteer = (this.m_nSteer - this.m_nSteerSpeed);
if (this.m_nSteer < -(_local19)){
this.m_nSteer = -(_local19);
};
};
if (((_local9) && ((this.m_nSteer < _local19)))){
this.m_nSteerSpeed = (this.m_nSteerSpeed + Car3D.STEER_SPEED_UP);
if (this.m_nSteerSpeed > Car3D.MAX_STEER_SPEED){
this.m_nSteerSpeed = Car3D.MAX_STEER_SPEED;
};
if (this.m_nSteer < 0){
this.m_nSteer = (this.m_nSteer + (3 * Car3D.MAX_STEER_SPEED));
};
this.m_nSteer = (this.m_nSteer + this.m_nSteerSpeed);
if (this.m_nSteer > _local19){
this.m_nSteer = _local19;
};
};
if (((!(_local8)) && (!(_local9)))){
this.m_nSteerSpeed = 0;
if (this.m_nSteer < 0){
this.m_nSteer = (this.m_nSteer + (2 * Car3D.MAX_STEER_SPEED));
if (this.m_nSteer > 0){
this.m_nSteer = 0;
};
};
if (this.m_nSteer > 0){
this.m_nSteer = (this.m_nSteer - (2 * Car3D.MAX_STEER_SPEED));
if (this.m_nSteer < 0){
this.m_nSteer = 0;
};
};
};
_local20 = ((-(this.m_nSteer) * _local12) / (Car3D.SCALE_FACTOR * 400));
_local21 = _local14.clone();
_local21.add(_local16);
_local21.add(_local17);
_local21.add(_local15);
_local21.add(_local18);
_local21.nLength = (_local21.nLength / this.m_iMass);
_local21.nLength = (_local21.nLength / Car3D.SCALE_FACTOR);
this.m_p3dSpeed.add(_local21);
if (this.m_nSteer != 0){
this.coords.rotateOnOwnY(_local20);
};
_local22 = this.m_p3dSpeed.clone();
this.m_p3dSpeed.clone().nLength = (_local22.nLength / Car3D.SCALE_FACTOR);
this.coords.translate(_local22);
if (this.m_iGearTimer > 0){
this.m_iGearTimer--;
};
this.dispatchEvent(new Event(Car3D.EVENT_UPDATE));
}
public function setTarget(_arg1:DisplayObject, _arg2:DisplayObject){
if (this.p3dTarget == null){
this.p3dTarget = new Point3D();
};
this.p3dTarget.nX = (_arg1.x * Game.TRACK_SCALE);
this.p3dTarget.nY = 0;
this.p3dTarget.nZ = (-(_arg1.y) * Game.TRACK_SCALE);
if (this.p3dTarget2 == null){
this.p3dTarget2 = new Point3D();
};
this.p3dTarget2.nX = (_arg2.x * Game.TRACK_SCALE);
this.p3dTarget2.nY = 0;
this.p3dTarget2.nZ = (-(_arg2.y) * Game.TRACK_SCALE);
}
}
}//package
Section 43
//CarMarkAI (CarMarkAI)
package {
import flash.display.*;
public dynamic class CarMarkAI extends Sprite {
}
}//package
Section 44
//CarMarkUser (CarMarkUser)
package {
import flash.display.*;
public dynamic class CarMarkUser extends Sprite {
}
}//package
Section 45
//ControlPanel (ControlPanel)
package {
import flash.display.*;
import flash.text.*;
public class ControlPanel extends Sprite {
public var tfSpeed:TextField;
public var tfGear2:TextField;
public var tfGear3:TextField;
public var tfGear4:TextField;
public var tfGear5:TextField;
public var tfGear6:TextField;
public var tfGear7:TextField;
public var tfGear8:TextField;
public var tfGear1:TextField;
public var mcTransmission:MovieClip;
public var mcTachometer:MovieClip;
private static const COLOR_GEAR_ACTIVE = 0xFF00;
private static const COLOR_GEAR_INACTIVE = 0xFFFFFF;
public function ControlPanel(){
this.setGear(2);
this.setSpeed(0);
}
public function setSpeed(_arg1:uint):void{
var _local2:String;
_local2 = _arg1.toString();
if (_arg1 < 10){
_local2 = ("00" + _local2);
} else {
if (_arg1 < 100){
_local2 = ("0" + _local2);
};
};
this.tfSpeed.text = _local2;
this.mcTachometer.gotoAndStop((Math.floor(((38 * _arg1) / 200)) + 1));
if (this.mcTachometer.currentLabel == "frmRed"){
this.tfSpeed.textColor = 0xFF0000;
} else {
if (this.mcTachometer.currentLabel == "frmYellow"){
this.tfSpeed.textColor = 0xFFFF00;
} else {
if (this.mcTachometer.currentLabel == "frmGreen"){
this.tfSpeed.textColor = 0xCC00;
};
};
};
}
public function setGear(_arg1:uint):void{
this.mcTransmission.gotoAndStop((_arg1 + 1));
}
public function setRPM(_arg1:uint):void{
}
}
}//package
Section 46
//Countdown (Countdown)
package {
import flash.display.*;
public dynamic class Countdown extends MovieClip {
public function Countdown(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 47
//CountdownSound (CountdownSound)
package {
import flash.media.*;
public dynamic class CountdownSound extends Sound {
}
}//package
Section 48
//Game (Game)
package {
import iriysoft.engine3d.*;
import iriysoft.math.*;
import flash.utils.*;
import flash.display.*;
import flash.events.*;
import iriysoft.sound.*;
import iriysoft.utils.*;
import flash.text.*;
import flash.system.*;
import flash.geom.*;
import flash.net.*;
public class Game extends Sprite {
private var dictHit:Dictionary;
private var arrow:Arrow3D;
private var aRivalResults:Array;
private var ftimerCountdownTimer:FrameTimer;
private var aCheckLines:Array;
private var mcLapMessage:MovieClip;
private var m_soundManager:SoundManager;
private var sprRaceLoadingScreen:Sprite;
private var beacon:Beacon3D;
private var cameraRear:Camera3D;
private var i:Number;
private var sprCheckLines:Sprite;
private var cameraMain:Camera3D;
private var sprSubmitWindow:Sprite;
private var sprTimer:Sprite;
private var sprPauseWindow:Sprite;
private var sprTrack:Sprite;
private var iRivalFinish:int;
private var controlPanel:ControlPanel;
private var m_iLevel:int;
private var m_bPause:Boolean;
private var iTime:int;
private var iFrameCounter:int;
private var mcPosition:MovieClip;
private var physics3D:Physics3D;
private var btnPause:SimpleButton;
private var sprTrainingScreen:Sprite;
private var ftimerRaceTimer:FrameTimer;
private var tfFPS:TextField;
private var sprMainScreen:Sprite;
private var mcCountdown:MovieClip;
private var sprRearView:Sprite;
private var sprCarMark:Sprite;
private var char:String;
private var sprRearViewMask:Sprite;
private var url:String;
private var mcResultsWindow:MovieClip;
private var bFinish:Boolean;
private var sprHowToPlayScreen:Sprite;
private var oKeysPressed:Object;
private var ftimerCheck:FrameTimer;
private var mcSoundSwitch:MovieClip;
private var sprSchemeTrack:Sprite;
private var m_iState:int;
private var m_iScore:int;
private var dictPrevHit:Dictionary;
private var carUser:Car3D;
private var dictCars:Dictionary;
private var scene3D:Scene3D;
public static const STATE_MAINSCREEN:int = 1;
private static const SND_HIT:String = "HitSound";
private static const SND_BUTTONOVER:String = "ButtonOverSound";
private static const TRACK_TEXTURE_WIDTH:int = 1300;
public static const STATE_TRAININGSCREEN:int = 3;
public static const TRACK_SCALE:Number = 2;
private static const RIVALS_NUM:int = 4;
private static const SND_COUNTDOWN:String = "CountdownSound";
private static const SND_RACEMUSIC:String = "RaceMusic";
public static const STATE_RACE:int = 4;
private static const SND_GO:String = "GoSound";
private static const RACE_LAPS:int = 3;
public static const STATE_TRAINING:int = 5;
private static const SND_MESSAGE:String = "MessageSound";
private static const SND_MAINMUSIC:String = "MainMusic";
private static const SND_BUTTON:String = "ButtonSound";
private static const REMINDER_TIME:int = 5000;
public static const STATE_HOWTOPLAYSCREEN:int = 2;
private static const TRACK_TEXTURE_HEIGHT:int = 900;
public function Game(){
this.m_bPause = false;
this.m_soundManager = new SoundManager();
this.m_soundManager.addSound(Game.SND_MAINMUSIC);
this.m_soundManager.addSound(Game.SND_RACEMUSIC);
this.m_soundManager.addSound(Game.SND_BUTTON);
this.m_soundManager.addSound(Game.SND_BUTTONOVER);
this.m_soundManager.addSound(Game.SND_COUNTDOWN);
this.m_soundManager.addSound(Game.SND_GO);
this.m_soundManager.addSound(Game.SND_HIT);
this.m_soundManager.addSound(Game.SND_MESSAGE);
this.m_soundManager.setVolume(Game.SND_RACEMUSIC, 0.5);
this.iState = Game.STATE_MAINSCREEN;
this.addEventListener(Event.ADDED_TO_STAGE, this.onAddToStage);
this.addEventListener(Event.REMOVED_FROM_STAGE, this.onRemoveFromStage);
}
private function onMouseOver(_arg1:MouseEvent):void{
if ((_arg1.target is SimpleButton)){
this.m_soundManager.playSound(Game.SND_BUTTONOVER);
};
}
private function onSubmitWindowClick(_arg1:MouseEvent):void{
var _local2:Boolean;
_local2 = false;
switch (_arg1.target){
case this.sprSubmitWindow.getChildByName("btnYes"):
if (((!(((this.sprSubmitWindow.getChildByName("tfScore") as TextField).text == ""))) && ((this.m_iScore > 0)))){
_local2 = true;
this.m_soundManager.playSound(Game.SND_BUTTON);
this.submitScore((this.sprSubmitWindow.getChildByName("tfName") as TextField).text, this.m_iScore);
};
break;
case this.sprSubmitWindow.getChildByName("btnNo"):
_local2 = true;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
};
if (_local2){
this.removeChild(this.sprSubmitWindow);
this.sprSubmitWindow = null;
this.iState = Game.STATE_MAINSCREEN;
};
}
private function onKeyPress(_arg1:KeyboardEvent):void{
this.oKeysPressed[_arg1.keyCode] = true;
if (!this.bFinish){
switch (_arg1.keyCode){
case 80:
this.bPause = !(this.bPause);
if (this.bPause){
this.sprPauseWindow = new PauseWindow();
this.addChild(this.sprPauseWindow);
this.sprPauseWindow.addEventListener(MouseEvent.CLICK, this.onPauseWindowClick);
} else {
this.sprPauseWindow.removeEventListener(MouseEvent.CLICK, this.onPauseWindowClick);
this.removeChild(this.sprPauseWindow);
this.sprPauseWindow = null;
};
break;
};
};
}
private function onSoundSwitchClick(_arg1:MouseEvent):void{
if (this.m_soundManager.soundOn){
this.m_soundManager.soundOn = false;
((_arg1.target as SimpleButton).parent as MovieClip).gotoAndStop("frmSoundOff");
} else {
this.m_soundManager.soundOn = true;
((_arg1.target as SimpleButton).parent as MovieClip).gotoAndStop("frmSoundOn");
};
}
private function initLevel(_arg1:uint){
var _local2:Class;
var _local3:Class;
var _local4:Class;
var _local5:Class;
var _local6:Class;
var _local7:Sprite;
var _local8:Bitmap;
var _local9:Object3D;
var _local10:Polygon3D;
var _local11:int;
var _local12:DisplayObject;
var _local13:int;
var _local14:Sprite;
var _local15:DisplayObject;
var _local16:Sprite;
var _local17:int;
var _local18:Sprite;
var _local19:DisplayObject;
var _local20:ObjectPseudo3D;
var _local21:Point3D;
var _local22:Number;
var _local23:int;
var _local24:Car3D;
_local2 = (ApplicationDomain.currentDomain.getDefinition(("TrackTexture" + _arg1)) as Class);
_local3 = (ApplicationDomain.currentDomain.getDefinition(("TrackRoad" + _arg1)) as Class);
_local4 = (ApplicationDomain.currentDomain.getDefinition(("TrackLines" + _arg1)) as Class);
_local5 = (ApplicationDomain.currentDomain.getDefinition(("TrackStarts" + _arg1)) as Class);
_local6 = (ApplicationDomain.currentDomain.getDefinition(("TrackObjects" + _arg1)) as Class);
this.scene3D = new Scene3D();
this.physics3D = new Physics3D();
this.physics3D.addEventListener(Event3D.PHYSICS_HIT, this.onPhysicsHit);
_local7 = new (_local2);
_local8 = new Bitmap(new BitmapData((TRACK_TEXTURE_WIDTH * TRACK_SCALE), (TRACK_TEXTURE_HEIGHT * TRACK_SCALE)));
_local8.bitmapData.draw(_local7, new Matrix(TRACK_SCALE, 0, 0, TRACK_SCALE));
_local9 = new Object3D(new Point3D(0, 0, 0));
_local10 = new Polygon3D(new Point3D(-5000, 0, 5000), new Point3D(5000, 0, 5000), new Point3D(5000, 0, -5000), new Point3D(-5000, 0, -5000));
_local9.addPolygon(_local10);
_local9.nZAtCamera = 40000000;
this.scene3D.addObject(_local9);
_local11 = 0;
_local9 = new Object3D(new Point3D(0, 0, 0));
_local10 = new Polygon3D(new Point3D((((-(Game.TRACK_TEXTURE_WIDTH) * Game.TRACK_SCALE) / 2) + _local11), 0, (((Game.TRACK_TEXTURE_HEIGHT * Game.TRACK_SCALE) / 2) - _local11)), new Point3D((((Game.TRACK_TEXTURE_WIDTH * Game.TRACK_SCALE) / 2) - _local11), 0, (((Game.TRACK_TEXTURE_HEIGHT * Game.TRACK_SCALE) / 2) - _local11)), new Point3D((((Game.TRACK_TEXTURE_WIDTH * Game.TRACK_SCALE) / 2) - _local11), 0, (((-(Game.TRACK_TEXTURE_HEIGHT) * Game.TRACK_SCALE) / 2) + _local11)), new Point3D((((-(Game.TRACK_TEXTURE_WIDTH) * Game.TRACK_SCALE) / 2) + _local11), 0, (((-(Game.TRACK_TEXTURE_HEIGHT) * Game.TRACK_SCALE) / 2) + _local11)));
_local10.applyTexture(_local8.bitmapData, new Point(1, 1), new Point(((TRACK_TEXTURE_WIDTH * TRACK_SCALE) - 1), 1), new Point(((TRACK_TEXTURE_WIDTH * TRACK_SCALE) - 1), ((TRACK_TEXTURE_HEIGHT * TRACK_SCALE) - 1)), new Point(1, ((TRACK_TEXTURE_HEIGHT * TRACK_SCALE) - 1)));
_local9.addPolygon(_local10);
_local9.nZAtCamera = 30000000;
this.scene3D.addObject(_local9);
this.cameraMain = new Camera3D();
this.cameraMain.name = "standartCamera";
this.cameraMain.nFOV = 80;
this.scene3D.addCamera(this.cameraMain);
this.addChild(this.cameraMain);
this.mcPosition = new RacePosition();
this.mcPosition.x = 330;
this.mcPosition.y = 45;
this.addChild(this.mcPosition);
if (this.iState == Game.STATE_RACE){
this.mcPosition.gotoAndStop(Game.RIVALS_NUM);
};
(this.mcPosition.getChildByName("tfLap") as TextField).text = ("Lap 1/" + Game.RACE_LAPS);
this.ftimerRaceTimer = new FrameTimer(this);
this.sprTimer = new RaceTimer();
this.sprTimer.x = 220;
this.sprTimer.y = 10;
this.addChild(this.sprTimer);
this.sprRearView = new RearViewMirror();
this.sprRearView.x = 10;
this.sprRearView.y = 10;
this.addChild(this.sprRearView);
this.sprRearViewMask = new RearViewMask();
this.sprRearViewMask.x = this.sprRearView.x;
this.sprRearViewMask.y = this.sprRearView.y;
this.addChild(this.sprRearViewMask);
this.cameraRear = new Camera3D(195, 91);
this.cameraRear.name = "rearCamera";
this.cameraRear.scaleX = -1;
this.cameraRear.x = 195;
this.cameraRear.nFOV = 120;
this.scene3D.addCamera(this.cameraRear);
this.sprRearViewMask.addChild(this.cameraRear);
this.sprSchemeTrack = new TrackScheme();
this.sprSchemeTrack.x = 470;
this.sprSchemeTrack.y = 55;
this.sprSchemeTrack.scaleX = 0.1;
this.sprSchemeTrack.scaleY = this.sprSchemeTrack.scaleX;
this.addChild(this.sprSchemeTrack);
(this.sprSchemeTrack.getChildByName("tfLevel") as TextField).text = this.m_iLevel.toString();
this.sprTrack = new (_local3);
this.sprSchemeTrack.addChild(this.sprTrack);
this.sprCheckLines = new (_local4);
this.sprCheckLines.visible = false;
this.sprSchemeTrack.addChild(this.sprCheckLines);
this.aCheckLines = new Array();
_local13 = 1;
while (true) {
_local12 = this.sprCheckLines.getChildByName(("mcCheck" + _local13));
if (_local12 != null){
this.aCheckLines.push(_local12);
} else {
break;
};
_local13++;
};
_local14 = new (_local5);
this.dictCars = new Dictionary();
_local15 = _local14.getChildByName("mcStart0");
this.carUser = new Car3D();
this.carUser.iDriver = Car3D.DRIVER_USER;
this.carUser.iCurrentCheck = (this.aCheckLines.length - 1);
this.carUser.iNextCheck = 0;
this.carUser.iCurrentLap = 0;
this.carUser.setTarget(this.aCheckLines[this.carUser.iCurrentCheck], this.aCheckLines[this.carUser.iNextCheck]);
this.carUser.addEventListener(Car3D.EVENT_UPDATE, this.onCarUpdate);
this.scene3D.addObject(this.carUser);
this.physics3D.addObject(this.carUser, 9, this.carUser.m_iMass);
_local16 = new CarMarkUser();
this.sprSchemeTrack.addChild(_local16);
this.dictCars[this.carUser] = _local16;
this.carUser.coords.rotateOnY(((-(Math.PI) * _local15.rotation) / 180));
this.carUser.coords.translate(new Point3D((_local15.x * Game.TRACK_SCALE), 0, (-(_local15.y) * Game.TRACK_SCALE)));
_local16.x = (this.carUser.coords.p3dOrigin.nX / Game.TRACK_SCALE);
_local16.y = (-(this.carUser.coords.p3dOrigin.nZ) / Game.TRACK_SCALE);
_local17 = 0;
if (this.iState != Game.STATE_TRAINING){
_local13 = 1;
while (true) {
_local15 = _local14.getChildByName(("mcStart" + _local13));
if (_local15 == null){
break;
};
_local24 = new Car3D();
_local24.iDriver = Car3D.DRIVER_AI;
_local24.coords.rotateOnY(((-(Math.PI) * _local15.rotation) / 180));
_local24.coords.translate(new Point3D((_local15.x * Game.TRACK_SCALE), 0, (-(_local15.y) * Game.TRACK_SCALE)));
_local24.iCurrentCheck = (this.aCheckLines.length - 1);
_local24.iNextCheck = 0;
_local24.iCurrentLap = 0;
_local24.iSkill = _local17;
_local24.setTarget(this.aCheckLines[_local24.iCurrentCheck], this.aCheckLines[_local24.iNextCheck]);
_local24.addEventListener(Car3D.EVENT_UPDATE, this.onCarUpdate);
this.scene3D.addObject(_local24);
this.physics3D.addObject(_local24, 9, _local24.m_iMass);
_local16 = new CarMarkAI();
this.sprSchemeTrack.addChild(_local16);
this.dictCars[_local24] = _local16;
_local16.x = (_local24.coords.p3dOrigin.nX / Game.TRACK_SCALE);
_local16.y = (-(_local24.coords.p3dOrigin.nZ) / Game.TRACK_SCALE);
_local13++;
if (this.m_iLevel > 2){
_local17 = (_local17 + this.m_iLevel);
} else {
_local17 = (_local17 + 2);
};
};
};
this.cameraMain.setTarget(Camera3D.MODE_TAIL, this.carUser.coords);
this.cameraRear.setTarget(Camera3D.MODE_REAR_VIEW, this.carUser.coords);
_local18 = new (_local6);
_local21 = new Point3D();
_local23 = _local18.numChildren;
_local13 = 0;
while (_local13 < _local23) {
_local19 = _local18.getChildAt(_local13);
if ((_local19 is TreePlace)){
_local20 = new Tree3D();
_local22 = 2;
} else {
if ((_local19 is TiresRedPlace)){
_local20 = new TiresRed3D();
_local22 = 5;
} else {
if ((_local19 is TiresWhitePlace)){
_local20 = new TiresWhite3D();
_local22 = 5;
};
};
};
_local21.nX = (_local19.x * Game.TRACK_SCALE);
_local21.nZ = (-(_local19.y) * Game.TRACK_SCALE);
_local20.coords.translate(_local21);
this.scene3D.addObject(_local20);
this.physics3D.addObject(_local20, _local22, Physics3D.MASS_INFINITE, false);
_local13++;
};
this.tfFPS = new TextField();
this.tfFPS.x = 10;
this.tfFPS.y = 10;
this.controlPanel = new ControlPanel();
this.controlPanel.x = 468;
this.controlPanel.y = 377;
this.addChild(this.controlPanel);
this.btnPause = new Pause();
this.btnPause.x = 125;
this.btnPause.y = 380;
this.addChild(this.btnPause);
this.btnPause.addEventListener(MouseEvent.CLICK, this.onPauseClick);
this.mcSoundSwitch = new SoundSwitch();
this.mcSoundSwitch.x = 30;
this.mcSoundSwitch.y = 380;
this.addChild(this.mcSoundSwitch);
this.mcSoundSwitch.addEventListener(MouseEvent.CLICK, this.onSoundSwitchClick);
if (!this.m_soundManager.soundOn){
this.mcSoundSwitch.gotoAndStop("frmSoundOff");
} else {
this.mcSoundSwitch.gotoAndStop("frmSoundOn");
};
this.iRivalFinish = 0;
this.aRivalResults = new Array();
this.m_soundManager.playBackSound(Game.SND_RACEMUSIC);
this.addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver);
this.bFinish = true;
}
private function onRaceLoadingEnterFrame(_arg1:Event):void{
if (this.iFrameCounter > 0){
this.sprRaceLoadingScreen.removeEventListener(Event.ENTER_FRAME, this.onRaceLoadingEnterFrame);
this.initLevel(this.m_iLevel);
this.removeChild(this.sprRaceLoadingScreen);
this.stage.focus = this.stage;
this.iFrameCounter = 0;
this.addEventListener(Event.ENTER_FRAME, this.onStartRaceEnterFrame);
} else {
this.iFrameCounter++;
};
}
private function onHowToPlayScreenMouseOver(_arg1:MouseEvent):void{
if ((_arg1.target is SimpleButton)){
this.m_soundManager.playSound(Game.SND_BUTTONOVER);
};
}
private function onPauseClick(_arg1:MouseEvent):void{
this.bPause = true;
this.sprPauseWindow = new PauseWindow();
this.addChild(this.sprPauseWindow);
this.sprPauseWindow.addEventListener(MouseEvent.CLICK, this.onPauseWindowClick);
}
private function onStageDeactivate(_arg1:Event):void{
this.oKeysPressed = new Object();
}
private function onAddToStage(_arg1:Event):void{
this.oKeysPressed = new Object();
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, this.onKeyPress);
this.stage.addEventListener(KeyboardEvent.KEY_UP, this.onKeyRelease);
this.stage.addEventListener(Event.DEACTIVATE, this.onStageDeactivate);
}
private function onCarUpdate(_arg1:Event):void{
var _local2:Car3D;
var _local3:Sprite;
var _local4:Point;
var _local5:Point3D;
var _local6:Point3D;
var _local7:Number;
var _local8:Number;
var _local9:TextField;
var _local10:TextField;
var _local11:TextField;
_local2 = Car3D(_arg1.target);
_local3 = this.dictCars[_local2];
if (_local2 == this.carUser){
this.controlPanel.setGear(_local2.m_iGear);
this.controlPanel.setSpeed(_local2.m_p3dSpeed.nLength);
this.controlPanel.setRPM(_local2.m_iRPM);
if (this.arrow != null){
this.carUser.coords.copyTo(this.arrow.coords);
_local5 = this.carUser.coords.p3dOrigin.clone();
this.carUser.coords.p3dOrigin.clone().nLength = (_local5.nLength * -1);
this.arrow.coords.translate(_local5);
_local6 = this.carUser.p3dTarget.clone();
_local6.substract(this.carUser.coords.p3dOrigin);
_local7 = Math.acos((_local6.findScalar(this.carUser.coords.p3dZAxis) / (_local6.nLength * this.carUser.coords.p3dZAxis.nLength)));
_local6.rotateOnY((Math.PI / 2));
_local8 = (_local6.findScalar(this.carUser.coords.p3dZAxis) / (_local6.nLength * this.carUser.coords.p3dZAxis.nLength));
if (_local8 < 0){
_local7 = (_local7 * -1);
};
this.arrow.coords.rotateOnY(_local7);
_local5.nLength = (_local5.nLength * -1);
_local5.nY = (_local5.nY + -15);
this.arrow.coords.translate(_local5);
};
};
_local3.x = (_local2.coords.p3dOrigin.nX / Game.TRACK_SCALE);
_local3.y = (-(_local2.coords.p3dOrigin.nZ) / Game.TRACK_SCALE);
_local4 = _local3.localToGlobal(new Point());
_local2.bOutOfTrack = !(this.sprTrack.hitTestPoint(_local4.x, _local4.y, true));
if (this.aCheckLines[_local2.iCurrentCheck].hitTestPoint(_local4.x, _local4.y, true)){
_local2.iCurrentCheck++;
if (_local2.iCurrentCheck >= this.aCheckLines.length){
_local2.iCurrentCheck = 0;
};
_local2.iNextCheck++;
if (_local2.iNextCheck >= this.aCheckLines.length){
_local2.iNextCheck = 0;
};
if (_local2 == this.carUser){
this.scene3D.removeObject(this.arrow);
this.arrow = null;
this.scene3D.removeObject(this.beacon);
this.beacon = null;
this.ftimerCheck.reset();
this.ftimerCheck.start();
};
_local2.setTarget(this.aCheckLines[_local2.iCurrentCheck], this.aCheckLines[_local2.iNextCheck]);
if (_local2.iCurrentCheck == 0){
_local2.iCurrentLap++;
if (_local2 == this.carUser){
(this.mcPosition.getChildByName("tfLap") as TextField).text = ((("Lap " + this.carUser.iCurrentLap) + "/") + Game.RACE_LAPS);
if ((((this.carUser.iCurrentLap > 1)) && ((this.carUser.iCurrentLap <= Game.RACE_LAPS)))){
this.mcLapMessage = new LapMessage();
this.mcLapMessage.x = (this.stage.stageWidth / 2);
this.mcLapMessage.y = (this.stage.stageHeight / 2);
_local9 = ((this.mcLapMessage.getChildByName("mcMessage") as MovieClip).getChildByName("tfMessage1") as TextField);
_local10 = ((this.mcLapMessage.getChildByName("mcMessage") as MovieClip).getChildByName("tfMessage2") as TextField);
_local11 = ((this.mcLapMessage.getChildByName("mcMessage") as MovieClip).getChildByName("tfMessage3") as TextField);
if (this.carUser.iCurrentLap < Game.RACE_LAPS){
_local9.text = ("LAP " + this.carUser.iCurrentLap.toString());
_local10.text = _local9.text;
_local11.text = _local9.text;
} else {
_local9.text = "FINAL LAP!";
_local10.text = _local9.text;
_local11.text = _local9.text;
};
this.addChild(this.mcLapMessage);
this.m_soundManager.playSound(Game.SND_MESSAGE);
};
};
if (_local2.iCurrentLap > Game.RACE_LAPS){
if (_local2 == this.carUser){
this.bFinish = true;
if (this.iState == Game.STATE_RACE){
this.m_iScore = (this.m_iScore + 500);
this.m_iScore = (this.m_iScore + (6000 - (this.iRivalFinish * 2000)));
this.m_iScore = (this.m_iScore + ((this.ftimerRaceTimer.nTime * 30000) / ((2 * 60) * 1000)));
};
this.showResultsWindow();
} else {
_local3 = (this.dictCars[_local2] as Sprite);
this.sprSchemeTrack.removeChild(_local3);
this.scene3D.removeObject(_local2);
this.physics3D.removeObject(_local2);
this.dictCars[_local2] = null;
delete dictCars[_local2];
this.iRivalFinish++;
this.aRivalResults.push(this.ftimerRaceTimer.nTime);
};
};
};
};
}
private function onMainScreenMouseOver(_arg1:MouseEvent):void{
if ((_arg1.target is SimpleButton)){
this.m_soundManager.playSound(Game.SND_BUTTONOVER);
};
}
public function get bPause():Boolean{
return (this.m_bPause);
}
public function setUILock(_arg1):void{
if ((((this.m_iState == Game.STATE_RACE)) || ((this.m_iState == Game.STATE_TRAINING)))){
if (_arg1){
this.removeChild(this.btnPause);
} else {
this.addChild(this.btnPause);
};
};
}
private function onHowToPlayScreenClick(_arg1:MouseEvent):void{
switch (_arg1.target){
case this.sprHowToPlayScreen.getChildByName("btnBack"):
this.iState = Game.STATE_MAINSCREEN;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case (this.sprHowToPlayScreen.getChildByName("mcSoundSwitch") as MovieClip).getChildByName("btnSoundOn"):
this.m_soundManager.soundOn = true;
(this.sprHowToPlayScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOn");
break;
case (this.sprHowToPlayScreen.getChildByName("mcSoundSwitch") as MovieClip).getChildByName("btnSoundOff"):
this.m_soundManager.soundOn = false;
(this.sprHowToPlayScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOff");
break;
};
}
private function onRaceEnterFrame(_arg1:Event):void{
var _local2:uint;
var _local3:*;
var _local4:String;
var _local5:uint;
var _local6:Car3D;
var _local7:Point3D;
var _local8:uint;
var _local9:uint;
var _local10:Number;
var _local11:*;
var _local12:*;
_local2 = this.iTime;
this.iTime = getTimer();
this.tfFPS.text = ("FPS: " + Math.round((1000 / (this.iTime - _local2))));
if (!this.bPause){
_local3 = FrameTimer.convertTime(this.ftimerRaceTimer.nTime);
_local4 = _local3.minutes.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
(this.sprTimer.getChildByName("tfMinutes") as TextField).text = _local4;
_local4 = _local3.seconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
(this.sprTimer.getChildByName("tfSeconds") as TextField).text = _local4;
_local4 = _local3.milliseconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
} else {
if (_local4.length < 3){
_local4 = ("00" + _local4);
};
};
(this.sprTimer.getChildByName("tfMilliSeconds") as TextField).text = _local4;
_local5 = (1 + this.iRivalFinish);
_local7 = new Point3D();
_local8 = this.aCheckLines.length;
_local9 = ((this.carUser.iCurrentLap * _local8) + this.carUser.iCurrentCheck);
this.carUser.p3dTarget.copyTo(_local7);
_local7.substract(this.carUser.coords.p3dOrigin);
_local10 = _local7.nLength;
for (_local11 in this.dictCars) {
_local6 = (_local11 as Car3D);
if (_local6 == this.carUser){
} else {
if (((_local6.iCurrentLap * _local8) + _local6.iCurrentCheck) > _local9){
_local5++;
} else {
if (((_local6.iCurrentLap * _local8) + _local6.iCurrentCheck) == _local9){
_local6.p3dTarget.copyTo(_local7);
_local7.substract(_local6.coords.p3dOrigin);
if (_local7.nLength < _local10){
_local5++;
};
};
};
};
};
this.mcPosition.gotoAndStop(_local5);
for (_local12 in this.dictCars) {
_local6 = Car3D(_local12);
_local6.process(this.oKeysPressed);
};
if (this.dictHit != null){
this.dictPrevHit = this.dictHit;
} else {
this.dictPrevHit = new Dictionary();
};
this.dictHit = new Dictionary();
this.physics3D.process();
};
}
private function onTrainingScreenClick(_arg1:MouseEvent):void{
switch (_arg1.target){
case this.sprTrainingScreen.getChildByName("btnBack"):
this.iState = Game.STATE_MAINSCREEN;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case this.sprTrainingScreen.getChildByName("btnLevel1"):
this.m_iLevel = 1;
this.iState = Game.STATE_TRAINING;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case this.sprTrainingScreen.getChildByName("btnLevel2"):
this.m_iLevel = 2;
this.iState = Game.STATE_TRAINING;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case this.sprTrainingScreen.getChildByName("btnLevel3"):
this.m_iLevel = 3;
this.iState = Game.STATE_TRAINING;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case this.sprTrainingScreen.getChildByName("btnLevel4"):
this.m_iLevel = 4;
this.iState = Game.STATE_TRAINING;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case this.sprTrainingScreen.getChildByName("btnLevel5"):
this.m_iLevel = 5;
this.iState = Game.STATE_TRAINING;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case (this.sprTrainingScreen.getChildByName("mcSoundSwitch") as MovieClip).getChildByName("btnSoundOn"):
this.m_soundManager.soundOn = true;
(this.sprTrainingScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOn");
break;
case (this.sprTrainingScreen.getChildByName("mcSoundSwitch") as MovieClip).getChildByName("btnSoundOff"):
this.m_soundManager.soundOn = false;
(this.sprTrainingScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOff");
break;
};
}
private function onPhysicsHit(_arg1:Event3D):void{
if ((((_arg1.op3dSource1 == this.carUser)) || ((_arg1.op3dSource2 == this.carUser)))){
if (((!((this.dictPrevHit[_arg1.op3dSource1] == _arg1.op3dSource2))) && (!((this.dictPrevHit[_arg1.op3dSource2] == _arg1.op3dSource1))))){
this.m_soundManager.playSound(Game.SND_HIT);
};
this.dictHit[_arg1.op3dSource1] = _arg1.op3dSource2;
};
}
private function onMainScreenClick(_arg1:MouseEvent):void{
switch (_arg1.target){
case this.sprMainScreen.getChildByName("btnChampionship"):
this.m_iLevel = 1;
this.iState = Game.STATE_RACE;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case this.sprMainScreen.getChildByName("btnTraining"):
this.iState = Game.STATE_TRAININGSCREEN;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case this.sprMainScreen.getChildByName("btnHowToPlay"):
this.iState = Game.STATE_HOWTOPLAYSCREEN;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case (this.sprMainScreen.getChildByName("mcSoundSwitch") as MovieClip).getChildByName("btnSoundOn"):
this.m_soundManager.soundOn = true;
(this.sprMainScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOn");
break;
case (this.sprMainScreen.getChildByName("mcSoundSwitch") as MovieClip).getChildByName("btnSoundOff"):
this.m_soundManager.soundOn = false;
(this.sprMainScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOff");
break;
};
}
private function onTrainingScreenMouseOver(_arg1:MouseEvent):void{
if ((_arg1.target is SimpleButton)){
this.m_soundManager.playSound(Game.SND_BUTTONOVER);
};
}
public function set iState(_arg1:int):void{
var _local2:*;
switch (this.m_iState){
case Game.STATE_MAINSCREEN:
this.sprMainScreen.removeEventListener(MouseEvent.CLICK, this.onMainScreenClick);
this.sprMainScreen.removeEventListener(MouseEvent.MOUSE_OVER, this.onMainScreenMouseOver);
this.removeChild(this.sprMainScreen);
this.sprMainScreen = null;
break;
case Game.STATE_HOWTOPLAYSCREEN:
this.sprHowToPlayScreen.removeEventListener(MouseEvent.CLICK, this.onHowToPlayScreenClick);
this.sprHowToPlayScreen.removeEventListener(MouseEvent.MOUSE_OVER, this.onHowToPlayScreenMouseOver);
this.removeChild(this.sprHowToPlayScreen);
this.sprHowToPlayScreen = null;
break;
case Game.STATE_TRAININGSCREEN:
this.sprTrainingScreen.removeEventListener(MouseEvent.CLICK, this.onTrainingScreenClick);
this.sprTrainingScreen.removeEventListener(MouseEvent.MOUSE_OVER, this.onTrainingScreenMouseOver);
this.removeChild(this.sprTrainingScreen);
this.sprTrainingScreen = null;
break;
case Game.STATE_RACE:
case Game.STATE_TRAINING:
this.physics3D.removeEventListener(Event3D.PHYSICS_HIT, this.onPhysicsHit);
this.removeEventListener(Event.ENTER_FRAME, this.onRaceEnterFrame);
this.removeEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver);
this.ftimerCheck.removeEventListener(TimerEvent.TIMER_COMPLETE, this.onCheckTimerComplete);
this.removeChild(this.cameraMain);
this.cameraMain = null;
this.cameraRear = null;
this.scene3D = null;
this.physics3D = null;
this.carUser = null;
for (_local2 in this.dictCars) {
this.dictCars[_local2] = null;
delete this.dictCars[_local2];
};
this.removeChild(this.sprSchemeTrack);
this.sprSchemeTrack = null;
this.sprCarMark = null;
this.sprTrack = null;
this.sprCheckLines = null;
this.removeChild(this.sprRearView);
this.sprRearView = null;
this.removeChild(this.sprRearViewMask);
this.sprRearViewMask = null;
this.removeChild(this.sprTimer);
this.sprTimer = null;
this.removeChild(this.mcPosition);
this.mcPosition = null;
this.removeChild(this.mcCountdown);
this.mcCountdown = null;
this.btnPause = null;
this.removeChild(this.controlPanel);
this.controlPanel = null;
this.removeChild(this.mcSoundSwitch);
this.mcSoundSwitch = null;
if (this.arrow != null){
this.arrow = null;
};
if (this.beacon != null){
this.beacon = null;
};
break;
};
this.m_iState = _arg1;
switch (this.m_iState){
case Game.STATE_MAINSCREEN:
this.sprMainScreen = new MainScreen();
this.addChild(this.sprMainScreen);
this.sprMainScreen.addEventListener(MouseEvent.CLICK, this.onMainScreenClick);
this.sprMainScreen.addEventListener(MouseEvent.MOUSE_OVER, this.onMainScreenMouseOver);
if (!this.m_soundManager.soundOn){
(this.sprMainScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOff");
} else {
(this.sprMainScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOn");
};
this.m_soundManager.playBackSound(Game.SND_MAINMUSIC);
break;
case Game.STATE_HOWTOPLAYSCREEN:
this.sprHowToPlayScreen = new HowToPlayScreen();
this.addChild(this.sprHowToPlayScreen);
this.sprHowToPlayScreen.addEventListener(MouseEvent.CLICK, this.onHowToPlayScreenClick);
this.sprHowToPlayScreen.addEventListener(MouseEvent.MOUSE_OVER, this.onHowToPlayScreenMouseOver);
if (!this.m_soundManager.soundOn){
(this.sprHowToPlayScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOff");
} else {
(this.sprHowToPlayScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOn");
};
this.m_soundManager.playBackSound(Game.SND_MAINMUSIC);
break;
case Game.STATE_TRAININGSCREEN:
this.sprTrainingScreen = new TrainingScreen();
this.addChild(this.sprTrainingScreen);
this.sprTrainingScreen.addEventListener(MouseEvent.CLICK, this.onTrainingScreenClick);
this.sprTrainingScreen.addEventListener(MouseEvent.MOUSE_OVER, this.onTrainingScreenMouseOver);
if (!this.m_soundManager.soundOn){
(this.sprTrainingScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOff");
} else {
(this.sprTrainingScreen.getChildByName("mcSoundSwitch") as MovieClip).gotoAndStop("frmSoundOn");
};
this.m_soundManager.playBackSound(Game.SND_MAINMUSIC);
break;
case Game.STATE_RACE:
this.m_iScore = 0;
case Game.STATE_TRAINING:
this.sprRaceLoadingScreen = new RaceLoadingScreen();
this.addChild(this.sprRaceLoadingScreen);
this.sprRaceLoadingScreen.addEventListener(Event.ENTER_FRAME, this.onRaceLoadingEnterFrame);
this.iFrameCounter = 0;
this.m_soundManager.stopBackSound();
break;
};
}
private function onCountdownTimer(_arg1:TimerEvent):void{
this.mcCountdown.play();
this.m_soundManager.playSound(Game.SND_COUNTDOWN);
}
private function onRemoveFromStage(_arg1:Event):void{
this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, this.onKeyPress);
this.stage.removeEventListener(KeyboardEvent.KEY_UP, this.onKeyRelease);
this.stage.removeEventListener(Event.DEACTIVATE, this.onStageDeactivate);
}
private function submitScore(_arg1:String, _arg2:int):void{
var tgtUrl:*;
var request:URLRequest;
var EncryptString:Function;
var sName = _arg1;
var iScore = _arg2;
EncryptString = function (_arg1){
var _local2:*;
var _local3:*;
_local2 = "121212121212121212212212221222221121212121212121212212212221222221121212121212121212212212221222221121212121212121212212212221222221121212121212121212212212221222221121212121212121212212212221222221121212121212121212212212221222221";
_local3 = "";
i = 0;
while (i < _arg1.length) {
char = (Number(_local2.substr(i, 1)) + _arg1.charCodeAt(i));
_local3 = (_local3 + String.fromCharCode(char));
i++;
};
return (_local3);
};
trace(sName, iScore);
url = (((("&namee" + sName) + "&scoree") + iScore) + "&passecoolgames");
tgtUrl = ("http://www.flashgames247.com/scores/race3d/index.php?" + EncryptString(url));
request = new URLRequest(tgtUrl);
navigateToURL(request, "_blank");
}
public function set bPause(_arg1):void{
this.m_bPause = _arg1;
this.setUILock(this.m_bPause);
if (this.m_bPause){
this.cameraMain.stopRender();
this.cameraRear.stopRender();
if (this.ftimerCheck != null){
this.ftimerCheck.stop();
};
if (this.ftimerRaceTimer != null){
this.ftimerRaceTimer.stop();
};
} else {
this.cameraMain.startRender();
this.cameraRear.startRender();
if (this.ftimerCheck != null){
this.ftimerCheck.resume();
};
if (this.ftimerRaceTimer != null){
this.ftimerRaceTimer.resume();
};
};
}
private function showResultsWindow():void{
var _local1:Number;
var _local2:Object;
var _local3:int;
var _local4:String;
var _local5:int;
var _local6:Array;
var _local7:Car3D;
var _local8:Number;
var _local9:int;
var _local10:*;
this.mcResultsWindow = new ResultsWindow();
this.addChild(this.mcResultsWindow);
if (this.iState == Game.STATE_TRAINING){
this.mcResultsWindow.gotoAndStop("frmFinish");
_local1 = this.ftimerRaceTimer.nTime;
_local2 = FrameTimer.convertTime((_local1 + Math.round((Math.random() * 100))));
_local4 = _local2.minutes.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
this.mcResultsWindow.mcResult.tfMinutes.text = _local4;
_local4 = _local2.seconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
this.mcResultsWindow.mcResult.tfSeconds.text = _local4;
_local4 = _local2.milliseconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
} else {
if (_local4.length < 3){
_local4 = ("00" + _local4);
};
};
this.mcResultsWindow.mcResult.tfMilliSeconds.text = _local4;
} else {
this.mcResultsWindow.mcResult.visible = false;
if (this.iRivalFinish <= 1){
if (this.m_iLevel == 5){
this.mcResultsWindow.gotoAndStop("frmTotalWin");
} else {
this.mcResultsWindow.gotoAndStop("frmWin");
};
} else {
this.mcResultsWindow.gotoAndStop("frmLose");
};
_local3 = 1;
_local5 = 0;
while (_local5 < this.iRivalFinish) {
_local2 = FrameTimer.convertTime((this.aRivalResults[_local5] + Math.round((Math.random() * 100))));
_local4 = _local2.minutes.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
(this.mcResultsWindow.getChildByName(("tfMinutes" + _local3)) as TextField).text = _local4;
_local4 = _local2.seconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
(this.mcResultsWindow.getChildByName(("tfSeconds" + _local3)) as TextField).text = _local4;
_local4 = _local2.milliseconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
} else {
if (_local4.length < 3){
_local4 = ("00" + _local4);
};
};
(this.mcResultsWindow.getChildByName(("tfMilliSeconds" + _local3)) as TextField).text = _local4;
_local3++;
_local5++;
};
_local1 = this.ftimerRaceTimer.nTime;
_local2 = FrameTimer.convertTime((_local1 + Math.round((Math.random() * 100))));
_local4 = _local2.minutes.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
(this.mcResultsWindow.getChildByName(("tfMinutes" + _local3)) as TextField).text = _local4;
_local4 = _local2.seconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
(this.mcResultsWindow.getChildByName(("tfSeconds" + _local3)) as TextField).text = _local4;
_local4 = _local2.milliseconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
} else {
if (_local4.length < 3){
_local4 = ("00" + _local4);
};
};
(this.mcResultsWindow.getChildByName(("tfMilliSeconds" + _local3)) as TextField).text = _local4;
_local3++;
(this.mcResultsWindow.getChildByName("mcPositionLine") as MovieClip).gotoAndStop((this.iRivalFinish + 1));
_local6 = new Array();
_local9 = this.aCheckLines.length;
for (_local10 in this.dictCars) {
_local7 = (_local10 as Car3D);
if (_local7 != this.carUser){
_local8 = _local1;
_local8 = (_local8 + ((((Game.RACE_LAPS - _local7.iCurrentLap) * _local9) + (_local9 - _local7.iCurrentCheck)) * 1100));
_local6.push(_local8);
};
};
_local6.sort(Array.NUMERIC);
_local5 = 0;
while (_local3 <= Game.RIVALS_NUM) {
_local2 = FrameTimer.convertTime((_local6[_local5] + Math.round((Math.random() * 100))));
_local4 = _local2.minutes.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
(this.mcResultsWindow.getChildByName(("tfMinutes" + _local3)) as TextField).text = _local4;
_local4 = _local2.seconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
};
(this.mcResultsWindow.getChildByName(("tfSeconds" + _local3)) as TextField).text = _local4;
_local4 = _local2.milliseconds.toString();
if (_local4.length < 2){
_local4 = ("0" + _local4);
} else {
if (_local4.length < 3){
_local4 = ("00" + _local4);
};
};
(this.mcResultsWindow.getChildByName(("tfMilliSeconds" + _local3)) as TextField).text = _local4;
_local3++;
_local5++;
};
};
this.sprTimer.visible = false;
this.bPause = true;
this.mcResultsWindow.addEventListener(MouseEvent.CLICK, this.onResultsWindowClick);
this.m_soundManager.playBackSound(Game.SND_MAINMUSIC);
}
private function onPauseWindowClick(_arg1:MouseEvent):void{
var _local2:Boolean;
_local2 = false;
switch (_arg1.target){
case this.sprPauseWindow.getChildByName("btnResume"):
this.sprPauseWindow.removeEventListener(MouseEvent.CLICK, this.onPauseWindowClick);
this.bPause = false;
_local2 = true;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case this.sprPauseWindow.getChildByName("btnExit"):
if (this.iState == Game.STATE_TRAINING){
this.iState = Game.STATE_TRAININGSCREEN;
} else {
if (this.iState == Game.STATE_RACE){
this.iState = Game.STATE_MAINSCREEN;
};
};
_local2 = true;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
};
if (_local2){
this.removeChild(this.sprPauseWindow);
this.sprPauseWindow = null;
this.stage.focus = this.stage;
};
}
public function get iState():int{
return (this.m_iState);
}
private function onCountdownTimerComplete(_arg1:TimerEvent):void{
this.ftimerRaceTimer.start();
this.ftimerCheck = new FrameTimer(this, Game.REMINDER_TIME, 1);
this.ftimerCheck.addEventListener(TimerEvent.TIMER_COMPLETE, this.onCheckTimerComplete);
this.ftimerCheck.start();
this.m_soundManager.playSound(Game.SND_GO);
this.bPause = false;
this.bFinish = false;
}
private function onCheckTimerComplete(_arg1:TimerEvent):void{
this.arrow = new Arrow3D();
this.scene3D.addObject(this.arrow);
this.beacon = new Beacon3D();
this.beacon.coords.translate(new Point3D((this.aCheckLines[this.carUser.iCurrentCheck].x * Game.TRACK_SCALE), 0, (-(this.aCheckLines[this.carUser.iCurrentCheck].y) * Game.TRACK_SCALE)));
this.scene3D.addObject(this.beacon);
}
private function showSubmitWindow():void{
this.sprSubmitWindow = new SubmitWindow();
this.addChild(this.sprSubmitWindow);
(this.sprSubmitWindow.getChildByName("tfScore") as TextField).text = this.m_iScore.toString();
this.stage.focus = (this.sprSubmitWindow.getChildByName("tfScore") as TextField);
this.sprSubmitWindow.addEventListener(MouseEvent.CLICK, this.onSubmitWindowClick);
this.m_soundManager.playBackSound(Game.SND_MAINMUSIC);
}
private function onStartRaceEnterFrame(_arg1:Event):void{
if (this.iFrameCounter > 1){
this.removeEventListener(Event.ENTER_FRAME, this.onStartRaceEnterFrame);
this.addEventListener(Event.ENTER_FRAME, this.onRaceEnterFrame);
this.mcCountdown = new Countdown();
this.mcCountdown.x = (this.stage.stageWidth / 2);
this.mcCountdown.y = (this.stage.stageHeight / 2);
this.addChild(this.mcCountdown);
this.ftimerCountdownTimer = new FrameTimer(this, 1000, 3);
this.ftimerCountdownTimer.addEventListener(TimerEvent.TIMER, this.onCountdownTimer);
this.ftimerCountdownTimer.addEventListener(TimerEvent.TIMER_COMPLETE, this.onCountdownTimerComplete);
this.ftimerCountdownTimer.start();
this.m_soundManager.playSound(Game.SND_COUNTDOWN);
this.bPause = true;
} else {
this.iFrameCounter++;
};
}
private function onResultsWindowClick(_arg1:MouseEvent):void{
switch (_arg1.target){
case this.mcResultsWindow.getChildByName("btnNext"):
this.removeChild(this.mcResultsWindow);
this.mcResultsWindow = null;
this.m_iLevel++;
this.iState = Game.STATE_RACE;
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
case this.mcResultsWindow.getChildByName("btnExit"):
this.removeChild(this.mcResultsWindow);
this.mcResultsWindow = null;
if (this.iState == Game.STATE_TRAINING){
this.iState = Game.STATE_TRAININGSCREEN;
} else {
if (this.iState == Game.STATE_RACE){
this.showSubmitWindow();
};
};
this.m_soundManager.playSound(Game.SND_BUTTON);
break;
};
}
private function onKeyRelease(_arg1:KeyboardEvent):void{
delete this.oKeysPressed[_arg1.keyCode];
}
}
}//package
Section 49
//GoSound (GoSound)
package {
import flash.media.*;
public dynamic class GoSound extends Sound {
}
}//package
Section 50
//HitSound (HitSound)
package {
import flash.media.*;
public dynamic class HitSound extends Sound {
}
}//package
Section 51
//HowToPlayScreen (HowToPlayScreen)
package {
import flash.display.*;
public dynamic class HowToPlayScreen extends Sprite {
public var btnBack:SimpleButton;
public var mcSoundSwitch:SoundSwitch;
}
}//package
Section 52
//LapMessage (LapMessage)
package {
import flash.display.*;
public dynamic class LapMessage extends MovieClip {
public var mcMessage:MovieClip;
public function LapMessage(){
addFrameScript(7, frame8);
}
function frame8(){
stop();
}
}
}//package
Section 53
//Main (Main)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public class Main extends MovieClip {
public var anim:MovieClip;
public var bt1:SimpleButton;
public var bt3:SimpleButton;
public var bt2:SimpleButton;
public var btbig:SimpleButton;
public var preloader:MovieClip;
public var introComplete:Boolean;
private static const PRELOADER_FRAME:String = "Preloader";
private static const GAME_FRAME:String = "Game";
private static const GAME_CLASS_NAME:String = "Game";
public function Main(){
addFrameScript(0, frame1, 2, frame3, 25, frame26);
introComplete = false;
preloader.btStart.visible = false;
this.bt1.addEventListener(MouseEvent.CLICK, this.fgbut);
this.bt2.addEventListener(MouseEvent.CLICK, this.fgbut);
this.anim.prebut.addEventListener(MouseEvent.CLICK, this.fgbut);
this.bt3.addEventListener(MouseEvent.CLICK, this.fgbut2);
if (this.loaderInfo.bytesLoaded == this.loaderInfo.bytesTotal){
preloader.gotoAndStop(2);
preloader.btStart.visible = true;
preloader.btStart.addEventListener(MouseEvent.CLICK, this.startGame);
trace(preloader.btStart);
} else {
this.gotoAndStop(_slot1.PRELOADER_FRAME);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, this.onLoadProgress);
this.loaderInfo.addEventListener(Event.COMPLETE, this.onLoadComplete);
};
}
private function fgbut2(_arg1:MouseEvent):void{
var _local2:*;
var _local3:URLRequest;
_local2 = "http://www.flashgames247.com/pages/freegames.html";
_local3 = new URLRequest(_local2);
navigateToURL(_local3, "_blank");
}
private function fgbut(_arg1:MouseEvent):void{
var _local2:*;
var _local3:URLRequest;
_local2 = "http://www.flashgames247.com/";
_local3 = new URLRequest(_local2);
navigateToURL(_local3, "_blank");
}
function frame1(){
stop();
}
function frame26(){
trace(("btbig=" + btbig));
this.btbig.addEventListener(MouseEvent.CLICK, this.fgbut);
}
private function isLock(){
var _local1:String;
var _local2:String;
var _local3:Class;
var _local4:Sprite;
_local1 = "flashgames247.com";
_local2 = this.root.loaderInfo.url.split("/")[2];
this.gotoAndStop(_slot1.GAME_FRAME);
_local3 = (this.loaderInfo.applicationDomain.getDefinition(_slot1.GAME_CLASS_NAME) as Class);
_local4 = (new (_local3) as Sprite);
this.addChild(_local4);
}
public function startGame(_arg1:MouseEvent):void{
trace("Start game");
isLock();
}
function frame3(){
stop();
}
private function onLoadProgress(_arg1:ProgressEvent):void{
var _local2:Number;
_local2 = (_arg1.bytesLoaded / _arg1.bytesTotal);
preloader.gotoAndStop(1);
preloader.tfPercents.text = (Math.floor((100 * _local2)) + " %");
}
private function onLoadComplete(_arg1:Event):void{
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, this.onLoadProgress);
this.loaderInfo.removeEventListener(Event.COMPLETE, this.onLoadComplete);
preloader.gotoAndStop(2);
preloader.btStart.visible = true;
preloader.btStart.addEventListener(MouseEvent.CLICK, this.startGame);
trace(preloader.btStart);
}
}
}//package
Section 54
//MainMusic (MainMusic)
package {
import flash.media.*;
public dynamic class MainMusic extends Sound {
}
}//package
Section 55
//MainScreen (MainScreen)
package {
import flash.display.*;
public dynamic class MainScreen extends Sprite {
public var btnTraining:SimpleButton;
public var btnChampionship:SimpleButton;
public var mcSoundSwitch:SoundSwitch;
public var btnHowToPlay:SimpleButton;
}
}//package
Section 56
//MessageSound (MessageSound)
package {
import flash.media.*;
public dynamic class MessageSound extends Sound {
}
}//package
Section 57
//Pause (Pause)
package {
import flash.display.*;
public dynamic class Pause extends SimpleButton {
}
}//package
Section 58
//PauseWindow (PauseWindow)
package {
import flash.display.*;
public dynamic class PauseWindow extends Sprite {
public var btnExit:SimpleButton;
public var btnResume:SimpleButton;
}
}//package
Section 59
//RaceLoadingScreen (RaceLoadingScreen)
package {
import flash.display.*;
public dynamic class RaceLoadingScreen extends Sprite {
}
}//package
Section 60
//RaceMusic (RaceMusic)
package {
import flash.media.*;
public dynamic class RaceMusic extends Sound {
}
}//package
Section 61
//RacePosition (RacePosition)
package {
import flash.display.*;
import flash.text.*;
public dynamic class RacePosition extends MovieClip {
public var tfLap:TextField;
public function RacePosition(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 62
//RaceTimer (RaceTimer)
package {
import flash.display.*;
import flash.text.*;
public dynamic class RaceTimer extends Sprite {
public var tfMinutes:TextField;
public var tfMilliSeconds:TextField;
public var tfSeconds:TextField;
}
}//package
Section 63
//RearViewMask (RearViewMask)
package {
import flash.display.*;
public dynamic class RearViewMask extends Sprite {
}
}//package
Section 64
//RearViewMirror (RearViewMirror)
package {
import flash.display.*;
public dynamic class RearViewMirror extends Sprite {
}
}//package
Section 65
//ResultsWindow (ResultsWindow)
package {
import flash.display.*;
import flash.text.*;
public dynamic class ResultsWindow extends MovieClip {
public var tfSeconds2:TextField;
public var tfSeconds1:TextField;
public var tfMilliSeconds1:TextField;
public var tfSeconds4:TextField;
public var tfMilliSeconds4:TextField;
public var tfMilliSeconds2:TextField;
public var tfMilliSeconds3:TextField;
public var tfSeconds3:TextField;
public var mcResult:MovieClip;
public var btnNext:SimpleButton;
public var btnExit:SimpleButton;
public var mcPositionLine:MovieClip;
public var tfMinutes2:TextField;
public var tfMinutes3:TextField;
public var tfMinutes4:TextField;
public var tfMinutes1:TextField;
}
}//package
Section 66
//SoundSwitch (SoundSwitch)
package {
import flash.display.*;
public dynamic class SoundSwitch extends MovieClip {
public var btnSoundOff:SimpleButton;
public var btnSoundOn:SimpleButton;
public function SoundSwitch(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package
Section 67
//SubmitWindow (SubmitWindow)
package {
import flash.display.*;
import flash.text.*;
public dynamic class SubmitWindow extends Sprite {
public var tfName:TextField;
public var btnNo:SimpleButton;
public var tfScore:TextField;
public var btnYes:SimpleButton;
}
}//package
Section 68
//TiresRed3D (TiresRed3D)
package {
import iriysoft.engine3d.*;
public dynamic class TiresRed3D extends ObjectPseudo3D {
}
}//package
Section 69
//TiresRedPlace (TiresRedPlace)
package {
import flash.display.*;
public dynamic class TiresRedPlace extends Sprite {
}
}//package
Section 70
//TiresWhite3D (TiresWhite3D)
package {
import iriysoft.engine3d.*;
public dynamic class TiresWhite3D extends ObjectPseudo3D {
}
}//package
Section 71
//TiresWhitePlace (TiresWhitePlace)
package {
import flash.display.*;
public dynamic class TiresWhitePlace extends Sprite {
}
}//package
Section 72
//TrackLines1 (TrackLines1)
package {
import flash.display.*;
public dynamic class TrackLines1 extends Sprite {
public var mcCheck1:MovieClip;
public var mcCheck4:MovieClip;
public var mcCheck5:MovieClip;
public var mcCheck2:MovieClip;
public var mcCheck3:MovieClip;
public var mcCheck7:MovieClip;
public var mcCheck8:MovieClip;
public var mcCheck9:MovieClip;
public var mcCheck6:MovieClip;
public var mcCheck10:MovieClip;
public var mcCheck12:MovieClip;
public var mcCheck16:MovieClip;
public var mcCheck18:MovieClip;
public var mcCheck19:MovieClip;
public var mcCheck13:MovieClip;
public var mcCheck15:MovieClip;
public var mcCheck17:MovieClip;
public var mcCheck21:MovieClip;
public var mcCheck22:MovieClip;
public var mcCheck24:MovieClip;
public var mcCheck25:MovieClip;
public var mcCheck26:MovieClip;
public var mcCheck20:MovieClip;
public var mcCheck29:MovieClip;
public var mcCheck23:MovieClip;
public var mcCheck27:MovieClip;
public var mcCheck11:MovieClip;
public var mcCheck14:MovieClip;
public var mcCheck30:MovieClip;
public var mcCheck31:MovieClip;
public var mcCheck28:MovieClip;
}
}//package
Section 73
//TrackLines2 (TrackLines2)
package {
import flash.display.*;
public dynamic class TrackLines2 extends Sprite {
public var mcCheck1:MovieClip;
public var mcCheck4:MovieClip;
public var mcCheck5:MovieClip;
public var mcCheck2:MovieClip;
public var mcCheck3:MovieClip;
public var mcCheck7:MovieClip;
public var mcCheck8:MovieClip;
public var mcCheck9:MovieClip;
public var mcCheck6:MovieClip;
public var mcCheck10:MovieClip;
public var mcCheck12:MovieClip;
public var mcCheck16:MovieClip;
public var mcCheck18:MovieClip;
public var mcCheck19:MovieClip;
public var mcCheck13:MovieClip;
public var mcCheck15:MovieClip;
public var mcCheck11:MovieClip;
public var mcCheck17:MovieClip;
public var mcCheck21:MovieClip;
public var mcCheck22:MovieClip;
public var mcCheck24:MovieClip;
public var mcCheck25:MovieClip;
public var mcCheck26:MovieClip;
public var mcCheck20:MovieClip;
public var mcCheck23:MovieClip;
public var mcCheck27:MovieClip;
public var mcCheck14:MovieClip;
}
}//package
Section 74
//TrackLines3 (TrackLines3)
package {
import flash.display.*;
public dynamic class TrackLines3 extends Sprite {
public var mcCheck1:MovieClip;
public var mcCheck4:MovieClip;
public var mcCheck5:MovieClip;
public var mcCheck2:MovieClip;
public var mcCheck3:MovieClip;
public var mcCheck7:MovieClip;
public var mcCheck8:MovieClip;
public var mcCheck9:MovieClip;
public var mcCheck6:MovieClip;
public var mcCheck10:MovieClip;
public var mcCheck12:MovieClip;
public var mcCheck16:MovieClip;
public var mcCheck18:MovieClip;
public var mcCheck19:MovieClip;
public var mcCheck13:MovieClip;
public var mcCheck15:MovieClip;
public var mcCheck17:MovieClip;
public var mcCheck21:MovieClip;
public var mcCheck22:MovieClip;
public var mcCheck24:MovieClip;
public var mcCheck25:MovieClip;
public var mcCheck26:MovieClip;
public var mcCheck20:MovieClip;
public var mcCheck29:MovieClip;
public var mcCheck23:MovieClip;
public var mcCheck27:MovieClip;
public var mcCheck11:MovieClip;
public var mcCheck14:MovieClip;
public var mcCheck30:MovieClip;
public var mcCheck28:MovieClip;
}
}//package
Section 75
//TrackLines4 (TrackLines4)
package {
import flash.display.*;
public dynamic class TrackLines4 extends Sprite {
public var mcCheck1:MovieClip;
public var mcCheck4:MovieClip;
public var mcCheck5:MovieClip;
public var mcCheck2:MovieClip;
public var mcCheck3:MovieClip;
public var mcCheck7:MovieClip;
public var mcCheck8:MovieClip;
public var mcCheck9:MovieClip;
public var mcCheck6:MovieClip;
public var mcCheck10:MovieClip;
public var mcCheck12:MovieClip;
public var mcCheck16:MovieClip;
public var mcCheck18:MovieClip;
public var mcCheck19:MovieClip;
public var mcCheck13:MovieClip;
public var mcCheck15:MovieClip;
public var mcCheck17:MovieClip;
public var mcCheck21:MovieClip;
public var mcCheck22:MovieClip;
public var mcCheck24:MovieClip;
public var mcCheck25:MovieClip;
public var mcCheck26:MovieClip;
public var mcCheck20:MovieClip;
public var mcCheck29:MovieClip;
public var mcCheck23:MovieClip;
public var mcCheck27:MovieClip;
public var mcCheck11:MovieClip;
public var mcCheck14:MovieClip;
public var mcCheck30:MovieClip;
public var mcCheck28:MovieClip;
}
}//package
Section 76
//TrackLines5 (TrackLines5)
package {
import flash.display.*;
public dynamic class TrackLines5 extends Sprite {
public var mcCheck11:MovieClip;
public var mcCheck34:MovieClip;
public var mcCheck1:MovieClip;
public var mcCheck4:MovieClip;
public var mcCheck5:MovieClip;
public var mcCheck2:MovieClip;
public var mcCheck3:MovieClip;
public var mcCheck7:MovieClip;
public var mcCheck8:MovieClip;
public var mcCheck9:MovieClip;
public var mcCheck6:MovieClip;
public var mcCheck10:MovieClip;
public var mcCheck12:MovieClip;
public var mcCheck16:MovieClip;
public var mcCheck18:MovieClip;
public var mcCheck19:MovieClip;
public var mcCheck13:MovieClip;
public var mcCheck15:MovieClip;
public var mcCheck17:MovieClip;
public var mcCheck21:MovieClip;
public var mcCheck22:MovieClip;
public var mcCheck24:MovieClip;
public var mcCheck25:MovieClip;
public var mcCheck26:MovieClip;
public var mcCheck20:MovieClip;
public var mcCheck29:MovieClip;
public var mcCheck23:MovieClip;
public var mcCheck27:MovieClip;
public var mcCheck14:MovieClip;
public var mcCheck30:MovieClip;
public var mcCheck32:MovieClip;
public var mcCheck31:MovieClip;
public var mcCheck33:MovieClip;
public var mcCheck28:MovieClip;
}
}//package
Section 77
//TrackObjects1 (TrackObjects1)
package {
import flash.display.*;
public dynamic class TrackObjects1 extends Sprite {
}
}//package
Section 78
//TrackObjects2 (TrackObjects2)
package {
import flash.display.*;
public dynamic class TrackObjects2 extends Sprite {
}
}//package
Section 79
//TrackObjects3 (TrackObjects3)
package {
import flash.display.*;
public dynamic class TrackObjects3 extends Sprite {
}
}//package
Section 80
//TrackObjects4 (TrackObjects4)
package {
import flash.display.*;
public dynamic class TrackObjects4 extends Sprite {
}
}//package
Section 81
//TrackObjects5 (TrackObjects5)
package {
import flash.display.*;
public dynamic class TrackObjects5 extends Sprite {
}
}//package
Section 82
//TrackRoad1 (TrackRoad1)
package {
import flash.display.*;
public dynamic class TrackRoad1 extends Sprite {
}
}//package
Section 83
//TrackRoad2 (TrackRoad2)
package {
import flash.display.*;
public dynamic class TrackRoad2 extends Sprite {
}
}//package
Section 84
//TrackRoad3 (TrackRoad3)
package {
import flash.display.*;
public dynamic class TrackRoad3 extends Sprite {
}
}//package
Section 85
//TrackRoad4 (TrackRoad4)
package {
import flash.display.*;
public dynamic class TrackRoad4 extends Sprite {
}
}//package
Section 86
//TrackRoad5 (TrackRoad5)
package {
import flash.display.*;
public dynamic class TrackRoad5 extends Sprite {
}
}//package
Section 87
//TrackScheme (TrackScheme)
package {
import flash.display.*;
import flash.text.*;
public dynamic class TrackScheme extends Sprite {
public var tfLevel:TextField;
}
}//package
Section 88
//TrackStarts1 (TrackStarts1)
package {
import flash.display.*;
public dynamic class TrackStarts1 extends Sprite {
public var mcStart0:MovieClip;
public var mcStart1:MovieClip;
public var mcStart3:MovieClip;
public var mcStart2:MovieClip;
}
}//package
Section 89
//TrackStarts2 (TrackStarts2)
package {
import flash.display.*;
public dynamic class TrackStarts2 extends Sprite {
public var mcStart0:MovieClip;
public var mcStart1:MovieClip;
public var mcStart3:MovieClip;
public var mcStart2:MovieClip;
}
}//package
Section 90
//TrackStarts3 (TrackStarts3)
package {
import flash.display.*;
public dynamic class TrackStarts3 extends Sprite {
public var mcStart0:MovieClip;
public var mcStart1:MovieClip;
public var mcStart3:MovieClip;
public var mcStart2:MovieClip;
}
}//package
Section 91
//TrackStarts4 (TrackStarts4)
package {
import flash.display.*;
public dynamic class TrackStarts4 extends Sprite {
public var mcStart0:MovieClip;
public var mcStart1:MovieClip;
public var mcStart3:MovieClip;
public var mcStart2:MovieClip;
}
}//package
Section 92
//TrackStarts5 (TrackStarts5)
package {
import flash.display.*;
public dynamic class TrackStarts5 extends Sprite {
public var mcStart0:MovieClip;
public var mcStart1:MovieClip;
public var mcStart3:MovieClip;
public var mcStart2:MovieClip;
}
}//package
Section 93
//TrackTexture1 (TrackTexture1)
package {
import flash.display.*;
public dynamic class TrackTexture1 extends Sprite {
}
}//package
Section 94
//TrackTexture2 (TrackTexture2)
package {
import flash.display.*;
public dynamic class TrackTexture2 extends Sprite {
}
}//package
Section 95
//TrackTexture3 (TrackTexture3)
package {
import flash.display.*;
public dynamic class TrackTexture3 extends Sprite {
}
}//package
Section 96
//TrackTexture4 (TrackTexture4)
package {
import flash.display.*;
public dynamic class TrackTexture4 extends Sprite {
}
}//package
Section 97
//TrackTexture5 (TrackTexture5)
package {
import flash.display.*;
public dynamic class TrackTexture5 extends Sprite {
}
}//package
Section 98
//TrainingScreen (TrainingScreen)
package {
import flash.display.*;
public dynamic class TrainingScreen extends Sprite {
public var btnBack:SimpleButton;
public var btnLevel1:SimpleButton;
public var btnLevel4:SimpleButton;
public var btnLevel5:SimpleButton;
public var btnLevel2:SimpleButton;
public var btnLevel3:SimpleButton;
public var mcSoundSwitch:SoundSwitch;
}
}//package
Section 99
//Tree3D (Tree3D)
package {
import iriysoft.engine3d.*;
public dynamic class Tree3D extends ObjectPseudo3D {
}
}//package
Section 100
//TreePlace (TreePlace)
package {
import flash.display.*;
public dynamic class TreePlace extends Sprite {
}
}//package