2 Replies Latest reply on Jul 19, 2010 4:48 AM by ThiagoRS

    How to change a label in a Element

    ThiagoRS

      Hello There

       

           I'm trying to change tha label of a button from an AS file. The problem is that I won't know the "id" of the button.

       

      ----------------------------

      product.xml

      ...

      <s:controlBarContent>
      <s:NavigatorContent width="100%" height="100%" >
        <mx:HBox width="589" id="nav_name">
         <s:Button name="name4" id="trad_4" label="teste" click="button1_clickHandler(event)"/>
         <s:Button name="name1" id="trad_1" label="Adicionar" click="funcaoAtualizaDatabase('adicionar')"/>
         <s:Button name="name2" id="trad_2" label="Salvar" click="funcaoAtualizaDatabase('salvar')"/>
         <s:Button name="name3" id="trad_3" label="Excluir" click="funcaoAtualizaDatabase('excluir')"/>
        </mx:HBox>   
      </s:NavigatorContent>
      </s:controlBarContent>

      ...

      ----------------------------

       

      in AS. I can get the number of elements

      const len:uint = nav_name.numElements;

       

      and also the id of this element

      var lObj:Object = nav_name.getElementAt(1);
      Alert.show(lObj.toString());

       

      Does anybody know how can I change the label of this nav_name.getElementAt(1); ?

       

      thanks and best regard

       

      Thiago

        • 1. Re: How to change a label in a Element
          BhaskerChari Level 4

          Hi ThiagoRS,

           

          const len:uint = nav_name.numElements;

           

          var lObj:Button = nav_name.getElementAt(1) as Button;

           

          lObj.label = "new label";

           

          Note: I hope the line of code nav_name.getElementAt(1) gives you a reference to the Button you are trying to change the label...

           

           

          If this post answers your question or helps, please kindly mark it as such.


          Thanks,

          Bhasker Chari

          • 2. Re: How to change a label in a Element
            ThiagoRS Level 1

            Hi Bhasker

             

               Thank you very much for your help, I already try this as well, and eclipse and it says:

             

            Não é possível resolver sem ambigüidade uma referência com vários nomes. spark.components:Button (de C:\Program Files\Adobe\Adobe Flash Builder 4 Plug-in\sdks\4.0.0\frameworks\libs\spark.swc(spark.components:Button)) e mx.controls:Button (de C:\Program Files\Adobe\Adobe Flash Builder 4 Plug-in\sdks\4.0.0\frameworks\libs\framework.swc(mx.controls:Button)) estão disponíveis.    produto_cadastro.mxml    Jaspion_maia9/src    Unknown    Flex Problem

             

             

            translating is something like:

            Can not  resolve unambiguously a reference with multiple names. spark.components:Button (de C:\Program Files\Adobe\Adobe Flash Builder 4  Plug-in\sdks\4.0.0\frameworks\libs\spark.swc(spark.components:Button)) and  mx.controls:Button (de C:\Program Files\Adobe\Adobe Flash Builder 4  Plug-in\sdks\4.0.0\frameworks\libs\framework.swc(mx.controls:Button)) are avaiable. produto_cadastro.mxml    Jaspion_maia9/src    Unknown    Flex Problem

             

            thanks and best regards

             

            Thiago