Game Development Reference
In-Depth Information
There are several ways to put elements into arrays. In the previous example, three elements were
added to the array when it was initialized. You'll usually start with an empty array and add elements
to it as you need to.
One way to put elements into an array is to assign elements directly to a position in the array's index:
[_khha_pekjF]nW.Y9bhu7
So whenever your code sees [_khha_pekjF]nW.Y it returns the value of bhu.
Let's look at a slightly more concrete example. The chapter source files include a folder called =nn]u
>]oe_, which contains an FLA file called ]nn]u>]oe_*bh]. Open it is as a project and have a look at the
I]ej[=nn]u>]oe_*]o file:
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
lq^he__h]ooI]ej[=nn]u>]oe_atpaj`oIkrea?hel
w
++@a_h]na]nn]u
lner]par]n[_khha_pekjF]n6=nn]u7
lq^he_bqj_pekjI]ej[=nn]u>]oe_$%
w
++Ejop]jpe]pa]nn]u
[_khha_pekjF]n9jas=nn]u$%7
++=``ahaiajpopk]nn]u
[_khha_pekjF]nW,Y9bhu7
[_khha_pekjF]nW-Y9ikomqepk7
[_khha_pekjF]nW.Y9^aa7
++Pn]_a]nn]uajpena_kjpajpo
pn]_a$Ajpena=nn]u6'[_khha_pekjF]n%7
++Pn]_aej`ere`q]hahaiajpo
pn]_a$Ahaiajp,6'[_khha_pekjF]nW,Y%7
pn]_a$Ahaiajp-6'[_khha_pekjF]nW-Y%7
pn]_a$Ahaiajp.6'[_khha_pekjF]nW.Y%7
y
y
y
If you test this, the pn]_a displays this:
Ajpena=nn]u6bhu(ikomqepk(^aa
Ahaiajp,6bhu
Ahaiajp-6ikomqepk
Ahaiajp.6^aa
 
Search Nedrilad ::




Custom Search