Hi, Im not sure why this isnt working...

I designed a very simple flash web banner and the requirement is to have it loop 3 times only. I entered this code at the last frame:

sample:
var i = 0;
if (i < 4)
{

gotoAndPlay(1);
i++;
}
else
{
stop();
}

trace(i);

obviously it isnt working... It keeps tracing 1 hence it just loops forever.. I know this is simple but I cant seem to get it pls help, thanks