在多个 SWC 文件中使用 Flash 组件时出现问题 [英] Problem using Flash Components in multiple SWC files

查看:21
本文介绍了在多个 SWC 文件中使用 Flash 组件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Flash Builder 中构建了一个相当大的 Flash 应用程序(因为在 Flash IDE 中进行编码/调试......不好),并且我有大量外部 SWC 文件要链接在我的应用程序中.到目前为止效果很好 - 文件大小偏大,但它比加载 SWF 简单得多,特别是因为我正在扩展每个 SWC 中的大多数类并以这种方式添加自定义代码(这是一个非常设计 -繁重的应用程序.)我遇到的问题是当我在多个 SWC 中拥有 Flash 组件(如 ComboBox 或 TextInput)时.无论最后编译哪个 SWC 都可以正常工作,但其他 SWC 将失败并出现如下错误:

I have a rather large Flash application which I'm building in Flash Builder (because coding/debugging in the Flash IDE is... not good) and I've got a ton of external SWC files which I'm linking in to my application. This has worked well so far - the file size is on the large side, but it's a lot simpler than loading in SWFs, especially since I am extending most of the classes in each SWC and adding custom code that way (it's a very design-heavy app.) The problem I'm having is when I have Flash Components, like ComboBox or TextInput, in more than one SWC. Whichever SWC was compiled last will work fine, but the others will fail with errors like the following:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@1f21adc1 to fl.controls.TextInput.
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at com.company.design.login::LoginForm()
    at com.company.view::Login()[/Users/ken/Workspace/src/com/company/view/Login.as:22]
    at com.company.view::Main/showLogin()[/Users/ken/Workspace/src/com/company/view/Main.as:209]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.company.view::Navigation/handleUIClick()[/Users/ken/Workspace/src/com/company/view/Navigation.as:88]

我一直在研究组件、ComponentShim 等,但我遇到了难题.我认为这可能是因为某些组件的皮肤在源 FLA 中进行了修改,所以我尝试用默认皮肤替换它们,但这似乎没有帮助.如何确保我的组件已导入并可供我的所有类使用,但仍然能够对它们进行蒙皮并将它们包含在我的各种 FLA 中?(我从不创建它们的新实例,它们都是由我的设计师设计的.)

I've been researching components, ComponentShim, etc. but I'm running up against a brick wall. I thought it might be the fact that some of the components had their skins modified in the source FLA, so I tried replacing them with the default skins, but that didn't seem to help. How can I ensure that I have the components imported and available to all my classes, yet still be able to skin them and include them in my various FLAs? (I am never creating new instances of them, they are all laid out by my designer.)

推荐答案

我找不到详细的修复方法(显然,我当时使用的工作电子邮件在我不知情的情况下丢弃了旧邮件!)但简短的回答是要创建一个包含您要在其中使用的所有组件的 FLA,请将这些组件(和 ComponentShim)设置为Export for Runtime Sharing".然后,在您的其他 FLA 中,只要您需要一个组件,就将其从组件 FLA 库中拖动(它应该显示在您的主库中,并打开导入以供运行时共享".)确保您没有 ComponentShim你的主图书馆.您需要将已编译的组件 SWF 文件与您的 FLA 放在同一文件夹中.

I can't find the detailed fix (apparently, the work email I used at the time was trashing older messages without my knowledge!) but the short answer is to create one FLA that has all the components you want to use in it, set those components (and the ComponentShim) to 'Export for Runtime Sharing'. Then, in your other FLAs, whenever you want a component, drag it from the components FLA library (it should show up in your main library with 'Import for Runtime Sharing' turned on.) Make sure you don't have a ComponentShim in your main library. You'll need the compiled component SWF file in the same folder as your FLAs.

这样做的目的是将包括皮肤在内的所有组件代码保存在一个中心位置,因此当您编译时(无论是作为 SWF 还是 SWC,虽然这个问题主要在使用 SWC 时出现),所以不会发生冲突.

What this does is keep all the component code, including skins, in one central place, so when you compile (be it as a SWF or a SWC, though this problem mainly crops up when using SWCs) there are no conflicts.

这篇关于在多个 SWC 文件中使用 Flash 组件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆