Prev | Current Page 219 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


Instance Fields
Instance fields are characteristics of the concretization of a class in an object. Inside the class methods, the
current object can be referenced using the keyword this .
Functions
Instance functions must be defined inside classes and follow the syntax described in Figure 5 - 2 .
public function fName(al : Type, ?a2 : Type) : Type
{
//...
}
access modifier: can
be public,
private or omitted
function return
type
optional arguments
have a ? prefix
argument
type
argument
name
function
name
arguments are enclosed in round
parenthesis and separated with a
comma
function body goes
between curly
brackets
Figure 5-2
The first keyword is an optional access modifier that declares which is the accessibility of the field.
If public is provided the function can be invoked from inside and/or outside the class declaration; if
private or when omitted the field will be only accessible from inside.
class Main
{
static function main()
{
var sample : RestrictAccessSample = new RestrictAccessSample();
trace(sample.


Pages:
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231