I wanted to talk a while ago about the [Mixin] meta-data tag but I forgot
.
Most programmers have heard of the static code concept but if they try to implement it in AS3/Flex they have problems. Here is how to do it:
package { import mx.managers.ISystemManager; [Mixin] public class StaticCode { public static function init(systemManager:ISystemManager):void { trace("this gets called first"); } } }
As long as this class is referenced somewhere in your application, the init method gets called when the application is starting up. The magic is done by the [Mixin] tag. It is used in the Automation Framework from Flex mainly to register automation delegate implementations to component classes before any instances get the chance to be created.
I use it in the logging framework to make all necessary initializations before the application even starts.
This post was inspired by a post done by Adam Flater.
Tags: felx 2, meta, mixin, tag
This post was written by Virgil Cristea
Views: 5463










Learn something new everyday, that is pretty handy and a much cleaner approach.
Thanks