tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/666-robotlegs-with-flexnativeeventRobotlegs: Discussion 2012-01-05T13:11:57Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/101144102011-09-21T17:24:05Z2011-09-21T17:24:05ZRobotlegs with FlexNativeEvent<div><p>Hi face1,</p>
<p>This works:</p>
<p><strong>In your Context:</strong>
mediatorMap.mapView(SomeNativeMenuView,
SomeNativeMenuMediator);</p>
<p><strong>SomeNativeMenuView</strong> is <s:Group<br>
having a <s:Button id="openMenu"</p>
<p>The script:</p>
<pre>
<code>
import mx.collections.ArrayCollection;
import mx.controls.FlexNativeMenu;
private var someNativeMenu:FlexNativeMenu;
public function setMenuDataProvider(dataProvider:ArrayCollection):void
{
someNativeMenu=new FlexNativeMenu();
someNativeMenu.dataProvider=dataProvider;
someNativeMenu.labelField="label";
someNativeMenu.showRoot=false;
someNativeMenu.setContextMenu(openMenu);
}</code>
</pre>
<p><strong>SomeNativeMenuMediator</strong></p>
<pre>
<code>
import org.robotlegs.mvcs.Mediator;
public class SomeNativeMenuMediator extends Mediator
{
public function SomeNativeMenuMediator()
{
}
[Inject]
public var view:SomeNativeMenuView;
override public function onRegister():void
{
eventMap.mapListener(eventDispatcher, SomeServiceEvent.DATA_RECEIVED, onDataReceived);
}
protected function onDataReceived(event:SomeServiceEvent):void
{
view.setMenuDataProvider(event.someData);
}
}</code>
</pre>
<p>Try it and tell if it helps:)</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/101144102011-09-22T18:02:53Z2011-09-22T18:04:14ZRobotlegs with FlexNativeEvent<div><p>You can not create a custom MXML component based on
FlexNativeMenu, if that’s what’s confusing you. It
isn’t a Robotlegs issue, but rather a Flex/AIR one:)<br>
If you don’t want to create a component as in my previous
example, then<br>
you can use the WindowedApplication (your ContextView) to hold
the</p>
<p><s:menu></p>
<pre>
<code> <mx:FlexNativeMenu id="someNativeMenu"/></code>
</pre>
<p></s:menu></p>
<p>and create a mediator for the ContextView, which will then set
the dataProvider as in my example from the previous post.</p>
<p>The method in the ContextView would be like this.</p>
<pre>
<code>
public function setMenuDataProvider(dataProvider:ArrayCollection):void
{
someNativeMenu.dataProvider=dataProvider;
someNativeMenu.labelField="name";
someNativeMenu.showRoot=false;
someNativeMenu.setContextMenu(this);
}</code>
</pre>
<p>HTH</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/101144102011-09-26T11:15:20Z2011-09-26T11:15:20ZRobotlegs with FlexNativeEvent<div><p>Ondina - thank you for your help - I will try your suggestions
and get back soon.</p></div>face1tag:robotlegs.tenderapp.com,2009-10-18:Comment/101144102011-11-16T09:23:53Z2011-11-16T09:23:53ZRobotlegs with FlexNativeEvent<div><p>Hi face1,<br>
Feel free to reopen this discussion in case you have more questions
or you need further assistance with this issue. Please open new
threads for new issues.<br>
Thank you for posting.<br>
Ondina</p></div>Ondina D.F.