Home > Web Front-end > JS Tutorial > body text

Summary of communication methods between flash javascript_javascript skills

WBOY
Release: 2016-05-16 18:57:26
Original
856 people have browsed it
Do not use getURL and fsCommand methods
The actionscript used by flash is very similar to javascript. The following describes how to call functions from each other:
1: javascript calls functions in flash
Add
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 exported function name, and the third parameter is the function name of as, so that you can call as in js The hello function
2: flash calls the js function
ExternalInterface.call("hello2", "jacky");
//The first parameter is the js function name , followed by the parameters of the js function
3: How to call each other
html code is as follows:







The javascript code is as follows:
function callFromFlash() {
var a=thisMovie("test").hello ();
alert(a);
}
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window [movieName]
}
else {
return document[movieName]
}
}
//Note that functions such as document.getElementById cannot be used to obtain the flash object in the web page. You can only use the code in thisMovie function
Another method seen abroad:
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);
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!