[flash 8] SetInterval (probably obvious) help

Hello all,

I’m doing my best to put together a little game my brother can change the graphics on to his own delight. Its a basic side scroller type thing. What I’m doing is programmatically creating the scenery in the background and making it move across the stage, but only when the right mouse button is pressed.

I’m trying to use SetInterval to randomly create these pieces of scenery in the background, but I can’t seem to get it working… I’ve searched the forum, and read nearly every post, and I just don’t seem to be able to get it running.

Here’s my code (it’s proably a mess, but at the moment, I’m just trying to get things to work):

// Define Variables. These are editable

var speed:Number = 5; // Speed of the charecter

//
// Do not edit anything past this point, or you'll mess stuff up.
//

// Uneditable Variables

var moving:Boolean = false; // If where moving or not

// objects that are inherited

var scenery_obj:Object = new Object();

scenery_obj.onEnterFrame = function() {
    if (moving==true){
    this._x-=speed;
    }
}

// Functions

function initialise() {
    var bg_container:MovieClip = this.createEmptyMovieClip("bg_container", this.getNextHighestDepth());
}

function createScenery() {

         var s:Number;
        var sc_container:MovieClip = this.createEmptyMovieClip("sc_container", this.getNextHighestDepth());
        sc_container.attachMovie("scenery_object", "scenery_object"+s, this.getNextHighestDepth(),  scenery_obj);
        s++;
}

// Setup enviroment

this.onLoad = function() {
    scenery_obj._y=230;
    scenery_obj._x=560;
    initialise();
}

// KEYS
var keyListener:Object = new Object(); // define listener object

// the check keys function
keyListener.onKeyDown = function() { 
    if (Key.isDown(Key.RIGHT)) {
        moving = true;
        createScenery()
    }
};
keyListener.onKeyUp = function() { 
    moving= false;
};
Key.addListener(keyListener);


Thanks in advance

this.onLoad = function() {
    scenery_obj._y=230;
    scenery_obj._x=560;
    initialise();
}

don’t use onLoad, just:


    scenery_obj._y=230;
    scenery_obj._x=560;
    initialise();

But I can’t see any interval. Use the

 to wrap you code