Flex:如何访问导入的 swf 中的影片剪辑
我已将 swf(不是用 Flex 创建的,即非框架)导入到 Flex 应用程序中。加载后,我想访问导入的 swf 中的影片剪辑。查看 Adobe 的文档 (http://livedocs.adobe .com/flex/3/html/help.html?content=controls_15.html),看起来很简单;但是,它们的示例是在 Flex 应用程序和导入的 swf(使用 Flex 创建的)之间。
就像他们的例子一样,我尝试使用 SystemManager 来访问导入的 swf 的内容;但是,我收到以下错误:
TypeError:错误 #1034:类型强制失败:无法将 flash.display::MovieClip@58ca241 转换为 mx.managers.SystemManager。
是发生此错误是因为我将非框架 swf 导入到框架 swf 中吗?预先感谢您的任何帮助。
代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:SWFLoader source="assets/test.swf" id="loader" creationComplete="swfLoaded()" />
<mx:Script>
<![CDATA[
import mx.managers.SystemManager;
[Bindable]
public var loadedSM:SystemManager;
private function swfLoaded():void
{
loadedSM = SystemManager(loader.content);
}
]]>
</mx:Script>
</mx:Application>
I have imported a swf (not created with Flex, i.e. non-framework) into a Flex application. Once loaded, I would like to access movieclips within that imported swf. Looking at Adobe's docs (http://livedocs.adobe.com/flex/3/html/help.html?content=controls_15.html), it seems straightforward; however, their examples are between a Flex app and an imported swf (created with Flex).
Like their example, I'm trying to use the SystemManager to access the imported swf's content; however, I receive the following error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@58ca241 to mx.managers.SystemManager.
Is this error occurring because I'm importing a non-framework swf into a framework swf? Thanks in advance for any assistance.
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:SWFLoader source="assets/test.swf" id="loader" creationComplete="swfLoaded()" />
<mx:Script>
<![CDATA[
import mx.managers.SystemManager;
[Bindable]
public var loadedSM:SystemManager;
private function swfLoaded():void
{
loadedSM = SystemManager(loader.content);
}
]]>
</mx:Script>
</mx:Application>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
test.swf 是使用早期 AS 版本创建的吗?根据 此 为 AS 1.0 发布的 swf /2.0 在与 AS 3 不同的 AS 虚拟机中运行。
Was test.swf created with an earlier AS version? According to this swfs published for AS 1.0/2.0 runs in a different AS virtual machine than AS 3.
您可以使用它们的实例名称直接访问它们。
You can access them directly, using their instance names.