AIR 2 and Flash Player 10.1 Betas now Available

Tonight we’ve released the AIR 2 and Flash Player 10.1 betas on Adobe Labs (direct download links for Flash Player and AIR). This is the first time we’ve simultaneously released the desktop (AIR) and browser (Flash Player) runtimes for all three platforms (Mac, Windows, Linux) at once, which is a great milestone for the Flash Platform. So what is this release and why should you care? One thing to note is that this is just the desktop runtimes, not any mobile runtimes. Those will be coming later. Luckily a lot of the work we did for mobile in terms of adding new APIs and optimizations are all in these releases so you’ll still get a lot of the benefits.

Flash Player 10.1

Lots of new stuff in Flash Player 10.1 including the multi-touch APIs, the performance gains, and some new networking APIs. The biggest thing (IMHO) with this release is the huge, huge memory improvements. Kevin showed the slide at MAX but it’s worth mentioning again. Without any code changes you’ll see significant improvements in memory with Flash Player 10.1.

flash_player_mem_footprint

AIR 2

air_logo_cloudsThe AIR team has been kicking all kinds of ass and I think AIR 2 is going to be a great release. One of the things we heard over and over again after AIR 1.0 was that people wanted more access to the native APIs of the operating system. AIR 2 brings a lot of that. Now you can open up a file with its default application as well as invoke native commands with the new NativeProcess API. We’ve also added the ability to create a socket server inside an AIR application and monitor changes to mounted drives. Plus a lot more. And you get all of the performance enhancements (and more) from Flash Player 10.1 so it should be a lean, mean AIR experience for end users as well.

Developing with the new Runtimes

(Update Christian has a list of AIR 2 resources that will help.) We won’t have a new Flex SDK for these runtimes yet so it’ll take a tiny bit of manual work to add support for the developer tools and the new runtime. Nick Kwiatkowski has a great screencast up for using the AIR 2 SDK in Flash Builder. It basically involves creating a copy of the Flex 4 SDK and then manually copying over the AIR SDK so it overwrites the AIR 1.5 SDK that ships with Flex 4. On the Flash Player side you’ll have to grab the playerglobal.swc and replace it in your Flex SDK.

I’m pretty excited about this particular set of runtimes. Talking to developers it seems like AIR 2 hits the mark and helps them accomplish more. Seeing the foundation put in on Flash Player 10.1 to create really great mobile experiences is also exciting. As always make sure to provide any feedback or any issues you run into over on the forums.

Adobe and RIM Collaborating on Tool Support for BlackBerry Devices

At the developer conference in San Francisco today, RIM and Adobe announced a collaboration around creating content for BlackBerry devices and Adobe’s Creative Suite tools. This builds off of the momentum we started with RIM when they announced they were joining the Open Screen Project and dedicated to bringing Flash Player to BlackBerry. There are some good links on Techmeme that cover the announcement pretty well.

rim_adobe_announcement

Creating Content with Adobe Tools

Adobe is known for first class design and development tools and today’s announcement means that you’ll be able to use those tools to target RIM’s devices. There are going to be multiple points of integration. One of the critical pieces of creating mobile content is to make sure it is optimized for the smaller screens and often less bandwidth. In Creative Suite 5 we’re going to support optimized graphic and video content from Adobe Photoshop, Adobe After Effects, and Adobe Illustrator. We’re also supporting a seamless workflow between those design tools and BlackBerry’s developer tools including the BlackBerry Web Plug-in for Eclipse and the BlackBerry Java Plug-in for Eclipse.

More interestingly for developers, we’re going to be working closely with RIM to enable full support for BlackBerry devices in Creative Suite Design Central, Dreamweaver, and Fireworks. You’ll be able to use those three tools to test and create content for BlackBerry’s mobile browser as well as to create widgets directly on the BlackBerry device. Device Central is a fantastic way to test both HTML and Flash content for specific mobile devices. It lets you tweak battery settings, screen sizes, and other phone-specific functionality. Now we’ll have support for most of the BlackBerry phones so you never have to leave Creative Suite to see exactly how something will look on the phone.

Lastly, on the application front, Adobe is to be working on applications for BlackBerry that will let users take rich media and image content from the phone and quickly and easily bring it into tools like Photoshop Elements and Photoshop.com so it can be edited and modified.

BlackBerry Momentum

My colleague Mark Doherty has some great stats on what the BlackBerry market looks like and what this collaboration will mean for people who want to use their existing skills with Adobe’s tools to create mobile content for BlackBerry. Seeing the level of cooperation between Adobe and RIM is an exciting thing for designers and developers. Unlike some companies, I think RIM sees the value in partnerships, and with the breadth of Adobe tools it means they’re able to leverage our community for all kinds of different content- not just Flash.

Next year is going to be incredibly exciting for Adobe developers and designers. We’ve already talked a lot about Flash Player being available for smart phones next year, you’ll undoubtedly be hearing more about AIR, and hopefully we’ll continue to see deeper mobile integration across all of our tools just like you’re seeing with RIM here today. For more information you can check out the BlackBerry portal on Adobe’s site to get the scoop on the details and see some of the workflows in action.

Enterprise Apps in the Cloud Just Got Better: Salseforce/Adobe Partnership

Today we announced an interesting partnership between Salesforce.com and Adobe. As Tim Anderson noted, there has always been a surface integration because Flash Builder could consume WSDL’s and Salesforce.com has always exposed them. But this goes quite a bit deeper. One, we’re working with the Salesforce.com team to make sure their IDE is completely integrated into ours. You’ll be able to get a combined Force.com and Flash Builder tool so you never have to switch environments to create Flex applications on top of the Force.com platform. The new tool exposes a new project type, the Force.com stratus type, and lets you automatically connect to the Force.com platform using a WSDL file. Then you can use the data features of Flash Builder to connect your data in the cloud with Flex components. It also has support out of the box for creating AIR applications that support online/offline synchronization.

The new tool and the partnership really simplify the process to connect to the Force.com platform so that you can focus more time on building a really great user interface that exposes those services. A “consumer-link” user experience is becoming more and more prevalent in the enterprise and is seeing a lot more demand. As ReadWriteWeb notes this is going to do a lot to help merge the consumer world of Flash with the enterprise back end of Force.com as well as some of our enterprise functionality in the form of LiveCycle Data Services. I think there are also some cool use cases here for integrating LiveCycle Collaboration Services. And of course the Force.com platform now gets access to over a million Flash developers who can target the cloud.

You can check out the video below for some getting started information. There is also a fantastic Force.com quickstart on Adobe’s Developer Connection and a lot of other information on the Force.com section of Devnet. Finally there will be a live webinar on November 3rd with James Ward and Markus Spohn where you can get a demo and then ask questions about how it all fits together.

Introducing “Contextual Applications”

We did a soft launch with some information of a concept that Adrian Ludwig and some of the other brain-trust folks at Adobe came up with recently called Contextual Applications. I have absolutely fallen in love with this term (and I had nothing to do with thinking of it). In a lot of ways I think this is RIA 2.0. One of the problems with RIA was that it had a grossly vague definition. It was kind of a Frankenstein combination of a desktop-like user experience, better design, real-time communication, rich media, and Web 2.0 ideals. In the end, RIA encompassed almost everything; Ajax, Flash, Silverlight, Adobe AIR, WPF, etc. That’s not a bad thing but it became hard to distinguish the value of RIAs because everyone could claim they were doing “RIA stuff”. The important thing is that we made a lot of progress with RIA and changed how people thought about software development.

Defining Contextual Applications

Contextual applications are a lot more concrete and have a better value proposition for both end-user and developer. It isn’t defined by a particular technology but instead a particular type of experience. So what is it? The idea is fairly simple. You’ve got a core set of data and a core experience that you have to deliver. But in today’s web there are multiple “touch points” out there. What about mobile? The desktop? A browser experience? A widget? An experience specific for social networking? Maybe a television? Users expect to have their content everywhere, on demand, regardless of how they’re connecting to it. The user experience and design challenge is creating a unified brand and experience that leverages the same content and is tailored to the specific technology limitations of a particular “touch point”. Solving that challenge will give you a contextual application. An application that moves with the user across a number of screens/devices while maintaining content and a user experience that is consistent but unique to each device.

Finetune: The Ultimate Contextual Application

The Contextual applications site has a number of examples but my favorite is definitely Finetune. They are a great example of one of the earliest contextual applications. They started out with a web-based application. Then, with the benefits of the desktop they created an AIR application that had native windows and used the file-system capabilities of AIR to tie into the iTunes library and pull artists that were interesting to the user; using the technological features of the underlying touch point to customize the experience. Then they were interested in deploying a version on the Wii so they created a Wii-specific browser application that ran on Flash Player in the Wii and maintained the Finetune branding. Then of course mobile was a big demand. So they built two mobile applications; a Flash Lite app that reused a lot of code and still maintained the Finetune experience but customized for the small screen. They also built an iPhone app with touch support that captured the experience of the iPhone while maintaining that core Finetune interface.

To me, the Flash Platform stands alone at being able to let developers and designers easily deploy contextual applications. With so many different operating systems and screens supported, it becomes easy to reuse the tools and workflows to create applications that are tailored for those screens while maintaining a sense of continuity. And think about the server infrastructure. Are you using FMS to stream Flash Video content? That content will be supported everywhere the Flash Player is so you can quickly jump between screens and be sure that your base content, the most important thing, is completely intact. It lets you design around your content and maintain that emotional branded connection with your users.

Ultimately it is about productivity. The number of touch points is only increasing and to be able to deploy on as many of them as possible you need to be able to reuse code, design assets, and workflows as quickly as possible. The Flash Platform gives you the broadest reach with a large community of designers and developers who are skilled with the tools. Ultimately that means you’ll be able to create contextual applications quickly and reach your users wherever they are. That’s why I’m so excited about this concept: ultimately it gives the user more control.

Rundown of the MAX News

The press releases just crossed the wire and we have a ton of news coming out of MAX. Plus more surprises in store for tomorrow. For those of you not here you can still check the keynotes out. I’m hosting the online side of the MAX keynotes and we’re doing some fun stuff before and after the keynotes to give you a sense of what’s going on at MAX. As you can tell from the rundown, there’s some fun stuff today.

Flash Platform Runtimes

We’ve been saying all year that Flash on mobile devices is a push this year and we’ve made a lot of progress. Today at the keynotes we’re going to be showing off Flash Player 10.1 for smartphones. This is the version of the Flash Player that we’ve been working on so hard this year. We’ve been working with some great partners including Nvidia and ARM to optimize the player for those devices and create a quality mobile experience.

Possibly more important is that the number of companies committed to the Open Screen Project continues to grow. Today we announced that RIM is joining the Open Screen Project, which means that Blackberry will be supporting Flash Player 10.1. Google is also on board. We’ll have public versions of Flash Player 10.1 for Palm, and Windows Mobile later this year with Google Android and Symbian following shortly. Developers will have mobile bits in their hands soon.

We also announced AIR 2.0, which is going to give Flash developers a lot more native hooks into the operating system. A lot of the developers I talked to wanted it and so that’s what the team did. Mike Chambers talked about some of these features at Flash on the Beach. Another cool feature of AIR 2.0 is the ability to record from the microphone without going to a server. getMicrophone can now be a reality

.

Tools

We also have public betas of both Flash Builder and Flash Catalyst that are available today. I’ve been really impressed with how far Flash Catalyst in particular has come from Beta 1 to Beta 2. It’s a lot more polished, has more functionality (including video) and feels a lot more fun to use. If you checked out Beta 1 and found it lacking, you should check out Beta 2. We’ve also made big progress on Flash Builder and I’ve been a very happy camper using the tool full-time.

Servers

Some very cool stuff is also happening on the server side. We’ve released ColdFusion 9, a spectacular release with some great features including the ability for you to consume ColdFusion as a service from inside of your Flex application without writing ColdFusion code. I’ve also been playing with the LiveCycle Data Services release and its modeler plug-in for Flash Builder. The team has focused on model-driven development making it easy to generate and create a model, and then link that model directly to your Flex application. It helps by generating all of the assemblers and you can directly modify the user interface just by changing the model.

Finally we’ve got some Flash Media Server news. We’re adding support for HTTP streaming, which will include support for content protection. We also have released the Collaboration side of Flash Platform Services and announced pricing so you can jump in and start adding collaboration to your application.

If you guys have any questions (sorry I don’t have more fleshed out info, it’s a lot of news), feel free to drop me an email – ryan@adobe.com and I’ll try and answer what I know.

2010 RIA Conferences List

Adrian Parr has a really great list of the 2010 RIA-themed conferences that have been announced. I’m hoping (and assuming) that he’ll be adding to this list as more conferences get added. There are a few on that list that I know I’ll be attending (and a couple I need to check on) and I’m looking forward to connecting with everyone. Hopefully Adrian will add MAX 2010 to this list when we announce the dates (hopefully) after this year.

Thanks for the list Adrian!

Google Wave Pisses Me Off

The hyptasticness that is Google Wave continues to annoy me as a Flash developer and RIA enthusiast. Now I preface all of this by admitting that I haven’t used it; maybe when I get an invite this thing will be worth all of the finger grease that keyboards have endured as people talk about it. And I’m not saying it’s not impressive; it is. It’s a great demo, it does some very cool stuff. I’m not annoyed at Google Wave, I’m annoyed because everything that people like about that demo was doable 3-5 years ago with Flash. Flash Remoting, Flash Communication Server, and our much better user interface capabilities pretty much could have created Google Wave. Now I understand that there’s some excitement because this is built on open standards with a more open model, but people don’t get excited about standards- they get exited about vision. And that’s what kills me.

I don’t care if you’re a Silverlight developer or a Flash developer; the technology platform you’ve got is years ahead of what Google Wave is built on. Yet with all of our UI prowess, our design sense, and our pure and simple technical superiority with things like real time communication and scalability we haven’t built very much that captures people’s imaginations the way that Google Wave has. I think we lack the vision.

I think it could be argued that in some cases we’re TOO visionary. If someone had actually built Google Wave 3-5 years ago it wouldn’t have made the same impact because people wouldn’t have realized what it meant. In the RIA world we live in the bubble of the future. I genuinely think that most of us look 3-5 years ahead because that’s where our technology puts us. When people don’t get what we’re trying to pitch we just move on to the next thing. Look at Augmented Reality. Possible with Flash for a couple of years now but it’s just starting to get some mainstream attention. RIA developers seem permanently entrenched in the Technology Trigger of the Hype Cycle and we don’t seem to be able to follow things through to the Plateau of Productivity.

Part of the Wave hypefest is probably because of the world’s love/hate relationship with Google. When they do something everyone goes nuts and that’s because they really do have the power to change the web. They did it once, they’re big, they’re smart, they can do it again. But there are a lot of smart people in the RIA world. Big companies like Microsoft and Adobe and small ones like Aviary and Picnik. We just don’t seem to encourage the visionary demos, the ones that make people rethink how they’ll communicate and interact. I don’t know if that has to come from the big companies directly or whether it’s something we can encourage startups to do. We don’t have a technology problem; if that was all it took we’d be cranking out Wave-esque demos all the time. We just don’t seem to be able to look at the entire scope of what we’ve been doing for the past couple of years and put it together in a game changing way.

I don’t have a solution, but if you’ve got suggestions, I’m all ears.

The Full Flash Platform Services Story

platform_servicesToday we announced the release of the distribution side of Flash Platform Services. Most of the action is on Techmeme but I liked the ReadWriteWeb post, the TechCrunch post, and the VentureBeat post specifically. Distribution Services is the one that’s new and the goal is to let you track your application across a number of different screens while also simplifying the distribution mechanism. There are also hooks that will let you easily bring in advertising so that you can both track and monetize your content. The first thing people will think of is widgets, and that makes sense because a lot of the “sharing” aspect, which we’re partnering with Gigya for, will remind people of the widgets they’re able to place on Facebook, MySpace, blogs, and other places. But as Serge’s MAX Widget shows, these can be more complicated applications as well. So while widgets may be the first thought, any one of these three threads–sharing, tracking, and advertising–can be brought into an application of any size. So regardless of what kind of application you’re building, these services should be helpful.

Show me the money
One thing this allows you to do is easily monetize your content. The money side of this is that advertisers or developers can buy installs and pay a fee (starting at one dollar) per successful installs. You can also target this a bit, so if you want to make sure a high number of people are embedding your widget, you can promote it via the network and you’ll be charged a fee anytime someone embeds or installs your content. On the profit side, you can also offer to host advertisements via our network. We’ll give you a specific CPM (cost per thousand impressions), we estimate around $5, and pay that out to you.

Mobile
These services also work with mobile devices. This is one of the slickest features I’ve seen demoed because when a user wants to install a shareable mobile application, they’ll get an SMS with a link to the application. When they click it, our distribution service detects which device they’re on and will push out the correct version of the application. Currently we support Symbian S60 phones, Windows Mobile, and the iPhone. That doesn’t mean you can use Flash on the iPhone, but you can create an iPhone version that can be pushed out with our distribution network.

The Rest of the Services Story
There are three parts to the Flash Platform Services initiative; Distribution, Collaboration, and Social. Distribution is what we announced today, Social will make it easy to integrate social networks like Facebook and MySpace, and Collaboration has been in beta for a while, you know it as Flash Collaboration Service. All of these will have a pay-per-use model and will provide added functionality or easy integration for developers. The Flash Platform is the most cutting edge technology on the web. The full range of things it lets developers and designers do just doesn’t exist on any other platform. As a result, we’re able to do some very interesting things when it comes to collaboration, tracking, distribution, or integration. The goal of these services is to make it much easier for any Flash Platform developer to accomplish those things. Lowering the barrier to entry for things that make Flash so powerful is going to be beneficial for a lot of developers.

Up-leveling the Flex User Interface Discussion

higher_levelLast week in New York I got a chance to present and watch at DelveNYC. It was a great conference and I wish I could have caught more of it; very valuable for designers of all stripes and a great set of speakers. One of the things that I thought was so valuable about it was that it focused on a lot of design theory. My favorite talk of all came from Theresa Neil who spoke on Rich Patterns in UI Design. It was a phenomenal talk and it was clear that Theresa is well versed in all of the RIA technologies as she talked about controls for each technology, accessibility, and pointed out great examples of her patterns being put to use in Flex applications and other RIAs.

I’m sorry you couldn’t be there, but I encourage

What struck me was that this woman with an amazing grasp on theoretical user interface design for rich Internet applications hadn’t gotten my attention before. I like to think I track the Flex world pretty closely and I totally missed her. I’d imagine others have also. I think part of the problem is that we’re still thinking about RIAs and Flex on a development level. This talk at Delve completely up-leveled the conversation for me and got me thinking about the wider world of user interface design and how we, as Flex developers, should be thinking about it.

I’m not smart enough to dive into this myself but I want to point out some of her great resources that I think all Flex and RIA developers should look at and take to heart.

  • 12 Standard Screen Patterns – A great list of standard UI patterns that you can leverage in your Flex applications. She literally has 100 examples of RIAs that use these patterns.
  • 30 Essential Controls – A list and examples of 30 controls/components that she thinks are critical for RIA user interface design. It includes a check list of major RIA frameworks so you can see which frameworks have which controls. Flex component developers, this is a great place to start if you’re looking to sell/create custom controls in Flex.
  • 6 Tips for a Great Flex UX – a six part series with some great tips and getting started links for Flex RIAs.
  • Slides from Theresa’s talk at DelveUI – I’m sorry if you couldn’t be there, but I encourage you to grab her slides and walk through them.

What made me so impressed after hearing her speak and reading through her blog was how Flex-savvy she was while coming from a completely different background than most of the Flex community. Having people like this thinking about Flex and where it fits makes me feel very happy and hopeful for the future of Flex as an RIA technology. We need so much more of this kind of conversation within our community; I see this as the next level. Beyond the prefix debate, beyond the ActionScript debate, beyond the spark/halo debate – this is the stuff that will ultimately help people create world class applications that change how people work with information.

Photo from oddsock.

A Week of Flash Collaboration: Shared Models and Collection Nodes

Update: This blog post took me the better part of a day and a half and just as I was posting it I realized I had a huge hole in the logic for my application because of the problem at the bottom. My plan is to come back and clean this up, as Peter suggested, divide it up into a couple of parts. The most important parts are the first couple of paragraphs that talk about the sharedModel classes and the last paragraph that mentions how the AFCS team architected things to build on top of very low level base classes like CollectionNode. Largely this blog post is a mess and digging into CollectionNode was interesting but I recommend it only after having some time playing with the other classes in sharedModel. After that this might be a useful post to read. Diving into the video tutorials is also highly recommended.

The basic building blocks of Adobe Flash Collaboration Service (AFCS) are really the sharedModel package and the CollectionNode classes included in it. Using the classes in the sharedModel package you can share any piece of data across AFCS connections and use these classes to build custom collaboration components like charts or maps where data can be updated and must change for everyone who is connected. I’ll first talk about some of the classes in the sharedModel package and then dive into how to use the CollectionNode, which provides the base functionality for sharing data.

Shared Models
The classes in the Shared Model package include a number of ways to share data and actions with AFCS. For the most part, the classes in sharedModel all use the CollectionNode to exchange data but they abstract a bit of the nuts and bolts of CollectionNode to make it easier to use. For instance the SharedProperty class lets you take any arbitrary property and share it across AFCS instances. It includes the ability to specify a CollectionNode or to just use one that will be generated as soon as the component using SharedProperty is created. Nigel Pegg has a great tutorial that covers using SharedProperty. Another set of classes in the sharedModel package are the Baton classes. The Baton is essentially a SharedProperty that gives you more control over when a user can edit something. The Baton class helps define when something is currently in use and shouldn’t be editable by anyone else in the room. It includes methods to grab() and putDown() a baton as well as a batonHolderChange event, which can be used to make changes to the user interface. Nigel’s video goes through this as well using the example of a TextInput box. Using the Baton classes it is easy to disable editing of the TextInput while someone else is typing inside of it.

CollectionNode All of the classes above use collection nodes and there are three major parts to the basic CollectionNode: creation, configuration, usage. As the documentation states, an AFCS room is essentially a bunch of CollectionNodes exchanging data and each of those nodes has specific configurations that define who and how people can interact with them. One thing to note is that CollectionNodes can only be created by a room owner, or someone with UserRoles.OWNER so when creating a CollectionNode, the owner must be the first person in the room so they can “initialize” it. After that the developer can use the NodeConfiguration classes to customize what level of user has read or write access to the node.

Creating a new CollectionNode is pretty straightforward. In this example I’m going to create a mini-game where the participants have to match up a ColorPicker to “win”. To set up the game, I’ve got one CollectionNode with a “Color” node that will contain the values of the ColorPicker. Here’s how I create the CollectionNode:

protected function application1_creationCompleteHandler(event:FlexEvent):void
{
     nodeGame = new CollectionNode();
     nodeGame.sharedID = "gameNodes";
     nodeGame.addEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE, onSync);
     nodeGame.addEventListener(CollectionNodeEvent.ITEM_RECEIVE, onItemRecieve);
     nodeGame.subscribe();
}

A few things to notice. First, the sharedID property is described in the docs as the “logical address of the collection within the room” and is how AFCS will refer to it so it needs to be unique. It is also the name that you will see when you browse the nodes in the room console that comes with the SDK. Second, in order to use the node we have to make sure it’s synchronized or we’ll get an error. After creating the node I added a CollectionNodeEvent listener that fires when we have a synchronization change event. I also added an event handler for when we receive messages upon subscribing to the node, which I’ll talk about later. Once the SYNCHRONIZATION_CHANGE event fires we can start making changes to our CollectionNode:

protected function onSync(event:CollectionNodeEvent):void
{
     var config:NodeConfiguration = new NodeConfiguration();
     config.modifyAnyItem = false;
     config.userDependentItems = true;
 
     nodeGame.createNode("Color",config);
     createMessage(false);
}

Now that we’re able to make changes to the CollectionNode I can create the Node that will store messages, in this case the “Color” Node. First I need to use the NodeConfiguration class to set up some rules for the game. By setting the modifyAnyItem property to false I make sure we’re not allowing users to modify messages that aren’t created by them. The userDependentItems property set to true means that when the user leaves the room, we clear out all of the messages belonging to them. In our game we don’t want to find a match with someone who isn’t playing any more. The NodeConfiguration classes allow us to tweak things like what happens to messages as well as define permissions for specific nodes within my CollectionNode. Once we’ve created the NodeConfiguration I can use the createNode() method to create a Node named “Color” and pass in the configuration values I just created. The last method there is a function I created. After we create the node and configure it I want to send the value of my ColorPicker to AFCS so I can start playing the game. I do that with a createMessage()

protected function createMessage(overwrite:Boolean):void
{
     var colorMessage:MessageItem = new MessageItem("Color");
     colorMessage.itemID = cSession.userManager.myUserID + "_color";
     colorMessage.body = color1.selectedColor;
 
     nodeGame.publishItem(colorMessage,overwrite);
}

My createMessage() takes one variable, a Boolean that we'll use to tell AFCS whether or not we are allowed to overwrite an existing message. The first part of the code is where we create our MessageItem to be sent. I'm just creating a new MessageItem and passing in which Node it will belong to, in this case the "Color" node I created above. Then I give it an itemID, which is how it will be referred to by AFCS. I use the current userID and prepend that to the word color. Finally I set the body of the message. The body of a MessageItem can be a String, a Boolean, a Number, or a key-value pair. In this case we're just going to pass in our selectedColor value. Once we create the MessageItem we need to add it to the Node. To do that we use the publishItem() method on the CollectionNode. This is where I pass in the overwrite flag. In this case, I don't want the MessageItem to be overwritten because this should be the first time we're adding it since we called it from the OnSync method. But later I want to make sure we overwrite it because we're making updates to it.

As soon as we publish our message, it's going to go into AFCS and then AFCS is going to send it back to us so we make sure it was sent correctly. When that happens it will fire an ITEM_RECEIVE event, for which we added an event handler in our initial function. That code looks like this:

protected function onItemRecieve(event:CollectionNodeEvent):void
{
     var tempMessage:MessageItem = event.item;
     var userName:String = cSession.userManager.getUserDescriptor(tempMessage.associatedUserID).displayName
 
     arrColors.push({color:tempMessage.body,user:userName});
     if(tempMessage.associatedUserID != cSession.userManager.myUserID)
     {
          if( tempMessage.body == color1.selectedColor )
          {
               Alert.show('Winner! Your partner is: ' + userName);
          }
     }
}

This is where we start to get to the game. The first two lines just put the MessageItem and user displayName into their own variables. Next we put the selectedColor from our message and the displayName into an array that's stored on the client. This is kind of important. A lot of the sharedModel classes, like SharedProperty for instance, will handle storing data for you but the CollectionNode class doesn't, it's a very basic, low level component. So in this case we can't tell AFCS to send us a list of messages to check and see if there is a match, we have to keep a record within our own application. I do that by storing the information in an Array. Once I do that I want to check if we have a match but I need to make sure we're not matching our own color so I do a quick check using the associatedUserID and myUserID from the ConnectSession. Once we know that isn't the case I can check the body of the message with my current color to see if there is a match and pop up the appropriate dialogue.

When we make changes to our color to try and find a match we also need to send the update to AFCS and check our Array so I added an event handler to my ColorPicker for any change event:

protected function color1_changeHandler(event:ColorPickerEvent):void
{
     createMessage(true);
     for(var i:Number=0; i<arrColors.length; i++)
     {
          if(event.color == arrColors[i].color)
          {
               Alert.show('Winner! Your partner is: ' + arrColors[i].user);
          }
     }
}

In this case the first thing we do is call createMessage() with the overwrite flag set to true so we are overwriting our current message with the new color value instead of creating a new one. Then we run through our array of colors to see if this new color matches anything on the system. Do you notice a problem?

The problem is this: We configured our Node to remove all messages as soon as someone leaves the room but because we're using CollectionNode instead of one of the higher level classes we also have that array that is storing the values. We're using that array to check for a match after we change our color but we don't ever clear out old messages from our array so we might get a match from someone who is no longer logged in. We're also not checking the array and updating values so we have a lot of old data.

Welcome to Multi-User Applications
Multi-user applications are fun but there is also a lot to deal with. Luckily, the AFCS team has done a very good job of building base functionality into classes like CollectionNode and then building on top of them with classes like SharedProperty that take care of a lot of the complicated parts of managing a collaborative application. I tried to get nitty gritty and show how CollectionNode works but I really encourage you to start with the higher level classes, get an idea of what's happening, and then break down to the low level base classes when you need to start creating very customized collaborative applications with specific rules, custom components, and many different types of data.

You can grab the full project here (Flash Builder 4 FPX file) and see how the parts fit together. I'll be updating it in the next few days to take into account the problem above and include a version that people can play.