Created
July 24, 2010 16:05
-
-
Save tana/488781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<title>haXe and Flash ExternalInterface</title> | |
<script type="text/javascript" src="http://www.google.com/jsapi"></script> | |
<script type="text/javascript">google.load("swfobject", "2.2");</script> | |
<script type="text/javascript"> | |
function incr() { | |
document["external"].increment(); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="external"> | |
</div> | |
<script type="text/javascript"> | |
swfobject.embedSWF("external.swf", "external", "320", "240", "9", false, {}, {"allowScriptAccess": "always"}, {}); | |
</script> | |
<br /> | |
<button onclick="incr()">+</button> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flash.external.ExternalInterface; | |
import flash.text.TextField; | |
class External { | |
static var tf : TextField; | |
static var count = 0; | |
static function main() { | |
tf = new TextField(); | |
tf.text = Std.string(count); | |
flash.Lib.current.addChild(tf); | |
ExternalInterface.addCallback("increment", increment); | |
} | |
static function increment() { | |
count++; | |
tf.text = Std.string(count); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
コンパイル方法: | |
haxe -main External -swf9 external.swf | |
注意: | |
ローカルで動かす時は、Flashの「グローバルセキュリティ設定パネル」で、external.swfとexternal.htmlがあるディレクトリを常に信頼するようにしておく。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment