The getURL and fsCommand methods are not required.
The actionscript used by flash is very similar to javascript. The following describes how to call functions for each other:
1: javascript calls functions in flash
Add in the flash script
Import flash. external. ExternalInterface;
Assume that the function to be called is hello, and the as code is as follows:
Function hello (){
Return "hello ";
}
ExternalInterface. addCallback ("hello", this, hello );
// The first parameter is the name of the exported function, and the third parameter is the name of the as function, so that the as hello function can be called in js.
2: flash calls js Functions
ExternalInterface. call ("hello2", "jacky ");
// The first parameter is the js function name, followed by the js function parameter
3: How to call each other
The html code is as follows:
<Object type = "application/x-shockwave-flash" data = "test.swf" width = "525" height = "390" name = "test">
<Param name = "allowScriptAccess" value = "sameDomain"/>
<Param name = "movie" value = "test.swf"/>
<Param name = "quality" value = "high"/>
<Param name = "scale" value = "noScale"/>
<Param name = "wmode" value = "transparent"/>
</Object>
The javascript code is as follows:
Function callFromFlash (){
Var a = thisMovie ("test"). hello ();
Alert ();
}
Function thisMovie (movieName ){
If (navigator. appName. indexOf ("Microsoft ")! =-1 ){
Return window [movieName]
}
Else {
Return document [movieName]
}
}
// Note: you cannot use the document. getElementById function to obtain the flash object on the webpage. You can only use the code in the thisMovie function.
Another method seen outside China:
You can't call a function, but you can change/set a variable and use the watch () method to execute the code whenever the value is changed.
ActionScript Code:
Function changeType (prop, oldval, newval ){
// Do your stuff
Return newval;
}
Var strType = "";
This. watch ("strType", changeType );