Prev | Current Page 13 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


xiv
Last thing: If I can give you a tip for reading this book, it ??™ s not to try to read every single page of it before
starting using haXe. First focus on the basics, then read the parts that you are more familiar with or that
you are most eager to learn, then experiment, modify, and try it by yourself. If you have questions,
contact the haXe mailing list; there will be people there ready to help you. Don ??™ t read this book like you
would read a novel, but more like an encyclopedia.
Thank you, and don ??™ t forget to have fun,
Nicolas Cannasse
haXe creator
Foreword
Contents
Acknowledgments xi
Foreword xiii
Introduction xxv
Part I: The Core Language
Chapter 1: Introducing haXe 3
A Problem with Internet Development 3
What Is haXe and Why Was It Created? 4
The haXe Compiler 5
The haXe Language 7
How Does haXe Work? 8
So What Is Neko? 8
haXe and Neko Requirements 9
Summary 10
Chapter 2: Installing and Using haXe and Neko 11
Installing haXe 11
Using the haXe Automatic Installer 12
Manually Installing haXe on Windows 12
Manually Installing haXe on Linux 13
Installing Neko 14
Manually Installing Neko on Windows 14
Installing Neko on Linux 16
Hello World! in Triplicate 17
Compiling Your First haXe Application 17
How Your Program Was Compiled 18
HXML Compiler Files 19
Compiling to Neko 19
Compiling to JavaScript 21
Program Structure 22
Compiler Switches 23
Summary 25
xvi
Contents
Chapter 3: Learning the Basics 27
The haXe Hierarchy 27
The Standard Data Types 28
Variables 28
Type Inference 30
Constant Variables 31
The Simple Value Types 31
Floating-Point Numbers 32
Integers 32
Which Number Type? 33
Booleans 33
Strings 33
Abstract Types 35
Void and Null 35
The Dynamic Type 35
The unknown Type 36
Bypassing Static Typing with untyped 36
Commenting Your Code 37
Block Commenting 37
Line Commenting 37
Converting Data Through Casting 38
The cast Function 38
Simple Type Conversion Functions 39
Comparing the Type of a Value 40
Using Arrays in haXe 40
Arrays 41
Lists 46
Hash Tables 48
Using Dates in haXe 50
Creating a Date Object 51
Retrieving the Components of a Date 52
The DateTools Class 53
Manipulating Data 55
Operators 55
The Math Class 63
Using String Functions 66
Summary 72
xvii
Contents
Chapter 4: Controlling the Flow of Information 73
Pushing Data Around 73
Conditional Statements 74
if Statements 74
switch Statements 77
Returning Values from Conditional Statements 78
Loops 79
The while Loop 80
The for Loop 81
Looping Over Collections 82
Break and Continue 84
Functions 85
Class Functions 85
Local Functions 90
The Lambda Class 96
Summary 99
Chapter 5: Delving Into Object-Oriented Programming 101
Classes and Objects 102
Instance Fields 104
Static Fields 114
Understanding Inheritance 115
Super 117
Functions Override 117
Constructor Override 118
toString() 119
Abstract Classes and Abstract Methods 119
Static Fields, Instance Variables, and Inheritance 120
Inheritance Roles 120
Using Interfaces 121
Advanced Classes and Objects Features 122
Implementing Classes 123
Type Parameters 123
Anonymous Objects 126
Implementing Dynamic 127
Typedef 128
Extensions 133
Enum 134
Constructor Arguments 136
Summary 138
xviii
Contents
Chapter 6: Organizing Your Code 139
Building Reusable Code 139
Using Packages 140
Declaring a Package 140
Implicit Import 141
Explicit Import 142
Enum and Packages 143
Type Lookup Sequence 144
Importing an Entire Package 144
Importing Libraries 145
haXe Standard Library 145
haxelib Libraries 146
Libraries from Other Projects 150
External Libraries 150
Using Resources 163
Documenting Your Code 166
Offline Documentation 167
Online Documentation 169
Unit Testing 170
The haxe.


Pages:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25