Book description
Develop exciting applications with this multi-platform programming language
- Build web applications from scratch using haXe
- Target multiple platforms using the same code and interface the code with the target platform
- Create a whole dynamic website with haXe targeting JavaScript as a case study, even if you haven't touched haXe before
- Learn about haXe remoting and how haXe applications communicate with each other
- Learn to manage your data and map haXe objects into your databases
In Detail
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
-
haXe 2
- Table of Contents
- haxe 2
- Credits
- Foreword
- About the Author
- About the Reviewers
- www.PacktPub.com
- Preface
- 1. Getting to know haXe
-
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
-
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
-
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
-
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
- 6. Using and Writing Interfaces, Typedefs, and Enums
- 7. Communication Between haXe Programs
-
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
-
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
- 10. Interfacing with the Target Platform
-
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
-
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
-
A. Pop Quiz Answers
- Chapter 1: Getting to know haXe
- Chapter 3: Being Cross-platform with haXe
- Chapter 4: Understanding Types
- Chapter 5: The Dynamic Type and Properties
- Chapter 6: Using and Writing Interfaces, Typedefs, and Enums
- Chapter 7: Communication Between haXe Programs
- Chapter 8: Accessing Databases
- Chapter 9: Templating
- Chapter 10: Interfacing with the Target Platform
- Chapter 12: Creating a Game with haXe and Flash
- Index
Product information
- Title: haXe 2
- Author(s):
- Release date: July 2011
- Publisher(s): Packt Publishing
- ISBN: 9781849512565
You might also like
book
Haxe Game Development Essentials
Create games on multiple platforms from a single codebase using Haxe and the HaxeFlixel engine About …
book
Learn C on the Mac: For OS X and iOS, Second Edition
Considered a classic by an entire generation of Mac programmers, Dave Mark's Learn C on the …
book
Web Development with ReasonML
ReasonML is a new, type-safe, functional language that compiles to efficient, readable JavaScript. ReasonML interoperates with …
book
Game Development with GameMaker Studio 2: Make Your Own Games with GameMaker Language
Create games from start to finish while learning game design and programming principles using the GameMaker …