6 Replies Latest reply on Sep 14, 2010 3:09 AM by Arun Ganesh

    how to get the status of the button?

    pad_birk

      i want to know how to get the clicked status of the button? whether it is in clicked state or in unclicked state?

       

       

      For ex: i have the following code...

       

      <components:IconButton id="bold_btn" width="22" icon="@Embed('/assets/bold.png')" click="onBoldClick()" enabled="{this.loadCompleted}" toggle="true"/>

       

      how to find whether the bold button is clicked or not?

       

      this.bold_btn.????

        • 1. Re: how to get the status of the button?
          BhaskerChari Level 4

          Hi Isa,

           

          You can make use of a Boolean variable to acheive this functionlaity...check out the below simple example...

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                  layout="vertical"
                  verticalAlign="middle"
                  backgroundColor="white" width="100%">

              <mx:Script>
                  <![CDATA[
                   import mx.controls.Alert;
                   private var isBtnToggle:Boolean = false;
                  
                   private function onButtonClick():void
             {
              isBtnToggle = !isBtnToggle;
              
              if(isBtnToggle)
              {
               btnToggle.label = "I am Toggled ON";
               Alert.show("Button is Toggled ON");
              }
              else
              {
               btnToggle.label = "I am Toggled OFF";
               Alert.show("Button is Toggled OFF");
              }
             
             }
                  ]]>
              </mx:Script>

              <mx:Button id="btnToggle" label="I am Toggled OFF" toggle="true" click="onButtonClick()" />

          </mx:Application>

           

           

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


          Thanks,

          Bhasker Chari

          • 2. Re: how to get the status of the button?
            Arun Ganesh Level 3

            Hi,

            You can get it easily. Make sure that button's toggle property is set to true.

             

            You can get the clicked state,

            buttonInstanceId.selected -> it will return the boolean value

             

            Hope this will solve your problem

            1 person found this helpful
            • 3. Re: how to get the status of the button?
              pad_birk Level 1

              Thanks

               

              It worked

               

              Regards,

              Lakshmi

              • 4. Re: how to get the status of the button?
                Arun Ganesh Level 3

                Kindly mark it


                • 5. Re: How to access the components of one mxml to another mxml?
                  pad_birk Level 1

                  Hi,

                   

                  I have a component named storylist as below in StoryList.mxml

                   

                  <mx:List id="storyList" width="100%" dataProvider="{this.currentDoc.stories}" height="100%" variableRowHeight="true" selectable="false" borderStyle="none"

                  itemRenderer="com.xxx.yyy.core.views.renderers.StoryRenderer">

                  </mx:List>

                   

                  I want to access the storylist in another mxml CoreCanvas.mxml

                   

                   

                  private function onOpenFile (doc:IdmlDocument):void {

                  logger.info("onOpenFile");

                  this.editor.currentDoc = doc;

                  this.editor.storyList.dataProvider = this.editor.currentDoc.stories;

                   

                   

                  }

                   

                  but when  i declared as a bindable variable in StoryList.mxml --> [Bindable] public var storyList:IdmlStory = null;

                   

                  it gives an error

                   

                  Description Resource Path Location Type

                  1151: A conflict exists with definition storyList in namespace internal. StoryList.mxml /WebEditorCore/src/com/xxx/yyy/core/views/editor line 10 Flex Problem

                   

                  how can i access storylist in the other mxml file?

                   

                  Message was edited by: Jochem van Dieten

                  • 6. Re: How to access the components of one mxml to another mxml?
                    Arun Ganesh Level 3

                    Where u add the StyleList component?

                     

                    Send the tag here