[ascoders] Re: Speicherung von Referenz im Activation-Object

  • From: "bokel" <actionscript@xxxxxxxxxxxx>
  • To: <ascoders@xxxxxxxxxxxxx>
  • Date: Fri, 13 Dec 2002 13:29:20 +0100

Na so halt:

<code>
function MyLittleHelperClass(parent){
    this.parent = parent;
}
MyLittleHelperClass.prototype.objMethod = function(){
    this.parent.myMethod ("objMethod");
}

function MyClass (){
    this.obj = new MyLittleHelperClass(this);
}
MyClass.prototype.myMethod = function(){
    trace("myMethod " + arguments);
}
MyClass.prototype.callHelper = function(){
    trace("callHelper " + arguments);
    this.obj.objMethod();
}

o = new MyClass();
o.callHelper();
</code>

mfg r
www.helpQLODhelp.de


----- Original Message -----
From: "Ralf Siegel" <ralf@xxxxxxxxxxx>
>
> >wg. Sauberkeit
> >Ich meinte, dass man on-the-fly Generierung
> >von Objekten allgemein vermeiden sollte, wenn
> >man sauber sein will.
>
> Hi Bokel, genau das habe ich nicht verstanden, wie du das meinst.
Michael's
> Beispiel:
>
> function MyClass ()
> {
>   this.obj = new Object ();
>   this.obj.parent = this;  // hier die referenz
>   this.obj.objMethod = function ()
>   {
>    this.parent.myMethod ("objMethod");
>   };
> }
>
>  >>> Perfekt (Object-Objekt -> Daten)
> --------------------------------
>
> this.obj = new Object ();
>
>  >>> Weniger Perfekt (Funktions-Objekt -> Code)
> -----------------------------------------
>
>   this.obj.objMethod = function ()
>   {
>    this.parent.myMethod ("objMethod");
>   };

------------------------------------------------------
Archiv   : //www.freelists.org/archives/ascoders/
Optionen : //www.freelists.org/list/ascoders
------------------------------------------------------

Other related posts: