We help IT Professionals succeed at work.

How do I control the x,y range using a symbol?

on
291 Views
I have two buttons. The "Right" button each time it is clicked moves a tiny symbol (tinysquare2) to the right 5 pixels; the Left" button moves the symbol to the left 5 pixels.  I have been able to restrain it between two points (x axis: 252 and 347) but it jumps to the middle position once it reaches the furthest point instead of moving from that current position in the far right or far left. How to get it to move left from the furthest right position instead of it jumping to the middle then moving to the left?

Right Button:

on (press) {
if (VOL.text=="VOL"){
turn2._alpha = 100;
Turnknob2.text = "Right >";
tinysquare2._x += 5;
};
if (tinysquare2._x >= 347.1) {
tinysquare2._x = 347.1;
};
if (tinysquare2._x <= 252.2) {
tinysquare2._x = 252.2;

};

}

Left Button:

on (press) {
if (VOL.text=="VOL"){
turn2._alpha = 100;
Turnknob2.text = "< Left";
tinysquare2._x -= 5;
};
if (tinysquare2._x >= 347.1) {
tinysquare2._x = 347.1;

};
if (tinysquare2._x <= 252.2) {
tinysquare2._x = 252.2;

};

}
Comment
Watch Question
Commented:
This problem has been solved!
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

Deciding to stick with EE.

Mohamed Asif

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant