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]
rondog
June 17, 2008, 4:57pm
2
try this:
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.
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:
rondog
June 17, 2008, 5:55pm
4
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.
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.
rondog
June 17, 2008, 9:22pm
6
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:
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.
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
rondog
June 18, 2008, 5:34am
8
hmm http://gotoandlearn.com/ has some good video tutorials…Ive taken pretty much all of them. Kirupa has a ton of tutorials too.
Ah! that’s the website I used to create my animated buttons.