.flash filename="as3_to_js.swf" bbox=420x440 version=9 fps=12 background=#666666 .edittext log width=400 height=150 border color=black multiline html .put log x=0 y=100 .edittext jst width=110 height=20 border color=red text="JavaScript call" .button js_b .show jst as=shape .show jst as=hover x=1 y=1 .end .put js_b x=70 y=5 .edittext clear_e width=100 height=20 border color=red text="Clear Log" .button clear_b .show clear_e as=shape .show clear_e as=hover x=1 y=1 .end .put clear_b x=180 y=5 .action: package { import flash.display.* import flash.text.* ; import flash.events.* ; import flash.external.ExternalInterface ; public dynamic class as3_to_js extends MovieClip { public function trace (s:String) { this.log.text+=s+"\n"; } public function reception(str) { this.log.text=str+"\n"; } private function actio(evt:MouseEvent){ var obj=evt.currentTarget; if ( obj.name=="clear_b") { this.log.text=""; return ; } trace("*****"); trace(ExternalInterface.call('prompt',"Enter something")); trace("*****"); } public function as3_to_js() { trace("javascript call AS3"); ExternalInterface.addCallback("myprompt",reception); this.js_b.addEventListener(MouseEvent.MOUSE_DOWN,actio); this.clear_b.addEventListener(MouseEvent.MOUSE_DOWN,actio); trace("Good Bye folks ... Thanks to Matthias"); } } } .end # action .end # .flash