PDA

View Full Version : Movement control with buttons.


bj8341
10-24-2001, 04:39 PM
I need help with some button programming.

Let me describe this part of my project. I have a stationery device with another part that slides up and down on it. I have two buttons labeled "on" and "off". When I push "on" I want the slider to travel up to the end and stop. When I push "off" I want the slider to travel down to the other end and stop.

My problem is that when the "on" button is pushed, instead of staying where it is (because it is already "on") it travels immediately back to "off" and then travels to "on" again. The same is true with the "off" movement.

I am familiar with "Basic" programming but very new to ActionScript. I would greatly appreciate help from anywhere!
Thanks in advance for any response.

mpol777
10-24-2001, 05:37 PM
if you have any code please post it.

pinkaboo
10-24-2001, 05:40 PM
Hmm, I just had a play and this seems to work:

eg:
the first frame of the main timeline :
_root:switch = "";


"on" button:

on (release) {
_root:switch = 370;
}


"off" button:
on (release) {
_root:switch = 150;
}


your slider should be a 3 frame movie with the following actions:

1st frame:
loops = 0;
target_x = _root:switch;
xdiv = (target_x-this._x)/12;

2nd frame:
loops = loops+1;
this._x = this._x+xdiv;

3rd frame:
loops = loops+1;
this._x = this._x+xdiv;
if (loops<12) {
gotoAndPlay (2);
} else {
gotoAndPlay (1);
}

Maybe?
Arggh, I would explain more but it's 5.30 and time for me to go home, hoorah. Any problem, post again and I might be able to take another look in the morning.

good luck

K