02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

haXe example

Check out a simple example of how to use HaXe

Video Transcript

00:00I'm just going to create a simple hex project.
00:03All right, so let's just say simple JS.
00:14So here I'm going to choose the JS example here.
00:16Hit Next.
00:18OK, here we go.
00:20Everything looks fine.
00:21Finish.
00:23So this template is one head and created for us.
00:26And we can actually all go ahead and just open up
00:28this index.html file.
00:30This is actually a web browser that's
00:32inside of Eclipse right now.
00:34And I'll just open up my source file with me.
00:39So here you see a very simple JavaScript example.
00:43Because this is actually an HTML page.
00:45You can see here.
00:46Actually, we open up with the source here.
00:49So this is actually all we got here.
00:50We got a very simple HTML document here.
00:53And you see we have this div here,
00:55which is showing what this guy is right here.
00:58And you can see it's actually very similar to the syntax
01:01and structure of ActionScript.
01:05So we have this JavaScript target already set up.
01:09And as you can see, I've just added this div here.
01:12And when you do that, the hex compiler automatically
01:16generates some JavaScript code that says, whenever
01:18you write trace, go ahead and push it to this div here.
01:23So that's actually how easy it is
01:27to actually work with creating some JavaScript and some HTML
01:30here.
01:31Suppose I want to, let's actually, let's get rid of this,
01:35hex, hello from hex, and flash, tent.
01:42Actually, I think it's one word, right?
01:45Let's do it.
01:46Let's do it, OK.
01:46It's going to be exciting.
01:48And so this is actually something else
01:50that I'm going to show you right now.
01:52The compiler is wickedly fast.
01:56And this even goes up for larger projects.
01:58So you'll see here that, again, this
02:00is this simple HTML web page I've got here,
02:03that as soon as I hit Save on this guy,
02:06so I'm going to hit Command-Save right now, the compiler,
02:10I don't know if you just saw that, but it just compiled it.
02:12It took about, I don't know what that was,
02:15a fraction of a second to compile.
02:17So then if I refresh my browser,
02:20you see that actually I'm seeing my updates.
02:23So what's happening to that really, really quick compile?
02:26Well, it's generating a whole bunch of JavaScript.
02:29Whoops, it's going to open up.
02:30We don't want to do that.
02:32I'll just open up.
02:33I don't have my JavaScript editor right now.
02:35So I'll just show this right here.
02:37So this is some of the JavaScript that it's creating.
02:40Now, this will look a little gnarly to people
02:44who are not familiar, both with JavaScript,
02:47but also how Hex generates the JavaScript.
02:52But all this is doing is basically
02:54setting up the minimal of Hex.
02:58Yeah, you're going to have a few hundred lines of JavaScript
03:02here, which you can minimize and take it down to very, very little.
03:06But this is just the very, very minimal
03:08that you need in order to have Hex work in a browser
03:13so it can kind of cross-compile.
03:17Actually, it's not really cross-compile.
03:19To properly generate the script so you have the Hex API
03:23is actually be mimicked right here in this JavaScript.
03:26And again, at first, it's going to seem overwhelming
03:30and a little much here.
03:32But then once you start actually becoming familiar with your code
03:36in Hex, you can see how, oh, you can see what's gone here.
03:39So you can see here, actually, here is my main methods.
03:42And here is like main.
03:43So you can actually see the class, as we're defining here.
03:46And the main method here is right here.
03:49And you can actually see where it's generating the JavaScript
03:53code from here right there.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!