Experience jquery in haxe

Source: Internet
Author: User

After reading the introduction about haxe by tie Ge, I can't help but try it out:

1. Download and install flashdevelop

Http://flashdevelop.org/download the latest flashdevelop and install it here (Note: Install this requires Java sdk1.6 or later, and install. netframework)

TIPS:

Flashdevelop does not recognize the latest JDK 1.7. If your machine is installed with version 1.7, You need to manually edit it.

X: \ Program Files (x86) \ flashdevelop \ tools \ flexsdk \ bin \ JVM. config

Find
Java. Home = "C: \ Java \ jre7 \"

Set java. Home to the jre7 path of the cost machine,

Insert another question: If your machine is Windows 64-bit, you 'd better install the Java SDK 64-bit version. Otherwise, eclipse may not be able to run.

Ii. Download and install haxe

Http://haxe.org/download and install haxe here

TIPS: manually installed by the supervisor.

III,You can useFlashdevelop experience haxePowerful

Javascript is a very good language. You can't think of it. However, this weak type language has a fatal flaw: the lack of a good IDE environment, and the compilation phase is not easy to find syntax errors, and haxe just makes up for this.

And it's amazing that jquery is seamlessly integrated (the haXe-2.09 has built-in jquery 1.6.4)

1,Create a haxe JS project and write a jquery ready example.

 

 
Import Js. jquery; import Js. LIB ;/***... * @ author Jimmy. yang */class main {static function main () {New jquery (null ). ready (function (E: jqevent) {Lib. alert ("jquery is ready! ");});}}

 

The above rowsCode, Which is equivalent

 

 
$ (Document). Ready (function () {alert ("jquery is ready! ");})

 

After compilation, a JS file jshaxe. js will be compiled and automatically referenced to the HTML page. If you are interested, you can analyze the generated JS Code on your own, which is easy to understand.

2,Test the jquery selector.

 
Static function main () {New jquery (null ). ready (function (E: jqevent) {var abc = new jquery ("Div. ABC "); // select the ABC element of all Div class =" ABC. each (function (I: int, E: htmldom) Export abc.eq( I ).html ("this is the" + I + "class = 'abc' Div ");}); vaR BTN = new jquery ("# BTN"); // select the id = "BTN" element BTN. click (function (E: jqevent): void {Lib. alert ("You clicked:" + E. currenttarget. ID );});});}

 

The above code is equivalent

 

 
$ (). Ready (function () {var abc = $ ("Div. ABC ");abc.each(function( I ){abc.eq( I ).html (" this is the "+ I +" class = 'abc' Div ") ;}); var BTN =$ (" # BTN "); BTN. click (function (e) {alert (E. currenttarget. ID );})})

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.