Adobe Flex Flash developer blog

Adventures of a Flex developer

Flash builder burrito Andorid Menu Buttons Items

Friday 18 February 2011 by jonnysparkplugs

If you have been using Flash Builder burrito you may have noticed that currently there is no support for the native menu system available to Java Android apps. I expect this is something that will be included in the final release of the up coming Flash Builder.

I have created a temporarily work around which seems to work quite nicely until an update is available. You must listen manually for the Menu hardware key press in your app.


 <s:MobileApplication   
      xmlns:fx="http://ns.adobe.com/mxml/2009"   
      xmlns:s="library://ns.adobe.com/flex/spark"  
      applicationComplete="init()">            
      <fx:Script>  
           <![CDATA[  
                protected function init():void {  
                     NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);  
                }  
                private function keyDown(e:KeyboardEvent):void {  
                     if(e.keyCode == Keyboard.MENU) {  
                          trace("Handle Menu button"); 
                     }  
                }                 
           ]]>  
      </fx:Script>  
 </s:MobileApplication>  


Once you have received your menu event you can handle it however you like. I have created a gingerbread styled menu which you can use in your own apps. See below:





You can view a normal Flash example here where the source code is available here or view the context menu

Filed under having  

0 comments:

Post a Comment