# Logic help!

**URL:** <https://forum.kirupa.com/t/logic-help/282433>\
**Category:** flash\
**Created:** [February 22, 2009, 12:45am UTC](https://forum.kirupa.com/t/logic-help/282433 "2009-02-22T00:45:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michdd](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@michdd](https://forum.kirupa.com/u/michdd)\
**Post date:** [February 22, 2009, 12:45am UTC](https://forum.kirupa.com/t/logic-help/282433/1 "2009-02-22T00:45:09Z")

</div>

On my game there is character creation, when creating a character you can choose it’s hair (along with other things…) you can change the hair color, and the hair design… It’s a bit hard to explain, so I’ll explain it a bit more after the code…

```auto

charBox.colorRightBtn.addEventListener(MouseEvent.CLICK, hairPlus);
var hairNum:int = 0;
var hairBitmap:hair_1_1 = new hair_1_1(1,1);
function hairPlus(event:MouseEvent):void{
	if(hairNum == 0){
	var hairBitmap:hair_1_2 = new hair_1_2(0,0);
	hairBase.copyPixels(hairBitmap, rect, pt);
	charBox.charDisplay.addChild(new Bitmap(hairBase));
	} 
	hairNum++;
	if(hairNum >= 1){
		hairNum = 0;
	}
}
hairBase.copyPixels(hairBitmap, rect, pt);
charBox.charDisplay.addChild(new Bitmap(bmd2));
charBox.charDisplay.addChild(new Bitmap(hairBase));
addChild(charBox);
var clicks:int = 0;
charBox.charDisplay.addEventListener(MouseEvent.CLICK, changePic);
function changePic(event:MouseEvent):void{
	if(clicks == 0){
		row = 1;
		clicks++;
	} else if(clicks == 1){
		charBox.charDisplay.scaleX = 1;
		charBox.charDisplay.x -= charBox.charDisplay.width;
		clicks++;
	} else if(clicks == 2) {
		row = 0;
		clicks++;
	} else if(clicks == 3){
	charBox.charDisplay.scaleX = -1;
	charBox.charDisplay.x += charBox.charDisplay.width;
	clicks = 0;
	}
	var rect:Rectangle = new Rectangle(96 * col, 128 * row, 96, 128);
	var pt:Point = new Point(0, 0);	
	bmd2.copyPixels(bmd1, rect, pt);
	hairBase.copyPixels(hairBitmap, rect, pt);
	charBox.charDisplay.addChild(new Bitmap(bmd2));
	charBox.charDisplay.addChild(new Bitmap(hairBase));
}

```

Now, there’s a box that displays the current character, and if you click the character it turns it to a different angle, so you can click to turn it one direction. (2-d isometric). When the character creation box it opened it starts with bitmap hair\_1\_1 then there’s a button to change the hair color. From this example it changes the bitmap being used to hair\_1\_2. That works, accept when I click on the box (charBox.charDisplay) to change the angle shown, the hair goes back to hair\_1\_1 orignally. This probably isn’t the best logic used to do this, so any help is greatly appreciated.

I need it to start at bitmap hair\_1\_1 then be able to change the bitmap resource that’s being used for the hair…
