Graphics Reference
In-Depth Information
Allow the Flash Player to Relax
ComputershavecomealongwaysinceIfirstsatdowninfrontof
my dad
'
s Apple II with a beginner
'
s game programming topic for
children (how
ve come a long way
in graphics, hard disk space, physical size, memory, and speed (as
well as many other aspects). As computers advanced in all of these
ways, software developers wrote their programs to utilize the
changes, and we, as Flash Platform developers, have done so as
well. However, as fast and efficient as a computer may be, it can
still be
'
s that for dating myself?). They
'
without too much effort. And, like the com-
puter itself, the Flash Player in which your work is viewed can be
bogged down or even stop responding if the correct preventative
care is not taken.
The Flash authoring environment will let you know about a few
problems in this area such as an infinite loop. What it won
bogged down
ttell
you is how to optimize and/or speed up your working processes.
The following are just a few tips that will help the Flash Player run
more smoothly.
If you
'
'
'
re calling a
simple function that affects each of those objects individually,
move the contents of that function inside the loop. In other words,
don
re looping through several objects and you
t make the Flash Player start a loop, find the object to be
affected, go outside the loop to find the function you
'
re calling, run
the function contents on the object, and then return to the loop
only to do it all again with another object. Instead, let the Flash
Player start the loop, find the object, affect it, and move on to the
next one.
When you give your objects data types, avoid overusing the
ambiguous Object type. Instead, figure out which type is better sui-
ted for the needs of the object, such as String, Number, or Array.
While those three types are very different, there may be times when
more than one type will suit your immediate needs. The Object type
should only be used when there is no other option, and if you
'
re
unsure which type to use, the Help section of the Flash authoring
environment should be able to answer your question.
'
TIP
If you ' re able to target Flash Player 10, you may want to look into the
Vector class for some of your Array needs. A Vector is very much like a
typed Array that is typically more efficient than an actual Array. Also, if
you are used to working with Arrays, then working with Vectors will be
very easy because they contain many (but not all) of the same methods.
You can find an example of the Vector being used in Chapter 12.
that is running the length of an
Array, avoid actually using Array.length in the for statement itself.
If you
'
re writing a
for loop
Search WWH ::




Custom Search