Difficulty Selection

Im trying to develop a way for my game to determin what difficulty settings were selected before making an action. So what I have tried to do is develop an IF/ELSE statment that says:

ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#808080]//easy</p>[/COLOR]
<p>this.[COLOR=#0000ff]onEnterFrame[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]</p>
<p>if COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]</p>
<p> [COLOR=#000000]var[/COLOR] easy:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];</p>
<p> [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR]easy[COLOR=#000000][[/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]floor[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]random[/COLOR]COLOR=#000000[/COLOR] * easy.[COLOR=#0000ff]length[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];</p>
<p>[COLOR=#808080]//normal</p>[/COLOR]
<p>[COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]</p>
<p> [COLOR=#000000]var[/COLOR] normal:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];</p>
<p> [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR]normal[COLOR=#000000][[/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]floor[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]random[/COLOR]COLOR=#000000[/COLOR] * normal.[COLOR=#0000ff]length[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];</p>
<p>[COLOR=#808080]//hard</p>[/COLOR]
<p>[COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]</p>
<p> [COLOR=#000000]var[/COLOR] hard:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];</p>
<p> [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR]hard[COLOR=#000000][[/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]floor[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]random[/COLOR]COLOR=#000000[/COLOR] * hard.[COLOR=#0000ff]length[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR]; </p>
<p> [COLOR=#000000]}[/COLOR]</p>
<p>[COLOR=#000000]}[/COLOR]; </p>
<p>
[/LEFT]
[/FONT]

Using various arrays to try and make it randomly select a certain frame just seems to be causeing issues. Its not actually selecting a frame and stoping… its just going nuts and I have no idea how to stop it.

Any ideas? Please take a look at the example I made.

Mark

I would do this;
I would make all my buttons to change the difficulty, labelling them like setTo1, setTo2, setTo… etc up to 5.

After that I would place this on the frame;

for(var i:Number = 1; i<6; i++){
//scan through, 1-5
_root["setTo"+i].id = i;
//give each button an id, to set the speed
_root["setTo"+i].onRelease = function(){
//set the button's onRelease
setDiff(this.id);
//call the difficulty function, passing "id"
}
}
function setDiff(which){
//this function sets the difficulty
level = which;
//set level to "which" (the variable passed)
}

then whatever variables you want to be effected by the difficulty i would multiply is by level.

For example;


ball._y += speed*level

That is ONE basic method, plenty of others :wink: