Mixins in ActionScript

During discussion with friends, colleagues and community, I have realized that ‘Mixins’ has been a topic of confusion and many people are not aware of. This might be because ‘Mixins’ concept is not intuitive in Object Oriented Programming and it also violates the principals of OOP. But sometimes a little violation can make our life simpler, Mixins concept let you do multiple inheritance someway even though multiple inheritance is not supported in the language.
‘Mixins’ are classes which are not used directly, rather we mix the properties and methods of these classes into other classes using language specific techniques. This allows a class having behaviours from different classe, much like multiple inheritance. ActionScript being a dynamic and prototype based language, this becomes more easier and useful. The very first ‘Mixins’ class I ever used, was ASBroadcaster, which is still undocumented class(object).
I tried my way to explain it but I guess, I have bookmarked an article which gives the better insight of this topic. This article is easy to understand and is in context of ActionScript , Macromedia V2 component architecture and Flex.
Article Link: http://www.macromedia.com/support/documentation/en/flex/1/mixin/index.html

  • n8

    Getting some wacky compiler errors when i try to extend the TextField.StyleSheet class when i compile in Flash 8.
    Flash MX 2004 Prof works like a champ, but I compile in Flash 8 and for some reason the compiler is telling me ‘super’ is not an property or a method.
    “There is no method with the name ‘super’.
    var format:TextFormat = super.transform(style);”
    The funny thing is, i pull the code out of the current application, and use the same code/classes in a very thin fla file, and it compiles correctly. So I thought, hey it’s something else in the application, but when i compile the application, it works fine. WEIRD! if i make a change ot the class, save and compile, the error re-appears. To fix it, I compile the thin fla, and re-compile the application, and viola! no error, any suggestions for compiling in Flash 8?

  • Srđan Prodanović

    You are a lifesaver N8! I noticed the same type of
    behaviour with the small FLA, but I didn’t realise
    the compiler could be tricked by keeping the swf
    running. This way I can keep the small FLA compiled
    and running in a minimized flash projector within
    the IDE, and continue to recompile the main app
    anytime I want to. I was about to start implementing
    a text content element by loading the small SWF :-S
    The compiler would have gotten quite a few glares
    from me, in case I hadn’t found this comment. Once
    again, thanks a bunch!