You mean that even with that code :
var loadDirection:Timer = new Timer
(delay_ini,str_lieux.length-1);
loadDirection.addEventListener(TimerEvent.TIMER,
onloadDirectionTimer);
loadDirection.addEventListener(TimerEvent.TIMER_COMPLETE,
doneloadDirectionTimer);
loadDirection.start();
//EACH TIMER CALL
function onloadDirectionTimer(event:TimerEvent):void
{
//Stop the timer to have 1 request at a time
loadDirection.stop();
//Define the path
path = str_lieux[i] + " to " + str_lieux[i+1];
//Calculate the direction
var dir:Directions = new Directions();
dir.addEventListener(DirectionsEvent.DIRECTIONS_SUCCESS,
onDirLoadInitial);
dir.addEventListener(DirectionsEvent.DIRECTIONS_FAILURE,
onDirFail);
trace(path);
dir.load(path);
}
As soon as the function called by the timer onloadDirectionTimer the
timer is stopped.
Say that the first call is A, then in A the timer is stopped. However,
what you're explaining is that the process to call A and to stop the
timer might be longer than another call B by the timer to the function
onloadDirectionTimer ?
What would you use instead of a Timer ?
Thank you
On Aug 14, 1:06 pm, Nianwei <[email protected]> wrote:
> Not necessarily.
> Your timer may already kicked off multiple requests before it ever get
> a chance to stop because the stop code is only executed after the
> first response.
> Timer is something that should be very careful in Async programming
> environment cause it can really mess things up and hard to debug.
>
> Of course you should find out first it is true the direction server
> does not like multiple concurrent requests. If it does not, you should
> avoid timer, if it's OK with it, you may need to look into using
> closure to make sure you are handling the response of your actual
> request to make sure your program runs correctly even it is a
> different issue to the error you get.
>
>
>
> > Therefore, I think this way of doing things prevents the
> > undeterministic approach, don't you think so ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API For Flash" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-maps-api-for-flash?hl=en
-~----------~----~----~----~------~----~------~--~---