[ascoders] AW: Klassenfrage

hmm, viel anders geht das aber nicht.
Bei setInterval gibt es ja das gleiche Problem.

Du kannst höchstens genauso machen wie es da ist

////////////////////////////////////////////////////////////////////////////
////

loadXML("file",Objekt,"Funktionsname")

////////////////////////////////////////////////////////////////////////////
////

also z.B.

////////////////////////////////////////////////////////////////////////////
////

loadXML("dummy.xml",_root.myclassInstance,"doMoreStuff")

////////////////////////////////////////////////////////////////////////////
////

und im callback dann

////////////////////////////////////////////////////////////////////////////
////

myClass.prototype.loadXML = function(path, obj, callback) {
        var testXML = new XML();
        testXML.ignoreWhite = true;
        testXML.dummyProp = "bar";


        testXML.callbackObj = obj;
        testXML.callback = callback;

        testXML.onLoad = function(success) {
                if(success) {
                        this.callbackObj[callback](this)
                }
        };
        testXML.load(path);
};

////////////////////////////////////////////////////////////////////////////
////

eine andere Möglichkeit wäre noch ein Broadcasting zu verwenden

////////////////////////////////////////////////////////////////////////////
////

myClass = function() {

        // Klasse zum Broadcaster machen
        AsBroadcaster.initialize(this)

        // Instanz bei sich selbst als listener anmelden
        this.addListener(this)

        this.dummyProp = "foo";
};
mcClass.prototype = new Object();


myClass.prototype.loadXML = function(path, callback) {
        var testXML = new XML();
        testXML.ignoreWhite = true;
        testXML.dummyProp = "bar";
        testXML._parent = this;
        testXML.callback = callback;


        testXML.onLoad = function(success) {
                if(success) {
                        this._parent.broadcastMessage(this.callback,this)
                }
        };
        testXML.load(path);
};

myClass.prototype.doMoreStuff = function() {
        trace("myClassInstance " + " -> " + "doMoreStuff" + this.dummyProp);
};


var bla = new myClass();
bla.loadXML("menu.xml","doMoreStuff");

_root.createEmptyMovieClip("clip",10)
_root.clip.doMoreStuff = function(src){
        trace(targetPath(this) + " -> " + "doMoreStuff")
}

bla.addListener(_root.clip)

////////////////////////////////////////////////////////////////////////////
////

Gruß
Timo H.







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

Other related posts: