Question

I am trying to create small gaming app in flash.

So have one movie clip , inside that I have 4 frames. I am calling one frame from those four randomly but I need to call it randomly again and again. setTimeout not working in my case, so how can I achieve randomly call any frame out of 4 repeatedly.

function createRandomCoinValues()
{
    for(var i = 0; i< 5; i++)
    {
        var my_timedProcess:Number = setTimeout(createMc(i),4000);
        if(my_timedProcess)
        {
            trace(my_timedProcess);
            clearTimeout(my_timedProcess);
        }
    }

    addListeners();

}
function createMc(i:Number)
{
    associatedRandomValues[i] = randomNumbers(1,5);
    var mc:MovieClip = this.getChildByName("coin"+ (i + 1) + "_mc") as MovieClip;
    mc.gotoAndStop(generateRandomAnimation(1,100));
    //By generateRandomAnimation() giving input to only either go to vertical or horizontal named frame.

}

Any help suggestion is very important to me. Thanks in advance.

Was it helpful?

Solution

What you need is addFrameScript().

Here is an example, not real code.

mc.addFrameScript( frame, function(){ mc.gotoAndStop(randomFrame) } )

Note: addFrameScript() start from frame 0 and end to totalFrame - 1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top