Welcome!

Adobe Flex Authors: Liz McMillan, RealWire News Distribution, Maureen O'Gara, Yakov Fain, Keith Swenson

Related Topics: Adobe Flex

Adobe Flex: Article

How Flash Communication Server is Helping the Multiplayer Game Industry

A Model for Dealing with the Flash Communication Server in Director

In Director we create a global variable named "isMouseDown". Assign a behavior to the ball sprite and use this variable to determine if user clicks on the ball sprite (isMouseDown = true) or not (isMouseDown = False).

We use the "rect" property of the ball sprite to test its location and the stage boundaries. "rect" is an array that has 4 elements: the left, top, right and bottom coordinates of the sprite.

In Director:


on exitFrame
if sprite("Ball").rect[1] <= 0 then
sprite("Ball").LocH =
sprite("Ball").LocH + 50
end if
if sprite("Ball").rect[2] <= 0 then
sprite("Ball").LocV =
sprite("Ball").LocV + 50
end if
if sprite("Ball").rect[3] >=
640 then
sprite("Ball").LocH =
sprite("Ball").LocH - 50
end if
if sprite("Ball").rect[4] >=
480 then
sprite("Ball").LocV =
sprite("Ball").LocV - 50
end if
if isMouseDown then
ball_so.data.x = sprite("Ball").LocH
ball_so.data.y = sprite("Ball").LocV
end if
go to the frame
end

The complete listing of this sample is shown in Listings 3 to 5.

Now, you can publish the project and run two instance of it. Drag the ball sprite and see the effect in other running instance.

What's Next?
You've just experienced some of the basic concepts of using FlashCom in Director. But all of those samples are client-side only. When you learn how to use server-side scripting with Director to receive from and send messages to it, the power of your multi-user applications will increase greatly.

For example, with server-side scripting you can manage users and verify them to accept or reject their connection request, and so on. Using authentication, you could give different users different roles in the system, assigning some users more power in the system than others. For example, think of our chat system extended to include a teacher and several students. The teacher would have the ability to correct false information and push additional material that the students might not have. In a more game-like environment, a "Game Master" might have the ability to control the positions of objects that the individual players do not have the right to move. By exploring the capabilities of the Flash Communication Server, and its use in Director, several of these types of applications can be built using the shared object model.

More Stories By Nima Azimi

Nima Azimi is a software engineer, multimedia project manager,
consultant and programmer on variety projects. His projects include
educational "How does it works" titles for children education with
real-time 3D content. He has worked with Director for over four years,
and he currently teaches courses in Director programming and multimedia.
In his spare time he makes highly detailed photorealistic 3D scenes as a
3D artist and writes video game scripts and gameplay ideas that he
wishes to develop into full games at within the near future.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Rob Sandie 11/01/05 03:03:15 PM EST

Just a note: with the new release this month it will not be FlashComm or Flash Communication Server. The beta has it anounced as Flash Media Server 2.

gamer4all 11/01/05 10:00:35 AM EST

|| Using authentication, you could give different users different roles in the system, assigning some users more power in the system than others ||

I've tried this. It works real well.