I'm changing the selectedIndex of a data grid with a simple function 
call triggered by a Timer. I posted something a few weeks ago about 
the same topic when changing an image. I was under the impression 
that it was the image that was makeing the IE object size grow but it 
seems with this new test that there is another issue with automating 
a function with a Timer. Does anybody have any work arounnd for this 
problem? I can't belive that this type of thing is an issue with a 
platform like flex. 

Here is the working code...it's pretty straight forward. I just don't 
get it.

---------------------------CODE---------------------------------------
<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="vertical"
    width="577" 
    height="68" 
    horizontalAlign="center" paddingBottom="0" paddingLeft="0" 
paddingRight="0" paddingTop="0" 
    verticalAlign="middle" initialize="RSSfeed.send()"  
creationComplete="ShortTimer()"> 
    
<mx:Script>
      <![CDATA[
      import mx.controls.Alert;
            private function nav(myUrl:String):void
            {
                  var urlToNav:URLRequest = new URLRequest(myUrl);
                  navigateToURL(urlToNav,"_blank");
            }
        [Bindable]
                private var num:int = 1;
        ////move the visible section of the data grid in focus
        private function changeIndex():void  
        {
            entries.scrollToIndex(num);//entries refers to the data 
grid below
                if (num < RSSfeed.lastResult.rss.channel.item.length){
                        num++;//increase if thess than the length of 
the feed
                }else{
                        num = 1;//set back to 1
                }
       }
        private function ShortTimer():void  
        {
            // creates a new five-second Timer
            var minuteTimer:Timer = new Timer(1000, 5);
            // designates listeners for the interval event and the 
completion event
            minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
            minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, 
onTimerComplete);
            
            // starts the timer ticking
            minuteTimer.start();
        }
                private function onTick(evt:TimerEvent):void 
        {
            if(evt.target.currentCount == 5){
                ShortTimer();
            }
        }
        public function onTimerComplete(evt:TimerEvent):void
                {
                        changeIndex()
                        ShortTimer();
                }
      
      
      ]]>
</mx:Script>
   <mx:Style>
   DataGrid {
   backgroundAlpha: 1;
   backgroundColor: #000000;
   alternatingItemColors: #ffffff, #eff1f2;
   horizontalGridLines: true;
   letterSpacing: 0;
   horizontalGridLineColor: #990000;
   verticalGridLines: false;
   useRollOver: false;
   borderThickness: 2;
   borderColor: #ffffff;
   selectionColor: #000000;
   color: #ff0000;
   textSelectedColor: #ff0000;
   textIndent: 0;
   dropShadowEnabled: true;
   shadowDistance: 3;
   shadowDirection: right;
   fontSize: 14;
   fontWeight: normal;
   headerStyleName: "mydataGridHeaderStyle";
}

.mydataGridHeaderStyle {
   color: #999999;
   letterSpacing: 0;
}
   </mx:Style> 
<mx:HTTPService showBusyCursor="true" id="RSSfeed" 
url="http://www.weather.gov/alerts/ma.rss"; resultFormat="object" />
       <mx:DataGrid sortableColumns="false" width="506" height="48" 
id="entries"  dataProvider="{RSSfeed.lastResult.rss.channel.item}" 
horizontalCenter="0" verticalCenter="0"
               click="nav(RSSfeed.lastResult.rss.channel.item
[entries.selectedIndex].link)" cornerRadius="6" borderStyle="solid" 
borderColor="#00ff00" alternatingItemColors="[#000000, #000000]" 
selectedIndex="1"> 
            <mx:columns>
                  <mx:DataGridColumn  dataField="title" 
headerText="Mass Weather Advisory Feed" fontSize="9" 
wordWrap="true"/> 
              </mx:columns> 
        </mx:DataGrid> 
</mx:Application>

Reply via email to