ActionScript 3.0 과 javascript 의 상호 조정


package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.net.NetConnection;
	import flash.text.TextField;
	
	public class Example extends Sprite
	{
		private var _connection:NetConnection;

		public function Example()
		{
			init2();
		}
		
		/**
		 *ActionScript  javascript 
		 * 
		 */
		public function init1():void
		{
			var t:TextField = new TextField();
			t.border = true;
			t.background = true;
			t.height = 30;
			t.backgroundColor = 0xFFFFFF*Math.random();
			t.text = "    ";
			addChild(t);
			t.addEventListener(MouseEvent.CLICK,clickListener);
			
			function clickListener(e:MouseEvent):void
			{
				/**
				 *  html     
				 * <script type="text/javascript"
				 * function ch()
				 * {
				 * 	  alert("  ");
				 * }
				 * </script>
				 */	
				ExternalInterface.call("ch","ActionScript 3.0 Cookbook");
			}
		}
		
		
		/**
		 *javascript  ActionScript 3.0 
		 * 
		 */
		public function init2():void
		{
				/**
				 *  html     
				 * <script type="text/javascript"
				 * function oc()
				 * {
				 * 	  alert(document.getElementById("ExternalInterfaceTest").cc("hello"));
				 * }
				 * </script>
				 * 
				 * <input type="button" value="  " onclick="oc()"/>
				 */	
				ExternalInterface.addCallback("cc",cc);
				function cc():String
				{
					return "  ";
				}
		}
	}
}

좋은 웹페이지 즐겨찾기