如何调用从动作脚本MXML应用程序(how to call mxml application fro

2019-11-02 04:23发布

我有一个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>

我怎么能叫second.mxml从main.mxml? 请指教,感谢您的帮助!

Answer 1:

OK这个例子是Flex 4中! 它采用火花,而不是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 >


文章来源: how to call mxml application from action script