Game Development Reference
Before you look at how this is working, let's first examine the result of the pn]_a directive. This is what
it looks like:
And this is what it displays in the Output panel:
As you can see, the string lh]pbkni has the value of the loop's index variable, e, appended to it.
e starts with a value of zero the very first time the loop runs, but it's increased by 1 every time the
loop repeats. This allows you to dynamically create the names of all the platform instances, from
lh]pbkni, to lh]pbkni5.
The code that actually checks for a collision between the player and the platform instances works in
exactly the same way as the pn]_a directive:
The key to making it work is this section of code:
The name of the instance is created by taking the base name, lh]pbkni, adding the current value of
the index variable to it, and surrounding the whole thing in square brackets. You use pdeo because the
platform instances are a property of “this class.”
Because I]ej[>qc?]p_dan is the document class, you can read pdeo to mean “in this object.” When
the SWF runs, it creates an instance of the I]ej[>qc?]p_dan class, which is an object just like any
other in your game. Any objects that are on the stage become internal properties of the document
class. You can refer to any of the class's internal properties with the pdeo keyword. The lh]uan and
lh]pbkni objects are all properties of the class, so they can be referred to as pdeo*lh]uan and pdeo*
lh]pbkni/, for example.
This is also the first time you've used square brackets in the code: