views:

28

answers:

1

Hi,

I have a function which makes a call to the server to load some financial data. This data is then displayed in a grid. In order to keep displaying the latest data I keep making this server call (every 30 secs). I'm using a Timer object to do this. The problem I have is that I have to wait 30 secs when the application starts for financial data to be displayed, what I'd like to happen is that the load data call is made, then start the update timer. Is there a way to set this up or shall I use to data load calls, one to get the initial data, then one to get the updates, which is made every 30 secs?

Thanks

Stephen

A: 

You will have a code like this:

timer = new Timer(30000);
timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void {
    loadData();
});
timer.start();

so just change it to

timer = new Timer(30000);
timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void {
    loadData();
});
loadData();
timer.start();

Note the call to loadData() before timer.start().

Borek
Thanks, that's a lot clearer.
stevo