5 Replies Latest reply on Jun 28, 2007 10:32 AM by kglad

    How to initialize an custom class(properly)?

    Miran Loncaric

      Does anyone have any suggestion how to properly initialize a custom class?
      I've tried already, but I think it must be some other way to do it without cusom initializer class.

      This is the ClassInit:
      package com.mloncaric.utils
      import flash.events.EventDispatcher;
      import flash.events.Event;

      public class ClassInit extends EventDispatcher
      private var _data :Object;

      public function ClassInit(args:Object)
      this._data = args;

      public function change(args:Object):void
      var isOK:Boolean = true;

      for(var i:String in args)
      this._data = args;

      for(var j:String in this._data)
      if(this._data[j] == null || this._data[j] == undefined || isNaN(this._data[j]))
      isOK = false;

      this.dispatchEvent(new Event(Event.INIT));

      All the variables that need to be checked for data are passed into the class constructor...
      For example: ..new ClassInit({x:this.x, y:this.y, ...});
      And when an variable is changed it calls the ClassInit method change
      Arguments are passed the same way as in constructor.
      When all data is set the event is dispatched.

      I just want to initialize the class in the other way, but at this time I've got no idea.