*sigh* The line:

return MyClip(ClipUtils.createCodeClip(" com.mycompany
,MyClip",parent,initObj,depth,inst));

should of course have read:

return MyClip(ClipUtils.createCodeClip("com.mycompany.MyClip
",parent,initObj,depth,inst));

Sorry!
 Ian

On 1/18/07, Ian Thomas <[EMAIL PROTECTED]> wrote:

On 1/17/07, Matthias Dittgen <[EMAIL PROTECTED]> wrote:

>
> And is there a way to automate the writing of SymbolName,SymbolLinked
> and create for all my classes which extend MovieClip?



Personally, I use b) (for clips which aren't in the library). There's no
way to automate the writing of symbolName etc. (unless you start looking at
preprocessors), but you can get rid of symbolName etc. completely to make
life easier. For example:

class com.mycompany.MyClip extends MovieClip
{
    public static function
create(parent:MovieClip,initObj:Object,depth:Number,inst:String):MyClip
    {
        return MyClip(ClipUtils.createCodeClip(" com.mycompany
,MyClip",parent,initObj,depth,inst));
    }
}

where ClipUtils looks like this:

class ClipUtils
{
    public static function
createCodeClip(classPath:String,parent:MovieClip,initObj:Object,depth:Number,inst:String):MovieClip

    {
        if (depth===undefined)
            depth=parent.getNextHighestDepth();
        if (inst===undefined)
            inst="inst"+depth;
        var constructor:Function=getConstructorFromPath(classPath);
        Object.registerClass("__Packages."+classPath,constructor);
        return parent.attachMovie
("__Packages."+classPath,inst,depth,initObj);
    }

    public static function
getConstructorFromPath(classPath:String):Function
    {
        var arr:Array=classPath.split(".");
        var obj:Object=_global;
        for(var i:Number=0;i<arr.length;i++)
        {
            obj=obj[arr[i]];
        }
        return Function(obj);
    }
}


In case it's not clear, you can then write:

var clip:MyClip=MyClip.create(parentMovie);

and everything else will default to something appropriate.

Hope that makes sense,
   Ian

_______________________________________________
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