# Please help me ( counter ++ problem as3)

**URL:** <https://forum.kirupa.com/t/please-help-me-counter-problem-as3/327736>\
**Category:** Uncategorized\
**Created:** [March 24, 2012, 7:35pm UTC](https://forum.kirupa.com/t/please-help-me-counter-problem-as3/327736 "2012-03-24T19:35:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![letscheers](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@letscheers](https://forum.kirupa.com/u/letscheers)\
**Post date:** [March 24, 2012, 7:35pm UTC](https://forum.kirupa.com/t/please-help-me-counter-problem-as3/327736/1 "2012-03-24T19:35:38Z")

</div>

var dragArray:Array = [square, circle, triangle];  
var matchArray:Array = [squareMatch, circleMatch, triangleMatch];  
var posArray:Array = [{x:216.3, y:237.40}, {x:381.3, y:237.35},{x:47.25, y:237.35}]

var currentClip:MovieClip;  
var startX:Number;  
var startY:Number;  
var clickCount:int = 0;

for(var i:int = 0; i \< dragArray.length; i++) {  
dragArray\*.buttonMode = true;  
dragArray\*.addEventListener(MouseEvent.MOUSE\_DOWN, item\_onMouseDown);  
matchArray\*.alpha = 0.2;  
}

function item\_onMouseDown(event:MouseEvent):void {  
currentClip = MovieClip(event.currentTarget);  
startX = currentClip.x;  
startY = currentClip.y;  
addChild(currentClip); //bring to the front  
currentClip.startDrag();  
stage.addEventListener(MouseEvent.MOUSE\_UP, stage\_onMouseUp);  
}

function stage\_onMouseUp(event:MouseEvent):void {  
stage.removeEventListener(MouseEvent.MOUSE\_UP, stage\_onMouseUp);  
currentClip.stopDrag();  
var index:int = dragArray.indexOf(currentClip);  
var matchClip:MovieClip = MovieClip(matchArray[index]);  
if(currentClip.hitTestObject(matchClip)) {  
//a match was made! position the clip on the matching clip:  
clickCount ++;  
currentClip.x = posArray[index].x;  
currentClip.y = posArray[index].y;  
CI.gotoAndPlay(“Correct”);  
//make it not draggable anymore:  
currentClip.removeEventListener(MouseEvent.MOUSE\_DOWN, item\_onMouseDown);  
currentClip.buttonMode = false;  
} if(clickCount == dragArray.length){

```
	trace("superbb");
	
}else {
	//match was not made, so send the clip back where it started:
	currentClip.x = startX;
	currentClip.y = startY;
	CI.gotoAndPlay("inCorrect");
}

```

}

please help

i just have taken this code from internet and try to use this , i want to make counter in this. After drag and hittest all it should trace , but there is a problem with my counter , i dont know how to solve this

please help

thank you so much in advance
