如何调用JavaScript函数,从在Flash应用程序? [英] How to call JavaScript function from with in Flash application?
问题描述
所以,在我作为文件我要打电话像
So in my AS file I want to call a function like
public function JS(streamUri:String):void{
JavascriptCommand(streamUri)
}
让我的JS code运行...
to get my JS code running...
如何做这样的事情(例如需要)
How to do such thing (Example needed)
推荐答案
这听起来像你正在寻找<一href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#call%28%29"相对=nofollow> ExternalInterface.call()。 Adobe公司有关如何使用它从ActionScript调用JavaScript的文章。
It sounds like you're looking for ExternalInterface.call(). Adobe has an article about how to use it to call JavaScript from ActionScript.
您也可以使用ExternalInterface的揭露ActionScript来JavaScript和调用函数内部从JavaScript您的SWF。
You can also use ExternalInterface to expose ActionScript to JavaScript and call functions internal to your SWF from JavaScript.
让我们假设你有一个JavaScript函数,看起来像这样:
Let's say you have a JavaScript function that looks like this:
function specialAlert(msg) {
alert(msg);
}
从您的Flash文件,你可以这样调用它:
From your flash file you can call it like this:
import flash.external.*;
ExternalInterface.call("specialAlert", "Hi mom!");
和你的JavaScript函数应该被调用,提醒用户妈妈你好!。
And your JavaScript function should be called and alert the user "Hi mom!".
这篇关于如何调用JavaScript函数,从在Flash应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!