I Won the AIR Cook-off

October 29th, 2008 by

I was waiting to post this until the results were announced which they were today. O’Reilly just posted the winners of the Adobe AIR Cook-off and I’m pleased to say I won the grand prize!

My recipe was Migrating Serialization Changes in AIR. Thanks to anyone who voted for it.

I have a follow-up recipe I haven’t gotten to write up yet, but I’ll try to get it up in the next week. It will provide a solution to add the marker which is required for this serialization to work to the front of your structures if you already have files being serialized in an existing AIR application and you want to start taking advantage of this migration technique.

Making WillPaginate and Rails to_xml play nice with ActiveResource

October 10th, 2008 by

We are currently working on a project that involves Flex and active resource + will_paginate and we needed to be able to paginate the xml transactions easily. Unfortunately, will_paginate and to_xml don’t play nicely when it comes to adding the current_page, total_pages, and page attributes to the xml. After many failed attempts I went looking around github and found in a few forks of will paginate that some people had solved this problem but, I didn’t want to install another version of the gem to risk breaking other apps on the server so I did it the rails way!

I started by creating a module that opens up the will_paginate collection class and includes ActiveResource and alias method chain the to_xml method to include these values. Example code below.

#enviroment.rb
...
require 'to_xml_extensions'
#lib/to_xml_extensions.rb
module WillPaginateHelpers
  include ActiveSupport::CoreExtensions::Array::Conversions
  def to_xml_with_collection_type(options = {})
        serializeable_collection.to_xml_without_collection_type(options) do |xml|
          xml.tag!(:current_page, {:type => ActiveSupport::CoreExtensions::Hash::Conversions::XML_TYPE_NAMES[current_page.class.name]}, current_page)
          xml.tag!(:per_page, {:type => ActiveSupport::CoreExtensions::Hash::Conversions::XML_TYPE_NAMES[per_page.class.name]}, per_page)
          xml.tag!(:total_entries, {:type => ActiveSupport::CoreExtensions::Hash::Conversions::XML_TYPE_NAMES[total_entries.class.name]}, total_entries)
        end.sub(%{type="array"}, %{type="collection"})
      end
      alias_method_chain :to_xml, :collection_type
 
      def serializeable_collection #:nodoc:
        # Ugly hack because to_xml will not yield the XML Builder object when empty?
        empty? ? returning(self.clone) { |c| c.instance_eval {|i| def empty?; false; end } } : self
      end
end
 
WillPaginate::Collection.send(:include, WillPaginateHelpers)

This now gives me the proper xml when I call to_xml

<?xml version="1.0" encoding="UTF-8"?>
<time-cards type="collection">
  <current_page type="integer">1</current_page>
  <per_page type="integer">25</per_page>
  <total_entries type="integer">108</total_entries>
  <time_card>
    <approved type="boolean">false</approved>
    <billable type="boolean">false</billable>
    <created_at type="datetime">2008-10-10T14:04:13-04:00</created_at>
    <date type="datetime">2008-10-10T14:04:13-04:00</date>
    <has_been_billed type="boolean">false</has_been_billed>
    <has_been_paid type="boolean">true</has_been_paid>
    <hours type="float">2.0</hours>
    <id type="integer">98</id>
    <is_overtime type="boolean">false</is_overtime>
    <task_id type="integer">6</task_id>
    <updated_at type="datetime">2008-10-10T14:04:13-04:00</updated_at>
    <user_id type="integer">1</user_id>
  </time_card>
  ...
</timecards>

Migrating Serialization Changes Within an AIR Application

September 11th, 2008 by

I just submitted my entry to the AIR Cookbook for the AIR Cookbook Cook-off.

It solves the problem of having your AIR application store an IExternalizable class on disk but then later adding more fields to that class. How would you read the old version of the class without encountering a runtime error if you tried to read the new field that wasn’t present in the older serialization?

Go check it out the cookbook entry to find out how to do this and please rate the article!

Serialization Error/Bug When Using a ByteArray and readObject in an IExternalizable Class?

August 27th, 2008 by

I’ve encountered some odd behavior that I would have expected to work when calling readObject() to de-serialize an array of anonymous objects. If anyone knows what’s going on here, please enlighten me. I’ve also filed a bug on Adobe’s bug tracking system if anyone wants to follow the progress at Adobe’s end.

I’m trying to read all of the bytes in the readExternal() function of a class implementing IExternalizable, so that I may use the position property to move back in stream in case I need to do so. The problem only seems to occur if I am trying to de-serialize an Array of anonymous objects. If I put plain old Strings in the Array it will work fine. I find this odd since I would expect

public function readExternal(input:IDataInput):void {
  var arr:Array = input.readObject() as Array;
}

to have the exact same behavior as:

public function readExternal(input:IDataInput):void {
  var ba:ByteArray = new ByteArray(); 
  var inputBytes:uint = input.bytesAvailable;
  input.readBytes(ba);
  var baBytes:uint = ba.bytesAvailable;
  var arr:Array = ba.readObject() as Array;
  trace("inputBytes == baBytes ?= " + (inputBytes == baBytes)); // traces "inputBytes == baBytes ?= true
}

AIR installer and code attached below… Read the rest of this entry »

Adobe AIR Alpha Released on Linux

March 31st, 2008 by

If this is the first time you’re reading this then you’ve been reading the wrong blogs, but today Adobe released their first public alpha for AIR on Linux. Additionally, Flex Builder alpha 3 was released today as well. Now I may finally move to Linux as my primary OS!

AIR 1.0 and Flex 3 Released

February 25th, 2008 by

Adobe just released Flex 3 and AIR 1.0. Congrats to both teams for doing a great job on these awesome products!

Adobe onAIR Bus Tour: Baltimore

August 21st, 2007 by

Yair and I went to the Baltimore stop of Adobe’s onAIR Bus Tour tonight.

Ryan Stewart

Ryan Stewart kicked off the keynote giving an introduction and overview to Adobe AIR. After briefly going over the background/web-history of the Flash player and the motivations behind the development of Adobe AIR, Ryan showcased some AIR applications:

He also highlighted that with the newly announced update to Flash Player 9 (codenamed “Moviestar”), Flash SWFs will be able to support H.264 video and HE-AAC audio. This will allow Quicktime movies to be played through SWFs and the Adobe Media Player.

Ryan then mentioned that the second public beta drop of AIR will be released during the MAX 2007 conference. Also, we were reminded of the AIR Developer Derby: a contest to see who can make the best AIR application. The grand prize is essentially a $100,000 travel coupon. There will also be five category winners that will win “The Ultimate Desktop Environment”, which is pretty much a bunch of beast hardware.

Mike Chambers

Next up was Mike Chambers demo’ing how to write a HelloWorld Flex-based AIR application. Pretty standard, but he went on to highlight the install experience for end-users that will be using AIR applications we developers will be creating. End-users will need the AIR runtime in order to install an AIR app, but developers will be able to place a Flash Badge on their website which will allow users without the AIR runtime to install both the runtime and their AIR application with only 4 clicks.

Mike finished off with pointing any developers that are starting to play around with AIR to the onAIR Bus APIs which have a ton of live data that can be used in an AIR app.

Kevin Hoyt

Kevin Hoyt was next to demo how to build an HTML-based AIR Application.

Kevin emphasized that Flex Builder is not necessary to create AIR applications. The Flex 3 SDK (which is freely downloadable) contains the AIR SDK as well, so you can compile and debug your AIR applications from the command line. Dreamweaver CS3 also has an AIR extension so if you’re a web developer that’s afraid of the command line you can go ahead and develop your HTML page in Dreamweaver and debug the application or package it as an AIR file directly within the comfort of Dreamweaver.

Script Bridging

Kevin next demo’d the script bridging capabilities of AIR, which lets JavaScript reach into the ActionScript world and invoke any methods in the Flash API (anything in the flash.* namespace). The reverse is also true (ActionScript reaching into the JavaScript world). This means you can have a purely HTML-based AIR application that can call methods in the Flash API by simply doing things like:

<script>
  var airFile = window.runtime.flash.filesystem.File;
  var desktop = airFile.desktopDirectory;
  var myFileInJS = new airFile(desktop.resolve("file_on_the_desktop.txt");
</script>

Here, myFileInJS is a JavaScript variable that references an ActionScript 3 class from the AIR SDK.

So “window.runtime.flash.* can let you directly use any Flash class from JavaScript. IMO the coolest thing Kevin covered is the ability augment the Flash packages you can use by simply script including a library.swf from any SWC to access those AS classes:

<script src="library.swf"></script>
<script>
  var encoder = runtime.com.adobe.images.PNGEncoder;
  encoder.encode( bitmapData )
</script>

In this example, encoder is the PNGEncoder from the as3corelib project, but the encoding is being done in JavaScript using AS classes! Very cool stuff. (FYI: a SWC is stored in a ZIP format, so you can just unzip a SWC file to access the library.swf inside of it)

Chafic Kazoun: Windowing in AIR

Windowing concepts Chafic covered/demo’d:

  • utility window
  • standard window
  • custom chrome transparent window
  • custom chrome where background is embedded in a SWF
  • custom window dispatching events and being listened to by another window

Ben Forta: AIR + ColdFusion

Highlights from Ben’s talk:

  • 50% of existing ColdFusion customers have upgraded to ColdFusion 8.
  • ColdFusion/Flex Extensions for Eclipse available at Adobe’s ColdFusion page.

Can generate a ColdFusion-backed Flex web app w/ literally no front-end coding; the extension has Master/Detail/Master_Detail and DB wizards to configure everything which then generates the CFCs, MXML components, and CSS stylesheets using all best practices.

This was possible before in ColdFusion 7, but now ColdFusion 8 can generate a ColdFusion-backed AJAX/HTML/CSS web app in the same manner.

From AIR you can load an HTML page from a ColdFusion backend and it will properly renders this AJAX/HTML/CSS generated content.

  • You are currently browsing the archives for the AIR category.


local background check | FUJITSU AMILO PA1510 REPLACEMENT LAPTOP LCD SCREEN