Game Development Reference
In-Depth Information
Invoking methods
I've written a lot about methods so far in this topic, but before you go much further you should take
a detailed look at exactly what they are and how they work.
Methods perform some kind of useful action in the program. They're made up of two parts:
Function definition : This part is a block statement that includes directives that do the tasks
you want the method to perform.
Method call : This part is a word that activates the directives in the function definition.
Let's have a closer look at these two elements.
Using method calls
You've seen two method calls already in this topic so far: pn]_a and ]``?deh`.
Method calls trigger directives in the method's function definition. (You'll be looking at function defi-
nitions in a moment.) The nice thing about method calls is that you can use them without having to
know how the function definition is programmed.
Many methods require some extra information to do their job. In programming terminology, this extra
information is called an argument . Arguments in method calls are included in parentheses after the
method name.
Here's an example of a pn]_a method call:
pn]_a$SksPdeoeo]j]ncqiajp%7
The text in quotation marks inside the parentheses is the method call's argument. You can use this
pn]_a method call to display the argument in the Output panel when the SWF runs. Here's another
example:
]``?deh`$op]npL]ca%7
No surprise. You saw this one before! ]``?deh`$% is the method call, and op]npL]ca is the method's
argument. Any instance name supplied as the argument of the ]``?deh` method is displayed on the
stage.
Some methods don't need arguments to do their job. Method calls without arguments simply use
empty parentheses. Here's an example:
oeilhaIapdk`$%7
Even though this method call has no arguments, you still need to provide empty parentheses.
 
Search Nedrilad ::




Custom Search