Back to description
The Internet is a fantastic invention. As developers, we determine its future and shape its usefulness through our own developments... more
The Internet is a fantastic invention. As developers, we determine its future and shape its usefulness through our own developments. This book will hopefully help to refine this path, as we seek to make the Internet ever more perfect.
In this chapter, you will acquire a broad perspective of:
Current issues with developing for the Internet.
What are haXe and Neko?
How haXe and Neko can alleviate issues with Internet development.
... less
Starting out with a new language can seem intimidating if you’re not sure how it relates to existing languages that you’re... more
Starting out with a new language can seem intimidating if you’re not sure how it relates to existing languages that you’re already comfortable with. That’s why you’ll take the traditional route. In this chapter, you’ll learn the very basics that will help you on your way to mastering haXe. You’ll learn the following:
How to manually install haXe and Neko on Windows and Linux machines
How to use the haXe automatic installer
How to write a simple application in haXe
How to compile your program to the Flash SWF format
How to compile your program to the JavaScript format
How to compile your program to the Neko format for the Web and desktop
How a basic haXe program is structured
How to build and execute an .hxml compiler file
.hxml
haXe is a language, first and foremost. This means that is has a defined structure and a grammar consisting of keywords and... more
haXe is a language, first and foremost. This means that is has a defined structure and a grammar consisting of keywords and contextual rules. In this chapter, you’ll examine the grammar of the haXe language and become familiarized with the various functions and data types it has to offer.
Specifically, you will look at:
The data types supported by haXe
Using Variables
Type inference
Working dynamically with untyped and Dynamic
untyped
Dynamic
Casting data from one type to another
Grouping data into Arrays, Lists, and Hash Tables
Array
List
Hash Table
Working with operators
Manipulating strings
Using the Math functions
Math
Using the String functions
String
Moving on from types and data manipulation brings you to how your data will flow in your applications. haXe supports a very... more
Moving on from types and data manipulation brings you to how your data will flow in your applications. haXe supports a very rich array of functionality which has been borrowed from the ML family of functional languages and tightly wrapped around the now ubiquitous object-oriented coding conventions. You will look at some of these practices in this chapter, including:
Conditional statements
Loops
Iterators and collections in loops
Functions and local functions
The haXe Lambda class
Lambda
Object-oriented programming (OOP) is a programming paradigm that enforces coding functionalities using objects as a metaphor... more
Object-oriented programming (OOP) is a programming paradigm that enforces coding functionalities using objects as a metaphor. Developers seem to find in object representations a natural way to cope with abstract concepts, especially when the complexity of the system grows larger.
The OOP has always been seen in opposition to procedural programming that approaches coding as a sequence of steps to carry out. The latter is very practical in some specific context and until recently was the preferred choice for scripting languages such as VB and JavaScript, but the former has proven over the years to be an effective way to write codes easier to maintain and reuse.
haXe is a recent language and has embraced the OOP fully, but it still maintains a great degree of flexibility by adopting concepts of procedural programming.
In this chapter, you will learn:
What classes and objects are and how can you use them in haXe
What the differences are between instance fields and static fields
How to declare and use variables and functions in classes
How to extend classes and implement interfaces
How to work with anonymous types, typedef and enum
typedef
enum
How to leverage on advanced features like extensions and type parameters
So far, you have learned a lot about types, classes, OOP, and so on. This chapter will show you how to manage the code for... more
So far, you have learned a lot about types, classes, OOP, and so on. This chapter will show you how to manage the code for better organization and efficiency. This means breaking the code in multiple files that you can reuse from project to project, writing comments that can produce documentation automatically, and creating a set of tests to check that everything is fine whenever you make corrections or you introduce new functionalities. In this chapter, you will learn about the following topics:
Dividing the code into packages
Importing types from packages
Adopting libraries written by others
Using resources
Commenting the code to produce documentation
Unit testing
Writing test code
Okay, let's face it; all programmers make mistakes. In fact, most programmers make lots of mistakes, and it seems the more... more
Okay, let's face it; all programmers make mistakes. In fact, most programmers make lots of mistakes, and it seems the more experienced you are, the more likely you're going to wind up pulling out tufts of hair over the most stupid mistakes imaginable. Now, while a bald head will make the women believe you're a virile stallion, or at least save on lighting bills in the office, surely you'd rather save on the price of a toupee for the time being and just get the darn code working.
Every programmer has their own preference of a debugging toolkit for their favourite language. Most languages even come with a proprietary debugger and output panel set nicely integrated into the associated IDE. However, with haXe in its infancy, it doesn't even come with its own IDE. Yet! Despite this, haXe does still provide quite a substantial array of features oriented to debugging the frilly bits out of your buggy code. What's more, each feature is well thought out, powerful and useful, leaving you wondering why the platform creators hadn't supplied as much exception and logging functionality themselves.
In this chapter, you will discover:
How to trace your code for each platform
How to extend the tracing capability
How to reroute the existing trace functionality to an alternative handling mechanism
What purpose exceptions facilitate in haXe
How to handle exceptions in your classes
Many classes in haXe standard library can be used cross-platform; some of them have already been discussed in the previous... more
Many classes in haXe standard library can be used cross-platform; some of them have already been discussed in the previous chapters and some more advanced ones are explained in the rest of the book. In this chapter you will find a description of some very commonly used classes that must be part of every developer toolkit and in particular they are:
XML
Regular expressions
Timer triggers
MD5 cryptography hashes
The haXe development environment was born with the main purpose of developing web applications. A web application is composed... more
The haXe development environment was born with the main purpose of developing web applications. A web application is composed of several components, both client- and server-side. The client aspect can be resolved with haXe targeting Flash or JavaScript whereas Neko manages the server-side. In this chapter you will take a deep look at building websites using Neko by covering the following topics:
What a web server is
What HTML is
How to write HTML pages
What HTML elements are used
How to use the NekoTools as a development web server
NekoTools
How to install mod_neko for Apache
mod_neko
How to generate dynamic pages with Neko
Templates are really a great way to create dynamic contents. In this chapter, you will see how to use them and the following... more
Templates are really a great way to create dynamic contents. In this chapter, you will see how to use them and the following will be discussed:
What templates are and what they are used for
How to use the haxe.Template class
haxe.Template
How to use the placeholders
How to provide some logic to templates using if and foreach
if
foreach
How to use macros for advanced functionalities
How to use resources to store templates
When it is better to use Motion-Twin Templo instead of haxe.Template
How to use advanced features of the Templo system
We have a cumulative experience of over twenty years developing with JavaScript and Flash ActionScript, and many of those... more
We have a cumulative experience of over twenty years developing with JavaScript and Flash ActionScript, and many of those years have been spent developing with the commercial tools provided by Macromedia (now Adobe). Since discovering the MTASC compiler for ActionScript development, and now the haXe compiler, we have marveled and pondered at just how much time we have spent dealing with these two languages within the confines of the development tools we had to handle, and wonder how much more could have been achieved had haXe been around during our entire development career. That is not to say that the tools we had were poor. Far from it. As they say, a good workman never blames his tools. Only, there have always been issues with JavaScript and ActionScript development that we can now say are almost entirely diminished thanks to the haXe compiler. Despite the sheer power and capabilities of haXe that we have come to love, though, it is not haXe that we consider as the be-all-and-end-all of development tools. That we save for the Neko Virtual Machine.
In this chapter, you'll begin to look at the Neko Virtual Machine in more depth, including:
How to use its standard libraries
How to access and manipulate databases
How to use the SPOD system to access and manipulate databases more easily
How to access and manipulate the filesystem
How to extend your Exceptions class to incorporate file-based logging
Exceptions
In this chapter you will discover the fundamental aspects of using haXe to produce Flash movies. The first section explains... more
In this chapter you will discover the fundamental aspects of using haXe to produce Flash movies. The first section explains how to build and manage interactive contents; the second part highlights the differences between ActionScript and haXe and how the Flash API has been implemented.
The chapter covers in detail the following topics:
What Flash is
How to manage contents in Flash
How to interact with Flash elements using the events
How to use haXe from the point of view of an ActionScript developer
How to use the Flash API in haXe
Many readers of this book have probably already created Flash movies using MTASC, the Adobe (formerly Macromedia) Flash IDE (last version is Flash CS3 Professional), or one of the Flex products (Flex Builder/Flex SDK). Those readers may find the first section of this chapter “The Flash Library” a little too basic for them and may want to jump directly to the “Flash to haXe” section.
An integrated development environment (IDE) may be a very important component in the working environment of a programmer.... more
An integrated development environment (IDE) may be a very important component in the working environment of a programmer. Adobe actually distributes the IDE to target Flash, the Flash CS3 Professional software that is aimed principally at designers, and the Adobe Flex Builder 2 that targets software developers. haXe is still young and does not have a lot of editors yet although new solutions are always emerging, but the very important fact is that haXe does not necessarily need a complex IDE to be fully functional and usable. Debugging in haXe is quite easy because the compiler is very smart in detecting inconsistencies and errors.
One of the biggest advantages of the Adobe Flash CS3 product is the presence of a visual editor that allows creating and importing graphics that can be embedded as symbols in the output movie and used by the code. Because haXe is a programming language and not an IDE, such functionalities must be provided using external tools. It is of course possible to use the Adobe products to integrate the haXe environment, but it is also possible to rely on a plethora of open source editors that can create and manipulate digital images, vector drawing, sounds, and videos. The problem is not how to produce the contents, but how to use and to integrate them with haXe.
In this chapter, the following topics will be discussed:
What SWFMill is
SWFMill
How to embed images and movies
How to embed fonts
How to define a user interface
How to create a user interface library in haXe
When properly used, the JavaScript language can be a very powerful tool to enhance the user interaction with web pages. This... more
When properly used, the JavaScript language can be a very powerful tool to enhance the user interaction with web pages. This chapter shows how to use haXe to produce useful scripts and to implement AJAX. This chapter reviews the following topics:
What JavaScript can do
Which tools can help the developer to work better
What the haXe JavaScript API is
How to validate a form on the client side
How to use AJAX with haXe
Communication is everything in the development of web applications. The haXe environment provides not only ways to communicate... more
Communication is everything in the development of web applications. The haXe environment provides not only ways to communicate between the client side and the server side, but also between different platforms on the same side. This chapter highlights the following topics:
Remoting concepts
Proxies
Synchronous and asynchronous communications
HTTP and socket connections
Platform-to-platform communication
The chapter is dedicated to the advanced classes in the haXe package. You will learn how to stretch the bounds of programming... more
haXe
The chapter is dedicated to the advanced classes in the haXe package. You will learn how to stretch the bounds of programming with haXe and how to achieve results otherwise impossible to obtain. The following topics are covered:
How to use advanced XML handling
What reflection API is
How to use Runtime Type Information
Serialization and deserialization
haXe Magic
As you’ve seen previously, the Neko Virtual Machine provides great flexibility for the development of applications for execution... more
As you’ve seen previously, the Neko Virtual Machine provides great flexibility for the development of applications for execution across the Internet, or with the use of a command window. However, the level of flexibility does not stop there. With the help of external libraries and tools, the Neko virtual machine can be used to produce highly portable and incredibly powerful desktop applications that can compete against any developed with a higher level language.
In this chapter, you’ll look closely at how desktop applications can be developed in haXe for Neko, with particular focus on the following:
What options are available for desktop applications development with Neko
How to create an executable from a Neko .n file
.n
What GUI frameworks are available to the Neko developer
How to use the nGUI portable GUI extension
nGUI
An introduction to using the hxGtk portable GUI extension
hxGtk
How to use Glade with hxGtk
As you should now be aware, the Neko Virtual Machine provides an awesome engine for web applications, as well as desktop... more
As you should now be aware, the Neko Virtual Machine provides an awesome engine for web applications, as well as desktop applications using the operating system’s native GUI libraries. The shear flexibility of the Neko platform allows you, the developer, to put the Neko virtual machine to practically any task.
Now, as a haXe developer, which you can now safely consider yourself, you have at your disposal a means to produce the various required components of both web- and desktop-based applications through the one language. This in itself is a great boon, and will enable you to greatly reduce development time within your projects, while at the same time, allowing you to greatly increase your capabilities as you hone your knowledge of a single all-powerful language. The haXe compiler makes all of this possible, enabling you to fully carry out any development brief by supplying the necessary output formats and tying them all together. This is especially true of web-based applications, whereby the Flash, JavaScript, and Neko output can each be combined to form a single application, but it is also true of desktop applications, thanks to ScreenWeaver HX.
ScreenWeaver HX, or SWHX, provides the needed communications layer to enable a Neko application to display and manage a Flash-based graphical interface. You can liken this technology to SWF-to-Executable applications such as Multidmedia’s Zinc or Northcode’s SWF Studio, only with a great increase in flexibility and a much faster, lighter framework.
Okay, so all you really need is Neko and the nGui library to create a desktop application, but it doesn’t give you the ultimate flexibility that both haXe and Neko were designed to provide. Besides, let's face it, no operating system’s native graphical interface library could ever compare with the slick possibilities afforded by the Flash platform. What’s more, if a particular control required to perform a certain task is not available in the nGui library, or indeed any native GUI library, then using SWHX instead will afford you the option to create such a control yourself, giving you ultimate freedom and total satisfaction.
nGui
Now, enough with the sales talk, let's get down to business. In this chapter, you’ll cover much of the SWHX library capabilities, including:
Comparing SWHX to its non-Neko cousins
Installing the SWHX library
Initializing and utilizing the SWHX library
Managing windows in SWHX
Managing communications from Neko to Flash and back again
Combining SWHX with dialogs from the SysTools library
SysTools
Working with menu’s and system tray icons in SWHX
The haXe language provides a flexible platform for the development of multimedia applications with Flash, but also, thanks... more
The haXe language provides a flexible platform for the development of multimedia applications with Flash, but also, thanks to the sheer power of the Neko Virtual Machine, you can now build executable desktop multimedia applications, without a single Flash file in sight. This is thanks to two very powerful, cross-platform libraries called the Simple DirectMedia Library (SDL) and Allegro.
Both of these libraries have been bound to the Neko Virtual Machine as ndll modules. The Allegro library has been included by the nGame module, which provides a simple haXe bindings layer into the Allegro API. The SDL library, however, forms the foundation of the Neko Media Engine (NME) framework, which also provides functionality for features not directly supported by the SDL library, such as a circular collision detection algorithm and a tile map manager. For this reason, this chapter focuses more closely on the use of the NME module, in particular with regard to the development of games.
ndll
Although this chapter is titled “Multimedia with Neko,” it actually focuses more upon the development of games. The reason for this is that games use almost all of the functionality that many multimedia applications require, and utilize these at much greater speeds than most multimedia applications. On the other hand, multimedia applications and games are very similar, and one could often argue that what little difference exists between them is merely a matter of perception.
In short, this chapter will cover:
How to use Neko for games development
Which library you should use: NME versus nGame
How to create a simple game loop
How to use timers
How to create and animate Sprite objects
Sprite
How to deal with player interaction
The Neko Virtual Machine is very powerful, and the complete haXe framework does provide an incredibly large number of features... more
The Neko Virtual Machine is very powerful, and the complete haXe framework does provide an incredibly large number of features suitable for most application requirements. That doesn’t mean, however, that it caters to all of your programming needs. If you require features in haXe for your desktop or server-side logic, you prefer specific optimized code, or you simply like extending languages, then you’ll need to get your hands dirty with a little C or C++ development. In this chapter, you’ll do just that by taking a look at the following:
What required files are needed by the compiler for building Neko libraries
How to expose C/C++ functions in a dynamic library for inclusion in Neko
How to convert data types between Neko and C/C++
How to deal with pointers to unsupported Neko types
How to handle errors in your code
How to make explicit use of the garbage collector
This appendix describes the most used and useful HTML 4.0 elements and their attributes. All the definitions that only have... more
This appendix describes the most used and useful HTML 4.0 elements and their attributes. All the definitions that only have formatting purposes, or that have been marked as obsolete from the older versions, have been discarded. All the formatting of the HTML document can be done using properly written CSS definitions.
The following sections describe groups of semantically related elements. Following the textual description, a table defining each element individually is provided. Beyond the element name and the description, the second column indicates if the element is of the empty type (it cannot contain other nodes) and the third column contains the names of the attribute groups or attributes that apply to the element. When you want to know more about an attribute, look for its name first in the table for attribute groups, and then in the table for attribute names in case you do not find it.
Purchase Before purchasing this product, please be sure you have met all software and system requirements, and that you understand any limits placed upon its use.
Return Policy Wrox Chapters on Demand are non-returnable and non-refundable.
Reader Software Wrox Chapters on Demand are offered as PDFs, and they must be viewed using the Adobe Reader. If you do not have the Reader installed, it can be downloaded for free at Adobe.com.
Test Download As Wrox Chapters on Demand purchases are non-returnable, it is advisable that you test your system and software configurations with a free sample download before you place an order.
Usage Rights for a Wrox Chapter on Demand File Any Wrox Chapter on Demand product you purchase from this site will come with certain restrictions that allow Wiley to protect the copyrights of its products. After you purchase and download this title, you:
If you have any questions about these restrictions, you may contact Customer Care at (877) 762-2974 (8 a.m. - 5 p.m. EST, Monday - Friday). If you have any issues related to Technical Support, please contact us at 800-762-2974 (United States only) or 317-572-3994 (International) 8 a.m. - 8 p.m. EST, Monday - Friday).
Related Books
Web Resources