returnObject does not return anything
I'm working with the latest SDK 4.5.0.20967. I worked before with the SDK Hero. Everything is working fine but I have a problem with my returndObject. That's the only thing that isn't working.
So I have a page where I make my returnObject:
override public function createReturnObject():Object
{
return m_parameters;
}
When I debug I see that my navigator.poppedViewReturnedObject = null.
var poppedViewReturnedObject:ViewReturnObject = navigator.poppedViewReturnedObject;
Does anybody knows what I'm doing wrong or has a solution?
Kin开发者_如何学Pythond regards,
Thibault Heylen
poppedViewReturnedObject is available only in the addHandler of the view which originally pushed your new view containing the overriden createReturnObject method.
When will poppedViewReturnedObject be available, i.e., not null? When popview() is invoked of course.
If you try to access poppedViewReturnedObject in other circumstances, for instance in a viewActivated handler, it will be null.
Code sample:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
add="addHandler(event)"
viewActivate="viewActivateHandler(event)"
>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import spark.events.ViewNavigatorEvent;
protected function addHandler(event:FlexEvent):void
{
if (navigator.poppedViewReturnedObject==null){
// do something
var poppedViewReturnedObject:ViewReturnObject = navigator.poppedViewReturnedObject;
}
}
protected function viewActivateHandler(event:ViewNavigatorEvent):void
{
// here , navigator.poppedViewReturnedObject is null
}
]]>
</fx:Script>
You have to initialize your ViewReturnObject in the add initializer. Then it works
精彩评论