Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
How Flash Communication Server is Helping the Multiplayer Game Industry
A Model for Dealing with the Flash Communication Server in Director

We live in a communications world. The number of software solutions that can provide communication between users grows every day. In the future it's likely that applications unable to provide this ability will be known as "traditional applications," shunned because of their lack of openness and communication ability. A simple example of this can be seen in the game industry. Gamers are addicted to multiplayer games with others and to the pleasure that such games bring because of the interactions in the player-base: without the option of multiplayer mode, Director-based games will be in the minority.

Fortunately, Macromedia has not left developers alone in this pioneer technology and has provided the Flash Communication Server (the heir of Multi-User-Server in my view). Macromedia wants FlashCom to supersede MUS. So, although the MUS is powerful enough to create amazing applications with Director such as we see on the web today, following the MX version of Director, Macromedia suggests using FlashCom Server instead. FlashCom is known as a revolution in Macromedia history and this is mainly because of its integration across several products. FlashCom is so "open" that a running joke on a few of the forums I see has Macromedia changing its name to the "Macromedia Communication Server." What follows is an example of combining Director and the FlashCom Server to provide a backbone for multi-user applications, in a more modern way than traditional MUS applications.

What Is FlashCom?
Flash Communication Server is a server technology that provides the connections between Flash 6+ players. The Flash Communication Server is a hub. Users connect to the hub using Macromedia's communication protocol called Real-Time Messaging Protocol (RTMP). FlashCom makes it possible to communicate with other users through Flash files (and, with some conversions, in Director files) in web pages or standalone applications. It does this with several types of communication streams, such as sending video, audio, and text between users in real time. End users experience these applications as video-audio conferences, chat rooms, and so on.

In addition to these types, FlashCom has a "remote shared object" that is the heart of its flexibility. It lets us make an object like a 2D sprite or 3D object exist in a way that is shared between users so that they can manipulate its properties - such as position, rotation, and so on in real time together. You can think of it as 3D ball in a football game that users can pass it to each other.

Flash Object in Director
Director has supported Flash objects for a number of years, with each ve rsion of Director supporting the latest available version of Flash. With this ability we can work with FlashCom in Director as a Flash object. We can manipulate and work with the Flash object in several ways. We can get or set all variables and objects in Flash files and access all properties of those variables and objects. If you have used FlashCom in Flash before, you're familiar with the "Developing Communication Applications" document provided by Macromedia (www.macromedia.com/support/flashcom/documentation.html). In that document there are six sample projects that illustrate the basic capabilities of FlashCom very smoothly. I think the best solution is to learn how to use FlashCom in Director would be to re-code those samples in Director one by one. Thanks to John Taylor and Jay Armstrong for their articles in Macromedia Developer Center, we have the torch to light the dark road of starting this kind of implementation.

But there are several situations in which the best way to implement these types of applications in Director is not immediately apparent. By starting with simpler, more contained, projects and gradually growing into more advanced applications, one can learn FlashCom more efficiently.

For this article, I have chosen two samples from the initial FlashCom documents that I think have good features and could be as a guideline for other projects, one on sharing text between users, and one on sharing a sprite object. FlashCom applications generally have a client side-script written in a .fla file (which we will either replace or encapsulate inside the .dir) and may have server-side script written in an external file in the ActionScript language with the same name as application name, or "main" with a ".acs" extension. In this article I focus on samples that don't need any server-side scripting, but if you see these files in other examples, that is likely their intended use.

Sample One - (Shared Text)
The first sample I present is a "Shared Text" project. The goal of this project is to have a textbox shared between any users that visit our Shockwave page. They could write any message to any other user. While a user is typing, other users can see the characters typed one by one.

The first step is to create the Flash object. We can do this dynamically with Lingo or by importing a Flash file into the cast window. I use this later in the sample. Since you don't want to use any built-in Flash embedded video or pre-provided FlashCom components in your project, you don't need to do anything in your Flash movie. You need only to create an empty 10 by 10 pixels Flash file and publish it to ".swf". When you import this .swf file to Director and drag it to the stage, you have all you need to work with FlashCom. Keep in mind that Shockwave file must contain the swf in its stage boundaries. You can drag it to the left down corner of the stage and set the ink property to "Background Transparent." When you publish your project, save your ".dcr" and ".htm" files to a directory named "myProjectDirectory" (or anything else you want) in your FlashCom applications directory (for example C:\inetpub\wwwroot\flashcom\applications\).

TIP: try to write all your FlashCom scripts and functions in one "behavior script" and assign it to your flash sprite; then call those functions from other sprite or frame "behavior scripts" if needed. try to write all your FlashCom scripts and functions in one "behavior script" and assign it to your flash sprite; then call those functions from other sprite or frame "behavior scripts" if needed.

Step #1:
To provide any FlashCom capability to your applications you need to establish a connection to "Flash Communication Server". Do this by creating a new NetConnection object.

If we were programming in Flash we would use the line:


client_nc = new NetConnection();

In Director, we first assign a variable to our flash sprite and then use this variable to create flash objects and manipulate them, like this:


pSprie = sprite("myFlashSprieName")
pNetConn = pSprite.newObject
("NetConnection")

Step #2:
Any NetConnection object has an "onStatus" event raised when a connection is established. We use this event to test our connection status. It has a parameter defined according to the status message. The message is stored in the code property of this parameter. In some situations we can use it as a guide to alert the user if the connection was a success, closed, failed, rejected, etc. In Flash, this is implemented through a "function literal" or "anonymous function" method but we can't do it in Director.

In Flash:


client_nc.onStatus = function(info) {
trace ("Level: " + info.level +
"Code: " + info.code);
if (info.code = "NetConnection.
Connect.Success") {
// Continue
}else if (info.code = "NetConnection.
Connect.Closed") {
{
// Alert Message
}
};

We must implement this code in Director with the help of the setCallBack command. setCallBack is a Flash command that can be used as a sprite or a global method to define a Lingo callback handler for a particular event generated by the specified object. When ActionScript triggers the event in the object, that event is redirected to the given Lingo handler, including all arguments that are passed with the event.

In Director:


pSprite.setCallBack(pNetConn,
"onStatus", #myOnStatus, me)
on myOnStatus (me, this, aInfo)
put "Level: " && aInfo.level &&
"Code:" && aInfo.code
if (aInfo.code = "NetConnection.
Connect.Success") then]
-- Continue
else
-- Alert Message
end if
end

The parameters of setCallBack are an Actionscript object (NetConnection), the Actionscript event that occures (onStatus), the Lingo handler that handles the Actionscript event (myOnStatus) and the Lingo object that contains the corresponding handler (me). Thus any time NetConnection tries to connect, onStatus handler is triggered and myOnStatus handler triggers with all onStatus arguments in Director. Keep in mind that third argument of myOnStatus handler (aInfo) is according to the "info" parameter.

About 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.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

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.

|| 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.


Your Feedback
Rob Sandie wrote: 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 wrote: || 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.
Latest Cloud Developer Stories
Can you bring services from the cloud to your customers faster and have them adopt it with ease of use or bring the power of bundled services to the fingertips of your clients without creating new rigid ‘apps stove pipes'? Do you want to prevent your business running away to publ...
OCZ Technology Group, a provider of high-performance solid-state drives (SSDs) for computing devices and systems, on Tuesday announced the Z-Drive R4 CloudServ PCI Express (PCIe) flash storage solution, designed to accelerate cloud computing applications and reduce operating expe...
Many organizations have embraced, or are considering, the benefits of cloud computing – speed, flexibility, increased expertise, shared workload, reduced costs, etc. The benefits are many – but so are the risks. What are the threats to cloud security? Which parties assume respons...
In August 2011, SHI Enterprise Solutions (ESS) division launched the SHI Cloud, offering reliable and cost-effective industrial-grade cloud computing platforms. That same division achieved an 82 percent increase in revenue over 2010.
SoftLayer Technologies on Tuesday announced the immediate worldwide availability of SoftLayer Object Storage, a redundant and highly scalable cloud storage service that allows users to easily store, search and retrieve data across the Internet, with optional CDN connectivity, or ...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers
ADS BY GOOGLE