Book Image

haXe 2 Beginner's Guide

5 (1)
Book Image

haXe 2 Beginner's Guide

5 (1)

Overview of this book

Table of Contents (21 chapters)
haxe 2
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Field access and function calls


Accessing fields and calling methods in haXe is quite easy. All fields of an object (that is all functions that are variables of this object) are accessed by using the dot notation. So, if you want to access the name variable of an object named user you can do so in the following way:

user.name

Calling a function is really easy too, all you have to do is put parentheses after the function's name and eventually write all of your arguments inside the parentheses, separated by commas. Here's how to call a function named sayHelloTo of an object named user, taking two strings as parameters:

user.sayHelloTo("Mr", "Benjamin");

That's all! It's quite easy, really.