• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 30. Monitoring Director > Monitoring the Current Sprite and Frame

Monitoring the Current Sprite and Frame

When many sprites are layered on the stage, you may sometimes need to identify which sprite is which at runtime. For instance, if a visible sprite is not receiving a click or rollover event message that you think it should be, it may be because another sprite in a higher channel is receiving the event. By applying monitoring techniques similar to those you used to determine the mouse's location, you can have Director report both the frame number and the current sprite so you can see what is happening.

Select cast member 4in the Cast window and click the Script button to open the movie script in the Script Editor.

Modify the on idle handler by adding the lines shown here in bold:

on idle             --Whenever the movie is not busy,
  member ("Coordinates").text = string(the mouseLoc)
                    --place the mouse coordinates in the Coordinates field.
  member ("Sprite Status").text = "Current sprite:" && the rollover
							--Place the number of the sprite the mouse is over
							--in the Sprite Status field.
							member ("Frame Status").text = "Current frame:" && the frame
							--Place the current frame number in the Frame Status field.

These statements will update two different status fields, Sprite Status and Field Status, with the current rollover value and the current frame number, respectively. Director always stores the number of the currently rolled-over sprite, if any, in a property called the rollover; Director always stores the current frame number in a property called the frame.

To see the results of the rollover and the frame, you need to create the fields that will display them. While you're at it, you can also create text cast members to label the fields on the stage. An easy method is to use copies of current cast members 1 and 2.

Select cast member 1 in the Cast window and copy it (Windows Ctrl+C, Macintosh Command+C). Paste copies in cast members 7and 9 (Windows Ctrl+V, Macintosh Command+V). Repeat the process with cast member 2, placing copies in cast members 8 and 10.

Figure .

Rename cast member 8 Sprite Status to match the name of the field used in the Lingo you added to the on idle handler. Rename cast member 10 Frame Status.

Double-click cast member 7 to open the Text Editor and change the text toThe Rollover Sprite is:. Change the text of cast member 9 to The Frame is:.

Place the four new cast members on the stage so that all six sprites are visible.

Figure .

If necessary, adjust all of the sprites in the score so they span frames 1 through 9 . Set the ink of the four new sprites to Background Transparent.

Figure .

Play the movie. Move the mouse around so that it passes over various sprites on the stage.

As the movie runs, the Sprite Status field displays the number of the sprite the mouse is over. If the mouse is not over a sprite, the field displays 0. If you look quickly, you will see the Frame Status field begin at 1 and count up to 9. The field display remains at 9 because the movie loops on that frame.

Figure .

Stop playback, rewind the movie, and save your work.

Now you know some techniques for getting test information while authoring.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint