# \[FMX\]\[OOP\] whats the diff

**URL:** <https://forum.kirupa.com/t/fmx-oop-whats-the-diff/96314>\
**Category:** Uncategorized\
**Created:** [December 7, 2003, 8:51pm UTC](https://forum.kirupa.com/t/fmx-oop-whats-the-diff/96314 "2003-12-07T20:51:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johnny64](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@Johnny64](https://forum.kirupa.com/u/Johnny64)\
**Post date:** [December 7, 2003, 8:51pm UTC](https://forum.kirupa.com/t/fmx-oop-whats-the-diff/96314/1 "2003-12-07T20:51:58Z")

</div>

whats the difference between…

```auto

MyClass.prototype = MovieClip.prototype;

```

and…

```auto

MyClass.prototype = New MovieClip();

```

thanx M64

:red: \<-- lol

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2003, 5:52pm UTC](https://forum.kirupa.com/t/fmx-oop-whats-the-diff/96314/2 "2003-12-10T17:52:29Z")

</div>

lol forgot about this theard 😛

[size=1]still like to know the answer 😛 [/size]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2003, 6:38pm UTC](https://forum.kirupa.com/t/fmx-oop-whats-the-diff/96314/3 "2003-12-10T18:38:22Z")

</div>

The difference lays in the fact the when using

```auto

MyClass.prototype = MovieClip.prototype;

```

You are setting the prototype object of MyClass to the prototype object of the MovieClip class, thus ensuring that every MyClass instance has access to the prototype object of the MovieClip class.  
However, if you use

```auto

MyClass.prototype = New MovieClip();

```

You are not only enabling every MyClass instance access to the prototype object of the MovieClip class, you are also placing the properties of the MovieClip class instance in the prototype object of MyClass. This doesn’t happen when just setting the prototype:

```auto

SuperClass = function(){
	this.property = "Property";
}
SuperClass.prototype.traceHello = function(){
	trace("Hello");
}
SubClass = function(){
}
SubClass.prototype = SuperClass.prototype
SubInstance = new SubClass();
SubInstance.traceHello()
trace(SubInstance.property)
// Hello
// undefined

```

```auto

SuperClass = function(){
	this.property = "Property";
}
SuperClass.prototype.traceHello = function(){
	trace("Hello");
}
SubClass = function(){
}
SubClass.prototype = new SuperClass();
SubInstance = new SubClass();
SubInstance.traceHello()
trace(SubInstance.property)
// Hello
// Property

```

This is a nice example of the **proto** property. As you may know, **proto** indicates where to search next if a varaible isn’t found. property was defined for the SuperClass, and then an instance of a SuperClass has been placed in the prototype object of the SubClass. This means that every SubClass also has access to ‘property’ via it’s prototype object.

When you trace SubInstance.property, it will go looking in the SubInstance itself first, and when it doesn’t find it there, it will use the **proto** property and go looking in the prototype object of SubClass, where it finds property::

```auto

SuperClass = function(){
	this.property = "Property";
}
SuperClass.prototype.traceHello = function(){
	trace("Hello");
}
SubClass = function(){
}
SubClass.prototype = new SuperClass()
SubInstance = new SubClass();
SubInstance.traceHello()
trace(SubInstance.property)
trace(SubInstance. __proto__ == SubClass.prototype)
// Hello
// Property
// true

```

So if you would’ve defined property also in the SubClass constructor, it won’t go looking in the prototype object because it will already find it in the SubInstance itself:

```auto

SuperClass = function(){
	this.property = "Property";
}
SuperClass.prototype.traceHello = function(){
	trace("Hello");
}
SubClass = function(){
	this.property = "Sub Property"
}
SubClass.prototype = new SuperClass()
SubInstance = new SubClass();
SubInstance.traceHello()
trace(SubInstance.property)
// Hello
// Sub Property

```

Hope this cleared things up 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2003, 7:02pm UTC](https://forum.kirupa.com/t/fmx-oop-whats-the-diff/96314/4 "2003-12-10T19:02:39Z")

</div>

that reminds me… my oop tutorial is still floating about around here somewhere needing to be posted 😮

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 10, 2003, 9:44pm UTC](https://forum.kirupa.com/t/fmx-oop-whats-the-diff/96314/5 "2003-12-10T21:44:26Z")

</div>

So

```auto

MyClass.prototype = New MovieClip();

```

is better then

```auto

MyClass.prototype = MovieClip.prototype;

```

as it can find whats in the constructor all so 🙂

and the “Sub Property” thing… i knew that 😛😃

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2003, 9:18am UTC](https://forum.kirupa.com/t/fmx-oop-whats-the-diff/96314/6 "2003-12-12T09:18:21Z")

</div>

lol forgot this thead again 8-]

thanx Voets 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2003, 11:29am UTC](https://forum.kirupa.com/t/fmx-oop-whats-the-diff/96314/7 "2003-12-12T11:29:04Z")

</div>

Geen probleem 😉
