haXe 2 Beginner's Guide

Develop exciting applications with this multi-platform programming language

haXe 2 Beginner's Guide

Benjamin Dasnois

Develop exciting applications with this multi-platform programming language
Mapt Subscription
FREE
$29.99/m after trial
eBook
$18.90
RRP $26.99
Save 29%
Print + eBook
$44.99
RRP $44.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$18.90
$44.99
$29.99p/m after trial
RRP $26.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781849512565
Paperback288 pages

Book Description

haXe is the universal programming language that is completely cross-platform and provides a standard library that remains the same – regardless of platform.

haXe 2 Beginner's Guide will get you up and running with this exciting language and will guide you through its features in the easiest way possible.

haXe has filled the gap in creating multi-platform applications, and haXe 2 Beginner's Guide will fill the gap in learning all you need to know about haXe – even if it's the first time you have heard of it.

This book will enable you to fully realize haXe's potential for translating code from a haXe program into different languages.

Start with learning how to install haXe, work your way up to templating, and finally learn exactly how to make the same code work for multiple platforms. In between, find heaps of tricks and techniques and work with haXe's typing system. Learn about inheritance, go from learning what a parameter is to creating your own parameterized classes, and find out what the fuss is all about regarding the dynamic type.

By the time you are done with this book, you'll find yourself writing efficient haXe code for multiple platforms in less time than you can say "compatible".

Table of Contents

Chapter 1: Getting to know haXe
Installing haXe
Choosing an editor
Writing your first program
Time for action – Writing a Hello World
A program with some interaction
Time for action – Interacting with the user
Summary
Chapter 2: Basic Syntax and Branching
Modules, packages, and classes
Constants and its types
Binary and unary operators
Blocks
Variable declaration and scope
Time for action – Declaring some fields
Field access and function calls
Constructing class instance
Conditional branching
Loops
Break and continue
Time for action – Using the break keyword
Time for action – Using the continue keyword
Return
Exception handling
Anonymous objects
Local functions
Managing a fridge
Time for action – Managing a fridge
Summary
Chapter 3: Being Cross-platform with haXe
What is cross-platform in the library
Platform-specific packages
Conditional compilation
The remap switch
Coding cross-platform using imports
Time for action – Welcoming the user on Neko & PHP
Time for action – Reading from the XML file
Time for action – Writing to an XML file
Testing our sample
Making it cross-platform
Summary
Chapter 4: Understanding Types
Explicitly typed variables
Static typing
Values with several types
Representing a blog article
Time for action – Representing different types of articles
Function's type
Anonymous objects
Creating a function to apply another one
Time for action – Applying a function on every item
Type inference
Casting
Type parameters
Extending the fridge
Time for action – A fridge with constraints
Summary
Chapter 5: The Dynamic Type and Properties
Freeing yourself from the typing system
Time for action – Assigning to Dynamic variables
Time for action – Assigning from Dynamic variables
Parameterized Dynamic class
Classes implementing Dynamic
Time for action – Implementing a non-parameterized Dynamic
Time for action – Implementing a parameterized Dynamic
Using a resolve function when implementing Dynamic
Time for action – Writing our Component class
Time for action – Parsing the configuration file
Time for action – Testing our parser
Time for action – Writing the configuration file
Time for action – Testing the writer
The dot-notation
Thoughts on writing our parser
The dynamic keyword
Warning
Properties in classes
Summary
Chapter 6: Using and Writing Interfaces, Typedefs, and Enums
Interfaces
Typedefs
Time for action – Naming Anonymous Types
Enums
Time for action – Switching over enums with parameters
Time for action – Writing our Fridge class
Time for action – Making it possible to iterate over a fridge
Time for action – Creating the iterator
Our main function
Summary
Chapter 7: Communication Between haXe Programs
The haXe serializer
haXe remoting
Time for action – Writing a zoo management tool
The Animal class
Representing the zoo
Time for action – Saving the list
Time for action – Loading the list
The remoting service
The client
Time for action – Initializing the client connection
Summary
Chapter 8: Accessing Databases
Connecting to databases
The SPOD
A concrete example of SPOD use
The Manager
Handling relations
Creating a blogging system
Time for action – Creating the Users table
Time for action – Creating the User class
Time for action – Creating the Posts table
Time for action – Creating the Post class
Time for action – Creating the connection to the database
Time for action – Listing posts
Time for action – Listing users
Time for action – Adding a user
Time for action – Adding a post
Time for action – Branching it with the main function
Summary
Chapter 9: Templating
Introduction to the haxe.Template class
Time for action – Executing code from a template
Integrating subtemplates
Creating a blog's front page
Time for action – Creating our SPOD class
Time for action – Connecting to the database
Time for action – Creating our template
Time for action – Reading the template from resources
Time for action – Executing the template
Time for action – Testing the result
Summary
Chapter 10: Interfacing with the Target Platform
Extern classes
Time for action – Writing an extern
Native types and haXe types
Magic functions
Summary
Chapter 11: A Dynamic Website Using JavaScript
Manipulating the DOM
Time for action – Using events from the DOM level 0
Time for action – Using DOM level 2 events
Time for action – Working around by storing reference to functions
Time for action – Setting up the model
Time for action – Setting up our view
Time for action – Setting up the controller
Time for action – Creating a computer view
The main class
Summary
Chapter 12: Creating a Game with haXe and Flash
Embedding assets
Time for action – Installing SWFMILL
Time for action – Creating a library
Time for action – Using assets
Event handling
Time for action – Drawing the character
Time for action – Handling moves
Time for action – Moving the character
Time for action – Adding balls
Time for action – Updating the position
Time for action – Detecting collisions
Summary

What You Will Learn

  • Install haXe, get to know the community, and write your first program
  • Declare classes and variables in haXe
  • Learn about branching so that your program can make decisions and choose different paths according to conditions
  • Iterate lists and get things organized into modules, packages, classes – the lot
  • Learn about haXe's typing system
  • Learn features such as type inference and Dynamic objects
  • Learn all there is to know about the famed Dynamic type
  • Use and write interfaces, typedefs, and enums
  • Learn to use templates in haXe to further enhance your web applications

Authors

Table of Contents

Chapter 1: Getting to know haXe
Installing haXe
Choosing an editor
Writing your first program
Time for action – Writing a Hello World
A program with some interaction
Time for action – Interacting with the user
Summary
Chapter 2: Basic Syntax and Branching
Modules, packages, and classes
Constants and its types
Binary and unary operators
Blocks
Variable declaration and scope
Time for action – Declaring some fields
Field access and function calls
Constructing class instance
Conditional branching
Loops
Break and continue
Time for action – Using the break keyword
Time for action – Using the continue keyword
Return
Exception handling
Anonymous objects
Local functions
Managing a fridge
Time for action – Managing a fridge
Summary
Chapter 3: Being Cross-platform with haXe
What is cross-platform in the library
Platform-specific packages
Conditional compilation
The remap switch
Coding cross-platform using imports
Time for action – Welcoming the user on Neko & PHP
Time for action – Reading from the XML file
Time for action – Writing to an XML file
Testing our sample
Making it cross-platform
Summary
Chapter 4: Understanding Types
Explicitly typed variables
Static typing
Values with several types
Representing a blog article
Time for action – Representing different types of articles
Function's type
Anonymous objects
Creating a function to apply another one
Time for action – Applying a function on every item
Type inference
Casting
Type parameters
Extending the fridge
Time for action – A fridge with constraints
Summary
Chapter 5: The Dynamic Type and Properties
Freeing yourself from the typing system
Time for action – Assigning to Dynamic variables
Time for action – Assigning from Dynamic variables
Parameterized Dynamic class
Classes implementing Dynamic
Time for action – Implementing a non-parameterized Dynamic
Time for action – Implementing a parameterized Dynamic
Using a resolve function when implementing Dynamic
Time for action – Writing our Component class
Time for action – Parsing the configuration file
Time for action – Testing our parser
Time for action – Writing the configuration file
Time for action – Testing the writer
The dot-notation
Thoughts on writing our parser
The dynamic keyword
Warning
Properties in classes
Summary
Chapter 6: Using and Writing Interfaces, Typedefs, and Enums
Interfaces
Typedefs
Time for action – Naming Anonymous Types
Enums
Time for action – Switching over enums with parameters
Time for action – Writing our Fridge class
Time for action – Making it possible to iterate over a fridge
Time for action – Creating the iterator
Our main function
Summary
Chapter 7: Communication Between haXe Programs
The haXe serializer
haXe remoting
Time for action – Writing a zoo management tool
The Animal class
Representing the zoo
Time for action – Saving the list
Time for action – Loading the list
The remoting service
The client
Time for action – Initializing the client connection
Summary
Chapter 8: Accessing Databases
Connecting to databases
The SPOD
A concrete example of SPOD use
The Manager
Handling relations
Creating a blogging system
Time for action – Creating the Users table
Time for action – Creating the User class
Time for action – Creating the Posts table
Time for action – Creating the Post class
Time for action – Creating the connection to the database
Time for action – Listing posts
Time for action – Listing users
Time for action – Adding a user
Time for action – Adding a post
Time for action – Branching it with the main function
Summary
Chapter 9: Templating
Introduction to the haxe.Template class
Time for action – Executing code from a template
Integrating subtemplates
Creating a blog's front page
Time for action – Creating our SPOD class
Time for action – Connecting to the database
Time for action – Creating our template
Time for action – Reading the template from resources
Time for action – Executing the template
Time for action – Testing the result
Summary
Chapter 10: Interfacing with the Target Platform
Extern classes
Time for action – Writing an extern
Native types and haXe types
Magic functions
Summary
Chapter 11: A Dynamic Website Using JavaScript
Manipulating the DOM
Time for action – Using events from the DOM level 0
Time for action – Using DOM level 2 events
Time for action – Working around by storing reference to functions
Time for action – Setting up the model
Time for action – Setting up our view
Time for action – Setting up the controller
Time for action – Creating a computer view
The main class
Summary
Chapter 12: Creating a Game with haXe and Flash
Embedding assets
Time for action – Installing SWFMILL
Time for action – Creating a library
Time for action – Using assets
Event handling
Time for action – Drawing the character
Time for action – Handling moves
Time for action – Moving the character
Time for action – Adding balls
Time for action – Updating the position
Time for action – Detecting collisions
Summary

Book Details

ISBN 139781849512565
Paperback288 pages
Read More

Read More Reviews

Recommended for You

Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Responsive Web Design with HTML5 and CSS3 Book Cover
Responsive Web Design with HTML5 and CSS3
$ 23.99
$ 4.80
Instant AngularJS Starter Book Cover
Instant AngularJS Starter
$ 12.99
$ 9.10
Adobe Flash 11 Stage3D (Molehill) Game Programming Beginner’s Guide Book Cover
Adobe Flash 11 Stage3D (Molehill) Game Programming Beginner’s Guide
$ 29.99
$ 21.00
HTML5 Games Development by Example: Beginner’s Guide Book Cover
HTML5 Games Development by Example: Beginner’s Guide
$ 26.99
$ 18.90
WebGL Beginner's Guide Book Cover
WebGL Beginner's Guide
$ 26.99
$ 18.90