Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
MPEG Xtra Controller Button
Page turn
StringLib
ToolTip Behavior
Saving Global Variables to a File
Text Search Engine
Force Characters
Tony's Quick Script Maker
Flash Sprite -- Simple Controller [Play, Pause, Rewind]
SceneList
MediaMacros Xtras Mall
 

 

 

Behavior Drag & Drop

Added on 6/10/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: GerryOrkin

Drag adn Drop behavior

property TargetSprite -- target sprite for the dragged sprite
property startPos -- starting poition of the dragged sprite

property correctspringBack
--  does the dragged sprite spring back to startpos
--  when released on target? (T/F)

property incorrectspringBack
--  does the dragged sprite spring back to startpos
--  when released off  target? (T/F)

property incorrectvanish

--  does the dragged sprite vanish when released off target? (T/F)

property correctvanish

--  does the dragged sprite vanish when released on target? (T/F)

property IncorrectCommand -- name of the handler to run if sprite dropped on target
property correctCommand -- name of the handler to run if sprite dropped off target

-- end property declaration

on mousedown me
  
  -- get start point of dragged sprite
  set startpos = the loc of sprite (the spritenum of me)
  
  -- move the sprite with the mouse
  repeat while the stilldown = true
    set the loc of sprite (the spritenum of me) = point(the mouseh, the mousev)
    updatestage
  end repeat
  
end

on mouseup me
  -- check to see if the MOUSE is inside the target sprite
  -- when released
  if inside(point(the mouseh, the mousev), the rect of sprite (the targetSprite of me)) then
    
    -- run the handler specified for a correct drop
    do the correctCommand of me
    
    -- if the dragged sprite should vanish then do that
    if the correctvanish of me = 1 then
      -- send the dragged sprite off screen
      set the loc of sprite the spritenum of me = point(1000,1000)
      exit
    end if
    -- sets the dragged sprite back to starting position
    if the correctspringback of me  = 1 then
      set the loc of sprite (the spritenum of me) = startpos
    end if
  else
    -- it was dropped off the target sprite
    
    do the incorrectCommand of me
    -- if the dragged sprite should vanish then do that
    if the incorrectvanish of me = 1 then
      -- send the dragged sprite off screen
      set the loc of sprite the spritenum of me = point(1000,1000)
      exit
    end if
    -- sets the dragged sprite back to starting position
    if the incorrectspringback of me  = 1 then
      set the loc of sprite (the spritenum of me) = startpos
    end if
    
  end if
  
end

on getBehaviorDescription
  return¬
"Creates sprites that can be dropped on any other [user specified] sprite. You can define the target sprite, "&& RETURN &¬
"whether the dragged sprite snaps back to it"s start position, and handlers to run if the drop was on or off target."
  
end


on getPropertyDescriptionList
  
  if voidp(TargetSprite) then set TargetSprite = 1
  
  set p_list = [#TargetSprite: [ #default:TargetSprite,#format:#integer, #comment:"Target Sprite Number", #range:[#min:1,#Max:120]],¬
  #incorrectspringBack:[#default:1,#format:#boolean,#comment:"Spring back when incorrect?"],¬
  #correctspringBack:[#default:0,#format:#boolean,#comment:"Spring back when correct?"],¬
  #incorrectvanish:[#default:0,#format:#boolean,#comment:"Vanish when dropped off the target?"],¬
  #correctvanish:[#default:1,#format:#boolean,#comment:"Vanish when dropped on the target?"],¬
#correctCommand:[#format:#string,#comment:"The handler to run if dropped off the target",#default:"beep" ],¬
#IncorrectCommand:[#format:#string,#comment:"The handler to run if dropped on the target",#default:"beep 2" ]]
  return p_list  
end

 


Upload Provided by ABCUpload ASP

Contact

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

Fax - (206) 339-5833

Send e-mail