如何读取动作一个全局JavaScript变量 [英] how to read a global javascript variable from actionscript

查看:124
本文介绍了如何读取动作一个全局JavaScript变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于没有对我的网页名为myVar的一个​​全局JavaScript变量,我怎么可以从我的Flash影片使用JavaScript中访问的变量myVar的价值?

Given that there is a global javascript variable on my web page named myVar, how can I access the value of the variable myVar from within my flash movie using javascript?

我看到很多使用外部接口,以便执行从动作的javascript的例子,但我无法找到使用ActionScript回返回值插入Flash影片的例子。

I see plenty of examples of using external interface in order to execute javascript from actionscript, but I am unable to find examples of returning values back into the flash movie using actionscript.

在此先感谢。我希望我的问题是很清楚。

Thanks in advance. I hope my question is clear enough.

推荐答案

ExternalInterface的工作原理是允许JavaScript在电影中调用ActionScript函数,反之亦然。您可以选择接收返回值从调用函数后面。这里有一个很简单的例子:

ExternalInterface works by allowing JavaScript to invoke an ActionScript function in the movie, and vice-versa. You can optionally receive a return value back from the invoked function. Here's a very simple example:

JavaScript的:

JavaScript:

<script language="JavaScript">
    function getMyVar()
    {
        return myVar;
    }
</script>

闪存/ AS:

Flash/AS:

import flash.external.ExternalInterface;
var result:string = ExternalInterface.call("getMyVar");

这篇关于如何读取动作一个全局JavaScript变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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