PDA

View Full Version : New to actionscripting (MX)


tinre
07-18-2002, 02:41 AM
I am trying to get a button to do 2 different things to 2 different mc's.
I have a transparent button with a mc behind it with a stop-frame (with a stop-image)and a start-frame (with a start-image). When I push the button the mc behind it goes to the start-frame. Push it again and it goes back to the stop-frame. So far, so good. But I also want the same button to stop and start another mc, and it will not. I am desperate! This is my code for now, can anybody tell me what I am doing wrong?

on (release) {
if (dummy = 0) {
with (_root.WorkingMov) {
gotoAndPlay("start");
dummy = 1;
}
with (_root.NOTworkingMov) {
stop();
}
} else if (dummy = 1) {
with (_root.WorkingMov) {
gotoAndPlay("stop");
dummy = 0;
}
with (_root.NOTworkingMov) {
play();
}
}
}

I know I have the path right because I use the "target"-thingy.

I would be VERY greatful for any help in this case...

Tine

Jesse
07-18-2002, 02:58 AM
if (dummy = 0) { ... }
// should be
if (dummy == 0) { ... }
// = sets a value, == tests a value

tinre
07-18-2002, 03:10 AM
Well, I changed it to == and now nothing works. Not even the one that did work before changing.(?!?)

Enything else you can think of?

Thank you for a quick reply, by the way!

Jesse
07-18-2002, 03:26 AM
You must use == in a conditional statement. if (something = something) {} will always be true.
The rest of your code looks technically correct. It's likely a problem with how it's setup. Where is the dummy variable supposed to be? Perhaps change all references to 'dummy' to '_root.dummy' to make sure you're always referencing the same variable.

tinre
07-18-2002, 03:48 AM
Ok, I feel really stupid. (But hey! I am new to this..)
I had forgotten to set the variable dummy in the first place. No wonder it got confused.

Thank you for helping me anyway. I wouldn't have thought about it if you hadn't asked me where the variable was supposed to be.