如何修改actionscript函数并在网页中执行它?

发布于 2024-10-12 12:14:56 字数 122 浏览 12 评论 0原文

我有一个动作脚本函数,在修改一些值并“执行”它之后,它必须返回一些特定的结果,我的问题是:

有没有办法构建一个网页,让用户使用表单修改该函数然后执行它为了得到结果?

如何“执行”动作脚本函数?谢谢!

I have an actionscript function that, after modifying some values and "executing" it, it has to return some specific result, my question is:

Is there a way to build a webpage that let users modify that function using a form and then execute it in order to get a result?

How do I "execute" actionscript functions? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云归处 2024-10-19 12:14:56

当您说修改函数时,您是否希望用户即时创建函数并允许他执行它?
或者您只是想将一些参数传递给已经存在的函数,然后进行一些计算并返回结果?

如果您只想从 JavaScript 执行 ActionScript 中的函数,您可以使用 ActionScript 3.0 中的ExternalInterface,定义一个函数并允许 javascript 调用该函数。

public function functionToBeCalledFromJS(argument1,argument2)
{
Alert.show(argument1);
}

ExternalInterface.addCallBack('ASfunction',functionToBeCalledFromJS);

In JS when user submits a form call: 

ASfunction(argument1,argument2);

如果你想从AS返回一些数据到JS,那么你需要从AS内部调用JS函数。
这可以使用ExternalInterface.call()轻松完成;

例如。
比方说,您需要进行一些计算,然后返回数据

public function functionToBeCalledFromJS(argument1,argument2)
{
var returnInt:int = argument1+argument2;
}
ExternalInterface.call('JSFunction',returnInt);

IN JS:
function JSFunction(result)
{
alert(result);

}

有关更多详细信息,您可以访问 http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#addCallback%28%29,这是关于AS3参考的官方网站。

When you say modifying a function, do you want the user to create a function on the fly, and allow him to execute it?
Or you simply want to pass some arguments to an already existing function and then do some calculation and return the result?

Incase you simply want to execute a function within actionscript, from javascript, you can use ExternalInterface in ActionScript 3.0 , define a function and allow javascript to call that function.

public function functionToBeCalledFromJS(argument1,argument2)
{
Alert.show(argument1);
}

ExternalInterface.addCallBack('ASfunction',functionToBeCalledFromJS);

In JS when user submits a form call: 

ASfunction(argument1,argument2);

Incase you want to return some data from AS to JS, then you need to call a JS function from within AS.
This can be easily accomplished using ExternalInterface.call();

Eg.
Lets say, you needed to do some calculation and then return the data

public function functionToBeCalledFromJS(argument1,argument2)
{
var returnInt:int = argument1+argument2;
}
ExternalInterface.call('JSFunction',returnInt);

IN JS:
function JSFunction(result)
{
alert(result);

}

For further details on this, you can go to http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#addCallback%28%29, which is the official site on AS3 reference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文