在 Flex 库项目中使用 .swc
我正在尝试为大约 10 个相关资产设置生产环境。某些元素(视觉元素和其他元素)将在这 10 项资产之间共享。我将每个资源视为 Flash Builder 4 中自己的纯 AS3 项目。
每个资源都有一个关联的 .fla,该资源将 .swc 输出到该资源的 libs 文件夹中 - 最终编译将通过 ant 完成,并且顶级源是每个 Flash Builder 项目中的主 .as 文件。
由于某些元素在多个资源之间共享,因此我在工作区中创建了一个 Flex 库项目。这个库项目有一个具有标准结构的 /src 文件夹,以及一个 /lib/ 文件夹,我在其中粘贴了例如 greensock 的 TweenLite。
除了源代码和第三方 .swc 之外,Library 项目还有一个 FLA,它将 .swc 导出到 /lib/ 文件夹中。
问题是:我无法在相关项目中看到该 .swc 的库导出。理论上,我从 Flex 库项目的 .fla 库导出的每个类都应该编译到库项目的 .swc 中。我发现事实并非如此,我不清楚为什么。
我将继续挖掘,但我想将其放在这里,以防其他人遇到这些问题。有人知道我做错了什么吗?
编辑:显然我的 greensock .swc 也没有被编译到最终输出中。昨天是这样。我不确定发生了什么变化。我想我的问题归根结底是这样的:如何确保 Flex 库项目的构建路径中包含的 .swc 文件将其所有类包含在 FLP 生成的最终 .swc 中?
EDIT2:我发现了一种可怕的解决方法。现在,我已经在 src 文件夹中创建了一个类,并且声明了我想要从任何 .swc 中包含的任何内容 - 例如,public var tweenLite:TweenLite、public var logo:Logo 等。我发现如果我在我的源文件之一中声明它,那么我就可以在相关项目中访问它。单独导入它是不够的 - 这意味着我必须手动声明我想要访问的每个类。一定有更好的方法。我缺少什么?
I'm trying to set up a production environment for about 10 related assets. Certain elements, visual and otherwise, are going to be shared between the 10 assets. I'm treating each one as its own Pure AS3 project in Flash Builder 4.
Each asset has an associated .fla which is outputting a .swc into the libs folder for that asset - the final compilation is going to be done via ant, and the top-level source is the main .as file in each Flash Builder project.
Because certain elements are shared between multiple assets, I've created a Flex Library Project in my workspace. This library project has a /src folder with a standard structure, as well as a /lib/ folder in which I'm sticking, for instance, greensock's TweenLite.
In addition to the source code and third-party .swc, the Library project also has an FLA which exports a .swc into the /lib/ folder.
Here's the problem: I'm not able to see library exports from that .swc in my related projects. In theory, every class I export from the library of the Flex Library Project's .fla should be compiled into the library project's .swc. I'm finding that this is not the case, and I'm not clear why.
I'm going to continue digging, but I wanted to throw this up here in case anyone else has run into these issues. Anyone know what I'm doing wrong?
EDIT: So apparently my greensock .swc isn't being compiled into the final output either. Yesterday it was. I'm not sure what has changed. I guess my question, distilled down, is this: how can I make sure that .swc files included in the build path for my Flex Library Project have all of their classes included in the final .swc that the FLP generates?
EDIT2: I've discovered a sort of a terrible workaround. Right now I've created a single class in my src folder and I'm declaring anything that I want included from any of my .swc's - so for instance, public var tweenLite:TweenLite, public var logo:Logo, etc. I find that if I declare it in one of my source files then I'm able to access it in a related project. Importing it alone is not enough - this means that I would have to manually declare every class I want access to. There must be a better way. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了一些问题,这些问题与我们从 SDK swc 1 获取 A 类和从 SDK swc 2 获取 B 类(blendMode 错误结果)是同一行的,最后我们必须保证所有依赖项都使用特定的编译器进行编译SDK 的版本(同样不好玩)。我认为听起来您想要一个包含新库所依赖的所有其他库的源代码的库。
基本上,每个 swc 都是一个目录文件和压缩为 zip 的 ActionScript(AS) 文件的 ActionScript 字节码 (ABC),因此您希望它将这两个部分合并到一个 swc 中。
使用运行时共享库 (RSL) 意味着不是在编译时从 swc 中提取字节码并将其包含在 swf 中,而是在运行时加载 swc(以这种方式打包时称为 swz)。缺点是它将所有类存储到 swz 中,而不是在编译时只提取所需 AS 的字节码。因此,我相信通过 RSL 进行链接应该会得到您想要的结果,但您必须从库中生成 swz 文件。你最终可能仍然不得不做一些荒谬的事情,比如在你的 swz 中引用你想要的所有东西(来自其他 SWC),但我相信你应该能够以某种方式解决这个问题......我正在继续环顾四周以获得更好的解决方案,如果我找到一个,将编辑此解决方案:
http://tv.adobe.com/watch/adc-presents/creating-runtime-shared-libraries/
编辑1:
还发现了这个:
compc -source-path ../mycomponents /组件/本地
-include-classes CustomCellRendererComponent
-目录=true
-调试=假
-output ../libraries/CustomCellRenderer
从此页面:
http://livedocs.adobe.com/flex/3/html/help.html?content=rsl_01.html#168690
我对此也有一些想法一直在环顾四周,1这在空间方面效率非常低,因此所有工作都只包括您正在使用的类,2如果使用上面的方法我可能会编写一个java应用程序来遍历项目所有类名称的文件夹,这样我就可以让它生成项目空间中所有类的列表。
感谢您听听我的想法(仍然是 WIP :),
肖恩
I've experienced some issues that are down the same line where we were getting Class A from SDK swc 1 and Class B from SDK swc 2 (blendMode error results), in the end we had to guarantee all our dependencies were compiled with a particular version of the SDK (also not fun). I think it sounds like you want a library that contains the source from all the other libraries that your new library depends on.
Basically each swc is a catalog file and the ActionScript Bytecode (ABC) for the ActionScript(AS) files compressed into a zip, so you'd want it to merge both of those parts into a single swc.
Using Runtime Shared Libraries (RSL) means instead of pulling the bytecode from the swc and including it in your swf during compile time it'll load the swc (called a swz when packaged this way) at run-time. The disadvantage is it stores all the classes into the swz as opposed to only pulling the bytecode for the AS you need when done at compile time. So going with linking via RSL should get you the result you want i believe but you'll have to generate the swz files from your library. You may still end up having to do something ridiculous like having references to everything you want in your swz (from the other swcs) but I believe you should be able to resolve the issue this way somehow... I'm continuing to look around for a better solution and will edit this if I find one:
http://tv.adobe.com/watch/adc-presents/creating-runtime-shared-libraries/
Edit 1:
Also found this:
compc -source-path ../mycomponents/components/local
-include-classes CustomCellRendererComponent
-directory=true
-debug=false
-output ../libraries/CustomCellRenderer
From this page:
http://livedocs.adobe.com/flex/3/html/help.html?content=rsl_01.html#168690
A couple of thoughts on this too as I've been looking around, 1 this is going to be horribly inefficient in terms of space, hence all the work to only include the classes you're using, 2 if using the method above I would probably write a java app that'll traverse a projects folders for all the Class names so I could have it generate a listing of all classes in the project space.
Thanks for hearing out my thoughts (still a WIP :),
Shaun