Thursday, April 22, 2010

Randomly choose the frame.

_global.frames = Array();

_global.getFirstFrame = function():Number
{
while(_global.frames.length > 0)
{
_global.frames.pop();
}
frameIdx = Math.floor(Math.random() * 4) + 1;

_global.frames.push(frameIdx);
return frameIdx;
}

_global.getNextFrame = function():Number
{
frameIdx = Math.floor(Math.random() * 4) + 1;
for(var i:Number = 0; i < _global.frames.length; i ++)
{
if(frameIdx == _global.frames[i])
{
frameIdx = Math.floor(Math.random() * 4) + 1;
i = 0;
}
}

_global.frames.push(frameIdx);

return frameIdx;
}

No comments:

Post a Comment