Function Limiter Example
By nbilyk - Posted on July 12th, 2008
Tagged:
The FunctionLimiter class is similar to a callLater function, except you can place it within a function and use it to prevent that function from being called too frequently.
This is good for drawing and invalidating, limiting rapid user input, or any time you want to limit the frequency something occurs.
The example below will call the method 'update' when the button was pressed, but limited to once per second.
Code:
function update():void {
var allowPass:Boolean = FunctionLimiter.limit(update, 1000, arguments);
if (!allowPass) return;
}
You can also use the frames method:
function update():void {
var allowPass:Boolean = FunctionLimiter.limitFrames(update, 12, arguments);
if (!allowPass) return;
}
| Attachment | Size |
|---|---|
| functionLimiterExample.zip | 11.18 KB |
| functionLimiterSrc.zip | 13.1 KB |

Post new comment