ActionScript3的JavaScript的通信:最佳实践

编程入门 行业动态 更新时间:2024-10-28 20:18:56
本文介绍了ActionScript3的JavaScript的通信:最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在一个更抽象的水平,那么一个previous问题,在我的经验,有三种方法可以从嵌入的.swf使用AS3调用的HTML页面的JavaScript函数。ExternalInterface的中,fscommand和navigateToURL

On a more abstract level then a previous question, in my experience there are 3 ways to call a javascript function on an html page from an embedded .swf using AS3: ExternalInterface, fscommand, and navigateToURL.

让我们来比较和对比这些方法(或者其他人我还没有上市),并谈谈各的优点和缺点 - 现在,ExternalInterface的的似乎的喜欢的方式去在灵活性方面,但是不是所有的情况呢?是否有执行速度之类的东西方面具体的好处?我很好奇 - ?我们怎么觉得

Let's compare and contrast these methods (and maybe others I haven't listed) and talk about the pros and cons of each - right now, ExternalInterface seems like the way to go in terms of flexibility, but is it right for all situations? Are there concrete benefits in terms of execution speed or anything like that? I'm curious - what do we think?

推荐答案

ExternalInferface是为了让JS和Flash之间更容易沟通,所以它好好尝试一下真正意义的使用别的。通常的做法是通过调用一些JS前评估ExternalInterface.available属性的值,以检查其可用的第一个。这个属性告诉你,如果要在其中调用一些JS的SWF是一个容器,提供了一个外部接口内。 。换句话说,如果使用ExternalInterface的正常工作。如果其不可用,则只需使用flash.sendToUrl。切勿使用fscommand(),因为它使用VBScript和可能导致与其他VBScript的冲突在页面上。此外,你只能发送一个参数字符串的fscommand并且必须对JS一边拆呢。

ExternalInferface was created to make communication between JS and Flash easier, so it doens't really make sense to use anything else. Common practice is to check if its available first by evaluating the value of the ExternalInterface.available property before making a call to some JS. This property tells you if the SWF in which you want to call some JS from is inside a container that offers an external interface. In otherwords, if using ExternalInterface will work. If its not available then just use flash.sendToUrl. Never use fscommand() as it uses VBScript and can cause conflicts with other VBScript on a page. Additionally, you can only send one argument string with fscommand and have to split it on the JS side.

更多推荐

ActionScript3的JavaScript的通信:最佳实践

本文发布于:2023-11-23 15:31:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621956.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通信   JavaScript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!