Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Wind-Xtra
Effector Set 1 Behavior Support
DirectTransition Xtra
Toggle Static Property of a Flash sprite
myWallpaper
SpellCatcher
Simple slide show
PrimeBase Xtra
ADisplay
ADOxtra for Shockwave Multiuser Server
MediaMacros Xtras Mall
 

 

 

Behavior Sprite Drag - Confine to stage

Added on 10/14/1999

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

Rating:

Author: MediaMacros (website)

This behavior allows you to drag a sprite around the stage but confine it to the stage boundries.

--Copyright 1999 Chuck Neal
--chuck@mediamacros.com
--If you find this code helpful, send me an e-mail and let me know.  :-)

property spriteNum, clickOffset

on mouseDown me
  clickOffset = sprite(spriteNum).loc - the mouseLoc
  stageWidth = the stageRight- the stageLeft
  stageHeight = the stageBottom - the stageTop
  leftAdjust = sprite(spriteNum).locH - sprite(spriteNum).left
  rightAdjust = sprite(spriteNum).locH - sprite(spriteNum).right
  topAdjust = sprite(spriteNum).locV - sprite(spriteNum).top
  bottomAdjust = sprite(spriteNum).locV - sprite(spriteNum).bottom
  repeat while the stillDown
    newLoc = the mouseLoc + clickOffset
    if newLoc.locH > stageWidth + rightAdjust then
      newLoc.locH = stageWidth + rightAdjust
    else if newLoc.locH < 0 + leftAdjust then
      newLoc.locH = 0 + leftAdjust
    end if
    if newLoc.locV > stageHeight + bottomAdjust then
      newLoc.locv = stageHeight + bottomAdjust
    else if newLoc.locV < 0 + topAdjust then
      newLoc.locV = 0 + topAdjust
    end if
    sprite(spriteNum).loc = newLoc
    updateStage
  end repeat
end

on getBehaviorDescription me
  return "Drop this on a sprite to make it draggable but constrained to the limites of the stage."
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