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

Lesson 26. Using a List Database > Using the the rect Function To Move Highligh...

Using the the rect Function To Move Highlights

The function the rect returns the coordinates of the rectangle for any graphic cast member. You will use this function to move the rectangle highlight to a new location. The new location will be the same location as one of the Location selections— when the user selects Aswan, for example, you will need to move the highlight sprite over the selected sprite. This provides the user feedback by highlighting the selected sprite.

1.
Open the Message window.

2.
Type the following and then press Enter (Windows) or Return (Macintosh):

sprite(15).rect = sprite(6).rect

Nothing happens. You need to update the stage to see any results.

3.
TypeupdateStage and then press Enter (Windows) or Return (Macintosh). Watch the stage carefully.

The rectangle now highlights Aswan because you moved the rectangle in sprite 15 so it covers sprite 6 (the sprite in channel 6). Notice that the rectangle not only has a new location but is resized as well. Because you set its value to sprite(6).rect, the rectangle has the same rectangular coordinates as sprite 6.

4.
Type the following and then press Enter (Windows) or Return (Macintosh). Watch the stage carefully.

sprite(15).rect = sprite(7).rect

5.
TypeupdateStage and then press Enter (Windows) or Return (Macintosh).

Now what?


Figure .


The rectangle highlights Blue Nile because that's sprite 7 (the sprite in channel 7). By setting the the rect value for the rectangle to the the rect value for a particular sprite, you move and resize the highlight.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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