Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Advanced Installer Professional
Sending a e-mail with attachment using CDO and VbScriptXtra
MP3 Player
BorderPatch
Minimizer
VarLord
Nero
ZGTSB-Bitmap Slider Scroll
De-Xplode that text random
Check For Asset
MediaMacros Xtras Mall
 

 

 

Behavior Drag and Droop

Added on 2/6/2001

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: usertron

Put this behaivour on the sprite you want to drag, and on the sprite you want it to snap to. You specify the distance it snaps from in pixels.

-- drag and droop behaivour v1.0 © 2001 Patrick Hammond, use this at your leasure, if you have any bugs or comments
-- or improvements (regarding this behaivour) you can send me an electronic message at usertron@ihug.co.nz

global gSnapped
property spritenum, pDropRange, pMagnetic, pOriginalLoc


on mouseUp me -- you have dropped the sprite
  gSnapped = 0 -- this is a global flag, set to 1 if the dragged sprite is SNAPPED!
  x = sprite(spritenum).loch -- horizontal dropzone
  y = sprite(spritenum).locv -- vertical dropzone
  sendAllSprites (#areYouNear, x, y, spritenum, pDropRange, pOriginalLoc) -- check to see if anyone is near
  if gSnapped = 0 then sprite(spriteNum).loc = pOriginalLoc -- if no-one is, put me back!
end

on mouseDown me
  pOriginalLoc = sprite(SpriteNum).loc -- record the original position
end

on areYouNear me ,x, y, spriteNumber, SnapRange, SendBack
  
  if spriteNumber = spritenum then exit -- to avoid dropping it on my own head!!
  
  if abs(sprite(spriteNum).loch - x) < SnapRange and abs(sprite(spriteNum).locv - y) < SnapRange  then -- if i am near someone
    if pMagnetic = 1 then -- check to see if they are sticky!
      sprite(spritenumber).loc = sprite(spritenum).loc -- if they are, stick me to their loc
      gSnapped = 1 -- and set the snapped flag
    end if
  end if
  
end

on getBehaviorDescription me
  return("Put this behaivour on the sprite you want to drag, and on the sprite you want it to snap to."&& RETURN &¬
"You specify the distance it snaps from, and to define a sprite "snappable" use magnetic = true")
end

on getPropertyDescriptionList me
  vPDList = [:]
  setaProp vPDList, #pDropRange, [#comment: "Snap Range (pixels)",
    #format: #integer, #default: 30,
    #range: [#min: 0, #max: 100]]
  setaProp vPDList, #pMagnetic, [#comment: "Magnetic?",
    #format: #boolean, #default: 1]
  return vPDList
end getPropertyDescriptionList

 


Upload Provided by ABCUpload ASP

Contact

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

Fax - (206) 339-5833

Send e-mail