Zania week 4: Asyncs

I have changed this to weekly updates since daily updates are insignificant and updates are spaced out and scheduled so real progresses are actually faster.


  • I sometimes feel stupid for wasting time. The reason why external xml loads are async is so that it doesn’t block the game from loading when it times out or fails to load. Changed the loading scheme to wait until the completion of all data loading. It is quite a difficult and perverted thing to do in Flash. I guess the language isn’t designed for parallelism.
  • There is a need to determine where the player’s position is loaded. It can either be done at Player class in the load function when the xml is copied or in the actor class when the Create function is called.
  • The constructor now looks like this:
    • case 2:
      m_player = new Player(this);
      m_player.addEventListener(“onPlayerLoad”, playerHandler);
  • The event handlers look like this:
    • function playerHandler(event:Event){
      m_player.removeEventListener(“onPlayerLoad”, playerHandler);
      m_ship = new Ship(this);
      m_ship.LoadShip(m_player.m_ship, m_player.m_x, m_player.m_y);
      m_ship.addEventListener(“onPlayerShipLoad”, playerShipHandler);
      function playerShipHandler(event:Event){
      m_ship.removeEventListener(“onPlayerShipLoad”, playerShipHandler);
      bd.position.x = m_player.m_x;
      bd.position.y = m_player.m_y;
      m_body = Zania.m_currSolarSystem.m_world.CreateBody(bd);
      m_body.m_actor = this;
  • While a dispatch event is added to each type of actor
    • dispatchEvent(new Event(“onPlayerLoad”));

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>