# Buttons direction

**URL:** https://forum.kirupa.com/t/buttons-direction/263601
**Category:** flash
**Created:** [June 17, 2008, 4:29pm UTC](https://forum.kirupa.com/t/buttons-direction/263601 "2008-06-17T16:29:27Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Lili000](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Lili000](https://forum.kirupa.com/u/Lili000)
#### Post date: [June 17, 2008, 4:29pm UTC](https://forum.kirupa.com/t/buttons-direction/263601/1 "2008-06-17T16:29:27Z")

</div>

Hello,

I’m trying to build my 1st flash website and I’m stuck!

I would like to go to frame5 when I click on my 1st button (b1) and I would like to go to frame 6 when I click on my 2nd button (b2).

I’ve tried a few things but it doesn’t work…

This is my action page below. Some help would be much appreciated.

Many thanks, Lili.

[COLOR=darkred]b1.onRollOver = over;  
b1.onRollOut = out;  
b1.buttText.buttonText.text = “Company Profile”;[/COLOR]  
[COLOR=darkred][/COLOR]  
[COLOR=darkred]b2.onRollOver = over;  
b2.onRollOut = out;  
b2.buttText.buttonText.text = “Directors”;[/COLOR]  
[COLOR=darkred][/COLOR]  
[COLOR=darkred]b3.onRollOver = over;  
b3.onRollOut = out;  
b3.buttText.buttonText.text = “Nigeria & Africa”;[/COLOR]  
[COLOR=darkred][/COLOR]  
[COLOR=darkred]b4.onRollOver = over;  
b4.onRollOut = out;  
b4.buttText.buttonText.text = “Strategy”;[/COLOR]  
[COLOR=darkred][/COLOR]  
[COLOR=darkred]b5.onRollOver = over;  
b5.onRollOut = out;  
b5.buttText.buttonText.text = “Our Offices”;[/COLOR]  
[COLOR=darkred][/COLOR]  
[COLOR=darkred]function over() {  
this.gotoAndPlay(2);  
}[/COLOR]  
[COLOR=darkred]function out() {  
this.gotoAndPlay(7);  
}[/COLOR]

---

<div class="post-metadata">

### Author: ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)
#### Post date: [June 17, 2008, 4:57pm UTC](https://forum.kirupa.com/t/buttons-direction/263601/2 "2008-06-17T16:57:31Z")

</div>

try this:

```auto

var buttons:Array = [["company Profile", 5], ["Directors", 6], ["Nigeria & Africa", 7], ["Strategy", 8], ["Our Offices", 9]];

for (var i = 0; i < buttons.length; i++)
{
    this["b" + i].id = i;
    this["b" + i].onRollOver = function()
    {
        over(this.id);
    };
    this["b" + i].onRollOut = function()
    {
        out(this.id);
    };
    this["b" + i].onRelease = function()
    {
        clickFunc(this.id);
    };
    this["b" + i].buttText.buttonText.text = buttons*[0];
}

function over(itemID)
{
    this["b" + itemID].gotoAndPlay(2);
}
function out(itemID)
{
    this["b" + itemID].gotoAndPlay(7);
}

function clickFunc(itemID)
{
    trace("gotoFrame: " + buttons[itemID][1]);
}

```

Note: I started your button instance names at b0, b1, b2 etc. When using arrays like I did, its easier to start by 0.

---

<div class="post-metadata">

### Author: ![Lili000](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Lili000](https://forum.kirupa.com/u/Lili000)
#### Post date: [June 17, 2008, 5:44pm UTC](https://forum.kirupa.com/t/buttons-direction/263601/3 "2008-06-17T17:44:56Z")

</div>

Thank you very much for your reply but is there just a line I could add to my existing script instead of changing everything ? :crying:

---

<div class="post-metadata">

### Author: ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)
#### Post date: [June 17, 2008, 5:55pm UTC](https://forum.kirupa.com/t/buttons-direction/263601/4 "2008-06-17T17:55:24Z")

</div>

No. alternatively you can make separate functions for each onRelease event for each button and make your code even more inefficient or just take what I did and use it. Its easy. The array contains your buttontext and the frame you want it to go to. Cant get simpler than that.

---

<div class="post-metadata">

### Author: ![Lili000](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Lili000](https://forum.kirupa.com/u/Lili000)
#### Post date: [June 17, 2008, 8:52pm UTC](https://forum.kirupa.com/t/buttons-direction/263601/5 "2008-06-17T20:52:28Z")

</div>

If I was making separate functions for each onRelease event for each button, what should I add to my script?

I’m sorry but I’m a real beginner and I have a lot to learn…

Many thanks.

---

<div class="post-metadata">

### Author: ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)
#### Post date: [June 17, 2008, 9:22pm UTC](https://forum.kirupa.com/t/buttons-direction/263601/6 "2008-06-17T21:22:13Z")

</div>

If you are a beginner and want to learn the right way, you would do what I am doing. But to do the inefficient way, do:

```auto

b1.onRelease = b1Release;
b2.onRelease = b2Release;
function b1Release()
{
    gotoAndStop(5);
}
function b2Release()
{
    gotoAndStop(6);
}

etc...I dont even know why I am showing you that..its terrible coding.

```

---

<div class="post-metadata">

### Author: ![Lili000](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Lili000](https://forum.kirupa.com/u/Lili000)
#### Post date: [June 17, 2008, 9:29pm UTC](https://forum.kirupa.com/t/buttons-direction/263601/7 "2008-06-17T21:29:04Z")

</div>

THANK YOU!!!

I really appreciate your help. It’s just that I followed a tutorial on how to create an animated button and with your code, I was lost.

Do you have any book or website to recommend to learn Flash?

Thanks a lot.

Lili

---

<div class="post-metadata">

### Author: ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)
#### Post date: [June 18, 2008, 5:34am UTC](https://forum.kirupa.com/t/buttons-direction/263601/8 "2008-06-18T05:34:55Z")

</div>

hmm [http://gotoandlearn.com/](http://gotoandlearn.com/) has some good video tutorials…Ive taken pretty much all of them. Kirupa has a ton of tutorials too.

---

<div class="post-metadata">

### Author: ![Lili000](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@Lili000](https://forum.kirupa.com/u/Lili000)
#### Post date: [June 18, 2008, 7:48am UTC](https://forum.kirupa.com/t/buttons-direction/263601/9 "2008-06-18T07:48:17Z")

</div>

Ah! that’s the website I used to create my animated buttons.
