03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

In the same directory as Alpha.as, create a new AS file named Beta.as that contains the<br />

following code:<br />

class Beta extends Alpha {<br />

function Beta() {<br />

trace("privateProperty is " + privateProperty);<br />

}<br />

}<br />

As the following code demonstrates, the constructor for the Beta class is able to access the<br />

privateProperty property that is inherited from the Alpha class:<br />

var myBeta:Beta = new Beta(); // Output: privateProperty is visible only<br />

within class <strong>and</strong> subclasses<br />

Attempts to access the privateProperty variable from outside the Alpha class or a class that<br />

inherits from the Alpha class result in an error. The following code, which resides outside of<br />

any class, causes an error:<br />

trace(myBeta.privateProperty); // Error<br />

See also<br />

public statement<br />

public statement<br />

class someClassName{<br />

public var name;<br />

public function name() {<br />

// your statements here<br />

}<br />

}<br />

Specifies that a variable or function is available to any caller. Because variables <strong>and</strong> functions<br />

are public by default, this keyword is used primarily for stylistic reasons. For example, you<br />

might want to use it for reasons of consistency in a block of code that also contains private or<br />

static variables.<br />

Availability: <strong>ActionScript</strong> <strong>2.0</strong>; Flash Player 6<br />

Parameters<br />

name:String - The name of the variable or function that you want to specify as public.<br />

226 <strong>ActionScript</strong> language elements

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

Saved successfully!

Ooh no, something went wrong!