![]() |
|||||||||
![]() |
![]() |
Haxe の変更点
- 3.1.3
- JavaScript 開発に使用
- jQuery に依存しまくり
* install [#u1df42f0]
** 本体 [#ad8e0c34]
http://haxe.org/download
** plugin [#g234f65d]
haxelib install jQueryExtern
haxelib install createjs
** エディタ [#t13eae66]
[[IntellijIDEA]]
keybind
Settings -> Code Style -> Haxe
''Wrapping and Braces''
|Keep when reformatting ||
|Comment at first column | off |
* ビルド設定 [#x899c62d]
project の設定で
- Compile with > HXML
- HXML file > build.hxml
''build.hxml''
#pre{{
-cp src
-main Main
-js ./html/test.js
-lib jQueryExtern
#--no-traces
}}
--no-traces を付けると trace文が無視されるようになる~
(それまではブラウザのコンソール等で見られる)
* ハマりメモ [#k7675a23]
*** JQueryStatic [#ka7a6cb3]
ごくまれにこれを使うとコンパイルが通らなくなることがある。~
import 文が悪さをする模様~
おそらく Haxe コンパイラのバグ
* code snipet [#n747f785]
project の設定で
- Libraries => 「+」 => Haxe => c:\HaxeToolkit\haxe\lib\jQueryExtern
+ 2.0.3 の source / class にチェックをいれてOK
+ 名前が 2.0.3 のままになっているので jQueryExtern にかえる
JQuery の alias
#pre{{
private static inline function _(str:Dynamic):JQueryEX {return untyped $(str);}
private static inline function __(str:String):Dynamic {return untyped __js__(str);}
private static var _this(get, null):JQueryEX;
private static inline function get__this():JQueryEX {return untyped $(__js__("this"));}
}}
''html/index.html''
#pre{{
<html>
<head>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="test.js"></script>
</head>
<body>
</body>
</html>
}}
''src/Main.hx''
#pre{{
package;
import js.JQuery.JqEvent;
import jQuery.JQuery;
import js.Browser;
class Main {
private static inline function _(str:Dynamic):JQuery {return untyped $(str);}
// haxe entry point ----
public static function main(){
_(Browser.window).ready(onReady);
}
private static function onReady(e:JqEvent){
new Main();
}
// ----
public function new(){
_("body").text("hello haxe");
trace("hello haxe trace");
}
}
}}
|
|||||||