--Make a sprite dragable using Lingo
--with an option to constrain to a rectangular shape.
--
-- Kurt Koenig * Belgium Useable in Director --> 7 and 8
--
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
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
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA