« Actionscript 3 Search Trend by Google
» Compare two objects

ActionScript, Flex 2

mixin

Virgil Cristea | 05.11.07 | Comment?

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.

Share and Enjoy:
  • Technorati
  • StumbleUpon
  • del.icio.us
  • NewsVine
  • Reddit
  • Digg
  • Furl
  • co.mments
  • blogmarks
  • Slashdot
  • description
  • Taggly
  • YahooMyWeb
  • connotea
  • Webride




Tags: , , ,

This post was written by Virgil Cristea

Views: 871

related

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

:

:


« Actionscript 3 Search Trend by Google
» Compare two objects