4 Replies Latest reply on Aug 10, 2010 1:43 PM by dougieweb

    Text as "buttons?"

    dougieweb

      In Flash you can turn text into Movieclips, then attach event listeners and functions like you can with Flex Buttons in Flex.  But can you do that with text in Flex?  My purpose for asking is that I rarely like the way Flex buttons look and need to remove all the lines and background color/shading from the buttons and I have not found an easy way to do that.  Can text blocks have events associated with them?

       

      Thanks,

      Doug

        • 1. Re: Text as "buttons?"
          mike_morales Level 2

          Yup, they have mouse events (along with others). In fact, in flex, you can even send events inline with the component - something like

           

          <mx:Text click="YOUR EVENT HANDLER" text="your text here"/>

           

           

          use code hinting in flex - it is a life saver!  A great/quick way to see all the common events associated with a component is to hit ctr-space when your cursor is within a component's tag, if you continue to hit ctr+space, you will filter by all the properties, events, methods etc.  (all events have the lighting bolt-looking icon)

           

          Mike

          • 2. Re: Text as "buttons?"
            Flex harUI Adobe Employee

            The recommended practice is to skin the button.

            1 person found this helpful
            • 3. Re: Text as "buttons?"
              ShardulSingh Level 3

              Hi,

               

              You have multiple ways for acheving your requirement.You can style buttons. Use Link button, image or label for the same purpose.

              But still if you want to use the text then it can be used as below. Let me know if you have any issue.

               

               

               

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
                  <mx:Script>
                      <![CDATA[
                          import mx.controls.Alert;
                          private function onTextClick():void
                          {
                              Alert.show("You clicked text.");
                          }
                      ]]>
                  </mx:Script>
                  <mx:Text text="Your Text" click="onTextClick()" buttonMode="true"
                      mouseChildren="false" useHandCursor="true" selectable="false"/>
                 
              </mx:Application>

               

               

               

               

               

               

               

              with Regards,

               

              Shardul Singh Bartwal

              1 person found this helpful
              • 4. Re: Text as "buttons?"
                dougieweb Level 1

                Wow!  I'll give it a try.

                Thanks.