Prev | Current Page 100 | Next

LordAlex Leon, Greg Goralski

"Foundation Flex for Designers"


private means just that: the class and its contents are not available to other classes.
internal means the class can be accessed from classes in its own package??”a sort of
semi-public.
protected works like a semi-private: members are only available to subclasses.
These allow developers to control the access they wish to provide to their packages, classes, functions,
or variables in their code.
I created a new package named myAnimals; inside it I created a simple class, Dog. If you look closely, the
properties legs and tail have been set as private variables. The logic here is that I created a blueprint
140
CHAPTER 7
for what a Dog is (see Figure 7-6); we know Dogs have four legs and one tail, and I do not want anyone
changing those values (after all, we wouldn??™t want a dog with six legs and two tails, would we?).
Also, there is a private method, breathe(). This function should be used internally in the class. I could
have a timer that would call this method automatically every two seconds inside the class to simulate
the dog breathing. This is a perfect example of a method you??™d want to keep private, as opposed to
bark() and sit(), which are public because unlike breathing (which is something that should be regulated
internally by the object itself), you want to teach your Dog to sit or bark on command.
Figure 7-6. Package with class and methods
141
ACTIONSCRIPT IN FLEX
Variables arrays and collections
Variables are special containers where you can store information to be later used in your program.


Pages:
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
szkolenia dla przedsiębiorców oferty spa Wczasy nad morzem projektowanie wnętrz opony michelin