A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] Hittest movieclips in array

  1. #1
    Join Date
    May 2006

    resolved [RESOLVED] Hittest movieclips in array

    So here's my situation... I'm working on a chess game, and I'm having a problem trying to detect what square you are moving your piece to. I'm trying to add the available squares to an array, and hittest if you are moving your piece to an available square.

    I'm adding the available squares to an array as a string. And then when they release the mouse from dragging the piece, I am looping through the available squares, but here's where I am stuck. I think having it on the mouseup handler should work, so I don't think I need it on an EnterFrame, but maybe I'm wrong. And I think party of the problem is converting the string from the array into the name of the movieclip.

    Anyway, if someone could point me in the right direction to detect what square they are touching when you release the mouse, I would really appreciate it!!

    My code is below:
    var myArray:Array = new Array;
    var myArrayLength;
    var whichRow = 3;
    myMc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    myMc.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
    function mouseDownHandler(evt:MouseEvent):void{
    	var object = evt.target;
    function mouseUpHandler(evt:MouseEvent):void{
    	var obj = evt.target;
    	var i=1;
    	myArrayLength = myArray.length;
    	for (i = 0; i < myArrayLength; i++){
    function addtoArray(){
    	var i = 1;
    	for (i = 1; i < 9; i++){
      myArray.push("block" + whichRow + i);

  2. #2
    Join Date
    May 2006
    Think I have this figured out. Thanks anyway!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center