My work with Adobe AIR 2.0 NativeProcess gets a mention on RIA Radio!

RIA Radio is a weekly podcast presented by InsideRIA as an open discussion with guests from the community, covering upcoming news and current best practices. In Episode 10, Antonio Holguin discusses agency life, application development workflow, and mobile application design and development. Around 38 minutes in, he mentions the work I’ve been doing with the Adobe AIR 2.0 beta in regard to NativeProcess and HandBrake CLI.

Super cool! Many thanks to Antonio for the mention!


Have a listen – the mention is about 38 minutes in, but you’ll want to listen to the entire conversation.

I’ve done a few screencasts of the project available at the following blog posts:

Strange ActionScript dispatchEvent / addEventListener Gotcha

I came across a strange situation over the weekend where a custom event being broadcast through dispatchEvent() was not being caught by the registered listener object. To make things even more bizarre, hasEventListener() definitely showed the event as registered, and I could even trace the type out through willTrigger().

Relevant example code is below:

1
2
3
4
5
6
7
8
	private function fileDoesNotExist(e:IOErrorEvent):void {
		textSlide = new TextSlide(data.comment);
		textSlide.addEventListener("slideReady", writeIt);
	}
 
	private function writeIt(e:Event):void {
		// Okay!
	}

After a bunch of experimentation and comparing this structure with similar classes, I found that simply delaying the event dispatcher with a Timer by a few milliseconds resulted in a successful dispatch and capture.

Now, the class transmitting the event is a very simple one that simply has a constructor function that renders some bitmapData from injected data (severely shortened for this example):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package edu.du.image {
	import edu.du.image.ResizeImage;
 
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.utils.Timer;
 
	[Event(name="slideReady", type="flash.events.Event")]
 
	public class TextSlide extends Bitmap {
 
		public function TextSlide(t:String, bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=true){
			super(bitmapData, pixelSnapping, smoothing);
 
			/*
 
			perform a set of processes to render text to bitmapData
			almost all is removed in this example
			you get the idea...
 
			*/
 
			var timer:Timer = new Timer(500, 1);
			timer.addEventListener(TimerEvent.TIMER_COMPLETE, eGo);
			timer.start();
		}
 
		private function eGo(e:TimerEvent):void {
			dispatchEvent(new Event("slideReady"));
		}
	}
}

Putting the Timer delay on there fixes everything. The only thing I can think of is that the constructor function must execute so quickly that the listener on the parent just hasn’t completely registered yet!

One of those things that can drive you nuts and waste hours of time.

Custom Event Reporting from Flash to Google Analytics

Back at Adobe MAX 2009 in Los Angeles, I did a 30 minute presentation for FITC. This is a composite video from a screen recording I did on my presenter laptop merged with the live stream hosted by Influxis.

I’ve been reformatting a lot of the presentations and webinars I’ve done over the past year and plan to host them all on Vimeo, at some point. So here is “Custom Event Reporting from Flash to Google Analytics”:

FITC Unconference at Adobe MAX
Los Angeles, California
October 2009

With the ability to define and report custom events from within your Flash application, you retain control over how specific events are reported and the information contained in these reports. This presentation will cover the implementation of the Google Analytics Tracking For Adobe Flash ActionScript 3 API for generating custom events and emulated page views from within Flash.

BTW: the FITC and Influxis people are really great to work with!

Adobe Creative Suite 5 Global Online Launch Event

Be among the first to see Adobe® Creative Suite® 5. Join the global online launch event on April 12.

With the right tools, your creative horizon changes. A tree is still timber, but suddenly in a whole new way. Old ideas germinate again, and new ideas branch into unexpected opportunities. Welcome to Adobe® Creative Suite® 5—software that will allow you to reach more people, more effectively, in more places, with whatever masterpiece you can imagine.

Join us for the exclusive Global Online Launch Event, Monday, April 12, 2010.

Register now

“DropFolders”: AIR 2.0 NativeProcess w/ HandBrake

DropFolders is an upcoming AIR 2.0 Windows-only (for now) application which allows a user to set up multiple presets consisting of watch folders, destination folders, and specific arguments for use in HandBrake. The app then polls the watch folders for new files, builds an internal processing queue, hands each file off to the embedded HandBrake CLI, and moves the new file into it’s proper home (while cleaning up after itself!) when finished.

The application uses some of the really cool APIs exposed through AIR 2.0, including SQLite databases and most importantly the NativeProcess APIs which allow AIR applications to talk with native processes.

Here is a video demonstrating the application in action running on both desktop and a remote server:

The main reason for building this application was to have it run on a server and allow users to transfer files to an exposed shared folder (the watch folder) and not have to worry about encoding and moving files around. It is obviously written to run on the desktop as well- but in case you’d like to set it up on a server, here is how I went about it:

I’m using a Windows Server, so we’ll be setting up our AIR application to run as a Service. That way, it will continue to run and monitor folders even while no one is logged in.

  1. Download Windows Server 2003 Resource Kit Tools
  2. Install WSRT on your server
  3. Open the command prompt and navigate to where you installed the toolkit
  4. Run instsrv DropFolders "C:\{pathToToolkit}\srvany.exe" to create a Service called “DropFolders “
  5. Add the following to your Registry: Run reg ADD HKLM\SYSTEM\CurrentControlSet\Services\DropFolders\Parameters /v Application /d “C:\Program Files\DropFolders\DropFolders.exe” to point the service to the AIR application
  6. I then went into the Service manager to have the thing run with my credentials. Also be sure that the Service will start automatically. You will have to modify based upon your specific environment.
  7. Create whatever system of watch and destination folders you need
  8. Create access to these watch folders through Network Shares or FTP or whatever
  9. Fire up DropFolders and set up your various presets
  10. Close DropFolders, start the Service, and logout
  11. All set!

Once again though; you don’t need to do any of this if running as a normal desktop application. Just install and use.

I’ll be releasing the application onto the AIR Marketplace as soon as AIR 2.0 final goes public.