Get list of classes in flex application
This isn’t common goal for developers. And furthermore problem solving isn’t easy. Actionscript code doesn’t give access to available classes at runtime. So only trick I can image is parsing swf file by itself and get class names. Crazy implementation? Yes, it is.
But no coding here because flash decompilers written in actionscript already exist.
Swfassist:
Nice library that gives ability to write and read tags in swf files. Developers are from Japan as I understand so it’s hard to determine full feature list. But I found no way to determine loaded class info there. It repo.
FlashDecompiler:
Cool air application that can load and decompile swf files.
For accomplishing my goal I took FlashDecompiler source and used only needed classes. Unfortunally code had a lot of dependency so I had to cut/change project code. Finally I got 60KB code for retrieving class info. And it is not only one inconvenience. Application load and parse swf at start time so it take few excess second to start. But I still think that it is acceptable. Here is cutted code.
You might ask me for why it is needed? He-he. That could open door for few nice features. You can build dependency injection engine by marking classes with specific metadata. That’s the main goal. Currently Flash Player gives only info about class by it name. But need to know which classes marked with specific metadata. That is what I’m going to implement.
Update 1:
I found more short way to get bytes of current runned swf. It is available via next code in Application class
systemManager.loaderInfo.bytes
So now no needs to load current swf file again. Sample code updated.
Use google.com/translate
For Japan sites
http://google.com/translate?u=http://www.libspark.org/wiki/yossy/swfassist&langpair=ja|en&hl=en&ie=UTF8