Ive always wondered how to do this because functions rock but they cause me so much pain due to how I use them.
For example. Say we’re driving a ship at a constant rate of 45 miles per second:
function milesTraveled() {
myMiles += 45;
if (myMiles>=4500) {
myMiles = 4500;
trace("reached destination");
refillGas();
}
}
setInterval(milesTraveled, 1000);
Now as you can see it runs the function refilllGas(); but it -keeps- on running refillGas(); due to the setInterval that runs the main function everysecond.
Any way to cut the function milesTraveled for good once I hit a certain condition?