Reputation: 1
Help, i have written a code, where it will detect an object position and do something according to the function, but i'm having a problem with the if else statement, the 2 last "else if" are for some reason not working
stage.addEventListener(Event.ENTER_FRAME, mainLoop);
function mainLoop (event:Event):void{
movePanel();
}
function movePanel():void{
Panel.x = 500;
if (panelIsClicked){
Panel.startDrag();
}else{
Panel.stopDrag();
}
if (Panel.y >= 1250){
Panel.y = 1250;
}
if (Panel.y <= -730){
Panel.y = -730;
}
if (Panel.y >= 770){
Pager.Butt1.play();
Pager.Butt2.gotoAndStop(1);
Pager.Butt3.gotoAndStop(1);
Pager.Butt4.gotoAndStop(1);
}
else if (170 < Panel.y <= 769){
Pager.Butt2.play();
Pager.Butt3.gotoAndStop(1);
Pager.Butt1.gotoAndStop(1);
Pager.Butt4.gotoAndStop(1);
}
else{
Pager.Butt4.play();
Pager.Butt1.gotoAndStop(1);
Pager.Butt2.gotoAndStop(1);
Pager.Butt3.gotoAndStop(1);
}
}
Upvotes: 0
Views: 34
Reputation: 42166
You've used a wrong syntax. Change this line:
else if (170 < Panel.y <= 769){
like this:
else if (170 < Panel.y && Panel.y <= 769){
and it'll work. Good luck!
Upvotes: 1