1 Reply Latest reply on Sep 2, 2009 9:25 PM by alejandrorrr

    Possible complicated question regarding images/datagrid.

    vindictive27

      I have an application that is monitoring socket messages for information.  Inside a datagrid, I have 'LED' lights - Rx and Tx that switch on and off depending on whether or not the socket is getting or transmitting data.  Really, it's just switching images using the code below.  Now, this works - but it's really ugly (as it shows the background of the datagrid in between switching from the 'off' to 'on' image and back again).  It also is quite slow when a lot of data is passing through the socket connection, it fails to keep up.  I was hoping one of you would either be able to point me in the direction of how to create a control using my two images that have a state of .off or .on or something similar, or maybe in a completely different direction for getting this to work!  Thank you.

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      public function showActivity(adata:ArrayCollection):void

      {

       

       

      var zone:String = adata[0].Zone;

       

       

      var at:String = adata[0].ActivityType;

       

       

       

      if (at == "Rx")

           {

       

       

                for (var i:int = 0; i < zoneCollection.length; i++)

       

       

                     if (zoneCollection[i].Zone == zone)

                     {

                          clearTimeout(intervalIdRx);

                          zoneCollection.itemUpdated(zoneCollection[i].imgSourceRx =

      "images/red-off-16.png",

                          zoneCollection[i].imgSourceRx  = "images/red-on-16.png");

                          intervalIdRx = setTimeout(revertIndicatorRx, delayRx, i, zone);

                     }

           }

       

       

      else if (at == "Tx")

           {

       

       

                for (var c:int = 0; c < zoneCollection.length; c++)

       

       

                     if (zoneCollection[c].Zone == zone)

                     {

                     clearTimeout(intervalIdTx);

                     zoneCollection.itemUpdated(zoneCollection[c].imgSourceTx =

      "images/green-off-16.png",

                     zoneCollection[c].imgSourceTx = "images/green-on-16.png");

                     intervalIdTx = setTimeout(revertIndicatorTx, delayTx, c, zone);

                     }

           }

       

      }

       

       

       

       

      public function revertIndicatorRx():void

      {

       

       

           var idx:int = arguments[0];

       

       

           var zone:String = arguments[1];

       

           zoneCollection.itemUpdated(zoneCollection[idx].imgSourceRx =

      "images/red-on-16.png",

           zoneCollection[idx].imgSourceRx = "images/red-off-16.png");

      }

       

       

       

       

      public function revertIndicatorTx():void

      {

       

       

           var idx:int = arguments[0];

       

       

           var zone:String = arguments[1];

       

           zoneCollection.itemUpdated(zoneCollection[idx].imgSourceTx =

      "images/green-on-16.png",

           zoneCollection[idx].imgSourceTx = "images/green-off-16.png");

      }

       

      Message was edited by: vindictive27 - added image.