MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual page 330

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

Using Function object properties in ActionScript 1
You can specify the object to which a function is applied and the parameter values that are passed
to the function, using the
in ActionScript is represented by a Function object, so all functions support
. When you create a custom class using a constructor function, or when you define
apply()
methods for a custom class using a function, you can invoke
function.
Invoking a function using the Function.call() method in ActionScript 1
The
Function.call()
In almost all cases, the function call operator (
function call operator creates code that is concise and readable. The
useful when the
Normally, if a function is invoked as a method of an object, within the body of the function,
is set to
myObject
myObject.myMethod(1, 2, 3);
In some situations, you might want
be invoked as a method of an object but is not actually stored as a method of that object, as shown
in the following example:
myObject.myMethod.call(myOtherObject, 1, 2, 3);
You can pass the value
function and not as a method of an object. For example, the following function invocations
are equivalent:
Math.sin(Math.PI / 4)
Math.sin.call(null, Math.PI / 4)
For more information, see
To invoke a function using the Function.call method:
Use the following syntax:
myFunction.call(thisObject, parameter1, ..., parameterN)
The method takes the following parameters:
The parameter
The parameters
myFunction
Specifying the object to which a function is applied using Function.apply()
in ActionScript 1
The
Function.apply()
ActionScript calls. This method also specifies the parameters to be passed to any called function.
The parameters are specified as an Array object. This is often useful when the number of
parameters to be passed is not known until the script actually executes.
330
Appendix E: Object-Oriented Programming with ActionScript 1
and
call()
method invokes the function represented by a Function object.
parameter of the function invocation needs to be explicitly controlled.
this
, as shown in the following example:
this
for the
null
thisObject
"Function.call()"
specifies the value of
thisObject
parameter1..., parameterN
. You can specify zero or more parameters.
method specifies the value of
methods of the Function object. Every function
apply()
) can be used instead of the
()
to point somewhere else; for instance, if a function must
parameter to invoke a function as a regular
in Flash ActionScript Language Reference.
this
specify parameters to be passed to
to be used within any function that
this
call()
and
call()
apply()
call()
method is primarily
call()
within the function body.
and
for the
method. The
this

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents