4 Replies Latest reply on Sep 11, 2009 12:03 AM by chandler124

    Repetition of variables in a textarea again and again and again

    chandler124

      Hello,

       

      I want to create a Flex Textarea which automatically change text variables. I think i'm very near the solution but it doesn't work as well as I want ... Here's my code :

       

      [CODE]<?xml version="1.0" encoding="utf-8"?>

      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="858" height="748" creationComplete="init()">

      <mx:Script>

           <![CDATA[

           import flash.utils.Timer;

           import mx.controls.Alert;    

       

           public function init():void{

                var mTimer:Timer=new Timer(1000,5);//ticks for 5 sec’s

                mTimer.addEventListener(TimerEvent.TIMER,Countsec);

                mTimer.addEventListener(TimerEvent.TIMER,Countsec1);

                mTimer.addEventListener(TimerEvent.TIMER,Countsec2);

                mTimer.addEventListener(TimerEvent.TIMER_COMPLETE,Comple);       mTimer.start();

           }

       

           private function Countsec(e:TimerEvent):void      {

                lbltime.text="bonjour";

           }

           private function Countsec1(e:TimerEvent):void      {

                lbltime.text="ola";

           }

           private function Countsec2(e:TimerEvent):void      {

                lbltime.text="hello";

           }

           private function Comple(e:TimerEvent):void      {

                lbltime.text="Time Complete";

           }

           ]]>

      </mx:Script>

       

      <mx:Image x="80.5" y="52" source="assets/OpenYourEyes (images)/Sans titre.png"/>

      <mx:Image x="34" y="632" source="assets/OpenYourEyes (images)/barreactualite.png" width="790" height="67"/>

      <mx:Label id="lbltime" x="367.5" y="617" width="369" height="61" fontWeight="bold" fontSize="30"/> </mx:Canvas> [/CODE]

       

      My problem is that there's only "Hello" on the screen for 3 secodns and then Time Complete. Can someone help me please by printing for 1 second : bonjour, then for 1 second : ola and then for one second : hello and it should work with the same cycle again and again and again ....

       

      Thank you.

       

      I apology for my bad English but I'm french ....

        • 1. Re: Repetition of variables in a textarea again and again and again
          babo_ya Level 3

            public function init():void{

                    var mTimer:Timer=new Timer(1000,5);//ticks for 5 sec’s

                    mTimer.addEventListener(TimerEvent.TIMER,Countsec);

                    mTimer.addEventListener(TimerEvent.TIMER,Countsec1);

                    mTimer.addEventListener(TimerEvent.TIMER,Countsec2);

                    mTimer.addEventListener(TimerEvent.TIMER_COMPLETE,Comple);     

                    mTimer.start();

           

           

          try this..

           

               var mTimer:Timer = new Timer(1000, 5);

               var mTimer2:Timer = new Timer(1000, 5);

               var mTimer3:Timer = new Timer(1000, 5);

           

                 mTimer.addEventListener(TimerEvent.TIMER,Countsec);

                    mTimer2.addEventListener(TimerEvent.TIMER,Countsec1);

                    mTimer3.addEventListener(TimerEvent.TIMER,Countsec2);

                    mTimer.addEventListener(TimerEvent.TIMER_COMPLETE,Comple);     

                    mTimer.start();

                    mTimer2.start();

                    mTimer3.start();

           

          Hope this helps,

           

          BaBo,

          • 2. Re: Repetition of variables in a textarea again and again and again
            chandler124 Level 1

            Well it doesn't work but I try this :

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="858" height="748" creationComplete="init()">
               <mx:Script>
                 <![CDATA[
                 
                   import flash.utils.Timer;
                    import mx.controls.Alert;
            
                    public var tabTextes:Array = ["bonjour","ola","hello"];
            
                    public function init():void{
            
            
                     var mTimer:Timer=new Timer(1000,4);//ticks for 5 sec’s
            
            
            
                    mTimer.addEventListener(TimerEvent.TIMER,Countsec);
                    mTimer.addEventListener(TimerEvent.TIMER_COMPLETE,Comple);
            
            
            
                    mTimer.start();
            }
            
            
                    private function Countsec(e:TimerEvent):void
                    {
                          lbltime.text += tabTextes[(e.target.currentCount)-1];
                    }
            
                    private function Comple(e:TimerEvent):void
                    {
                            lbltime.text="Time Complete";
                    }
                 
                 ]]>
            </mx:Script>
            
            
                 <mx:Image x="80.5" y="52" source="assets/OpenYourEyes (images)/Sans titre.png"/>
                 <mx:Image x="34" y="632" source="assets/OpenYourEyes (images)/barreactualite.png" width="790" height="67"/>
                 <mx:Label id="lbltime" x="367.5" y="617" width="369" height="61" fontWeight="bold" fontSize="30"/>
            </mx:Canvas>
            
            
            

            and I have :

             

            bonjourolahello

             

            and I want

             

            bonjour (1 second)

            /initialisation (0 second)

            ola (1 second)

            /initialisation (0 second)

            hello (1 second)

            /initialisation (0 second)

             

            I don't know how to do it ...

             

             

             

             

            And the second problem is to repeat that again and again and again ...... and again

            • 3. Re: Repetition of variables in a textarea again and again and again
              babo_ya Level 3
              lbltime.text += tabTextes[(e.target.currentCount)-1];
              change this to::::
              
              lbltime.text += tabTextes[(e.target.currentCount)-1] + "(1 second)

              /initialisation (0 second)";

               

               

              I don't think I understand your question..

               

              BaBo,

              • 4. Re: Repetition of variables in a textarea again and again and again
                chandler124 Level 1

                By initialisation, I mean that for example "bonjour" disappears and "ola" appears It s just to understand my problem as well as possible ^^