StepFrame

From Director Online Wiki
Jump to: navigation, search

A Frame Event that is sent to objects in the actorList.

stepFrame is the first event to be sent in any given frame, unless there are beginSprite or prepareMovie events. It is followed by prepareFrame.

See Frame Events for a ordered list of the events.

Usage

Stepframe is useful in child objects, who don't get enterframe and exitframe events. When a child object needs to recieve events every frame, add it's object to the actorlist. The example below is a custom handler you can call to add an object to the actorlist:

on StartGettingStepframes me
  add the actorlist, me
end 

Once the above handler has been called, the object will now have it's StepFrame handler called every frame:

on Stepframe me
  put "I'm getting a stepframe event!" && the milliseconds
end

To stop the object from receiving StepFrame events, delete it from the actorlist like so:

on StopGettingStepframe me
  deleteone the actorlist, me
end

Once the above handler has been called, the object will no longer recieve stepframe events.

Unless you're doing very careful cleanup of your scripts, it's best to initialize the actorlist at the beginning or end of your movie for authoring purposes, like so:

on startmovie me
  the actorlist = []
end

This keeps old objects and duplicate objects from sticking around in the actorlist.