Vinnie Vivace from New Zealand raises an interesting problem, exactly the same one as I’m having. He is authoring UIMovieClips in Flash using the Flex Component Kit for Flash. He is getting compiler errors because certain classes are missing, such as ArrayCollection.
A commenter on his blog suggests that he eliminate all dependency on Flex classes. Well, duh. If that was possible, that would be easy. But I am using value objects that are used in communication with the server via remoting. It’s not reasonable to have to ask the backend developers not to use ArrayCollection just for the sake of some damn problem Flash has. For God’s sake, UIMovieClip is in mx.flash … I wonder if it’s possible to compile certain other mx classes into my UIMovieClip. If I find a solution I will post it here.




The reason for this is that the Flex Component Kit only contains the mx.flash.* package, which contain no direct dependencies to the Flex framework beyond a few interfaces in this package. So ArrayCollections don’t work. And databinding metadata is from the Flex compiler. So as a rule, don’t use anything in ‘CustomClass extends UIMovieClip’ that is not in mx.flash.* or the AS3/Flash API.
The solution is easy enough.
If you have a CustomClass asset in the FLA library which extends UIMovieClip in CustomClass.as, make sure it does not contain any flex-specific behaviour. In Flex, create a subclass of CustomClass as your final component, such as ‘FlexCustomClass extends CustomClass’, and add your Flex-specific behaviour in that class. FlexCustomClass will be compiled by the Flex compiler and thus have access to the Flex SDK.
That sounds good – but how do I make my Flash-authored component act as a FlexCustomClass instance?
Joshua,
According to Joeflash, you create another class that extends your CustomClass (which extends UIMovieClip) in Flex. At that point, you can add any other properties or variables you need in that class, such as the ArrayCollection. The only downside is you would still need to map between them from an ArrayCollection to classes that are available in your CustomClass.as.