Thursday, March 6, 2008

Getting TwitterCamp to work with AIR 1

When I was at the 360Flex Atlanta conference they had TwitterCamp running on a few large flat screens. I still don't get Twitter but it was cool to watch the bubbles changing as people put in their tweets.

I can't remember what people were saying but I think it's pretty funny that I was watching people tell me what they were doing at 360Flex on a monitor that was at 360Flex. They were probably saying they were at 360Flex.

Today I was trying to find a Flex Twitter app. I found AirTalkr and TwitterCamp. Neither of them work. AirTalkr is supposed to hook into Twitter but I could not figure out how. At least it's not obvious. TwitterCamp does not work with the production AIR 1 release.

I think TwitterCamp is cool and I would like to run it, now... I decided to download the source for TwitterCamp and update it to work with AIR 1. Then I thought this would be a great thing to Blog about so here goes...

I downloaded the TwitterCamp source from Daniel Dura's blog at:

http://www.danieldura.com/code/twittercamp/

I copied the zip file to C:\Download\AIR and then unzipped it to C:\Download\AIR\twittercamp

I then created a new Flex AIR application in Flex Builder 3 and named it TwitterCamp.

I copied the files in the C:\Download\AIR\twittercamp source root directory to to the TwitterCamp\src directory.

The project wouldn't build because I had accepted the default source directory of TwitterCamp\src. I fixed the problem by moving the files from TwitterCamp\src to TwitterCamp.

Then I had another build problem because com.adobe.utils:DateUtil could not be found.

I followed a link to the source code that was in one of the comments but it turned out to be a broken link.

I Googled com.adobe.utils.DateUtil and eventually found:

http://code.google.com/p/as3corelib/downloads/list

I downloaded corelib-.90 and expanded it to:

C:\Program Files\Adobe\corelib-.90

After adding C:\Program Files\Adobe\corelib-.90\corelib\bin\corelib.swc to the Flex 3 library path I then started getting:

Severity and Description Path Resource Location Creation Time Id
1119: Access of possibly undefined property window through a reference with static type flash.display:Stage. TwitterCamp TwitterCamp.mxml line 61 1204846931832 21


To fix the compiler error I changed

systemManager.stage.window.x = 10;
systemManager.stage.window.y = 10;

to

systemManager.stage.x = 10;
systemManager.stage.y = 10;

Then one more error was left:

Expected a single content tag in TwitterCamp-app.xml

I Googled "Expected a single content tag" and found a blog post that referred to a similar problem and explained how to fix it. The problem was caused by the app.xml being different in AIR 1.0

To figure out what changes I needed to make to TwitterCamp-app.xml, I created a new AIR project named TwitterCampTest and compared TwitterCamp-app.xml to TwitterCampTest-app.xml.

I changed

http://ns.adobe.com/air/application/1.0.M4

to

http://ns.adobe.com/air/application/1.0

I then started adding XML elements one by one until the compile errors went away.

I added:

the id, filename, version and initialWindow tag. For the id and filename tags I also changed TwitterCampTest to TwitterCamp.

I tried debugging and got the following error:

[SWF] TwitterCamp.swf - 1,148,762 bytes after decompression
Error: Error #2071: The Stage class does not implement this property or method.
at Error$/throwError()
at flash.display::Stage/set x()

I fixed this by commenting out the following statements:

//systemManager.stage.window.x = 10;
//systemManager.stage.window.y = 10;

note that I added .window back to the statements.

I ran the app but it didn't look good on my laptop screen. It was too big. I changed the stageHeight and stageWidth to:

systemManager.stage.stageWidth = 800;
systemManager.stage.stageHeight = 600;

Now it all works!

It looks cool but I'd like to customize it so it says AIR instead of Apollo, etc... Stay tuned.

I have posted the code to:

http://www.riaplayground.com/download/TwitterCamp/TwitterCamp.zip

I also left a comment on Daniel's blog and let him know where the code is in case he wants to use it.

Monday, March 3, 2008

Breakdown of the 2008 360Flex Atlanta Conference

The conference was incredible.

Summary: Flex 3 and Air 1 were released, Cairngorm still rocks!, had a lot of good conversations about Flex development.

I think most people involved with Flex development already knew that Flex 3 and Air would be released during the conference. I had known for a month. Of the new Flex 3 features, my favorites are refactoring, memory profiling and the AdvancedDataGrid.

One of the main reasons I went to the conference was to talk with other developers that are using Flex. I asked quite a few of them what they thought of Cairngorm. I was shocked to learn recently that not everyone is as excited about Cairngorm as I am and I wanted to ask developers at the conference what they thought. Basically I found that most of the developers had issues but not enough to make them stop using Cairngorm. The main complaint is that Cairngorm requires you to setup an event for each command. I've never seen that as a big deal.

The main "competitor" of Cairngorm is PureMVC. I talked to one developer about PureMVC and he explained that PureMVC does not allow binding model data to a view, service locator, etc... I see this as a big disadvantage. DataBinding is great and I can't imagine doing without it.

My favorite sessions were the Keynotes, Doug McCune's sessions on being an independent Flex developer and open source Flex projects, Ben Stucki's 3D demos. The coolest demo by far was Joe Berkovitz's demo of a music editing application.

The best technical presentation was by John Wright on Building an iTunes-like Browser Component for Flex. I wasn't able to stay for the whole session because I had to catch a plane but he presented some good reasons for not using regular expressions in Flex. I plan on downloading the slides for this presentation and investigating further. Regular expressions are great but if the ideas he presented are faster then it's worth looking into.

Most of the presenters have posted their presentations on their blogs. The 360Flex Atlanta site has a link to these blogs.

The conference was great and I'll definitely go again.