開発環境 Apache Flex SDK 4.13.0
FlashDevelop 4.7.1.1
実行環境 Microsoft Windows 8.1 (64bit)
プロジェクトの種類 ActionScript 3/AS3 Project
プロジェクト名 js2flash3

Project/Properties
Output
Background color #6495ED


Main.as
package
{
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.text.*;
 
	public class Main extends Sprite 
	{
		private var tf:TextField;
 
		public function Main() 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
 
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
 
			tf = new TextField;
			tf.defaultTextFormat = new TextFormat(null, 20, 0xffffff);
			tf.autoSize = TextFieldAutoSize.LEFT;
			tf.text = "ready";
			addChild(tf);
 
			ExternalInterface.addCallback("display", display);
		}
 
		private function display(str:String):void 
		{
			tf.text = str;
		}
 
	}
 
}
 

js2flash3.html
<!doctype html>
<head>
<title>js2flash3</title>
<script>
 
function onDragOver(event)
{
	event.preventDefault();
}
 
function onDrop(event)
{
	event.preventDefault();
 
	var files = event.dataTransfer.files;
	var file = files[0];
 
	var str = "";
	str += "name=[" + file.name + "]\n";
	str += "type=[" + file.type + "]\n";
	str += "size=[" + file.size + "]\n";
	js2flash3.display(str);
}
 
function upload()
{
	js2flash3.display("hello");
}
 
function onChange()
{
	js2flash3.display(input_file.value);
}
 
</script>
</head>
 
<body>
<div id="drop" ondragover="onDragOver(event)" ondrop="onDrop(event)">
<embed src="js2flash3.swf" id="js2flash3" width=800 height=600 />
</div>
<button onclick="upload()">upload</button>
<br>
<input type="file" id="input_file" size=80 accept="audio/wav" onchange="onChange()" />
</body>
 
最終更新:2015年02月06日 16:05