UPDATE: Chalk this post up to my own ignorance - Simon Cave has pointed out that you can basically do exactly what I proposed by just exporting a
swc and compiling with the
FlexSDK. Obviously that has it's own advantages and disadvantages, but for the sake of this benefit I'm probably going to move over to that
workflow. Here's the original post anyway....
Here's a "what if" post for any developer who works with the Flash
IDE. Something that often bugs me is that when you want to access
DisplayObjects which have been placed on the timeline of a
MovieClip, you don't know what
DisplayObjects are there, or their type. For example, say you have an animation, and nested 3
MovieClips deep in the animation is a "hand"
MovieClip. You can access the clip with "throwAnimation.leftArm.hand", but while you are developing you can't be sure that this path actually exists, and you won't know the type of "hand". If you want to call a function in hand, you might end up doing something like: "Hand(throwAnimation.leftArm.hand).closeFist()". It works, but again you don't know while you're typing that "hand" actually is an instance of the Hand class.
One solution might be to create a
ThrowAnimation class, an Arm class and a Hand class and set the linkages of each
MovieClip in the library. These classes would simply contain public variables for the
DisplayObjects they contain. Then you can happily type: "
throwAnimation." (hit
CTRL-SPACE in Eclipse) and your code editor will give you a drop-down menu showing all the variables of
throwAnimation, including
leftArm, hit ENTER and then get a list of
leftArm's properties, including hand. The only downside is, you have to create 2 more classes just to get
autocompletion.
Thinking back to my days doing Visual Basic, I think I remember that it
autogenerated some code every time you added a button to the design view. Flash just needs to do the same thing. Think about it - all the information it needs is right there to
autogenerate classes which know what
DisplayObjects they contain and their type. It can get the instance names from the stage and the type from the Library. Then we happily know while we code that we are accessing
DisplayObjects that exist. I think this is basically the same idea behind
MXML and
XAML - so maybe what we need is a just an XML-driven FLA format in CS5? Any thoughts?