第四章

Using External API and LocalConnection
SWF files are executed and rendered into Flash Player via a browser or desktop. This sometimes requires external communications with web scripting languages such as JavaScript or with other SWF applications running on different instances of Flash Player to exchange data. ActionScript 3.0 enables this type of communication by providing a set of APIs and classes.
This chapter will primarily focus on the following two points:
1.Using External API
2.Using LocalConnection

The External API is a subset of ActionScript 3.0 and enables communication between a Flex application and the container application within which your Flex application is running. When you build a Flex application from Flex Builder, it also generates an HTML wrapper to execute your Flex .swf file into Flash Player instance. This HTML wrapper is known as the container application in this context.
This section gives you an overview of how the External API can be used to establish communication and exchange data between your ActionScript and JavaScript from HTML wrapper and vice versa.
An external API can be very useful in cases where you want to interact with container applications directly, or exchange data between JavaScript and ActionScript (and vice versa). A common example would be if you want to pass some data from an HTML page to your SWF file.、
外部API和本来连接的使用方法
SWF文件如果要通过浏览器或桌面在Flash Player中运行,这有时需要web脚本语言通过外部交换在不同Flash Player版本运行来交换数据,例如:javascript或其SWF应用程序
ActionScript 3.0 提供一系列的APIs和类达成这种数据交换。
本章内容将主要集中在以下两方面:
1、External API(外部应用程序接口)的使用
2、LocalConnection(本地连接口)的使用
External API(外部应用程序接口)外部API是ActionScript 3.0 的一个子集,它能让一个Flex应用程序与你flex运行的范围内容器应用程序交流数据。
他能在一个Flex应用程序和你运行的Flex应用程序容器之间交换数据。当您建立一条从Flex Builder的Flex应用程序,也生成一个HTML把你Flex中的.swf文件执行到Flash Player 示例中。这个HTML封装被认为是在这上下文(context)的容器应用程序.这HTML包装被称为在这方面容器应用程序。
这章节概述关于如何使用外部API通过html包装在你的Actionscript和JavaScript之间建立数据交流和数据交换,反之亦然
一个外部(external)API在当你想直接去和容器的应用程序交互或者在JavaScript和Actionscript交互数据的时候是非常有用的。
如果你想从HTML页传送一些数据到您的SWF文件,请看下面的例子:

你可能感兴趣的:(JavaScript,Flex,Flash,Exchange,actionscript)