i've got some working actionscript3 code that i'd like to present as a library. there's no skins or components, just pure as3 classes. so i created an SWC, put all the code there, packaged it as SWC. the code itself depends on several other SWCs, so i included these as merged dependencies, so the resulting SWC has it all inside (size sucks, but to be sure). checked the linker report to be sure as well, everything looks fine.
however, when i try to use this SWC in a Flex application (which can even be 开发者_StackOverflowempty), i get weird runtime errors like this:
ReferenceError: Error #1065: Variable _FormItemStyle__embed_css_Assets_swf_mx_containers_FormItem_Required_527421487 is not defined.
at flash.display::MovieClip/nextFrame()
at mx.managers::SystemManager/deferredNextFrame()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:319]
at mx.managers::SystemManager/preloader_initProgressHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2945]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/timerHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\preloaders\Preloader.as:398]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
i haven't got a clue what that means and what did i miss o_O (apparently there's something wrong with library packaging). i suppose it's something very stupid, as millions of developers create their own SWCs without any problems. my Flex SDK is 3.2.0, i use Maven and flex-mojos (but that doesn't matter as i tried to build the SWC purely with Flash Builder and got the same results) and i build towards flash-player 9 (but that also doesn't matter, i got the same shit building towards 10).
can someone help me on this one?
UPDATE.
apparently it has to do with transitive dependencies, if i add all the SWCs my library depends on to the final Flex application, everything works. so the question now is: how do i make it work without doing so and why doesn't it work even that these transitive dependencies are merged in my SWC?
Looks like you're trying to use runtime shared library or external as the linkage for your dependencies. Try changing them to merged into code. In Flash Builder that's in Properties -> Flex Library Build Path -> Library Path
. (I'm not sure how to do that using Maven though). That way the bytecode for those classes will be included in the swc, and there won't be "transitive dependencies".
精彩评论