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
APresentationTrakker Xtra
Set ViewScale Property of a Flash Sprite
RoboDemo Review
RGB to CMYK
Coloring Book
Curve Sprite - Move a sprite along a curved path.
Toggle ActionsEnabled Property of a Flash Sprite
Shocking the Web : Windows
Power Blender
KeyboardControl Xtra Standard
 

 

 

Behavior Drag Sprite with Hotspot

Added on 9/23/2004

 

Compatibilities:
D9

This item has not yet been rated

Author: jayhilwig (website)

This adds the ability to drag a sprite with a FIXED hotspot defined. It is primairily intended for dragging windows from the top (folder windows, Explorer Windows etc...). It can be changed by altering "mouseH, mouseV" and sprite.top, sprite.right etc... You cannot define an irregular (non rectangular) hotspot with this behavior. Dont' know if this works in any version other than the MX(s).

property spriteNum, pMySpriteRef, topSpot

on getBehaviorDescription me
  return
    "how much from top?" & RETURN & RETURN &
    "PERMITTED MEMBER TYPES:" & RETURN &
    "Graphic" & RETURN & RETURN &
    "PARAMETERS:" & RETURN &
    "* pixels from top?"
end getBehaviorDescription

on getBehaviorTooltip me
  return
    "Drag a sprite with a hotspot defined. "
end getBehaviorTooltip

on isOKToAttach (me, aSpriteType, aSpriteNum)
  
  tIsOk = 0  
  if aSpriteType = #graphic then  
    tIsOK = 1
  end if
  
  return(tIsOK)  
end on

on getPropertyDescriptionList me
  return
[
#topSpot:
[
  #comment: "How many pixels from top of sprite?",
  #format:  #integer,
  #default:  33
]
]
end getPropertyDescriptionList

on beginSprite me
  pMySpriteRef = sprite(me.spriteNum)
  sprite(pMySpriteRef).moveableSprite = FALSE
end

on mouseDown me

  if ((the mouseH > pMySpriteRef.left) and (the mouseH < pMySpriteRef.right)) and ((the mouseV > pMySpriteRef.top) and (the mouseV < pMySpriteRef.top+topSpot)) then
    sprite(pMySpriteRef).moveableSprite = TRUE
  else
    sprite(pMySpriteRef).moveableSprite = FALSE
  end if
  
end

on getBehaviorTooltip me
  return
    "Drag a sprite with a hotspot defined. "
end getBehaviorTooltip


on isOKToAttach (me, aSpriteType, aSpriteNum)
  
  tIsOk = 0  
  if aSpriteType = #graphic then  
    tIsOK = 1
  end if
  
  return(tIsOK)  
end on


on getPropertyDescriptionList me
  return
[
#topSpot:
[
  #comment: "How many pixels from top of sprite?",
  #format:  #integer,
  #default:  33
]
]
end getPropertyDescriptionList


on beginSprite me
  pMySpriteRef = sprite(me.spriteNum)
  sprite(pMySpriteRef).moveableSprite = FALSE
end

on mouseDown me
  
  if ((the mouseH > pMySpriteRef.left) and (the mouseH < pMySpriteRef.right)) and ((the mouseV > pMySpriteRef.top) and (the mouseV < pMySpriteRef.top+topSpot)) then
    sprite(pMySpriteRef).moveableSprite = TRUE
  else
    sprite(pMySpriteRef).moveableSprite = FALSE
  end if
  
end

 


Contact

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

Send e-mail