The web site for Flash ActionScript 3.0 game developers

 
         
   

Help with expanding Catching Game

I need help with the Catching Game from here:
http://flashgameu.com/podcast/flashgameu_com_video_tutorial_catching_gam...

I want to expand it so that it will drop three different type of objects. 1 being the "good", 2 being the "bad", and three being the "health".

The following is from line 50 to 69, which is where the coding isn't working.

var healthObjects:Array = ["Health1","Health2"]

if (Math.random() < .5) {
var r:int = Math.floor(Math.random()*goodObjects.length);
var classRef:Class = getDefinitionByName(goodObjects[r]) as Class;
var newObject:MovieClip = new classRef();
newObject.typestr = "good";
} else {
r = Math.floor(Math.random()*badObjects.length);
classRef = getDefinitionByName(badObjects[r]) as Class;
newObject = new classRef();
newObject.typestr = "bad";

} else {
r = Math.floor(Math.random()*healthObjects.length);
classRef = getDefinitionByName(healthObjects[r]) as Class;
newObject = new classRef();
newObject.typestr = "health";

I get the following error: 1083: Syntax error: else is unexpected.

So what should I be using instead of else? I have tried else if but that hasn't worked either. =(
Thank you!



Copyright Gary Rosenzweig