Hi Rick,
This is scope issue, handleTimer() function is being called
in different scope and updateData(..) function is not resolved in that scope,
hence not invoked. This problem happens when you pass a function reference to
setInterval(..), this is currently issue with
setInterval(..).
With little change in your code, you can avoid this using
any one of following ways:
1)
function
updateData() {
trace('updating');
TagDataService.send();
trace('updated');
}
function
handleTimer() {
trace('firing');
updateData();
trace('fired');
}
function
enableTimer() {
setInterval(this, "handleTimer", 5000 ); }
2)
function updateData() {
trace('updating');
TagDataService.send();
trace('updated');
}
function
handleTimer() {
trace('firing');
updateData();
trace('fired');
}
function
enableTimer() {
setInterval( mx.utils.Delegate.create(this,
handleTimer), 5000 );
} From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rick Bullotta Sent: Tuesday, June 28, 2005 8:15 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Using setInterval to call an HttpService and update visual components Using the following
AS, I expected to see the updateData method being called each 5 seconds.
The “firing” and “fired” trace output occurs, but the updateData method is
never called. The enableTimer method is called upon creation of a
DataGrid which is the display object for the HttpService named TagDataService.
If the updateData method is explicitly called (via a button press),
everything works fine. What am I missing?
function
updateData() {
trace('updating');
TagDataService.send();
trace('updated');
}
function
handleTimer() {
trace('firing');
updateData();
trace('fired');
}
function
enableTimer() {
setInterval(
handleTimer, 5000 );
} -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com ---- LSpots keywords ?>---- HM ADS ?> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com ---- LSpots keywords ?> ---- HM ADS ?> YAHOO! GROUPS LINKS
|
- RE: [flexcoders] Using setInterval to call an HttpService and ... Abdul Qabiz