Making your first Sandy-HX 3D JavaScript Application (Page 2 of 2)

Article by Matthew Casperson (4,883 pts ) , published Sep 29, 2009

You need to download and install a few things for this demo:

Getting the last three can be a bit of a pain, so I have included them in the source code download.

Open up FlashDevelop, and create a new project.

1

Create an Empty Haxe project.

2

Go to the project properties.

3

Set the project to compile to JavaScript, and set the output file.

4

Add the three libraries, neash, Canvas-NME and Sandy-HX, to the classpath.

5

Add the –remap flash:neash option to the Additional Compiler Options, and set the Main Class to Dice.

6

Add the dice.hx file from the dice_demo folder in the sandy-hx tutorials download. You need to change the line that says

var parser: ColladaParser = Parser.create( "../assets/dice.dae", Parser.COLLADA );

to

var parser: ColladaParser = Parser.create( "dice.dae", Parser.COLLADA );

7

Compile the project

8

You should now have a demo.js file in the jsbin folder. In order to run the demo you will also need the demo.html, dice.dae and dice.jpg files from the download.

You can not just open the html file directly on your PC and have it work. I suspect that this has something to do with the Sandy-HX resource loading not working from local drives. You can get around this by installing a local web server. I like the Abyss web server because it is small (the download is less than 1MB). Copy the 4 files (demo.html, demo.js, dice.dae and dice.jpg) over to C:\Abyss Web Server\htdocs (assuming you installed Abyss with the defaults).

9

Now open up http://localhost/demo.html in Google Chrome.

10

Congratulations – you have compiled and run your first 3D JavaScript application.

You can see this demo live for yourself here. I have found that only Chrome and Opera will display the 3D properly (compiling Sandy-HX to JavaScript is still experimental), and of them only Chrome works at an acceptable speed.

You can download the source code, which includes all of the nessessary Haxe libraries, here.

Read more in the Flash and JavaScript 3D with Sandy-HX series

Related Article

away3d-logoAway3D Programming Tutorials - Away3D Lite

Learn how to make your first Away3D Lite application with Flex with this free article.

Showing page 2 of 2
 
Subscribe to Web Development
RSS
Get free weekly updates, directly to your inbox.
Browse Web Development