View Single Post
Old 11-13-2012, 08:12 AM   PM User | #5
Labrar
New Coder

 
Join Date: Jun 2008
Posts: 61
Thanks: 0
Thanked 12 Times in 12 Posts
Labrar is an unknown quantity at this point
Maybe i am absolutely wrong but
PHP Code:
myobject.prototype=new CLASSNAME 
is wrong.

I'm not really sure if
PHP Code:
Object.prototype=new CLASSNAME 
will work.

So why won't you use a class directly.
PHP Code:
var call=new CLASSNAME 
and add your object in the next line?

A prototype does'nt make any sense in your case.

If you want to share attributes between objects, prototypes are useful.
But not in your case, if i understood right.

In the other Hand, you could use prototypes as a function. So you could call the methods from all your used Objects.

PHP Code:
<script type="text/javascript">
Object.prototype.addsomething=function(){
    
this.added='Hello';
}
var 
h=new Object;
h.addsomething();
var 
x=new Object;
x.addsomething();
alert(h.added+' '+x.added);
</script> 
But what you're apparently looking for is a way to transmit from one object to another.
In that case you should do the old way.
PHP Code:
var call=new CLASSNAME 
Please correct me if i'am wrong or if there is a better way.
Labrar is offline   Reply With Quote