June 9th, 2010
Hi, we started making one of the our largest AIR projects with Flex SDK 3.5 version, but we had some problem while scrolling for example with mouse wheel or even more serious bug like: sometimes while resizing window or changing size of some block during runtime(for example HDivideBox) , application stops respond for any user action and we were seeing a wheel of death. I did not remember exactly why, but tried to compile application with Flex SDK 4, and some bugs are gone. So I recommend you to use Flex SDK 4 with compile option ” -compatibility-version=3.0″, you should use compatible mode with version three to compile your old projects with Flex SDK 4, as version 4 has some new architect structure and you wont wanna fix whole code by hands to make it works with Flex SDK 4.
February 21st, 2010
Hi, yesterday I was looking for fast answer on question “Can I have sub-menu for context menu in my adobe AIR application ?” Could not fast quick answer on 1st google page, with code example or explanation. It’s can be confusing cause actually Flex Web-based application can not implement context sub-menu, but in AIR application you can and it’s very simple! So I hope this post will be displayed on google 1st page when somebody will type similar question above.
So how to make it ?
First we need create our context menu:
var myContextMenu:ContextMenu = new ContextMenu();
Make our application use this contex menu:
this.contextMenu = myContextMenu;
Then we need to add some menu items for it:
var menuItem1:ContextMenuItem = new ContextMenuItem('Menu 1');
var menuItem2:ContextMenuItem = new ContextMenuItem('Menu 12);
Now will assign this items to our context menu:
// we should assign array of items to customItems property of the context menu
myContextMenu.customItems = [menuItem1, menuItem2 ];
For now you’ll see context menu consists from two items on right click. Now we will add nested sub-menu.
Again we need to create context menu with items:
var subMenuItem1:ContextMenuItem = new ContextMenuItem('Sub-Menu 1');
var myContextSubMenu:ContextMenu = new ContextMenu();
myContextSubMenu.customItems = [subMenuItem1];
And now magic line that will assign our context sub-menu to one of main context-menu items:
menuItem1.submenu = myContextSubMenu;
So all about this property submenu that enable for AIR but not for Flex.
Btw to run some action when click for some menu item you can use code below:
subMenuItem1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemClick);
private function menuItemClick(event:Event):void{
Alert.show('TADA');
}
You can download simple source code.