如何从动作脚本中调用mxml应用程序

时间:2013-05-29 06:45:04

标签: actionscript-3 flex adobe mxml flexbuilder

我有一个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?请指教,谢谢你的帮助!

1 个答案:

答案 0 :(得分: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 >