Domanda

I've one main.mxml which has login button which looks like below -

                     <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>

Now I want to call second.mxml file which looks like below -

                     <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>

How can I call second.mxml from main.mxml? Please advice, Thanks for your help!

È stato utile?

Soluzione

OK this example is in flex 4! it uses spark instead of mx This shows the basics of states. You can read more here: http://www.artima.com/articles/flex_4_states.html This article shows the difference between flex3 and flex4 states This is only a start. Hope this helps you.

<?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 >
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top