haXe Complex Sample
Time for a more complicated sample of how to work with haXe.
Video Transcript
00:00For example, which I believe we have time for,
00:03I think, yeah, we have about five, 10 minutes here,
00:06that I can show you a little bit more of a complicated JavaScript
00:11example, how you can still see the relationship
00:14between the generated code and what's going on with hex.
00:19So that's our simple hex JavaScript.
00:22I'm just going to close these guys out.
00:25All right, close all.
00:28So let's actually jump to something a little more
00:31exciting here.
00:32Let's actually jump to this Canvas demo here.
00:36And let's open up this guy here.
00:39So this is actually a WebGL example I'm using right here.
00:44This is done by Mike Can, I believe is his name.
00:48I would check him out.
00:49He's a very talented, both with shader languages, like WebGL.
00:55And he's also a very, very proficient hex developer.
01:00So this is actually using Canvas and WebGL right now.
01:04That is written in hex, and I see I can right-click here,
01:06and I don't have the flash pop up.
01:10So I can update this, and it's actually really fast.
01:13I think having all these applications
01:15I have right now running, slowing things down a little bit.
01:19However, this scales up pretty nicely, actually.
01:21And if you check on his website,
01:26let me put a million crawlers on the screen,
01:29and it actually holds up really, really well.
01:32So we'll just keep this guy running here.
01:34So to give you an idea here, we'll
01:37look at this example at the source code.
01:40So I'm going to open up the source code here,
01:42and we'll just keep this guy over here so we can look at it.
01:47And you can see I hear it.
01:48So here's his website here, so I'll definitely
01:51check him out for some really cool hex examples.
01:54And I'm just going to kind of briefly just run through this
01:57really, really, really quick.
01:59And you can see that this is, of course, not everything,
02:03but this is the main method here.
02:06So the first thing that you have in hex
02:08is you have this entry point for your application.
02:12It's always like a static method.
02:14It's very similar to Java has the same thing.
02:17I think some of the languages have it, too.
02:19Or this is the entry point for the application.
02:22And you generate an instance of itself.
02:26And that might seem kind of odd, but it's actually really cool
02:28because you can pre-initialize your application before it
02:34starts up.
02:34So if you have other things to configure in your environment
02:38before you want the application to start up,
02:40that's what this actually does for you.
02:42And I actually really like it.
02:43I kind of wish Flash would have that option.
02:47But it just, like, right off the bat,
02:48when you double click on it, it just runs and executes
02:51builds right away.
02:52So actually, you can see right here
02:54where he's doing a redirect of console tracing.
02:58And that's simply just moving the traces from that div.
03:03You remember in that first example,
03:04I had that div that was showing these traces.
03:07And hex is automatically putting traces right
03:09to this div on the page.
03:12You went ahead and just created a method here
03:14to redirect from that div to actually the JavaScript
03:18console.
03:20And then he creates a new instance of itself.
03:24So this is actually where the party starts.
03:27So again, we're waiting for this.
03:29And if you're familiar with the JavaScript API, again,
03:32if you remember where I talked back earlier,
03:35you had to be familiar with at least how JavaScript behaves
03:40and how the DOM works and how browsers work.
03:43Because otherwise, you're going to be really lost.
03:46So here, we're actually lib.window.ownload.
03:49That's a standard DOM event that's being thrown.
03:53And then he's just catching it and creating this event
03:56handler for that.
03:58And he's using a dynamic event, because that's
04:01how it's going from the DOM.
04:03It's a dynamic event.
04:05JavaScript, it's not typed.
04:07But it's still being thrown nonetheless.
04:10And again, he's creating some default crawlers.
04:14He's doing some selectors.
04:16Again, if you know jQuery, you're
04:18familiar with this, which is creating a new jQuery instance,
04:22which is very similar if you just use the dollar sign.
04:27And so we're adding some events.
04:28Like here, I'll actually send this guy over a little bit.
04:33So actually, numCrawler's input is actually
04:35this guy right here, the input.
04:38And then the Update button is this guy right here.
04:41So you can actually see how we're
04:42intertwining JavaScript and jQuery and hex all together
04:48and using those in the event system
04:51and binding all together to work with your target.
04:56And again, straightforward, once we generate or catch
05:02the event, we have these callbacks and some other stuff
05:05that he's done for help.
