You need to do correct re-initialization. First, you've messed up static code with functions, and class-wide variables with pre-init, so declare those variables without initialization, and make a newPing()
function with the following code, and call it whenever you need to.
function newPing():void {
ldr=new URLLoader();
ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, ldrStatus);
times++; // this will also track how many pings were there
doThePing();
}
You have the rest of variable initialization already done, and they do not need to be re-initialized. Your ldr
is the only thing that should be renewed. In more complicated situations you might need a lot of re-assignments, say if you make a game with lives and score, set lives to initial amount and score to zero. But you should always find what needs re-assignment by yourself. This is only the principle.