MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 382

Actionscript language reference
Table of Contents

Advertisement

This property is useful for enabling highly transparent client/server communication, and is the
recommended way of invoking server-side methods.
Example
The following examples progressively build upon the first example and illustrate five different
usages of the
__resolve
previous usage are in bold typeface.
Usage 1: the following example uses
property returns the value
// instantiate a new object
var myObject:Object = new Object();
// define the __resolve function
myObject.__resolve = function (name) {
return "Hello, world!";
};
trace (myObject.property1); // output: Hello, world!
trace (myObject.property2); // output: Hello, world!
Usage 2: the following example uses
functions. Using
.
myFunction
// 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) {
return function () { this.myFunction(name); };
};
// test __resolve using undefined method names
myObject.someMethod(); // output: Method someMethod was called
myObject.someOtherMethod(); //output: Method someOtherMethod was called
Usage 3: The following example builds on the previous example by adding the ability to cache
resolved methods. By caching methods,
interest. This allows lazy construction of object methods. Lazy construction is an optimization
technique that defers the creation, or construction, of methods until the time at which a method is
first used.
// 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");
};
382
Chapter 6: ActionScript Core Classes
property. To aid understanding, key statements that differ from the
__resolve
"Hello, world!"
__resolve
redirects undefined method calls to a generic function named
__resolve
to build an object where every undefined
.
as a functor, which is a function that generates
is called only once for each method of
__resolve

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents