Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Can anyone tell me why it is saying this to me?

Im trying to make a game and was adding a movie into the game but it keeps telling me this:


Scene=Scene 1, Layer=actions, Frame=4: Line 72: 'else' encountered without matching 'if'
} else {
________________________________________________________________________

I do not know what this means and its starting to get frusterating why i cant get it to work. This is the code i am using. If you can figure out how to repair it, it would be very much appreicated.

// create next food and set its locations
lastfood++;
if (Math.random() < .5) {
// 45% chance of a poison
attachMovie( "poison", "food"+lastfood, lastfood ); _root["food"+lastfood].type = "poison";
} else {
// 55% chance of a food
attachMovie( "food", "food"+lastfood, lastfood );
_root["food"+lastfood].type = "food";
} else {
// 5% chance of a goodapple
attachMovie( "goodapple", "food"+lastfood, lastfood );
_root["food"+lastfood].type = "goodapple";
}
f = int(Math.Random()*_root["food"+lastfood]._totalFrames) + 1;
trace(f);
_root["food"+lastfood].gotoAndStop(f);
_root["food"+lastfood]._x = Math.random()*490+30;
_root["food"+lastfood]._y = 0;

Comments

  • tsopranotsoprano Posts: 3Member
    [b][red]This message was edited by tsoprano at 2002-12-17 23:1:26[/red][/b][hr]
    : Im trying to make a game and was adding a movie into the game but it keeps telling me this:
    :
    :
    : Scene=Scene 1, Layer=actions, Frame=4: Line 72: 'else' encountered without matching 'if'
    : } else {
    : ________________________________________________________________________
    :
    : I do not know what this means and its starting to get frusterating why i cant get it to work. This is the code i am using. If you can figure out how to repair it, it would be very much appreicated.
    :
    : // create next food and set its locations
    : lastfood++;
    : if (Math.random() < .5) {
    : // 45% chance of a poison
    : attachMovie( "poison", "food"+lastfood, lastfood ); _root["food"+lastfood].type = "poison";
    : } else {
    : // 55% chance of a food
    : attachMovie( "food", "food"+lastfood, lastfood );
    : _root["food"+lastfood].type = "food";
    : } else {
    : // 5% chance of a goodapple
    : attachMovie( "goodapple", "food"+lastfood, lastfood );
    : _root["food"+lastfood].type = "goodapple";
    : }
    : f = int(Math.Random()*_root["food"+lastfood]._totalFrames) + 1;
    : trace(f);
    : _root["food"+lastfood].gotoAndStop(f);
    : _root["food"+lastfood]._x = Math.random()*490+30;
    : _root["food"+lastfood]._y = 0;
    :

    replace the first else with "else if".

  • tsopranotsoprano Posts: 3Member
    : : Im trying to make a game and was adding a movie into the game but it keeps telling me this:
    : :
    : :
    : : Scene=Scene 1, Layer=actions, Frame=4: Line 72: 'else' encountered without matching 'if'
    : : } else {
    : : ________________________________________________________________________
    : :
    : : I do not know what this means and its starting to get frusterating why i cant get it to work. This is the code i am using. If you can figure out how to repair it, it would be very much appreicated.
    : :
    : : // create next food and set its locations
    : : lastfood++;
    : : if (Math.random() < .5) {
    : : // 45% chance of a poison
    : : attachMovie( "poison", "food"+lastfood, lastfood ); _root["food"+lastfood].type = "poison";
    : : } else {
    : : // 55% chance of a food
    : : attachMovie( "food", "food"+lastfood, lastfood );
    : : _root["food"+lastfood].type = "food";
    : : } else {
    : : // 5% chance of a goodapple
    : : attachMovie( "goodapple", "food"+lastfood, lastfood );
    : : _root["food"+lastfood].type = "goodapple";
    : : }
    : : f = int(Math.Random()*_root["food"+lastfood]._totalFrames) + 1;
    : : trace(f);
    : : _root["food"+lastfood].gotoAndStop(f);
    : : _root["food"+lastfood]._x = Math.random()*490+30;
    : : _root["food"+lastfood]._y = 0;
    : :
    :
    : replace the first if with an else if
    you can't have two else's with one if, it doesn't make sense.

  • slim00slim00 Posts: 3Member
    : Im trying to make a game and was adding a movie into the game but it keeps telling me this:
    :
    :
    : Scene=Scene 1, Layer=actions, Frame=4: Line 72: 'else' encountered without matching 'if'
    : } else {
    : ________________________________________________________________________
    :
    : I do not know what this means and its starting to get frusterating why i cant get it to work. This is the code i am using. If you can figure out how to repair it, it would be very much appreicated.
    :
    : // create next food and set its locations
    : lastfood++;
    : if (Math.random() < .5) {
    : // 45% chance of a poison
    : attachMovie( "poison", "food"+lastfood, lastfood ); _root["food"+lastfood].type = "poison";
    : } else {
    : // 55% chance of a food
    : attachMovie( "food", "food"+lastfood, lastfood );
    : _root["food"+lastfood].type = "food";
    : } else {
    : // 5% chance of a goodapple
    : attachMovie( "goodapple", "food"+lastfood, lastfood );
    : _root["food"+lastfood].type = "goodapple";
    : }
    : f = int(Math.Random()*_root["food"+lastfood]._totalFrames) + 1;
    : trace(f);
    : _root["food"+lastfood].gotoAndStop(f);
    : _root["food"+lastfood]._x = Math.random()*490+30;
    : _root["food"+lastfood]._y = 0;
    :
    try if on the f=int statement that might be the problem


Sign In or Register to comment.