I am trying to create an object(Simme_Coll_MC) that is draggable but stays within the space of another object(Path_MC). I want to be able to control this object and not be able to pull it out of the Path_MC movie clip at all. I know that hitTest will be one of the functions to use but what about knowing the space of the path object? I got this so far I can move the character but the collision object is capable of moving out of the path and then it locks up. Any help is appreciated. Thanks



PHP Code:
onClipEvent (enterFrame
{
var 
_root.Path_MC.getBounds(this);

//if registration point is in the center of draggable object

//_root.Simme_MC.Simme_Coll_MC(false, b.xMin+this._width/2, b.yMin+this._height/2, b.xMax-this._width/2, b.yMax-this._height/2);

//this is the collision code
if (this.Simme_Coll_MC.hitTest(_root.Couch_MC)) 
{
    
trace("hitting couch!!");
    
stop();
    }
    if (
this.Simme_Coll_MC.hitTest(_root.Plant_MC)) 
{
    
trace("hitting plant!!");
    
stop();
    }
    
//Collision with path    
//checking if crossing path
    
if (this.Simme_Coll_MC.hitTest(_root.Path_MC)) 
{
//this is the collision code
trace("in Path!!");

    
//dircetional left right and scalar
 
if (Key.isDown(Key.RIGHT)) 
 {
 
this._x this._x+14;
 
_root.Simme_MC._xscale=+100
 gotoAndStop
(2);
 }
 if (
Key.isDown(Key.LEFT)) 
 {
  
_root.Simme_MC._xscale=-100
  this
._x  this._x-14
  gotoAndStop
(2);
  
 }
 
 
// up and down directional
  
if (Key.isDown(Key.UP)) 
 {
 
this._y this._y-=5;
 
gotoAndStop(2);
 }
  if (
Key.isDown(Key.DOWN)) 
 {
 
this._y this._y+=5;
 
gotoAndStop(2);
 }
 
 
 
//  attack
 
if (Key.isDown(Key.SPACE)) 
 {
     
gotoAndStop(4);
     }
    
stop();
    }else
    {
        
trace("out of path");
        }

 
/*