I've got a chunk of script:

.flash filename="Cherries.swf" version=6 bbox=640x480 fps=24

.swf cherry "cherry.swf"

.put cherries0=cherry x=5 y=40
.put cherries1=cherry x=25 y=60
.put cherries2=cherry x=45 y=80


.action:
    score = new Array(0, 0, 0);

    initcherries = function ()
        {
        i = 0;
        while (i < 3)
            {
            this["cherries"+i]._x = 20 + i * 20;
            this["cherries"+i]._y = 120;
            i++;
            };
        };
    initcherries();

    score[0] = 1;

    updateScore = function ()
        {
        cx = 5;
        i = 0;
        while (i < 3)
            {
            if (score[i]==1)
                {
                this["cherries"+i]._x = cx;
                this["cherries"+i]._y = 460;
                cx += 20;
                }
            else
                this["cherries"+i]._y = 500;
            i++;
            }
        };

    scoreUpdate = SetInterval (updateScore, 25);

    .end

.end

Substitute any other 16x16 graphic for cherry.swf.

Now, the issue is this: When I compile this, the first function (initcherries) works precisely as advertised. However, the second function (updateScore) does not relocate the cherries, as intended.

Any other code inserted anywhere in updateScore works great. It is only the relocation code (this["cherries"+i]._y) that seems to be ignored. And the only difference between the two functions is that the second is called by a SetInterval.

Before you mention the if statement in updateScore, inserting a similar if statement in initcherries will result in code that still works as advertised.

Any suggestions?

Reply via email to