flash hittest? moving around shapes

  • Started
  • Last post
  • 0 Responses
  • wwfc

    ...anyone know their way around the hittest command in flash?

    I have an .as file that controls the mc named cursor in my fla.

    At present the cursor mc is reacting to the bounding boxes of two other mc's (obstacle1&2) - If the cursor touches either obstacle it stays at the border and follows the actual mouse position whilst remaining at the bounding box border.

    How the hell do I make it follow the actual shape of the obstacle??? I have got the cursor to recognise the real shape to trigger the hittest but the cursor jumps back to the bounding box as soon as the hittest happens!

    this is the code from the .as file http://pastebin.com/d217385ae

    the only real reference to the hittest that I can see is here:

    // Default to mouse position.
    cursor._x = mouseX;
    cursor._y = mouseY;

    // Move the cursor if it is inside an obstacle.
    for (var i:Number = 0; i < obstacleList.length; i++)
    {
    // Assumes that the obstacles are children of _level0.
    // Might need to use the Rectagle classes intersection function to
    // determine if the cursor is intersecting.
    if (obstacleList[i].hitTest(_root.c...
    {
    moveCursorOutsideObstacle(obstac... _root.cursor._x,_root.cursor._y...
    break;
    }
    }
    }

    but don't really understand why it works for the cursor mc moving to the actual shape but not for moving around the shape when the mouse is within the obstacle shape?

    ...been going at this for some time now with little progress so any suggestions or advice or help for that matter would be really welcome...

    anyone see where my problem is?