两个swf之间相互调用
利用LocalConnection来通信。详见api中LocalConnection类 ? 有4中通信方式 在一个swf文件内 在多个swf文件之间 在AIR应用程序的内容(基于SWF或基于HTML)之间 在 AIR 应用程序的内容(基于 SWF 或基于 HTML)和运行于浏览器中的 SWF 内容之间 ? 同一个域。这是使用 LocalConnection 对象最简单的情况,它只允许在位于同一个域中的 LocalConnection 对象间通信,这是因为默认情况下,应用程序允许同域通信。当同一个域中的两个 文件通信时,无需实施任何特殊的安全措施,而只需将 // receivingLC is in http://www.domain.com/receiving.swf receivingLC.connect('myConnection'); ? // sendingLC is in http://www.domain.com/sending.swf // myMethod() is defined in sending.swf sendingLC.send('myConnection','myMethod'); ? 具有可预知域名的不同域。当不同域中的两个 SWF 文件通信时,需要通过调用 ? ? // receivingLC is in http://www.domain.com/receiving.swf receivingLC.allowDomain('www.anotherdomain.com'); receivingLC.connect('myConnection'); ? // sendingLC is in http://www.anotherdomain.com/sending.swf sendingLC.send('www.domain.com:myConnection','myMethod'); ? 具有不可预知域名的不同域。有时候,可能希望具有接收方 LocalConnection 对象的 文件在域之间具有更好的可移植性。为了避免在 ? ? // receivingLC is in http://www.domain.com/receiving.swf receivingLC.allowDomain('*'); receivingLC.connect('_myConnection'); // sendingLC is in http://www.anotherdomain.com/sending.swf sendingLC.send('_myConnection','myMethod'); ? 可以使用 LocalConnection 对象发送和接收单个 文件中的数据,但这不是通常的用法。 ? //====================我的实例 ? 这是两个不同域的swf,要么用allowDomain('*'); connectionName前加下划线 要么用特定的域名限制,connectionName前不加下划线 ? ManagerApp.as ? ViewApp.as? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |