hey everyone, my code is listed below.
as you can see, I have a container MC which I have added to the stage. I set its drag constraints using a Rectangle(). I then add the 'cat' child movieclip to the container, and I want this to be dragable too. However, as soon as I click on my cat when testing the MC. It shoots to point x=0 y=0 on the stage and doesn't move.
The container MC can be moved without any trouble.
If I remove the rectangle bounds from the containers startdrag() function. both MC's can be dragged without any issue.
any help would be awesome.
thanks
//panning ability
my_x = 800 - myImage.width;
my_y = 480 - myImage.height;
myWidth = 0 - my_x;
myHeight = 0 - my_y;
container.addEventListener(MouseEvent.MOUSE_DOWN, bgMouseDown);
container.addEventListener(MouseEvent.MOUSE_UP, bgMouseUp);
function bgMouseDown(evt:MouseEvent):void
{
var object = evt.currentTarget;
object.startDrag(false, new Rectangle(my_x, my_y, myWidth ,myHeight));
}
function bgMouseUp(evt:MouseEvent):void
{
var object = evt.currentTarget;
object.stopDrag();
}
//adding ze cat
cat = new ACat();
container.addChild(cat);
cat.x = 100;
cat.y = 400;
cat.addEventListener(MouseEvent.MOUSE_DOWN, catMouseDown);
cat.addEventListener(MouseEvent.MOUSE_UP, catMouseUp);
function catMouseDown(evt:MouseEvent):void
{
var object = evt.currentTarget;
object.startDrag(false);
}
function catMouseUp(evt:MouseEvent):void
{
var object = evt.currentTarget;
object.stopDrag();
}