# How can I make a button do two things?

**URL:** <https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387>\
**Category:** Uncategorized\
**Created:** [August 23, 2004, 10:16pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387 "2004-08-23T22:16:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrEmonkey](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mrEmonkey](https://forum.kirupa.com/u/mrEmonkey)\
**Post date:** [August 23, 2004, 10:16pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387/1 "2004-08-23T22:16:27Z")

</div>

I’ve made a photo gallery using this tut:

[http://www.kirupa.com/developer/mx/photogallery.htm](http://www.kirupa.com/developer/mx/photogallery.htm)

But I wish to have some corresponding text appear next to it.

So far i’ve created the texts as external MC’s, and placed them in an array (same as the pics in the above tut, but named all of the elements differently).

When I assign the AS to the buttons to change the pic, they will only change one thing: either the pic or the text, not both.

Each element will change if its own, but they wont work together.

This is the AS on a button:

```auto
  
on (release) {
 _root.changePhoto(1)
 and _root.changePhoto2(1)
}

```

Can anyone please tell me what AS I need to add to make the button perform both functions.

Thanks

:p:

---

<div class="post-metadata">

**Author:** ![icio](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/icio/32/484_2.png) [@icio](https://forum.kirupa.com/u/icio)\
**Post date:** [August 23, 2004, 10:20pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387/2 "2004-08-23T22:20:59Z")

</div>

what’s the

```auto
and

```

for? just take it out. if i am right in thinking that the changePhoto2() functions changes the text, then this is definately your problem. you do not need and for more that one line of code.

---

<div class="post-metadata">

**Author:** ![mrEmonkey](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mrEmonkey](https://forum.kirupa.com/u/mrEmonkey)\
**Post date:** [August 23, 2004, 10:28pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387/3 "2004-08-23T22:28:13Z")

</div>

The changphoto2() does change the text.

The ‘and’ was not in there to start with, but it didn’t work, so I added it in case that was what was missing.

In short, the ‘and’ makes no difference.

---

<div class="post-metadata">

**Author:** ![Gumby19](https://avatars.discourse-cdn.com/v4/letter/g/3da27b/32.png) [@Gumby19](https://forum.kirupa.com/u/Gumby19)\
**Post date:** [August 23, 2004, 11:02pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387/4 "2004-08-23T23:02:43Z")

</div>

I think cyberathlete is right. You should be able to control as many timelines and have as many functions as you want after the on release. I don’t know why the following wouldn’t work.

on (release) {  
\_root.changePhoto(1)  
\_root.changePhoto2(1)  
}

Post your .fla, someone will figure it out quick.

---

<div class="post-metadata">

**Author:** ![Mad\_Flasher](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Mad\_Flasher](https://forum.kirupa.com/u/Mad_Flasher)\
**Post date:** [August 24, 2004, 6:53pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387/5 "2004-08-24T18:53:27Z")

</div>

Just add the text to the bottom of the graphic, and then update them in the library

---

<div class="post-metadata">

**Author:** ![mrEmonkey](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mrEmonkey](https://forum.kirupa.com/u/mrEmonkey)\
**Post date:** [August 24, 2004, 8:58pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387/6 "2004-08-24T20:58:36Z")

</div>

Thanks guys,

the .fla is attached.

There are two MC’s on the loadboxes layer that the jpegs and text Mc’s load into.

And there are two action layers for each array, obviously if your looking at this, you’ll have to substitue your own MC’s and jpegs in them.

The buttons contain the AS mentioned earlier.

At the moment the buttons contain both lots of AS, but only change the text MC’s when pressed. If I remove that AS for the text Mc’s, the pics change!!!

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![mrEmonkey](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mrEmonkey](https://forum.kirupa.com/u/mrEmonkey)\
**Post date:** [August 24, 2004, 9:00pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387/7 "2004-08-24T21:00:05Z")

</div>

Mad Flasher,

Thanks for the reply, but I don’t follow.

Could you break it down for me?

---

<div class="post-metadata">

**Author:** ![Mad\_Flasher](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Mad\_Flasher](https://forum.kirupa.com/u/Mad_Flasher)\
**Post date:** [August 24, 2004, 9:39pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387/8 "2004-08-24T21:39:00Z")

</div>

well im not sure if I undertsnad what effect you want, but you could either place the text directly on the pics, so there is no need to load to seperate things, or is you want the pic, and then the caption sepratly underneath it, (prefrably do this using a graphical software thing) get your pic, and then leave a gap under it and place the text, save it and update in flash. If you really want it to look cool, you could have a seperate mask for the pic, and the text.

If you still dnt undertand, I mite be able to show you what I mean later

---

<div class="post-metadata">

**Author:** ![mrEmonkey](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mrEmonkey](https://forum.kirupa.com/u/mrEmonkey)\
**Post date:** [August 24, 2004, 9:57pm UTC](https://forum.kirupa.com/t/how-can-i-make-a-button-do-two-things/120387/9 "2004-08-24T21:57:47Z")

</div>

ok I think I understand you.

What your basically saying, is to include the text in the same MC as the pic, so they load together as one file?

I’m aware I can do this, but I was saving it as a last resort. The layout of my page, with buttons makes it a bit awkward to do that.

If I cant get the AS sorted on the buttons that’s what i’ll have to do anyway.

Thanks for the suggestion anyway.

:thumb:
