The problem is your use of a single equals sign in the if statement. There are two similar looking operators
= (assignment)
== (equality)
When you are testing for equality, such as in an if statement, you need to use the second one (which is two equal signs). Otherwise, it assumes you want to assign the value on the right side to the variable on the left side.
Also, you should omit the semicolons after the if statement, they will cause it to execute incorrectly.
It's
if (cond) statement; or
if (cond) { block; }
not
if (cond); statement; and not
if (cond); { block }
Here's are some rewrites of your code which simplifies some other things.
code:
on (release)
{
_root.win=0;
_root.win=random(2);
if (_root.win==0)
{
gotoAndStop(3);
} //Lose
if (_root.win==1)
{
gotoAndStop(4);
} //Win
}
Simplification #1. Use the 'else' clause.
code:
on (release)
{
_root.win=0;
_root.win=random(2);
if (_root.win==0)
{
gotoAndStop(3);
} //Lose
else
{
gotoAndStop(4);
} //Win
}
Simplification #2. Omit the variable.
code:
on (release)
{
if (random(2)==0)
{
gotoAndStop(3);
} //Lose
else
{
gotoAndStop(4);
} //Win
}
Simplification #3. Use the random value to compute the frame number. This is clever, but not particularly easy to understand - I would probably use the previous method.
code:
on (release)
{
gotoAndStop(3 + random(2));
}
- Jim