6 Replies Latest reply on Jul 8, 2011 10:33 AM by lingo55

    Newbie question about text size

    lingo55

      Hi all, I am verrrrry new to Flex, just a few days using it.


      I am trying to build and application to let people design businesscards online.
      I am using FB 4.

       

      I have managed to create text inside editable rich text fields that can be dragged and the content can be edited by the user.
      The problem is I want the users to be able to change the font size of text containes in those fields using a slider.
      I have managed to use a slider to change the size of a logo in my app...but I can't figure out how to do that with text,
      Please help.
        • 1. Re: Newbie question about text size
          kokorito Level 4


          try using  myEditableRichText.textFlow.fontSize =

          • 2. Re: Newbie question about text size
            lingo55 Level 1

            thanks kokorito, but can I use that with a slider?. I am very new to Flex and I don't really know how to do it.

            Could you give me a code example using a slider?

            Thanks

            • 3. Re: Newbie question about text size
              lingo55 Level 1

              OK, I have created a slider like this:

               

              <s:HSlider
              x="700"
              y="253"
              change="MyName.textFlow.fontSize = 14"
              value="24"
              stepSize="2"
              maximum="24"
              minimum="14"
              id="resizeMyName"/>

               

              What this does is to reduce the size of the text to size 14 (no intermediate sizes) an it doesn't increase it back to 24 when I move the slider up.

              Any ideas?

              • 4. Re: Newbie question about text size
                kokorito Level 4

                add a change event to the slider, and in the handler set the fontsize for the richtext

                 

                you'll need to mess with max min and step values but something like this should work

                 

                 

                 

                 

                protected function slider_changeHandler(event:Event):void

                {
                               
                     rt.textFlow.fontSize = slider.value;
                }

                 

                 

                 

                <s:VSlider id="slider" x="547" y="217" height="190" maximum="36" value="2" change="slider_changeHandler(event)"/>

                 

                <s:RichEditableText id="rt" x="55" y="217" width="439" height="190">

                • 5. Re: Newbie question about text size
                  kokorito Level 4

                  OK, here is the whole thing

                   

                   

                  <?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[
                             
                             
                             
                              protected function slider_changeHandler(event:Event):void
                              {
                                  // TODO Auto-generated method stub
                                  rt.textFlow.fontSize = slider.value;
                              }
                             
                          ]]>
                      </fx:Script>
                     
                      <fx:Declarations>
                          <!-- Place non-visual elements (e.g., services, value objects) here -->
                      </fx:Declarations>
                     
                     
                      <s:RichEditableText id="rt" x="34" y="33" width="439" height="190"/>
                      <s:VSlider id="slider" x="521" y="28" height="195" change="slider_changeHandler(event)"
                                 maximum="72" minimum="6" stepSize="1" value="12"/>
                     
                  </s:Application>

                  • 6. Re: Newbie question about text size
                    lingo55 Level 1

                    Thanks so much Kokorito, that worked perfect.