Comments
Patrick Collands wrote: collands (AT) gmail com I'd be very grateful for an invitation. Thank you.
Cloud Computing
Conference & Expo
November 2-4, 2009 NYC
Register Today and SAVE !..

SYS-CON.TV
Today's Top SOA Links


Integrating Remote Shared Objects with Flex and Flash Communication Server
In this project, a remote shared object on a Flash Communication Server contains data that changes frequently

Example 2: flexFCS_02.mxml (additions are highlighted) <?xml version="1.0"
encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns="*" creationComplete="initializeApplication( event )">

<mx:Script>
<![CDATA[
var myData:Array;
function initializeApplication( event )
{
//We are called by the creation complete event of the application tag
//Instantiate a new Array
myData = new Array();

//Connect to the flash communication server.
//we are using rtmp as our first protocol attempt
my_fcs.connect(Œrtmp://[your_server]/random');
}

]]>

</mx:Script>

<mx:DataGrid id="display_grid" dataProvider="{myData}" width="90%" height="90%"/>

<!--Created a DataGrid and bound the dataProvider to myData-->
<!--Instantiate an FCSService component-->
<FCSService id="my_fcs"
closed=" alert( Œserver closed connection' )"
rejected=" alert(ŒServer rejected connection')"
failed=" alert(ŒServer connection failed')" />

<!--Instantiate an SharedRemote component and bind it to the FCSService tag
above-->

<!--The name property of this tag must match the argument in the SharedObject.get
command on the server file main.asc-->

<SharedRemote id="my_remote1"
name="RandomNumbers"
service="{my_fcs}"
failed="alert(ŒShared Object Failed')"
status="alert(ŒStatus Œ + event.info.level + Œ Œ + event.info.code );"/>
</mx:Application>

In this version, I added three important blocks of code:

  • An FCSService component
  • A SharedRemote component
  • A call to the FCSService object's connect method
First, examine the FCSService component. The FCSService has an id of my_fcs, which you use to reference the instance going forward. You also defined event handlers for the closed, rejected, and failed events. If an end user encounters any type of problem, an alert box will display.

Second, the SharedRemote component has an id of my_remote1. The service property is set to {my_fcs}, the id of the FCSService component. This allows any FCSService component to have multiple shared remote objects defined. The SharedRemote component also defines event handlers for the failed and status messages. If an end user encounters a problem with the shared object, an alert box displays on the screen.

Finally, the initializeApplication handler calls my_fcs.connect(Œrtmp://yourServerName/random' ). The name, random, is the name of the application created when you placed the main.asc file into the random folder on your FCS.

When you invoke the connect method, you attempt to make a connection initially through RTMP to FCS. In reality, you actually have several protocols/port combinations which will be tried before a connection occurs. While this concept is outside the scope of this article, please read "Tunneling Macromedia Flash Communications Through Firewalls and Proxy Servers" for more information.

If you run the application at this point, you will see a DataGrid, much like the previous example.

If an alert box appears, ensure that your Flash Communication Server is running and that you placed the main.asc file in the proper directory as explained in the "Flash Communication Server" section.

The Good Stuff
After the last round of revisions, your application can receive updates from the server, but can't do anything with them yet. Now you'll add that functionality.

Add the highlighted code below to Example 2 (flexFCS_02.mxml) or, open the solution file, flexFCS_03.mxml, which contains all of the changes. The flexFCS_03.mxml file is included in the fcs_flex_sample.zip that you downloaded in the Requirements section of this article.

About Michael Labriola
Michael Labriola is a founding partner and senior consultant at Digital Primates IT Consulting Group. Digital Primates analyzes client business processes and develops custom solutions that extend the latest technology.

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

Register | Sign-in

Reader Feedback: Page 1 of 1

Communication Server (FCS) together provide an amazing toolbox that will undoubtedly provide inspiration to thousands of developers and projects. Unfortunately, without concrete examples and guidelines for good practices on their integration, we spent many hours on tiny issues that, with additional information, could have been easily circumnavigated.


Your Feedback
SYS-CON Italy News Desk wrote: Communication Server (FCS) together provide an amazing toolbox that will undoubtedly provide inspiration to thousands of developers and projects. Unfortunately, without concrete examples and guidelines for good practices on their integration, we spent many hours on tiny issues that, with additional information, could have been easily circumnavigated.
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