onError

Availability

AS2 and AS3.

Usage

... onError:value, ...

Parameters

value:Function — A function that gets called when an error occurs when trying to run a tweening. This is used to handle errors more commonly thrown by other events (that is, from code not controlled by Tweener), such as onStart, onUpdate or onComplete. The function scope (in which the event is executed) is the target object itself, unless specified by the onErrorScope parameter.

This parameter is more useful on ActionScript 3 than on ActionScript 2, since errors tend to be silent on AS2.

Examples

// Tweens an object, outputting what's wrong if an error occurs on any event (AS3)
this.handleError = function(errorScope:Object, metaError:Error) {
	trace ("Warning! Object " + errorScope + " has thrown an error: " + metaError);
};
this.someCrazyFunction = function() {
	// This function must do something to throw an error that will be caught by onError
	// One example would be referring to a property of a null object
	var whatever:Object = null;
	var whatever2 = whatever.someProperty;
};
Tweener.addTween(this.box, {x:100, time:1, onUpdate:this.someCrazyFunction, onError:this.handleError});

See also

onErrorScope