Having constrains object to move X,Y at the same time?

Posted by Hwang on Stack Overflow See other posts from Stack Overflow or by Hwang
Published on 2010-03-25T19:18:26Z Indexed on 2010/03/27 13:03 UTC
Read the original article Hit count: 270

Filed under:
|

The stage is separated into 4 sections, and I will be moving the camera around the stage. So at each particular section the camera will have an area of constrain it can move. I mange to constrain its X & Y, but it could only navigate either X or Y. How to move in X+Y at the same time?

if (mouseX>sec2maxX) {
                TweenLite.to(vC, 1, {x:sec2maxX});
            } else if (mouseX<sec2minX) {
                TweenLite.to(vC, 1, {x:sec2minX});
            } else {
                TweenLite.to(vC, 1, {x:mouseX});
            }

            if (mouseY<sec2minY) {
                TweenLite.to(vC, 1, {y:sec2minY});
            } else if (mouseY>sec2maxY) {
                TweenLite.to(vC, 1, {y:sec2maxY});
            } else {
                TweenLite.to(vC, 1, {y:mouseY});
            }

if i were to put X & Y in a same line of code it would be a lot of possibilities when the mouse is on top left or right bottom kind of situation, so I need to have it running seperately, but how can I combine it so that it could move X+Y?

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about constraints