# Classes - every object to be associated with own MovieClip

**URL:** <https://forum.kirupa.com/t/classes-every-object-to-be-associated-with-own-movieclip/287729>\
**Category:** flash\
**Created:** [May 5, 2009, 5:29pm UTC](https://forum.kirupa.com/t/classes-every-object-to-be-associated-with-own-movieclip/287729 "2009-05-05T17:29:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThinkKirupa](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@ThinkKirupa](https://forum.kirupa.com/u/ThinkKirupa)\
**Post date:** [May 5, 2009, 5:29pm UTC](https://forum.kirupa.com/t/classes-every-object-to-be-associated-with-own-movieclip/287729/1 "2009-05-05T17:29:08Z")

</div>

[COLOR=“Green”][SIZE=4] **SOLVED - see thread** [/SIZE][/COLOR]

Hi.

To explain what I want in a easy way I will use an example.

Say I want to make a flash movie with cars of different kind. Every car looks different and have their own specifications like weight, horse powers, top speed. So… I want to create a class _ **Car** _ that can hold the variables **weight** , **horsePowers** , **topSpeed** and should be linked with a specific MovieClip (the car).

The problem is I cannot link all my MovieClips, holding the cars, to the same class _ **Car** _!

Should I create a container to associate with the class and then place different car MovieClips in them depending on which car object I’m creating? (so the MovieClip itself is sort of a variable)  
|  
|  
|  
/

```auto
package 
{
	import flash.display.MovieClip;
	import flash.display.DisplayObject;
	import flash.text.TextField;
	
	public class Car extends MovieClip
	{
		private var _weight:Number;
		private var _topSpeed:Number;
                private var _movieclip:MovieClip;
				
		function Car( weight:Number, topSpeed:Number, movieclip:MovieClip )
		{
			_weight = weight;
			_topSpeed = topSpeed;
			_movieclip = movieclip;
			
			this.addChild(_movieclip);
		}
	}
}

```

And then I create an empty **container\_mc** and **volvo\_mc** , **audi\_mc** , **opel\_mc**. **container\_mc** is linked with _ **Car** _

var theVolvo:_ **Car** _ = new _ **Car** _ ( 1230, 230, volvo\_mc);

Hope you get what I mean. Always hard to explain things you don’t know so good and that’s of course most often the case. :rambo:
