2 Replies Latest reply on Mar 26, 2007 12:42 PM by lowroller

    How Can I Simultaneously Play An SWF File On Mutiple Clients

    lowroller Level 1
      Hi,

      I am developing a gaming application which needs to play an swf file simultaneously on all clients so all players can view the same game action. When I play the file on a single client, the file plays as intended. If, however, I attempt to play the file on multiple clients, the file plays on the first client ONLY, even if I start the file from a different client.

      I have included some of my code for review. Thanks!


      public function send():void {
      die1Value = Math.round(Math.random()*(6-1))+1;
      die2Value = Math.round(Math.random()*(6-1))+1;

      rollDice();
      var message:AsyncMessage = new AsyncMessage();
      message.body = {
      die1Value: die1Value,
      die2Value: die2Value
      };

      producer.send(message);
      }

      public function messageHandler(event:MessageEvent):void {
      var body:Object = event.message.body;
      die1Value = body.die1Value;
      die2Value = body.die2Value;
      rollDice();
      }

      private function rollDice():void {
      var lc:LocalConnection = new LocalConnection();
      var connectionName:String = loggedInUser.name;

      lc.client = this;
      lc.connect(connectionName);
      lc.send("swf8connector", "rollDice", die1Value, die2Value);
      lc.close();
      }


      <mx:Producer id="producer" destination="game_board"/>
      <mx:Consumer id="consumer" destination="game_board" message="messageHandler(event)"/>

      <mx:SWFLoader x="10" y="10" scaleContent="true" autoLoad="true" source=" http://localhost:8700/flex/GameCode/components/board/game.swf"/>