All entries for Friday 06 March 2009

March 06, 2009

Automating web workflow in Adobe AIR

This entry was created using an AIR based browser.

Yes, it's possible. I wrote a simple AIR app that signs me in to Warwick Blogs by loading the login page into an AIR app, populating the login form fields, and submitting. It's also possible to call javascript methods in the page. Here's the code:

<mx:WindowedApplication xmlns:mx="" layout="absolute" width="1024" height="768">

			import mx.controls.Alert;
			private var domWindow:Object;
			private var blnAlertThrown:Boolean = false;
			private var load:int = 0;
	        private function initDomWindow(event:Event):void {
			if(load == 0)
	        domWindow = event.currentTarget.domWindow;
        	getElementFromHTML("userName").value = "myusername";
        	getElementFromHTML("password").value = "mypassword";

	        private function getElementFromHTML(elementName:String):Object {
				var arrayContainingAllFoundElements:Object = domWindow.document.getElementsByName(elementName);
				return arrayContainingAllFoundElements[0];	

<mx:HTML id="htmlTranslate" x="10" y="84" location=";newPermissions=Anyone&amp;newCommentPermissions=Anyone" complete="initDomWindow(event)"/>