Beginner doesn't get this actionscript concept

Hi Folks,

I am attempting to learn the basics(very basic!) of flash programming and global variables.
Here’s the scenario:


Frame one contains this actionscript:
var length=0;

Frame two contains this actionscript:
length=length+1;
trace(“length in second frame is”);
trace(length);
bar._xscale=length;

Frame three contains this actionscript:
length=length+1;
trace(“length in third frame is”);
trace(length);
bar._xscale=length;
if (length == 100) {
stop()
}
gotoAndPlay(2);


Irrelevant of what I am trying to do, in frame three I expected the movie to stop once the global variable “length” reached 100 but this is not the case, the movie continues on.

Now if I make the following in frame 3:


if (length == 100) {
stop()
}
else{
gotoAndPlay(2);
}


instead of:


if (length == 100) {
stop()
}
gotoAndPlay(2);


all works properly.

Can someone explain to me what I am not understanding in regards to how actionscripting works? Obviously I am missing what seems to be a VERY IMPORTANT concept in actionscripting.

Thanks,
Greg
[email protected]