I want to change the frame of the MovieClip by dragging the ball, but it's not working.
My screen width is 800.
In the onPressMove function, I first set the range of ball's movement on the X-axis between 20 and 780.
I want to change the frame of car to 0 when the ball's position is { top: 1, right: 20, bottom: 1, left: 685.5 }, and change it to 1 when the ball's position is { top: 1, right: 114.5, bottom: 1, left: 590.15 }.
My ball can move now, but car not change the frame when ball move to the specific region.
Could anyone tell me what's wrong?

car have a lot of frame inside.

var root = this;
var ball = root.ball;
var car = root.car;
function main()
{
createjs.Touch.enable(stage);
stage.mouseMoveOutside = true;
root.stop();
ball.hitFrame = 1;
ball.missFrame = 0;
//ball.dropArea = { top: 1, right: 20, bottom: 1, left: 20 };
ball.stopCar0 = { top: 1, right: 20, bottom: 1, left: 685.5 };
ball.stopCar1 = { top: 1, right: 114.5, bottom: 1, left: 590.15 };
ball.stopCar2 = { top: 1, right: 209.85, bottom: 1, left: 495.35 };
ball.on("mousedown", onMouseDown);
}
function onMouseDown(e)
{
var target = e.currentTarget;
target.offset = { x: stage.mouseX / stage.scaleX - target.x, y: stage.mouseY / stage.scaleY - target.y };
target.pressMoveListener = ball.on("pressmove", onPressMove);
target.pressUpListener = ball.on("pressup", onPressUp);
}
function onPressMove(e)
{
var target = e.currentTarget;
target.x = stage.mouseX / stage.scaleX - target.offset.x;
if (target.x < 20) {
target.x = 20;
} else if (target.x > 780) {
target.x = 780;
}
else if (target.x > ball.stopCar0.left && target.x < ball.stopCar0.right)
{
root.car.gotoAndStop(0);
}
else if (target.x > ball.stopCar1.left && target.x < ball.stopCar1.right)
{
root.car.gotoAndStop(1);
}
else if (target.x > ball.stopCar2.left && target.x < ball.stopCar2.right)
{
root.car.gotoAndStop(2);
}
}
function onPressUp(e)
{
var target = e.currentTarget;
target.off("pressmove", target.pressMoveListener);
target.off("pressup", target.pressUpListener);
}
if (!root.frame0Started)
{
main();
root.frame0Started = true;
}
