02.02.2013 Views

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Flash</strong> <strong>MX</strong> <strong>2004</strong> <strong>Games</strong><br />

Figure 10.4 Errors reported when ‘set’ and ‘get’ functions are missing<br />

create a function like:<br />

function set area(a:Number){<br />

triarea = a;<br />

}<br />

You may think, why not set the variable directly such as:<br />

tri.triarea = 3;<br />

Because the member variable is private you cannot do this. Using classes allows you <strong>to</strong> expose just<br />

the variables you choose, <strong>to</strong> hide complexity and <strong>to</strong> make the code you have written easier <strong>to</strong><br />

follow.<br />

Figure 10.5 Errors reported when trying <strong>to</strong> set a private variable<br />

That covers the most important aspects of classes. We will meet them again in later chapters.<br />

150

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!