Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How Can I Simultaneously Play An SWF File On Mutiple Clients

Avatar

Level 2
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"/>
2 Replies

Avatar

Level 2
Hi lowroller,



I remember I used LocalConnection before. It seemed
LocalConnection is an one to one connection -- onle one client can
be connected at the same time. Why not create your swf8 client into
a Flex component so that you can use message service to play
mutiple clients simultaneously?



Jeffrey

Avatar

Level 2
Hi Jeffrey,



Thank you for your response.



Since I posted, I have realized that my code works as
expected if I use multiple machines. It is only when I open several
instances of IE on my development machine that I have problems. I
assumed that each instance of IE on my development machine would
act as an individual client, but apparently that isn't the case.