Game Development Reference
If you're organizing lots of little boxes filled with different types of things, it's sometimes useful to
know what type of information each box should contain. Imagine that you have a sugar container and
you accidentally pour a bag of salt into it. That could be a problem when the aunties come to visit for
tea! You need to know that the container you fill is the sugar container.
In AS3.0, you can tell a variable what type of information it should store. To do this, use a colon and
the name of the type, like this:
If the kitchen existed in an AS3.0 universe, you could label the containers in the cupboards like this:
That labeling would prevent you from putting the wrong substance in the wrong container and spoil-
ing the tea parties. Mom would be proud!
Figure 3-4 shows what the imaginary variables might look if like you assigned them types. This will
prevent you from putting the wrong type of thing into the wrong container. (In AS3.0, any information
made up of letters is referred to as a string , as in “string of letters or words.”)
Figure 3-4. Assign types to variables so that you don't
put the wrong type of information or object into the