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 );

                                    }

 

 

hope that helps...

 

BTW! This has been discussed earlier, you can search archives to  know more...

 

-abdul

 

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




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to