简体   繁体   中英

How to call javascript function with flash/actionscript 3

我想从Flash菜单中使用动作脚本3调用我的update(id) javascript函数。我该怎么办?

You can use ExternalInterface.call.

import flash.external.ExternalInterface;


ExternalInterface.call('update', id);
<script>
function displayCurrentTime()
{
var date = new Date();
return date.toLocaleTimeString();
}
</script>

You can call this function just like you always would, but simply call it like you would any other kind of a getter function where you store the returned value as part of some variable:

var currentTime:string = ExternalInterface.call("displayCurrentTime()");

When this code runs, Flash will call the displayCurrentTime JavaScript function and store the returned value from it in the currentTime variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM