# How to use one set of buttons to control different movieclip?

**URL:** https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501
**Category:** Uncategorized
**Created:** [August 14, 2003, 12:26pm UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501 "2003-08-14T12:26:38Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![SBUH](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@SBUH](https://forum.kirupa.com/u/SBUH)
#### Post date: [August 14, 2003, 12:26pm UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/1 "2003-08-14T12:26:38Z")

</div>

I have one set of buttons for moving up, down, left, right of the movieclip. now I have two movieclips they need the same functions. Is that possible I apply the same buttons to both of the movieclips and works on the one which I clicked.

anyother suggestions are welcome too!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 14, 2003, 1:10pm UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/2 "2003-08-14T13:10:48Z")

</div>

I’m not too sure what you mean?? Do you want one button to control several movieClips? or Several buttons which all have the same code?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 14, 2003, 2:00pm UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/3 "2003-08-14T14:00:30Z")

</div>

In the set of buttons, just give example of moving up button.

I have two movieclips. And I want this moving up button can have effect on both of them. And if I click the first movieclip and then click the up button, it goes upward. And if I click the second movieclip and then click the up button, the second one goes upward, and the first one stays where it was.

Am I made myself clear this time.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 14, 2003, 2:18pm UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/4 "2003-08-14T14:18:52Z")

</div>

yea…you can make a variable. Then when you click on the first MC, the variable = 1, and the second MC, the variable = 2.

Then you say if whatever\_variable == 1 {  
moveUp();  
}

then the same with ‘2’. Make a function called moveUp and tahts all!

BTW, did you post two of the same questions? youre not suppose to :-\

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 15, 2003, 6:21am UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/5 "2003-08-15T06:21:55Z")

</div>

Hello, thanks for your idea. I have tried but there is some problem with it.

I have on the first movieclip:  
on (release) {  
var spress=1;  
}  
and on the second one  
on (release) {  
var spress=2;  
}

and on the moving upward button, I have

on (release) {  
trace(\_root.spress); // the spress is undefined when  
//I trace it ,so cannot continue

```
if (spress==1) {
	_root.screen._y -= 5;
	switch (state) {
	case 1 :
		y_value1 = _root.screen._y;
		break;
	case 2 :
		y_value2 = _root.screen._y;
		break;
	case 3 :
		y_value3 = _root.screen._y;
		break;
	case 4 :
		y_value4 = _root.screen._y;
		break;
	}
}
else if(spress==2) {
	_root.mulscreen._y -= 5;
	switch (state) {
	case 1 :
		y_valuem1 = _root.mulscreen._y;
		break;
	case 2 :
		y_valuem2 = _root.mulscreen._y;
		break;
	case 3 :
		y_valuem3 = _root.mulscreen._y;
		break;
	case 4 :
		y_valuem4 = _root.mulscreen._y;
		break;
	}
	
	
	}

```

}

Any idea about this ? Thanks in advance !

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 15, 2003, 6:24am UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/6 "2003-08-15T06:24:20Z")

</div>

Try using AS tags next time 🙂

I havn’t really used switch;break, so i don’t really understand it but thats not the main problem. I have always had a problem doing:

var spress = 1

instead i just do:  
\_root.spress = 1  
\_root.spress = 2

Seems to work better for me. Try it and tel lme if it works 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 15, 2003, 6:53am UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/7 "2003-08-15T06:53:47Z")

</div>

Thanks for your idea of \_root.spress=1. Now it works perfectly well. and the switch also works. Thanks again!

By the way, do u have idea about the combo box for changing the font face of the input and output textfields. I can make the font face shown on the input textfiles, but not on the output textfield after submit. Do u have any idea about that?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 15, 2003, 6:55am UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/8 "2003-08-15T06:55:55Z")

</div>

Do you have an example? i’m not too sure what you mean :-\

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 15, 2003, 7:02am UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/9 "2003-08-15T07:02:53Z")

</div>

Here is the attachment of it there. Many thanks in advance.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 15, 2003, 2:01pm UTC](https://forum.kirupa.com/t/how-to-use-one-set-of-buttons-to-control-different-movieclip/28501/10 "2003-08-15T14:01:14Z")

</div>

Sbuh,

I made this cos i was bored, and cos i knew how to do it. Enjoy.

Regards,  
Viru.
