Prev | Current Page 15 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Web Class 236
Using Neko as a Front Controller 238
Summary 250
Chapter 10: Separating Design Using Templates 251
What Are Templates? 251
The Template Class 252
The Template Syntax 253
Using Resources 257
When to Use Code in Templates? 258
Templo for Server-Side Templates 258
Installing Templo 259
Using Templo 259
Differences in Expressions Between haxe.Template and mtwin.Templo 261
Attr Expressions 262
Raw Expressions 262
Logical Expressions 263
Loop Expressions 263
set, fill, and use Expressions 264
xx
Contents
Using Macros with Templo 266
Compiling Templates Manually 268
Summary 269
Chapter 11: Performing Server-Side Trickery 271
Introducing Neko 271
The Neko Virtual Machine 272
The Neko Standard Libraries 272
Working with Databases 273
Choosing a Database 273
Connecting to the Database 276
The Connection Class 277
The ResultSet Class 283
Using the SPOD System 286
Getting Started 287
Simple Use of the SPOD System 287
Table Mapping with neko.db.Object 289
The neko.db.Manager Class 291
Adding Table Relations 295
Working with Files 301
Traversing Files and Directories 301
Working with Files and Streams 304
Creating a Logger Class 311
Summary 314
Chapter 12: Building Interactive Content with Flash 315
The Flash Library 315
The Flash Movie 316
The Movie Clip 319
Text 322
Multimedia Contents 323
Loading Values 325
Events 328
Events over Time 331
The Drawing API 337
Extending the MovieClip Class 342
Flash to haXe 344
Data Types 344
Global Constants and Special Values 346
Top-level Functions 347
xxi
Contents
Operators 352
Statements, Structures, and Keywords 354
Global Properties 356
Top-level Classes Replaced by haXe-Specific Types 357
Flash API Classes 359
Summary 362
Chapter 13: Replacing the Need for an IDE 363
Assets with SWFMill 364
Creating an Image Movie Clip 365
Embedding Fonts 368
User Interfaces 369
How to Implement an UI 369
Events 371
Views, Controls, Containers, and Elements 373
Element 373
Controls 375
Containers 376
The Flash 9 Implementation 381
A Complete Example: the Tree Editor 381
Conclusions 384
Summary 385
Chapter 14: More Interactive Content with JavaScript 387
Dynamic Content in JavaScript? 387
The Web Developer Tools 389
Trace to Firebug 389
JavaScript as haXe Target 390
The JavaScript Library 391
Manipulating the Page with JavaScript 396
The OnLoad Problem 396
Advanced JavaScript Libraries 399
Traversing HTML with JavaScript 400
What Is AJAX? 414
Removing the Myths Around AJAX Complexity 415
Updating a Panel Content Using AJAX 416
Building an Auto-Complete Control 417
Advantages of haXe/JS Development 422
Summary 423
xxii
Contents
Chapter 15: Putting It All Together with haXe Remoting 425
What Is haXe Remoting? 425
Remote Connection and Local Connection 426
Synchronous and Asynchronous Communications 426
Pull or Push? 426
The haXe Remoting API 427
Connection 428
AsyncConnection 432
FlashJsConnection 435
LocalConnection 435
SocketConnection 436
NekoSocketConnection 436
AsyncDebugConnection, DelayedConnection, and AsyncAdapter 437
SocketProtocol 437
Proxy Objects 437
TicTacToe Game 443
Summary 452
Part III: Extending the Possibilities
Chapter 16: haXe Advanced Topics 455
XML 455
Fast 455
Check 458
XML Proxy 463
Reflection API 464
The Reflect Class 464
The Type Class 467
Runtime Type Information (RT TI) 470
Serialization 473
haXe Magic 475
Summary 478
Chapter 17: Desktop Applications with Neko 479
Why Use Neko for Desktop Applications? 479
Creating a Neko Executable 480
Graphical User Interface Libraries 480
ScreenWeaver HX 480
Xinf: Xinf Is Not Flash 481
xxiii
Contents
nGui 481
hxGtk 481
Installing the Required Library 481
The nGui Library 482
The nGui Manager Class 482
Working with Static Controls 484
The Control Class 485
Container Classes 487
Working with Interactive Controls and Events 488
Working with Menus 496
The hxGtk Library 499
The hxGtk Function Proxy 499
The Gtk Class 501
hxGtk Events 502
Rapid hxGtk GUI Development with Glade 503
The Glade IDE 504
The Glade Class 505
Summary 506
Chapter 18: Desktop Flash with SWHX 509
Why SWHX? 510
Installing SWHX 511
Getting Started with SWHX 511
Working with Windows 513
Window Decoration Flags 513
Window Properties 514
Window Events 515
Communication Between Flash and Neko 517
Asynchronous Communication 518
Synchronous Communication in haXe 520
Synchronous Communication in ActionScript 523
Using SysTools 525
Creating a System Tray Icon 526
Creating Menus 526
Using Dialogs 529
Summary 530
Chapter 19: Multimedia with Neko 531
Why Use Neko for Games Development? 532
Neko??™s NME is Your Friend 532
xxiv
Contents
Getting Started with NME 533
The Manager Class 534
Writing Text to the Display 537
Working with Surfaces 537
Keeping Time with Timers 546
The Wonderful World of Sprites 546
Interaction Through Events 549
Summary 553
Chapter 20: Extending haXe with C/C++ 555
Neko Libraries 555
Setting Up the Compiler 556
A Simple Hello World Example 556
Building the ndll Library in C 556
Building the haXe Script 557
The Post-Mortem 557
Neko Value Types in C/C++ 558
The Neko value Struct 558
Preparing Data for Transit from haXe to C/C++ 559
Restructuring Data in haXe from C/C++ 560
Neko Type Checking in C/C++ 560
Passing C/C++ Values to Neko 562
Abstract Types 563
Object Types 565
Arrays 567
Functions 568
Managing Neko Primitives 570
Garbage Collection 571
alloc_root() 571
free_root() 572
alloc() 572
Garbage Collecting Abstract Values 572
Error Handling 573
val_throw() and val_rethrow() 573
failure() 573
bfailure() 574
val_print() 574
neko_error() 574
Summary 574
Appendix A: Semantic HTML 577
Index 603
Introduction
haXe is a language, a compiler, and a framework of classes designed to empower the developer to write
clean code targeted at multiple platforms on multiple operating systems.


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