在 swf 之间共享代码
假设我有两个 swf A 和 B,在运行时,swf A 加载 swf B,并且我希望在它们之间共享代码,以最大限度地减少文件大小和下载时间。
如果 swf B 有一些代码(例如 com.blah.HelloWorld),我告诉编译器将 swf B 的源代码放在 swf A 的类路径中,但只进行编译时链接,而不实际将 com.blah.HelloWorld 编译到 swf A 中 这是
有效的,我已经尝试过使用 -includes 和 -externs 编译器选项。
然而,我的问题是我希望以另一种方式做到这一点。即 swf A 和 B(以及可能的 swf C)都需要 com.blah.HelloWorld,但我希望将 com.blah.HelloWorld 编译为 swf A,将其作为 swf B(以及可能的 C)中的外部引用.)
我尝试使用 externs 和 include 来执行此操作,但是当我执行此操作时,我收到了 ReferenceErrors。
我想在没有单独的 rsl 的情况下执行此操作,这样我就可以减少 http 请求的数量。 这可能吗?
Lets say I have two swfs A and B, and at runtime, swf A loads swf B, and I wish to share code between them, to minimize file size and download times.
If swf B has some code (say. com.blah.HelloWorld), I tell the compiler to have swf B's source in swf A's classpath, but only do a compile-time link and not actually compile com.blah.HelloWorld into swf A.
This works, and I have tried it, using a the -includes and -externs compiler options.
However, My problem is that I wish to do this the other way. i.e. swf A and B (and potentially swf C) all need com.blah.HelloWorld, but I want com.blah.HelloWorld to be compiled into just swf A, have it as an external reference in swf B ( and potentially C as well.)
I tried doing this using the externs and includes, but I get ReferenceErrors when I do this.
I want to do this without a having a separate rsl, so I can reduce the number of http requests.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将 Flex 应用程序拆分为模块。
或者,您可以使用
ApplicationDomain
类的getDefinition
方法从运行时加载的 SWF 访问各个类:You can split your flex application into modules.
Or you can access individual classes from an SWF loaded at runtime using the
getDefinition
method of theApplicationDomain
class:我不确定我是否完全理解你的问题,但我认为你可以使用 AS3 Loader 类来做你想做的事。格式将是这样的 - 假设我们正在创建您的主应用程序(称为“a.swf”),并且您想要访问已编译到另一个应用程序(称为“b.swf”)中的方法和属性),你会这样做:
......我认为这会起作用。我现在无法测试它,但尝试一下并告诉我。基本上,您将加载 b.swf 作为基本对象,然后您可以针对该对象调用方法。
请告诉我这是否有效,如果无效,我明天可以为您改进。
I'm not sure I'm quite understanding your question, but I think you can use the AS3 Loader class to do what you want. The format would be something like this - let's say we're creating your main app (which will be called "a.swf") and you want to access methods and properties that have been compiled into another app (called "b.swf"), you'd do this:
... and I THINK that'll work. I can't test it right now, but try it and let me know. Basically you're going to be loading b.swf in as a basic object, and you can then call methods against that object.
Please let me know if that worked, and if not I can refine it for you tomorrow.
我不确定这是否正是您想要的,但您可以使用一些 javascript 来允许两个 swf 一起工作。
这是一个教程:
http://greeneggsandcam.com/tutorials/connect-2-swfs
I'm not sure if this is exactly what you want, but you could use some javascript to allow the two swfs to work together.
Here is a tutorial:
http://greeneggsandcam.com/tutorials/connect-2-swfs