5 Replies Latest reply on Sep 18, 2010 2:14 AM by Arun Ganesh

    Blinking Text possible?

    vunnikri

      Hi,

       

      I work on a product which uses Flex as the UI and Java and Unix at the backend.

       

      This is my curent problem.

       

      In the UI, i am using a textarea control to receive the logs from java.

       

      <

      <mx:TextArea id="recoveryLog" htmlText="{parentApplication.model.request.log}" width="100%" height="100%" editable="false" />

      </mx:Canvas>

      mx:Canvas label="Log" width="100%" height="100%">

       

      I have changed the textArea property to htmlText, and am thus able to display basic html controls like font and bold as shown below.

       

      sb.append(

      "<b><font color=\"#FF0000\">\n Error : " + command.getError() + "</font></b>" );

       

      (this is to display the errors in the log in bold Red Font)

       

      Is there anyway to get the text to blink? the html <blink> tag does not seem to be of any help.

       

      I've been searching a lot of flex discussions, but to no good result.

       

      Any help appreciated.

       

      P.S. Thanx in Advance!

        • 1. Re: Blinking Text possible?
          John Hall Level 4

          Looks like you might be using Flex 3 with the mx controls so maybe something along the lines of the following:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                          layout="absolute"
                          width="400"
                          height="300">

           

              <mx:Script>
                  <![CDATA[
                      private var timer : Timer;

           

                      protected function myButton_clickHandler( event : MouseEvent ) : void {
                          timer = new Timer( 500, 4 );
                          timer.addEventListener( TimerEvent.TIMER, toggleMessage );
                          timer.addEventListener( TimerEvent.TIMER_COMPLETE, removeListeners );
                          timer.start();

           

                      }

           

                      private function toggleMessage( e : TimerEvent ) : void {
                          recoveryLog.visible = !recoveryLog.visible;
                      }

           

                      private function removeListeners( e : TimerEvent ) : void {
                          timer.removeEventListener( TimerEvent.TIMER, toggleMessage );
                          timer.removeEventListener( TimerEvent.TIMER_COMPLETE, removeListeners );
                      }
                  ]]>
              </mx:Script>

           

              <mx:Canvas x="0"
                         y="0"
                         width="100%"
                         height="100%">
                  <mx:TextArea id="recoveryLog"
                               htmlText="Sample text for demo"
                               y="69"
                               horizontalCenter="0"
                               backgroundAlpha="0.0"
                               borderThickness="0"
                               fontSize="14"
                               textAlign="center"/>
                  <mx:Button y="131"
                             id="myButton"
                             label="Blink"
                             horizontalCenter="0"
                             click="myButton_clickHandler(event)"/>
              </mx:Canvas>

           

          </mx:Application>

          • 2. Re: Blinking Text possible?
            vunnikri Level 1

            Hi John,

             

            Thanx for the fast response.

             

            This seems to be a solution for getting the mx:control to blink, however (sadly) that is not my concern.

             

            I need a part of the text insile the textarea to blink, and not the whole thing

             

            See if you can crack that

            • 3. Re: Blinking Text possible?
              John Hall Level 4

              Whoops. Sorry that I misunderstood. Sounds like you're down to the level of text rendering engine.  Might see if tinyTLF allows this or you're likely into the depths of the new Flash text engine.

              1 person found this helpful
              • 4. Re: Blinking Text possible?
                vunnikri Level 1

                Oh No... how that complication for me.... hehe.

                 

                Jokes aside (ahem), i managed to get colors running by simply adding html tags. Somehow, the <blink> tag is obselete or most browsers just don't support them (i'm assuming coz they had no effect whatsoever)

                 

                I was thinking more on the lines of using some javascript to generate a blink, that would be displayed in the textArea as html.

                 

                Any ideas in that direction? (or any direction would... i'm clueless here )

                • 5. Re: Blinking Text possible?
                  Arun Ganesh Level 3

                  Hi Dude,

                  Try this (Have to modify something),

                   

                   

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="{init()}">

                       <mx:Script><![CDATA[
                           import mx.collections.ArrayCollection;
                      import mx.controls.textClasses.TextRange
                      import flash.utils.setTimeout;
                      
                      [Bindable]

                      private var timerObj:Timer;
                      private var sourceFormat:Object;
                      private var modifiedFormat:Object;
                      private var formatted:Boolean;
                      private function resetText():void {
                          var txtRange:TextRange =getRanges(ta1,10,15);
                           if(sourceFormat!=null){
                                setFormat(txtRange,sourceFormat)
                           }
                           formatted = false;
                      }
                      private function getRanges(txtArea:TextArea,startIndex:Number,endIndex:Number):TextRange{
                          return new TextRange(txtArea,false,startIndex,endIndex)
                      }
                      public function alterText():void {        
                          var txtRange:TextRange =getRanges(ta1,10,15);
                          if(sourceFormat==null)
                              sourceFormat = new Object();
                          if(!formatted){
                              sourceFormat.color=txtRange.color;
                              sourceFormat.fontSize=txtRange.fontSize;
                              sourceFormat.fontStyle=txtRange.fontStyle;
                              sourceFormat.fontWeight=txtRange.fontWeight;
                          }
                          if(modifiedFormat==null)
                              modifiedFormat = new Object;
                          modifiedFormat.color=0xFF0000;
                          modifiedFormat.fontSize=12;
                          modifiedFormat.fontStyle = "plain";
                          modifiedFormat.fontWeight = "bold";
                          setFormat(txtRange,modifiedFormat)
                          formatted = true;
                       }
                       private function setFormat(txtRange:TextRange,txtFormat:Object):void{
                           txtRange.color = txtFormat.color;
                          txtRange.fontSize = txtFormat.fontSize;
                          txtRange.fontStyle = txtFormat.fontStyle;
                          txtRange.fontWeight = txtFormat.fontWeight;
                       }
                       private function init():void{
                          alterText();
                          timerObj = new Timer(500);
                          timerObj.addEventListener(TimerEvent.TIMER,Blink);
                          timerObj.start();
                      }
                      private function Blink(evt:TimerEvent):void {

                           if (formatted) {
                                resetText();
                          } else {
                              alterText();
                          }
                      } 
                    ]]></mx:Script>

                   

                    <mx:TextArea id="ta1" fontSize="12" fontWeight="bold" width="100%" height="100">
                       <mx:text>
                          This is a test of the emergency broadcast system. It is only a test.
                       </mx:text>
                    </mx:TextArea>

                   

                  </mx:WindowedApplication>