2011-07-06 36 views
2

朋友导航到新的视图。 我正在开发一个flex移动应用程序。我已经声明了一个标题窗口,其中包含“TourdeFlex”示例之后的警报消息。点击YES按钮后,我无法导航到新的视图。点击使用flex

<fx:Script> 
    <![CDATA[ 
      protected function some_handler():void 
      { 
       (new AlertMsg()).open(this,false); 
      } 
    ]]> 
</fx:Script>   
    <fx:Declarations> 
    <fx:Component className="AlertMsg"> 
     <s:SkinnablePopUpContainer x="70" y="300"> 


      <s:TitleWindow title="MSG" close="close()"> 
       <s:VGroup horizontalAlign="center" paddingTop="8" paddingBottom="8" paddingLeft="8" paddingRight="8" gap="5" width="100%"> 
        <s:Label text="Some Alert MSG"/> 
        <s:HGroup> 
         <s:Button label="YES" click="{outerDocument.navigator.pushView(myNewView)}"/> 
         <s:Button label="No" click="close()"/> 
        </s:HGroup> 

       </s:VGroup> 
      </s:TitleWindow> 
     </s:SkinnablePopUpContainer> 
    </fx:Component> 

</fx:Declarations> 

该代码可以编译成功,但它是在运行时错误:错误#1009:无法访问空对象引用的属性或方法。 我该如何处理这类问题。

回答

3

outerDocument为空。尝试owner

click="(owner as spark.components.View).navigator.pushView(myNewView)" 
+2

@ user822222,这肯定是答案,不过,我会考虑把ALERTMSG到它自己的文件,并使用事件与打开它的父母进行沟通。这样你的代码就可以重用了。 –