在flash中编译一个swc以在flex中使用,并使用一个用flex编写的类

发布于 2024-07-25 14:16:40 字数 512 浏览 16 评论 0原文

好吧,

听起来很复杂,但事实并非如此。 开始: 我想使用一些我在 Flex ActionScript 项目中在 Flash 中创建的资源(按钮等)。 由于我的所有资源都低于 10K,所以我不打算加载 swf,等到它加载并创建界面。 我想使用 SWC 并仅实例化我需要的剪辑。 另外,我希望我的 Button 类具有一些额外的属性,这就是问题发生的地方。

如果在 Flash IDE 的链接属性中添加对自定义按钮类的引用并跟踪按钮 MovieClip 的子级,我会得到正确的跟踪。 如果然后我在 Flex 的 Main 类中使用生成的 SWC 文件创建一个 Button 并跟踪 Button MovieClip 的同一个子项,我将得到 null。

这是为什么 ? 有办法解决这个问题吗? 我考虑过使用 Flex Component Kit,但由于我正在开发一个简单的 ActionScript 项目,并且没有使用 Flex 框架,因此我认为此时使用 Component Kit 没有任何意义。

谢谢!

OK,

It sounds complicated, but it's not. Here goes:
I want to use some assets ( buttons, etc. ) I'm creating in flash in a flex actionscript project. Since all my assets are bellow 10K, I'm not planning to load a swf ,wait until it's loaded and create the interface. I want to use a swc and just instance the clips I need. Also, I want my Button class to have some extra properties, and this is where the problem occurs.

If in the Linkage Properties in the Flash IDE I add a reference to a custom Button Class and trace a child of the Button MovieClip, I get the right trace. If then I create a Button, in the Main class in Flex, using the generated swc file and trace the same child of the Button MovieClip, I get null.

Why is that ? Is there anyway to get around this ? I've considered using the Flex Component Kit, but since I'm working on a simple actionscript project and I'm not using the Flex framework, I see no point in using the Component Kit at this point.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明天过后 2024-08-01 14:16:40

我想我明白了。

我的 Button MovieClip 链接到与 Flex 动作脚本项目中的其余动作脚本代码位于同一 src 文件夹中的类。 (as3 类路径设置为“../”,从 .fla 文件所在的 asset 文件夹,向上一层到 src )

当 Flash 编译时,找到了该类,并进入了 .swc 文件。 这就是为什么我从闪存中追踪到符号的原因。
当Flex编译时,在src目录中找到该类,因此编译了同一类的新版本,尽管它已经存在于swc文件中。 由于 Flex 找到了 .as 文件,但不知道我已将其链接到 Flash IDE 中的符号(我认为它无法做到这一点),Flex 创建了该类的版本,但由于没有链接任何符号对于该类,我正在跟踪的 Button 的子级为 null。

我猜想使用包并将 fla 链接的类分开,这样 Flex 就不会编译同一个类两次。

奇怪的是我没有收到任何警告或错误,所以我认为一切都很好。

一个快速且不太脏的解决方法是从文件系统中删除物理 Button 类,以便 Flash 可以在编译时生成它的版本并引用 Button 符号的子代。 然后在 Flex 中我创建了一个扩展 Button 的类并添加了我需要的代码。 由于生成的类是在 .swc 文件中编译的,Flex 可以看到这一点,并且我在扩展时没有问题。

就是这样! 鲍勃你是叔叔!

我假设会发生什么,我不是 100% 确定。 这是我的直觉通过观察而认为理所当然的事情,所以我在技术上可能是错误的。
如果有人有任何纠正,欢迎指正。

I think I got it.

My Button MovieClip was linking to a class in the the same src folder as the rest of my actionscript code in the Flex actionscript project. (The as3 classpath was set to "../", from the assets folder where the .fla file lives, one level up to src )

When Flash compiled, the class was found and I got in the .swc file. That is why I got the symbol traced from flash.
When Flex compiled, the class was found in the src directory, so a new version of the same class was compiled, although it already existed in the swc file. Since flex found the .as file, but wouldn't know I had it linked to a symbol in the Flash IDE ( I don't think it can do that ), Flex created its version of the class, but since no symbol was linked to that class, the child of Button I was tracing was null.

I guess using packages and keeping the fla linked classes separate so Flex wouldn't compile the same class twice.

The weird thing is I didn't get any warning or error, so I assumed everything was fine.

A quick and not so dirty workaround was to delete the physical Button class from the filesystem, so that Flash could generate it's version on compile time and have references to the children of the Button symbol. Then in Flex I cread a class that extends Button and added the code I needed. Since the generated class got compiled in the .swc file, Flex could see that and I had no problem extending.

That was it! Bob's you're uncle!

I assumes that what happens, I am not 100% sure. It's something my intuition takes for granted through observation, so I might be technically wrong.
If anyone has any correction they're welcome.

游魂 2024-08-01 14:16:40

我不确定我是否正确地阅读了您的问题,但您本质上是否想要嵌入从一开始就可用的图像/资产,插入应用程序初始化后加载的图像/资产?

如果是这种情况,请查看此链接。 它解释了如何将任何资产嵌入到动作脚本项目中。 http://kennethsutherland.com/2009/04 /21/why-flex-why-actionscript-why-flash/

希望这就是您想要的。

I'm not sure if I'm reading your question correctly but are you essestially wanting to embed an image/asset that is available from the start, insted of the image/assets being loaded once the app initilises?

If this is the case then check out this link. It explains how to embed any asset into an actionscript project. http://kennethsutherland.com/2009/04/21/why-flex-why-actionscript-why-flash/

Hope this is what your after.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文