# MX: OOP and Mc's!

**URL:** <https://forum.kirupa.com/t/mx-oop-and-mcs/27382>\
**Category:** Uncategorized\
**Created:** [August 1, 2003, 6:18pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382 "2003-08-01T18:18:13Z")\
**Posts on this page:** 14\
**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:** [August 1, 2003, 6:18pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/1 "2003-08-01T18:18:13Z")

</div>

Hoi

is there a way to make a mc belang to a new object like this (but this doesn’t work)

```auto

newMc = function () {
	this.createEmptyMovieClip("new_mc", 0);
};
Mc1 = new newMc()
// and i tryed this
newMc = function () {
	this = new MovieClip();
	this.createEmptyMovieClip("new_mc", 0);
};
Mc1 = new newMc()

```

i know i can do it like this

```auto

newMc = function () {
	_root.createEmptyMovieClip("new_mc", 0);
};
Mc1 = new newMc()

```

but now i and makeing a new object and a new Mc but they are not in the same… thay have nothing in commen!!  
its  
\_root.Mc1 and \_root.new\_mc  
and not Mc1.new\_mc :sigh:

G i hope that this all adds 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:** [August 1, 2003, 6:22pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/2 "2003-08-01T18:22:59Z")

</div>

are you trying to do a movieclip-subclass?

---

<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:** [August 1, 2003, 6:28pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/3 "2003-08-01T18:28:40Z")

</div>

Yeah:beam: (i think:-)

but i am new to all this oop stuff

---

<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:** [August 1, 2003, 6:46pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/4 "2003-08-01T18:46:55Z")

</div>

theres no standard way of associating an empty movieclip with a class, you’d need to alter its **proto**

```auto
newMc = function () {}
newMc.prototype = new MovieClip();

_root.createEmptyMovieClip("someName", someDepth);
someName. __proto__ = newMc.prototype;
newMc.call(someName); // if the constructor added any properties

```

---

<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:** [August 1, 2003, 6:52pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/5 "2003-08-01T18:52:00Z")

</div>

WELL =)

i will look into that :thumb:

the Q’s will be going soon 😉

---

<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:** [August 1, 2003, 7:06pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/6 "2003-08-01T19:06:28Z")

</div>

> \*Originally posted by senocular \*  
> \*\*theres no standard way of associating an empty movieclip with a class, you’d need to alter its **proto**

```auto
newMc = function () {}
newMc.prototype = new MovieClip();

_root.createEmptyMovieClip("someName", someDepth);
someName. __proto__ = newMc.prototype;
newMc.call(someName); // if the constructor added any properties

```

\*\*

Sen, can’t we just make someName an instance of newMc? I mean, it’s not really reliable to edit the **proto** property when you can use the ‘new operator’ instead, Knowing it will also invoke the constructor without the need of call?

---

<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:** [August 1, 2003, 7:11pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/7 "2003-08-01T19:11:54Z")

</div>

the thing is any new newMc wont be a movieclip. You can make it a normal object and give it a movieclip as a property, but it wont be the movieclip object - just an object with a movieclip for a property. For an empty movieclip to be an instance of a class, since it has no association with Object.registerclass, you’d need to alter its **proto** reference. Then that movieclip would have access to that class’s prototype and methods.

There’s a good discussion about **proto** and what really happens there and what it does in some of the links posted in the best of senocular. Worth checking out if you havent seen them already

---

<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:** [August 1, 2003, 8:07pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/8 "2003-08-01T20:07:11Z")

</div>

Hoi

what does call(); do i can’t find it in the flash help and there is nothing on it in [http://www.debreuil.com/docs/ch01\_Intro.htm](http://www.debreuil.com/docs/ch01_Intro.htm)

and **constructor**?

---

<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:** [August 1, 2003, 8:34pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/9 "2003-08-01T20:34:56Z")

</div>

call runs a function. Basically its a different format of calling a function.

functionName.call(objectName)

instead of

objectName.functionName();

The big difference is that in that second example, objectName.functionName(); for objectName to run functionName, that function has to be defined in or exist in objectName (or it needs to be accessible through a prototype). With call, that doesnt need to be the case. Because of that, it allows you to run the myMc constructor function in the scope of the empty clip instance without having to assign it to exist within that clip, since, as I said before, theres no direct method of associating a class with an empty clip.

**constructor** is used in correcting super. I didnt include that in the first code sample because I didnt think you needed to worry about it and things were probably confusing enough then as it was. Basically, what it does is allow super to correctly reference the right superclass when called. You can read more about super in the best of senocular links (and the **constructor** is mentioned there).

---

<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:** [August 1, 2003, 8:41pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/10 "2003-08-01T20:41:46Z")

</div>

Thanks :}

still a little :q:

but too a :sleep: to think much more

I am going to bed

ThanksThanksThanks=)

---

<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:** [August 2, 2003, 5:28pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/11 "2003-08-02T17:28:36Z")

</div>

Hoi

so what this does  
is changes the prototype of the someName to the prototype of newMc  
and newMc’s prototype is a new MovieClip!

am i right?

---

<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:** [August 2, 2003, 5:55pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/12 "2003-08-02T17:55:26Z")

</div>

yeah more or less 😉

read through this  
[http://www.flashkit.com/board/showthread.php?s=&threadid=462834](http://www.flashkit.com/board/showthread.php?s=&threadid=462834)

---

<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:** [August 2, 2003, 5:57pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/13 "2003-08-02T17:57:12Z")

</div>

_faints_

---

<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:** [August 2, 2003, 6:57pm UTC](https://forum.kirupa.com/t/mx-oop-and-mcs/27382/14 "2003-08-02T18:57:30Z")

</div>

hoi

:}

ok i read your post 😉

and i found this [http://userpages.umbc.edu/~tmccau1/...pcreatures.html](http://userpages.umbc.edu/~tmccau1/...pcreatures.html)  
it saw going to be my next Q

i will understand all this OOP over time (hope!!)

Thanks for all your help

P.s if i may ask?  
how lang did it take you (sen) to learn OOP?
