RIA Developer, Flex / Flash, Widgets
Tip of the Day – Creating an AIR application for a kiosk
Today I needed to prototype a chromeless AIR application for use in a kiosk. It’s actually a whole lot easier than I thought it would be.
Here’s a quick example of what you can do with Adobe AIR and FlexMDI.
The cool thing about Adobe AIR is that it can run on Linux. So if I needed to deploy thousands of kiosks I could install Linux on them and save on windows licensing.
Here is the application source:
<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flexmdi="flexlib.mdi.containers.*" layout="absolute" backgroundColor="0x000000" showFlexChrome="false" applicationComplete="onReady()"> <mx:Script> <![CDATA[ import mx.core.UIComponent; import mx.controls.Button; import mx.core.Application; import mx.events.MenuEvent; import flexlib.mdi.containers.MDIWindow; import flash.display.StageDisplayState; import net.natebeck.BrowserWindow; [Bindable] public var ADOBE:String = "Adobe"; // FlexMDI Manager layout types [Bindable] public var TILE:String = "Tile"; [Bindable] public var TILE_FILL:String = "Tile and Fill"; [Bindable] public var CASCADE:String = "Cascade"; // File Menu [Bindable] public var EXIT:String = "Exit"; [Bindable] public var buttons:Array = [] private function onReady():void { // Enter Fullscreen Interactive State stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE; } public function openWindow(event:MenuEvent):void { var location:String = ""; switch(event.label) { case ADOBE: location = "http://www.adobe.com"; break; case CASCADE: mdic.windowManager.cascade(); break; case TILE: mdic.windowManager.tile(false, 10); break; case TILE_FILL: mdic.windowManager.tile(true, 10); break; case EXIT: var exitingEvent:Event = new Event(Event.EXITING, false, true); this.nativeApplication.dispatchEvent(exitingEvent); if (!exitingEvent.isDefaultPrevented()) { this.nativeApplication.exit(); } break; } if(location.length > 0) { var window:BrowserWindow = new BrowserWindow(); mdic.windowManager.add(window); window.title = event.label; window.location = location; window.maximize(); } } ]]> </mx:Script> <mx:ApplicationControlBar dock="true"> <mx:MenuBar id="myMenuBar" labelField="@label" width="100%" height="100%" itemClick="openWindow(event);" > <mx:XMLList> <menuitem label="File" > <menuitem label="Exit"/> </menuitem> <menuitem label="Launch" > <menuitem label="Adobe"/> </menuitem> <menuitem label="Window" > <menuitem label="Tile"/> <menuitem label="Tile and Fill"/> <menuitem label="Cascade"/> </menuitem> </mx:XMLList> </mx:MenuBar> </mx:ApplicationControlBar> <flexmdi:MDICanvas id="mdic" top="10" bottom="10" left="10" right="10"/> </mx:WindowedApplication>
And here is Browser.mxml
<?xml version="1.0" encoding="utf-8"?> <flexmdi:MDIWindow xmlns:flexmdi="flexlib.mdi.containers.*" xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300"> <mx:Script> <![CDATA[ [Bindable] public var location:String = ""; ]]> </mx:Script> <mx:HTML width="100%" height="100%" location="{location}" /> </flexmdi:MDIWindow>
The full application can be downloaded here.
:: Update ::
There seems to a be a little bug in the applicaiton… when you’re rendering HTML with Flash Content within it. It won’t display in StageDisplayState.FULL_SCREEN_INTERACTIVE mode. However, if you hit the ESC key… the flash content will show up. I’ll have to check and see if there is a bug filed on this.
| Print article | This entry was posted by Nate Beck on January 30, 2009 at 11:58 pm, and is filed under Flex, Tip of the day. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |


about 1 year ago
Very cool!
You’re correct, I hit ‘esc’ and the flash loaded. Unfortunately it also resized my window, allowing access to the desktop. I’ll be interested to see your conclusions! Best regards! – Jeremy
about 1 year ago
@Jeremy
Hitting the ‘esc’ key takes you out of the FULL_SCREEN_INTERACTIVE display mode. So the bug seems to be that the HTMLLoader class doesn’t render Flash when in FULL_SCREEN_INTERACTIVE mode.
After searching through the Flex bug system for a bit, I couldn’t find this in the bug system. I created one: https://bugs.adobe.com/jira/browse/SDK-19194
Feel free to vote on and watch it.
about 1 year ago
Nate,
Did you find a way around this problem?
I looked at the bug report, and it has been closed but is still unresolved?…
Cheers
about 1 year ago
The problem with Flash rendering in FULL_SCREEN_INTERACTIVE was fixed in Adobe AIR 1.5. I have verified, and it indeed has been fixed.
about 1 year ago
I’ve checked and I have the latest AIR installed so not sure what’s going on. Tried your app above and works great until its told to go tranparent.
Back to the drawing board…
Thanks,
Paul
about 1 year ago
Hey Paul,
What are you trying to turn transparent… the application or the HTML control?
about 8 months ago
Nothing Your App Will Not Show Flash In Full Screen Interactive I Also Have Latest Adobe Air And Have Been Following This Thread And App For Quite Some Time With This Bug, And Supposedly It Was Fixed But I Have Never Seen Any Difference In Full Screen Interactive Even With The Default Adobe Air Link Flash Will Not Load Either
about 8 months ago
Regarding The Above I Have Found That You NEED TO INSTALL The Latest SDK Also For The Full Screen Interactive Flash To Render As You May Still Be Compiling On Old 1.5 SDK L:ike I Was Even Tho The Client Has 1.5.2 Didnt Make A Difference
about 8 months ago
@Rick
I’m not sure what you are doing wrong I just built out the AIR application from above using Flash Builder 4 and the Flex SDK 3.4. It works exactly how I described with no trouble.
Here is the fxp export from FlashBuilder. Just do File > Import > Flash Builder Project
about 1 month ago
@Nate
Hi, I was looking around for some examples on flex MDI and came across your blog. The full application download link seems to be broken.
I tried manually on my side and ge tthis error:
Error: Unable to locate specified base class ‘flexlib.mdi.containers.MDIWindow’ for component class ‘browser’
Can anyone guide me here what i’m doing wrong here as I am newbie
about 1 month ago
by the way, im working on the new licensed version of flex 4 premium.
about 1 month ago
Hey Ross, I fixed the download link.
You need to make sure that Flex MDI is in your project’s source path. The easiest way is to put the FlexMDI swc in your project’s “libs” directory.
For more information on the libs directory, check out this tip. Using the libs directory in Flex Builder.
about 3 weeks ago
Thanks, the link works. I resolved the flexlib library by placing the flexlib.swc in the “libs” directory. But then I encounter this problem on compiling…
File not found: file:/Users/Ross/Documents/Adobe%20Flash%20Builder%204/KatMDI/bin-debug/KioskTest.html
Seems that KioskTest.html file is not found here, what could have gone wrong?
Also, please correct me here. I did some research over the web and understood that flexlib is the advanced version of flexmdi? Most of the code development happens in flexlib as the new version of flex2.5 was released couple of months back.
Here is the link
http://groups.google.com/group/flexlib/browse_thread/thread/2364c60d2c2209d9?pli=1
about 3 weeks ago
I compiled again with this main BrowserWindow.mxml file (previous one was wrong ) but still the same problem.
File not found: file:/Users/Ross/Documents/Adobe%20Flash%20Builder%204/KatMDI/bin-debug/BrowserWindow.html
about 3 weeks ago
Hey Ross,
It sounds like the html file isn’t being generated. Maybe your project isn’t setup properly? Try deleting the project and then rebuilding it.
Also you can double check that your application is set to build the html files by right clicking on the project, going to Properties > Flex Compiler, and making sure that “Generate HTML Wrapper file” is checked.