如何从 Flash 应用程序中调用 JavaScript 函数? [英] How to call JavaScript function from with in Flash application?

查看:32
本文介绍了如何从 Flash 应用程序中调用 JavaScript 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以在我的 AS 文件中我想调用一个像

So in my AS file I want to call a function like

        public function JS(streamUri:String):void{
        JavascriptCommand(streamUri)
        }

让我的 JS 代码运行...

to get my JS code running...

如何做这样的事情(需要例子)

How to do such thing (Example needed)

推荐答案

听起来您正在寻找 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!".

这篇关于如何从 Flash 应用程序中调用 JavaScript 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆