package{import flash.display.sprite;import flash.events.event;import flash.external.externalinterface;import flash.text.textfield;import flash.text.textfieldautosize; import flash.utils.setinterval;import flash.utils.settimeout; [SWF (framerate= ", width=", " height=", backgroundcolor= "0xFFFFFF")]public class main extends sprite{private var _txt:textfield;public function main () {This . _txt = new textfield (); This.addchild (_txt);this._txt.autosize = textfieldautosize.left;this._txt.multiline = true;this._txt.text = "Test data receive example, External methods Please use: Externalfunction "; This._txt.appendtext (" \ n \ nthe start run, not join the display list "); This.addeventlistener (Event.added_to_stage, Addtostage);} Private function addtostage ($evt: Event): Void{this.removeeventlistener (Event.added_to_stage, Addtostage), This._txt.appendtext ("\ n already added to the display list"), if (externalinterface.available) {this._txt.appendtext ("\ n player isIn the container for external interfaces "); Externalinterface.addcallback ("Externalfunction", callback); Externalinterface.call ("Callbackbridge");} Else{this._txt.appendtext ("\ n the player is not in the container of the external Interface");}} Private function callback ($param: Object): Void{this._txt.appendtext ("\ n received parameter" +string ($param)); this._ Txt.appendtext ("\ n Test succeeded! ");}}}
AS3 Test Code