This discussion is very interesting, so I would like to offer my
approach of attaching/construction of visual classes. I am open for
optimization hints.
I am using something like this:


1) THE CLASS EXTENDING MOVIECLIP

class com.path.MyVisual extends MovieClip
{
        
        public static var _SYMBOL_NAME:String = "__Packages.com.path.MyVisual";
        public static var _SYMBOL_OWNER:Function = MyVisual;
        public static var _SYMBOL_LINKED =
Object.registerClass(_SYMBOL_NAME,_SYMBOL_OWNER);
        
        private var __width:Number;
        private var __text:String;
        
        public static function create(target:MovieClip, initObject:Object,
depth:Number, name:String):MyVisual
        {
                depth = (depth!=undefined?depth:target.getNextHighestDepth());
                name = (name!=undefined?name:"myVisual"+depth);
                return MyVisual(target.attachMovie(MyVisual._SYMBOL_NAME, name,
depth, initObject));
        }
        
        public static function createInitObject(width:Number, 
text:String):Object
        {
                return {
                        __width: width,
                        __text: text};
        }
        
        private function MyVisual()
        {
                // I can use __width and __text here, if I like so.
        }
}


2) THE "CONSTRUCTION" OF AN INSTANCE
I use the static create/createInitObject methods. The latter gives me
its signature when the editor supports code completion. This way, it
feels like a constructor and I get the correct type returned:

var mv:MyVisual = MyVisual.create(this, MyVisual.createInitObject(200,
"Hello World"));


Have fun,
Matthias
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to