Hi Guys,
I'm a complete Flash newbie, all I've done is a few days of tutorials and stuff on the Internet. I'm knocking together a prototype for a University project.
I have a radio button list, and once a button is selected and submit is pressed it takes the user to a certain frame. Each radio button represents a different condition, and for the distance condition I want it to take the user to one of two frames; one which shows the animation close up, and one which shows it far away.
Before I attempted to have this button selection send the user to one of two frames, I had it working just sending them to the one. This is the code that I used:
ActionScript Code:
if (group.selection == distance) {
stop();
submit.addEventListener(MouseEvent.CLICK, submit2Click);
function submit2Click(event:MouseEvent):void{
gotoAndPlay(32);
}
}
From what I've found on the Internet I believe that I need to generate random numbers and have this within an if statement. I've played about with various combinations with no luck. Below is what I currently have:
ActionScript Code:
if (group.selection == distance) {
stop();
var n:Number = Math.round(Math.random()* 1+0);
trace(n);
if (n == 1) {
submit.addEventListener(MouseEvent.CLICK, submit2Click);
function submit2Click(event:MouseEvent):void{
gotoAndPlay(32);
}
if (n == 0) {
submit.addEventListener(MouseEvent.CLICK, submit8Click);
function submit8Click(event:MouseEvent):void{
gotoAndPlay(501);
}
}
}
}
The trace shows me that the number generating is working, but when I click submit it always take me to frame 32 no matter what the number is. I'm unsure as to whether an if within an if is something which is going to work? I've been trying to get this to work for a couple of hours now and have run out of ideas. If any of you guys could give me some help then that would be great.
Thank you, Tom.