Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Multiple languages in the same movie.
Custom Hyperlink Colors And Cursor Change
Drag & Drop
Elapsed Time
Determine if a Year is a Leap Year
Initialize QuickTime Video (no white flash)
Mosaic-Alphamania
Tic Tac Toe
ColorCursor
Generic behavior to detect if the key has been pressed
 

 

 

Behavior Sub Rect

Added on 7/1/1999

 

Compatibilities:
behavior D6_5 D7 D8 Mac PC

Rating:

Author: ColeTierney

A behavior that ties a logical rect to a sprite and can respond to clicks. From Cole Tierney"s Code Corner http://homepages.together.net/%7Etierney/cole/code/

property offsetRectStr

property spriteNum
property rOffset
--
--   sub rect
--
--      Cole B. Tierney.
--
on getPropertyDescriptionList  
  set defaultRectStr = "rect( 0, 0, 0, 0 )"
  set s = getAreaSprite()  
  if NOT voidP( s ) then    
    if the currentSpriteNum > 0 then
      set r = the rect of sprite s - the rect of sprite the currentSpriteNum
      set defaultRectStr = string( r )
    end if    
  end if  
  set description = [:]  
  addprop description, #offsetRectStr, [#default:defaultRectStr,
                                 #format:#string,
                                 #comment:"offset rect:"]  
  return description  
end

on getBehaviorDescription  
  set str = "Defines a logical rectangle that "sticks" to the sprite it is "
  put "attached to and knows when the mouse cursor is over it." after str  
  put RETURN after str  
  put "     Put a temporary shape rect called "Target Area" " after str
  put "on the stage in relation to the main sprite, " after str
  put "then drop the this behavior on it (the main sprite).  -- CBT; 5/1/98 -- " after str  
  return str  
end

on getAreaSprite  
  repeat with i = 1 to 120    
    set thisMem = the member of sprite i
    if the number of member thisMem > 0 then
      if the type of member thisMem = #shape then
        if the name of member thisMem = "target area" then          
          set areaSprite = i
          exit repeat          
        end if
      end if
    end if    
  end repeat
  return areaSprite  
end

on beginSprite me
  set rOffset = value( offsetRectStr )
end

on insideRect me
  return inside( point( the mouseH, the mouseV ), rOffset + the rect of sprite spriteNum )
end

on mouseUp me -- Test method.
  if insideRect( me ) then beep
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail