MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference page 1003

Actionscript 2.0 language reference
Table of Contents

Advertisement

myObject.someOtherMethod(); // does not call __resolve, no longer undefined
Usage 4: The following example builds on the previous example by reserving a method name,
, for local use so that it is not resolved in the same way as other undefined
onStatus()
properties. Added code is in bold typeface.
// instantiate a new object
var myObject:Object = new Object();
// define a function for __resolve to call
myObject.myFunction = function(name) {
trace("Method "+name+" was called");
};
// define the __resolve function
myObject.__resolve = function(name) {
// reserve the name "onStatus" for local use
if (name == "onStatus") {
return undefined;
}
trace("Resolve called for "+name); // to check when __resolve is called
// Not only call the function, but also save a reference to it
var f:Function = function () {
this.myFunction(name);
};
// create a new object method and assign it the reference
this[name] = f;
// return the reference
return f;
};
// test __resolve using the method name "onStatus"
trace(myObject.onStatus("hello"));
// output: undefined
Usage 5: The following example builds on the previous example by creating a functor that
accepts parameters. This example makes extensive use of the arguments object, and uses
several methods of the Array class.
// instantiate a new object
var myObject:Object = new Object();
// define a generic function for __resolve to call
myObject.myFunction = function (name) {
arguments.shift();
trace("Method " + name + " was called with arguments: " +
arguments.join(','));
};
// define the __resolve function
myObject.__resolve = function (name) {
// reserve the name "onStatus" for local use
if (name == "onStatus") {
return undefined;
Object 1003

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents