0 Replies Latest reply on Aug 30, 2011 5:27 AM by gopi k

    Game object error

    gopi k

      hi

       

              Am new  to flash builder creating a game  using Action script here is my program

       

       

       

      <?xml version="1.0" encoding="UTF-8"?>

      <mx:Application click="{click(event);}"

      creationComplete="{creationComplete();}"

      enterFrame="{enterFrame(event);}"

      height="384"

      layout="absolute"

      mouseDown="{mouseDown(event);}"

      mouseMove="{mouseMove(event);}"

      mouseUp="{mouseUp(event);}"

      width="480"

      xmlns:mx="http://www.adobe.com/2006/mxml">

      <mx:Script><![CDATA[

              import flash.events.*;

              import flash.ui.*;

              import flash.utils.*;

              import mx.events.*;

              import mx.binding.*;

              import mx.containers.*;

              import mx.controls.*;

              import mx.core.*;

              import mx.events.*;

              import mx.states.*;

              import mx.styles.*

       

              protected var  inGame:Boolean = false;

       

       

              public function _main_State1_c() : State

              {

                  var _loc_1:* = new State();

                  _loc_1.name = "Game";

                  _loc_1.addEventListener("enterState", ___main_State1_enterState);

                  _loc_1.addEventListener("exitState", ___main_State1_exitState);

                  return _loc_1;

              }// end function

       

              public function _main_State2_c() : State

              {

                  var _loc_1:* = new State();

                  _loc_1.name = "MainMenu";

                  _loc_1.overrides = [_main_AddChild1_i()];

                  return _loc_1;

              }// end function

       

              public function click(event:MouseEvent) : void

              {

                  GameObjectManager.Instance.click(event);

                  return;

              }// end function

       

              public function ___main_State1_enterState(event:FlexEvent) : void

              {

                  enterGame(event);

                  return;

              }// end function

       

              public function startGameClicked(event:Event) : void

              {

                  currentState = "Game";

                  return;

              }// end function

       

              public function ___main_State1_exitState(event:FlexEvent) : void

              {

                  exitGame(event);

                  return;

              }// end function

       

              public function mouseMove(event:MouseEvent) : void

              {

                  GameObjectManager.Instance.mouseMove(event);

                  return;

              }// end function

       

              public function mouseUp(event:MouseEvent) : void

              {

                  GameObjectManager.Instance.mouseUp(event);

                  return;

              }// end function

       

              public function _main_Button1_i() : Button

              {

                  var _loc_1:* = new Button();

                  btnStart = _loc_1;

                  _loc_1.x = 380;

                  _loc_1.y = 344;

                  _loc_1.label = "Start";

                  _loc_1.width = 90;

                  _loc_1.height = 30;

                  _loc_1.addEventListener("click", __btnStart_click);

                  _loc_1.id = "btnStart";

                  if (!_loc_1.document)

                  {

                      _loc_1.document = this;

                  }

                  return _loc_1;

              }// end function

       

              public function mouseDown(event:MouseEvent) : void

              {

                  GameObjectManager.Instance.mouseDown(event);

                  return;

              }// end function

       

              public function enterGame(event:Event) : void

              {

                  Mouse.hide();

                  GameObjectManager.Instance.startup();

                  Level.Instance.startup();

                  inGame = true;

                  return;

              }// end function

       

              public function exitGame(event:Event) : void

              {

                  Mouse.show();

                  Level.Instance.shutdown();

                  GameObjectManager.Instance.shutdown();

                  inGame = false;

                  return;

              }// end function

       

              public function __btnStart_click(event:MouseEvent) : void

              {

                  startGameClicked(event);

                  return;

              }// end function

       

              public function enterFrame(event:Event) : void

              {

                  if (inGame)

                  {

                      GameObjectManager.Instance.enterFrame();

                      myCanvas.graphics.clear();

                      myCanvas.graphics.beginBitmapFill(GameObjectManager.Instance.backBuffer, null, false, false);

                      myCanvas.graphics.drawRect(0, 0, this.width, this.height);

                      myCanvas.graphics.endFill();

                  }

                  return;

              }// end function

       

              public function creationComplete() : void

              {

                  GameObjectManager.Instance.addCollidingPair(CollisionIdentifiers.PLAYER, CollisionIdentifiers.ENEMY);

                  GameObjectManager.Instance.addCollidingPair(CollisionIdentifiers.ENEMY, CollisionIdentifiers.PLAYERWEAPON);

                  GameObjectManager.Instance.addCollidingPair(CollisionIdentifiers.PLAYER, CollisionIdentifiers.ENEMYWEAPON);

                  return;

              }// end function

       

              public function _main_AddChild1_i() : AddChild

              {

                  var _loc_1:* = new AddChild();

                  _main_AddChild1 = _loc_1;

                  _loc_1.position = "lastChild";

                  _loc_1.targetFactory = new DeferredInstanceFromFunction(_main_Button1_i);

                  BindingManager.executeBindings(this, "_main_AddChild1", _main_AddChild1);

                  return _loc_1;

              }// end function

          ]]></mx:Script>

       

      <mx:Canvas height="100%" id="myCanvas" width="100%" x="0" y="0"/>

       

      </mx:Application>

       

       

       

       

       

       

      from Above program denotes the error in game object funtion.plz check it and correct eror