1 Reply Latest reply on Sep 10, 2009 9:54 AM by Gregory Lafrance

    Require Help

    MandrakeC

      Hi,


      I am new to using Flex so I have a few questions that if anyone could answer that would be great!

       

      I have two mxml files one.mxml and two.mxml.

       

      one.mxml file has one text input and a button.After entering the text in text box and clicking the button ..i need to navigate to two.mxml.Also entered text should be displayed in a textbox in two.mxml.

       

       

      Can anybody help me with sample code how can i do this ???

       

      Thanks in Advance

        • 1. Re: Require Help
          Gregory Lafrance Level 6

          This code should answer your question:

           

          ----- main app -----

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            xmlns:comp="*">
            <mx:ViewStack id="vs" creationPolicy="all">
              <comp:one id="comp1"/>
              <comp:two id="comp2"/>  
            </mx:ViewStack>
          </mx:Application>

           

          ----- one.mxml -----

          <?xml version="1.0" encoding="utf-8"?>
          <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="70">
            <mx:Script>
              <![CDATA[
               import mx.core.Application;
                private function buttonClickHandler():void{
                  mx.core.Application.application.comp2.txt2.text = txt1.text;
                  mx.core.Application.application.vs.selectedIndex=1;
                }
              ]]>
            </mx:Script>
            <mx:HBox>
              <mx:Label text="txt1: "/>
              <mx:TextInput id="txt1"/>
            </mx:HBox>
            <mx:Button label="Send to Txt2" click="buttonClickHandler();"/>
          </mx:VBox>
          

          ----- two.mxml -----

          <?xml version="1.0" encoding="utf-8"?>
          <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="70">
            <mx:HBox>
              <mx:Label text="txt2: "/>
              <mx:TextInput id="txt2"/>
            </mx:HBox>
          </mx:VBox>

           

          If this post answered your question or helped, please mark it as such.