Opening the web page index.html in a web browser produces the effect shown in Figure 6 - 1 ; using
the left mouse button pressed when the cursor is over the gray box, the box can be dragged on the
page; the two buttons on the left are used to pause and resume the dragging functionality and to hide
and show the box.
(continued)
Figure 6 - 1
163
Chapter 6: Organizing Your Code
Using Resources
The haXe compiler allows you to embed in the compiled output the content of files that are not code.
They can be simple text, localization files, or configuration files. To include a resource, it is necessary to
add the switch - resource as follows:
-resource resourcefile@resourcename
Where resourcefile is the path to the file to embed and resourcename is an identifier that will be
used in the code to reference the resource. The static function resource of the Std class is used to access
the content of the resource in this way:
var content : String = Std.resource(???resourcename???);
As an example, a Config class is defined that will recur on an embedded XML file to store configuration
information about the database connections.
Pages:
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328