0

我有一个 main.mxml,它具有如下所示的登录按钮 -

                     <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            backgroundColor="#C4D4EF" layout="absolute">

         <mx:HTTPService id="serverCall" method="POST"  
                url="http://localhost:8080/LDAPService/reg" 
                result="on_Result(event)" fault="on_Fault(event)"        
                 />
            <mx:Script>
    <![CDATA[    
        private function on_Result(event:ResultEvent):void {
        // How to write here
        }

    ]]>
</mx:Script> 
<mx:Panel x="414" y="145" width="355" height="200" layout="absolute"
    <mx:Button x="142" y="115" label="Login" id="callToServer"  
            click="send_data(event)"/>                    
</mx:Panel>

</mx:Application>

现在我想调用如下所示的 second.mxml 文件 -

                     <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
            xmlns="*" creationComplete="iFrame.visible=true"  
                  viewSourceURL="srcview/index.html"> 

            <mx:HBox width="100%" height="100%">

           <mx:Panel title="/ Company Home" width="200" height="100%" >
                 </mx:Panel>

     <mx:Panel width="100%" height="100%" title="Ticket Details" paddingTop="1" >
        <IFrame id="iFrame" source="some service call url" width="100%" height="100%"  />
        <mx:ControlBar>
            <mx:CheckBox id="cbVisible" label="IFrame Visible" selected="true" 
         click="iFrame.visible=cbVisible.selected"/>
        </mx:ControlBar>
         </mx:Panel>

         </mx:HBox>



       </mx:Application>

如何从 main.mxml 调用 second.mxml?请指教,谢谢您的帮助!

4

1 回答 1

0

好的,这个例子在 flex 4 中!它使用 spark 而不是 mx 这显示了状态的基础。您可以在此处阅读更多内容:http ://www.artima.com/articles/flex_4_states.html 这篇文章展示了 flex3 和 flex4 状态之间的区别 这只是一个开始。希望这对您有所帮助。

<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark" >
    <fx:Script ><![CDATA[
        import mx.rpc.events.ResultEvent;

        <![CDATA[
        private function on_Result( event:ResultEvent ):void
        {
            currentState = "result";
        }

            ]]>
        ]]>
    </fx:Script >

    <fx:Declarations >
        <s:HTTPService id="serverCall"
                       url="http://localhost:8080/LDAPService/reg"
                       useProxy="false"
                       method="POST"
                       result="on_Result(event)" >

        </s:HTTPService >
    </fx:Declarations >

    <s:states >
        <s:State name="init" />
        <s:State name="result" />
    </s:states >

    <s:Panel x="414"
             y="145"
             width="355"
             height="200" >
        <s:Button x="142"
                  y="115"
                  label="Login"
                  id="callToServer"
                  includeIn="init"
                  click="serverCall.send()" />
    </s:Panel >

    <s:Panel title="/ Company Home"
             width="200"
             height="100%"
             includeIn="result" >
    </s:Panel >

    <s:Panel width="100%"
             height="100%"
             includeIn="result"
             title="Ticket Details" >

        .... your stuff
    </s:Panel >


</s:Application >
于 2013-05-29T13:52:07.097 回答