I have the need to change a variable in a child Flash file.
The setup is a parent Flash file, that has called a child Flash, and placed it in a movieClip
.
I can send a variable using Javascript to the parent Flash file, but not directly to the child Flash file. Is there a way that I can access the child Flash file directly with Javascript?
Or do I need to send the variable to the parent Flash file, and then have the parent send the variable to the child Flash file?开发者_JAVA技巧 Is there a sort of dot notation that I can use with Javascript to get to the child Flash file without first accessing the parent, when the child is added to the parent using the loadClip
function in flash?
yeah..
from flash 8 you can use ExternalInterface. it is bidirectional.
in your first SWF(fla) you call the javascript function with paramaters like:
in SWF -->
ExternalInterface.call("setValue", form, field, publish);
in javascript
function setValue(form, field, publish) {
alert(form + " " + field + " " + publish)
}
for bidirectional to your parent SWF you can do something like this in your parent SWF:
import flash.external.ExternalInterface;
function getValueFromJavaScript(strTmp){
textMC.text = "Value received from JS" + str;
}
ExternalInterface.addCallback("sendValueToFlash", this, getValueFromJavaScript);
in Javascript:
<script >
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function formSend() {
var text = "Hello Flash";
getFlashMovie("ExternalInterfaceExample").sendValueToFlash(text);
}
</script>
精彩评论