问题描述
我有一个相当大的Flash应用程序,我建立在Flash Builder(因为编码/调试在Flash IDE是...不是很好),我已经有了大量的外部SWC文件,这我链接在我的应用程序。这工作很顺利 - 文件的大小是在大的方面,但它比装在主权财富基金更简单了很多,尤其是因为我伸出大部分的类中的每个SWC并添加自定义的code的方式(这是一个设计非常重应用程序。)我遇到的问题是,当我有闪光灯组件,如组合框或的TextInput,在一个以上的深港西部通道。无论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源在他们的皮肤,所以我尝试用默认的皮肤取代他们,但似乎并没有帮助。我怎么能保证我有部件采用进口,并提供给所有我的班,但仍然能够剥他们,包括他们在我的各种FLAS? (我从来没有创造他们的新实例,它们是由我设计的所有布局。)
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),以出口为运行时共享。然后,在你的其他FLAS,每当你想要的一个组成部分,从组件FLA库将它(它应该出现在你与主库导入为运行时共享开启。)请确保您没有ComponentShim在你的主库。你需要在同一个文件夹作为FLAS编译组件的SWF文件。
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.
这里做的事情是把所有的组件code,包括皮肤,在一个中心位置,在编译时(无论是为SWF或深港西部通道,但这个问题使用的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组件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!