Code does not works whet it's not attached to any node

Hello I have following code:
var test1 = qc.defineBehaviour('qc.engine.test1', qc.Behaviour, function() {
//window.gameRoot = this.gameObject;
}, {
// fields need to be serialized
});

// Called when the script instance is being loaded.
test1.prototype.awake = function() {

};

test1.prototype.remind = function() {
console.log("-------- test1.remind()");
};
and second file:
var test2 = qc.defineBehaviour('qc.engine.test2', qc.Behaviour, function() {
window.gameRoot = this.gameObject.parent;
this.script = window.gameRoot.getScript('qc.engine.test1');
}, {
// fields need to be serialized
});

// Called when the script instance is being loaded.
test2.prototype.awake = function() {

this.ask();

};

test2.prototype.ask = function() {

this.script.remind();
};
So everything works fine when "test1.js" is attached to UIroot node but i dont want attache it to any node. When i remove  "test1.js" from UIroot node it stops working. Is there any way to make this file work without attaching it to any node?
 
Has invited:

QC-Cindy

Favor from:

Hello, because there is "window.gameRoot = this.gameObject.parent;" in your code file, so if you do not want to attache it to any node, this.gameObject can not be found, so the file can not work.

george828

Favor from:

Well imagine that tere is no "window.gameRoot = this.gameObject.parent;" and there is just 
console.log(123); in awake function. it also does not works if file is not attached on any node.

eric

Favor from:

You should see this http://ask.qiciengine.com/?/question/8 

"qc.defineBehaviour" is for defining component script to be add on node, if you just want to define a normal Class that is nothing to do with specified node, then you should do it as normal JavaScript way:

To reply to a question, please Login or registered