# Movieclip subclass?

**URL:** <https://forum.kirupa.com/t/movieclip-subclass/24788>\
**Category:** flash\
**Created:** [July 4, 2003, 7:05pm UTC](https://forum.kirupa.com/t/movieclip-subclass/24788 "2003-07-04T19:05:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DumbMonkey](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DumbMonkey](https://forum.kirupa.com/u/DumbMonkey)\
**Post date:** [July 4, 2003, 7:05pm UTC](https://forum.kirupa.com/t/movieclip-subclass/24788/1 "2003-07-04T19:05:15Z")

</div>

Hi,  
I have several different AVIs which I have imported as movieclips.  
I want to be able to have some common functions for the different clips which will for example start them playing at the same position.  
For example if I have five different car avi movie clips, I would like to have a funciton AnimateDriving() or StopDriving() which I can invoke for each car (maybe from a super class) which executes the same code (eg gotoAndPlay(5)).  
I know I can use MovieClip.prototype but this in not really OOP  
and most websites i viewed say this is wasteful, as I have many other different (non-car) movieclips.  
Can anyone suggest the best way to do this.  
Much appreciated.

DumbMonkey.

---

<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:** [July 4, 2003, 7:21pm UTC](https://forum.kirupa.com/t/movieclip-subclass/24788/2 "2003-07-04T19:21:46Z")

</div>

movieClip.prototype IS OOP. People might complain about it because of its exposure (ALL movieclips gain access to those functions), but in terms of functionality, it does what you need.

From what you’re explaining though it would seem like a waste to go through all the effort of setting up a class, defining inheritance and all that other bull just to call a couple of functions on a couple of clips - especially when they seems to be static in nature (though I could be wrong there).

Heres what _I_ would do. Somethng like…

```auto
AnimateDriving = function(frame){
	for(var i=0; i<movies.length; i++) movies*.gotoAndPlay(frame);
}
StopDriving = function(){
	for(var i=0; i<movies.length; i++) movies*.stop();
}

movies = [movie1_mc, movie2_mc, movie3_mc, movie4_mc, movie5_mc];

```

and theres your groundwork for playing or stopping all your movies. Technically theres no OOP involved but there doesnt need to be. Youre not assigning any redundant functions and the operations are completed quickly and smoothly… and it much less hassle and typing on your end to set 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:** [July 5, 2003, 1:06pm UTC](https://forum.kirupa.com/t/movieclip-subclass/24788/3 "2003-07-05T13:06:19Z")

</div>

Much appreciated!
