2 Replies Latest reply on Nov 1, 2012 5:15 PM by havefreetime

    How can I access object of NavigatorContent's child?

    havefreetime Level 1

      111.png

      Hi, All.

       

      In this code, how can I access object 'lbl'?

       

      I'm very new to flex. Please help me.

       

      Thanks in advanced, and sorry for my English.

       

      Kevin.

        • 1. Re: How can I access object of NavigatorContent's child?
          Atul(Flex Dev) Level 1

          Hi,

          Pls use following code to access object

           

          <?xml version="1.0" encoding="utf-8"?>

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                xmlns:s="library://ns.adobe.com/flex/spark"

                xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

           

          <fx:Script>

            <![CDATA[

             import mx.controls.Alert;

             import mx.controls.Label;

            

             import spark.components.NavigatorContent;

             private var num:Number=1

             private function perform():void

             {

                 var nav:NavigatorContent=new NavigatorContent();

              var lbl:Label=new Label();

              lbl.text=num.toString();

              num++;

              nav.addElement(lbl);

              myTab.addChild(nav);

             }

             private function changeText():void{

              for(var i:int=0; i<myTab.numElements; i++){

               var navContent:NavigatorContent = NavigatorContent(myTab.getElementAt(i));

               for(var i:int=0; i<navContent.numElements; i++){

                  navContent.getElementAt(i)

                 Alert.show(""+navContent.getElementAt(i))  ;

               }

              }

             

             }

            ]]>

          </fx:Script>

           

          <fx:Declarations>

            <!-- Place non-visual elements (e.g., services, value objects) here -->

          </fx:Declarations>

          <s:VGroup>

            <mx:TabNavigator x="57" y="21" width="346" height="335" id="myTab">

            

            </mx:TabNavigator>

            <s:Button x="75" y="370" label="Button" click="perform()"/>

            <s:Button x="174" y="370" label="Button" click="changeText()"/>

          </s:VGroup>

          </s:Application>

           

          Thanks,

          Atul(atagrawal@infocepts.com)

          • 2. Re: How can I access object of NavigatorContent's child?
            havefreetime Level 1

            Thank you very much.  Atul.

             

            Finally I solved the problem.

             

            I use this code.

             

            val label:Label;

             

            for(var i:int=0; i<selectedChild.numElements; i++)

            {

                  label = selectedChild.getElementAt(i) as Label;

            }

             

            Thanks again.

             

            Kevin.