1 Reply Latest reply on Jan 28, 2010 7:39 AM by archemedia

    TileList and Timer class

    el_kolo

      Hi,

       

      I have a TileList with buttons. I want to rollOver buttons and send their labels to the Rich TextEditor. But I want to do this after 2sec of the cursor being over the current button. Flex doesn't show eny error in my code and nothing happens after rollOver. My code below. Please help.

       

      <?xml version="1.0"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
          >
          <mx:Script>
          <![CDATA[
              import mx.events.CollectionEvent;
               import mx.events.ListEvent;
              import mx.controls.Button;
              import mx.collections.ArrayCollection;
              import mx.controls.RichTextEditor;
              import mx.controls.TileList;
              import mx.events.ListEvent;
              import flash.events.*

       

            public var listArray:Array=[
                {label: "item0", data: 0},{label: "item1", data: 1},
                {label: "item2", data: 2},{label: "item3", data: 3},
                {label: "item4", data: 4},{label: "item5", data: 5},
                {label: "item6", data: 6},{label: "item7", data: 7},
                {label: "item8", data: 8}];
               
               
           [Bindable]   
           public var TileListdp:ArrayCollection = new ArrayCollection(listArray);
            
           public var timer1:Timer= new Timer(2000,0);     
          
           private function rollOver(e:ListEvent):void{
                      rte1.text+=e.itemRenderer.data.label;
                         }
          
          private function delay():void{
                     
                  timer1.addEventListener(TimerEvent.TIMER, rollOver);
                  timer1.start();
                 
                  }

          ]]>
          </mx:Script>
       
          <mx:TileList dataProvider="{TileListdp}"
             itemRenderer="mx.controls.Button" itemRollOver="delay()"/>
          <mx:RichTextEditor title="Title" id="rte1">
          </mx:RichTextEditor>
      </mx:Application>

        • 1. Re: TileList and Timer class
          archemedia Level 4

          I modified your code so that it works properly:

           

          <?xml version="1.0"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
              creationComplete="init()"
              >
              <mx:Script>
              <![CDATA[
                  import mx.events.CollectionEvent;
                   import mx.events.ListEvent;
                  import mx.controls.Button;
                  import mx.collections.ArrayCollection;
                  import mx.controls.RichTextEditor;
                  import mx.controls.TileList;
                  import mx.events.ListEvent;
                  import flash.events.*

           

           

           

                public var listArray:Array=[
                    {label: "item0", data: 0},{label: "item1", data: 1},
                    {label: "item2", data: 2},{label: "item3", data: 3},
                    {label: "item4", data: 4},{label: "item5", data: 5},
                    {label: "item6", data: 6},{label: "item7", data: 7},
                    {label: "item8", data: 8}];
                  
                  
               [Bindable]  
               public var TileListdp:ArrayCollection = new ArrayCollection(listArray);
               
               public var timer1:Timer= new Timer(2000); 
               private var rolledItem:Object;    
             
             
              private function init():void
              {   
                  timer1.addEventListener(TimerEvent.TIMER, handleTimer);   
              }
             
               private function rollOver(e:ListEvent):void
               {
                   rolledItem = e.itemRenderer;
                   timer1.reset();
                   timer1.start();
               }
              
             
              private function handleTimer(e:TimerEvent):void
              {
                  timer1.reset();
                  rte1.text += rolledItem.label;
              }

           

              ]]>
              </mx:Script>

              <mx:TileList dataProvider="{TileListdp}" id="tl" rollOut="timer1.reset()"
                 itemRenderer="mx.controls.Button" itemRollOver="rollOver(event)"/>
              <mx:RichTextEditor title="Title" id="rte1">
              </mx:RichTextEditor>
          </mx:Application>

           

           

           

          Dany