Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Irregular MIAW
FilmLoop Controller
Mosaic-Alphamania
Back Button - All In One
Generic behavior to create a Shortcut
Flip Image Algorithm - Imaging Lingo
Change ShapeType of a Shape cast member
Rolling a Ball.
DmmXLS Excel XTRA
Importing bitmaps without loosing white space
MediaMacros Xtras Mall
 

 

 

Behavior Sprite Stick To Mouse Cursor

Added on 9/8/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: KurtKoenig (website)

Make a sprite dragable using Lingo with an option to constrain to a rectangular shape

Download PC Source    Download Mac Source
--Make a sprite dragable using Lingo
--with an option to constrain to a rectangular shape.
--
--    Kurt Koenig * Belgium                 Useable in Director --> 7 and 8
--
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

property pStick, pStickNow, pWhenDown, pConstrain, pConstrainRect

on getPropertyDescriptionList me
  desclist = [:]
  
  addProp desclist, #pStickNow, [#comment: "Do you want the sprite to¬
  stick to the mouse cursor after being clicked?", #format: #Boolean, #default:FALSE]
  addProp desclist, #pWhenDown, [#comment: "Or do you want the sprite¬
  to stick, only when the mouse is down ?", #format: #Boolean, #default:FALSE]
  addProp desclist, #pConstrain, [#comment: "Enable if you want to constrain this spite¬
  to another(rectShape) sprite", #format: #Boolean, #default:FALSE]
  addProp desclist, #pConstrainRect, [#comment: "The number of the sprite that¬
  contains the rectangle shape castmember", #format: #integer, #default:""]
  
  return desclist
  
end getPropertyDescriptionList


on getBehaviorDescription me
  return "Put this behavior on a sprite to make it stick to the"&return&"¬
cursor while the mousedown, or after being clicked."&return&"¬
an option is included to constrain this sprite to"&return&"¬
a shape sprite"&return&&return&"¬
Kurt Koenig * Belgium"
  
end getBehaviorDescription


on getBehaviorTooltip me
  return "¬
Put this behavior on a sprite to make it stick to the"&return&"¬
cursor while the mousedown, or after being clicked."
end getBehaviorTooltip


on beginsprite me
  pStick = 0
  if pConstrain then
    sprite(me.spritenum).constraint = pConstrainRect
  end if
end beginsprite

on mouseup me
  if pStickNow then
    pDifference =  sprite(me.spritenum).loc - the clickloc
    if pStick = 1 then
      pStick = not pStickNow
    else
      pStick = 1
    end if
  end if
  if pStick then
    repeat while the mouseup
      sprite(me.spritenum).loc = the mouseloc + pDifference
      updatestage
    end repeat
  end if
end mouseup

on mouseupoutside me
  if pStickNow then
    pDifference =  sprite(me.spritenum).loc - the clickloc
    if pStick = 1 then
      pStick = not pStickNow
    else
      pStick = 1
    end if
  end if
  if pStick then
    repeat while the mouseup
      sprite(me.spritenum).loc = the mouseloc + pDifference
      updatestage
    end repeat
  end if
end mouseup

on mousedown me
  if pWhenDown then
    pDifference =  sprite(me.spritenum).loc - the clickloc
    repeat while the mousedown
      sprite(me.spritenum).loc = the mouseloc + pDifference
      updatestage
    end repeat
  end if
end mousedown

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail