What would be the AS3 conversion script for the following?



stop();

function initGame() {
    // the range of falling apple clips
    firstApple = 1;
    lastApple = 0;
    
    // init the score
    score = 0;

    // set the number of apples to fall
    totalApples = 30;

    // init the speed and time delay
    timeSinceLastApple = 0;
    appleSpeed = 5;

    // create the fox so that it is on top of the apples
    attachMovie("running fox","fox",999999);
    fox._x = 375;
    fox._y = 350;
}

function moveFox() {
    // check for arrow keys
    if (Key.isDown(Key.RIGHT)) {
        dx = 10;
        // fox faces right
        fox._xscale = -Math.abs(fox._xscale);
    } else if (Key.isDown(Key.LEFT)) {
        dx = -10;
        // fox faces left
        fox._xscale = Math.abs(fox._xscale);
    } else {
        // no movement
        dx = 0;
    }

    // move the fox and limit that movement
    fox._x += dx;
    if (fox._x < 30) fox._x = 30;
    if (fox._x > 520) fox._x = 520;

    // make the fox run or stand still
    if ((dx != 0) and (fox._currentFrame == 1)) {
        fox.gotoAndPlay("run");
    } else if ((dx == 0) and (fox._currentFrame != 1)) {
        fox.gotoAndPlay("stand");
    }
}

function dropNewApple() {
    // only drop if it has been long enough
    if (timeSinceLastApple > 20) {

        // only drop if there are more apples
        if  (lastApple < totalApples) {

            // only drop 10% of the time
            if (Math.random() < .1) {

                // create next apple and set its locations
                lastApple++;
                if (Math.random() < .5) {
                    // 50% chance of a bad apple
                    attachMovie( "bad apple", "apple"+lastApple, lastApple );                    
                    _root["apple"+lastApple].type = "bad";
                } else {
                    // 50% chance of a good apple
                    attachMovie( "good apple", "apple"+lastApple, lastApple );
                    _root["apple"+lastApple].type = "good";
                }
                f = int(Math.Random()*_root["apple"+lastApple]._totalFrames) + 1;
                _root["apple"+lastApple].gotoAndStop(f);
                _root["apple"+lastApple]._x = Math.random()*490+30;
                _root["apple"+lastApple]._y = 0;

                // reset time delay for next apple
                timeSinceLastApple = 0;

                // increase apple speed
                if (appleSpeed < 10) appleSpeed += .5;
            }
        }
    }

    // even if no apple dropped, get closer to next drop
    timeSinceLastApple++;
}

function moveApples() {
    // loop through all existing apple clips
    for (i=firstApple;i<=lastApple;i++) {

        // get apple location
        x = _root["apple"+i]._x;
        y = _root["apple"+i]._y + appleSpeed;

        // see whether apple reached ground
        if (y > 400) {
            removeApple(i);

      
        } else if ((Math.abs(y-fox._y) < 10) and (Math.abs(x-fox._x) < 25)) {
            if (_root["apple"+i].type == "good") {
                // good apple, get a point
                score += 5;
            } else {
                // bad apple, lose a point
                score -= 5;

                // don't go below 0
                if (score < 0) score = 0;
            }
            removeApple(i);

        // continue to move apple
        } else {
            _root["apple"+i]._y = y;
        }
    }
}

function removeApple(n) {
    // take away apple movie clip
    _root["apple"+n].removeMovieClip();

    // reset range of apples to move
    firstApple = n+1;

    // see whether this was the last apple
    if (n == totalApples) {
        fox.removeMovieClip();
        gotoAndPlay("game over");
    }
}

THANKS,

Scott