compile a swc in flash for use in flex, with a class written in flex

时光总嘲笑我的痴心妄想 提交于 2019-11-29 12:25:18

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!