0

I an using the Robotlegs framework and I am busy with an AIR desktop application and I want to use FlexNativeMenu. THe problem is that I am not able to create a view class based on mx.controls.FlexNativeMenu for dependency injection. When not using Robotlegs the code is pretty straightforward - any help will be appreciated. Thanks.

2 Answers2

1

generally you can use whatever you want to a view. The problem is that the mediator's onRegister method will be called only if your view dispatches ADDED_TO_STAGE event. And because FlexNativeMenu doesn't fire this event your mediator is not working (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/FlexNativeMenu.html#eventSummary)

Krasimir
  • 13,306
  • 3
  • 40
  • 55
0

for RobotLegs v2

If you're trying to inject into the FlexNativeMenu (hereinafter referred to FNM), you can try something like this (I'd do this in your IConfig implementor):

injector.injectInto( fnmInstance );

If you are trying to inject an instance of FNM (say in it's mediator):

[Inject]
public var view:MyFNMClass;

If you are trying to attach a mediator to the FNM instance you do something like this in your IConfig implementor:

//requires that you map the FNM (assuming you're subclassing it)
mediatorMap.map( MyFNMClass ).toMediator( MyFNMClassMediator );

//else where where you decide to wire it up
mediatorMap.mediate( fnmInstance );

The "gotcha" is this: There isn't a very pretty way to access the FNM prior to injection. I grabbed it like so:

//very nasty I know
var fnm:MyFlexNativeMenu = FlexGlobals.topLevelApplication.myMenu;

code

Made a git repo - https://github.com/jusopi/RobotLegs-v2-FlexNativeMenu-example

jusopi
  • 6,791
  • 2
  • 33
  • 44