Director Help

on stepFrame

Usage

-- Lingo syntax
on stepFrame
    statement(s)
end

// JavaScript syntax
function stepFrame() {
    statement(s);
}

Description

System message and event handler; works in script instances in actorList because these are the only objects that receive on stepFrame messages. This event handler is executed when the playhead enters a frame or the Stage is updated.

An on stepFrame handler is a useful location for Lingo that you want to run frequently for a specific set of objects. Assign the objects to actorList when you want Lingo in the on stepFrame handler to run; remove the objects from actorList to prevent Lingo from running. While the objects are in actorList, the objects’ on stepFrame handlers run each time the playhead enters a frame or the updateStage command is issued.

The stepFrame message is sent before the prepareFrame message.

Assign objects to actorList so they respond to stepFrame messages. Objects must have an on stepFrame handler to use this built-in functionality with actorList.

The go, play, and updateStage commands are disabled in an on stepFrame handler.

Example

If the child object is assigned to actorList, the on stepFrame handler in this parent script updates the position of the sprite that is stored in the mySprite property each time the playhead enters a frame:

-- Lingo syntax
property mySprite

on new me, theSprite
    mySprite = theSprite
    return me
end

on stepFrame me
    sprite(mySprite).loc = point(random(640),random(480))
end

// JavaScript syntax
// define a constructor class that contains the mySprite property
function Frame(theSprite) {
    this.mySprite = theSprite;
}

function stepFrame() {
    var myFrame = new Frame(sprite(spriteName).spriteNum);
    sprite(myFrame.mySprite).loc = point(random(640),random(480));
end