Conflict on using the same base class

Hi. Trying my luck again even thought the last thread i wrote here was never answered :slight_smile:

I’m creating an application with an animated kid figure.
All the kid symbols sit in a kidLibrary.Fla file, Each of these symbols have a class named “Kid” linked to it on its Properties >Base Class.
This Kid class is responsible for setting the right color and hair type for each kid symbol instance.

Every time i need to include one of these kid symbols i drag it to the current .fla file I’m working on.
If I place only one kid symbol in the library of the file I’m working on, everything works fine!

Now here is the problem:

When i place more than one kid symbol in the library, and then drag it to the stage, then one of the symbols works fine while the other one doesn’t seem to access all the properties of the Kid base-class. The result is that only one symbol act perfect while the other one(s) not.

the error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Kid/setColor()
at Kid/colorBodySkin()
at Kid/setSkin()
at Kid()
at StandTired()

The Kid class:

package {

import flash.display.MovieClip;
import flash.display.Sprite;
import flash.geom.ColorTransform;

public class Kid extends MovieClip {

	private const SKIN_LIGHT:Number=0xFCD194;
	private const SKIN_DARK:Number=0xCC6600;
	private const SHORTS_COLOR:Number=0x336666;
	
	public var headCoverContainer:Sprite;

	private var bodyParts:Array=new Array("kidFace_mc","body_mc","legR_mc","legL_mc","neck_mc","handR_mc","handL_mc","legs_mc");

	private var faceParts:Array=new Array("face_mc","eyeCloser_mc");

	private var clothParts:Array=new Array("shorts_mc","skirt_mc","shirt_mc");

	//Library symbols:
	private var cap:Cap;
	private var capFill_mc:MovieClip;
	private var hair_boy:Hair_boy;
	private var hair_girl_s:Hair_girl_s;
	private var hair_girl_l:Hair_girl_l;


	public function Kid() {
		trace("----------------------");
		trace("Kid class",this.name);
		setSkin();
		setCloth();
		setHeadCover();

	}

	private function setColor(p_mc:MovieClip,p_value:Number) {
		var ct:ColorTransform;
		ct=p_mc.transform.colorTransform;
		ct.color=p_value;
		p_mc.transform.colorTransform=ct;
	}

	private function colorBodySkin(p_skinColor:Number):void {
		//checking which body instances this class instance actualy contains:
		for (var i:int=0; i<bodyParts.length; i++) {
			if (this.hasOwnProperty(bodyParts*)) {

				trace("Y",bodyParts*);

				if (bodyParts*=="kidFace_mc") {//ttreat the kidFace_mc seperatly
					for (var j:int=0; j<faceParts.length; j++) {
						if (kidFace_mc.hasOwnProperty(faceParts[j])) {
							var tempFaceMC:MovieClip=kidFace_mc[faceParts[j]];
							//set color:
							setColor(tempFaceMC,p_skinColor);
						}
					}
				} else {//rest of body parts

					var tempMC:MovieClip=this[bodyParts*];
					//set color:
					setColor(tempMC,p_skinColor);
				}

			} else {//instance doesn't include body part
				trace("N",bodyParts*);
			}
		}

	}

	public function setSkin():void {
		//call this function in the kid symbol on the stage or in the constructor:
		switch (glo.bal.skinColor) {
			case 1 :
				colorBodySkin(SKIN_LIGHT);
				break;
			case 2 :
				colorBodySkin(SKIN_DARK);
				break;
		}
	}

	public function setCloth():void {
		for (var i:int=0; i<clothParts.length; i++) {
			if (this.hasOwnProperty(clothParts*)) {
				if (glo.bal.boy&&clothParts*=="shorts_mc") {
					this["skirt_mc"].visible=false;
					this["shorts_mc"].visible=true;

					setColor(this["shorts_mc"],SHORTS_COLOR);
				} else if (glo.bal.girl && clothParts*=="skirt_mc") {
					this["skirt_mc"].visible=true;
					this["shorts_mc"].visible=false;

				} else if (clothParts*=="shirt_mc") {
					trace("::SHIRT::");
					setColor(this["shirt_mc"],glo.bal.shirt);
				}
			} else {
				trace("No shorts/skirt/shirt");
			}
		}


	}

	public function setHeadCover():void {
		headCoverContainer=new Sprite();
		kidFace_mc.addChild(headCoverContainer);

		if (glo.bal.cap) {
			//add cap:
			cap=new Cap();
			var fill_mc:MovieClip=MovieClip(cap.getChildByName("capFill_mc"));
			headCoverContainer.addChild(cap);
			//set cap's color:
			setColor(fill_mc,glo.bal.hairColor);

		} else if (glo.bal.hairBoy) {
			hair_boy=new Hair_boy();
			headCoverContainer.addChild(hair_boy);

			setColor(hair_boy,glo.bal.hairColor);

		} else if (glo.bal.hairGirlL) {
			hair_girl_l=new Hair_girl_l();
			headCoverContainer.addChild(hair_girl_l);

			setColor(hair_girl_l,glo.bal.hairColor);

		} else if (glo.bal.hairGirlS) {
			hair_girl_s=new Hair_girl_s();
			headCoverContainer.addChild(hair_girl_s);

			setColor(hair_girl_s,glo.bal.hairColor);
		}
	}
}

}

Hope very much to get some help.

Thank you.

Tzach