Lingo: Frame Scripts

Use a frame script when you want a frame event (usually exitFrame) to trigger an action (usually navigation). Frame scripts are not associated with anything onstage; they belong to the whole frame! Frame scripts live in the script channel in the score (see illustration below).

Example: A simple frame script

In this example, we want to create a script that sends the playback head back to the marker every time it reaches the end of the section (frame 28), causing the animation to loop over & over.

  1. Double click in the cell in the script channel in the frame where you want the script (in this case, the last frame of the animation):

  2. The script window will open with "on exitFrame" and "end" already there. Just type the action in between the two.


    Notice the new cast member in the cast & new sprite in the score's script channel (just above the playback head; the "2" indicates that it's cast member #2 in there).

That's it!

Remember, a frame script (like any other cast member) is reusable! If you ever want to reuse a frame script, simply drag it from the cast to the desired frame (or: edit:copy sprite from one part of the score, edit:paste sprite where you need it).

 

Learn these handy frame scripts!

Here are some frame scripts that will always be useful; get to know them.

To make a section of your score loop (by sending the playback head backwards to the nearest marker):

on exitFrame
  go loop
end

To hold the playback head in a frame (but keep the movie running, keep buttons & filmloops active):

on exitFrame
  go to the frame
end

To send the playback head to a marker named "Opening":

on exitFrame
  go to "Opening"
end

To send the playback head back to the beginning of your score:

on exitFrame
  go to frame 1
end

 

>>Next: Behaviors

Back