EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 210

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
210 Functions and Methods
Similarly, the following code placed on any frame does not work:
myWidth();
var myWidth:Function = function () {
trace(my_mc._width);
};
However, this code works properly:
var myWidth:Function = function () {
trace(my_mc._width);
};
myWidth();
When defining a named function, calling it in a frame script works, even though the
equivalent code with an anonymous function does not work:
// the following does work because you are calling a named function:
myWidth();
function myWidth() {
trace("foo");
}
// the following does not work because you are calling an anonymous
function:
myWidth();
var myWidth:Function = function () {
trace("foo");
};
For more information, see “Writing named functions” on page 207.
NOTE
You could also place myWidth() on any frame that is after the frame that contains the
myWidth function.
NOTE
For information on writing code using Script Assist, see “Using Script Assist to write
ActionScript” on page 328, “Creating a startDrag/stopDrag event using Script Assist”
on page 331 and the ActionScript:Use Script Assist Mode tutorial (which begins with
“Open the starter document” on page 213).

Table of Contents

Related product manuals