Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
More encryption
3D Groove
Lingo and Shockwave Sourcebook
WinGroup Xtra
Lingofish
Generic behavior to check Windows Platform
DriveInfo
Check QuickTime Version
Hangman
Set DirectToStage Property of a Flash Sprite
 

 

 

Behavior Interactive Flash File Behavior

Added on 6/30/1999

 

Compatibilities:
behavior D6_5 D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: GeoffHoffman

Flash Drag Behavior

--=========================================--
--           by geoffrey hoffman           --
--=========================================--

-- Flash Drag Behavior
global keyPress
property action, startHPoint, startVpoint, startPt, startScale, startRot
property memRef, button_active

on mouseDown me
  -- capture the currently clicked flash member
  set the memRef of me = member(the memberNum of sprite (the spriteNum of me))
  -- capture the loc of the currently clicked flash member
  set the startPt of me = the loc of sprite (the spriteNum of me)
  -- capture the mouseH origin
  set the startHPoint of me = the mouseH
  -- capture the mouseV of origin
  set the startVpoint of me = the mouseV
  -- capture the origin scale
  set the startScale of me = the scale of member (the memRef of me)
  -- capture the origin rotation
  set the startRot of me = the rotation of member (the memRef of me)

  case (keyPress) of
    "S","s": set the action of me = 1 -- scale
    "R","r": set the action of me = 2 -- rotate
    "P","p": set the action of me = 3 -- position
    otherwise
      set the action of me = 0 -- no key
      alert "Press the S, R, or P key to Scale, Rotate, or Position the item, respectively. Then click & drag."
  end case

  repeat while the stillDown

    case (the action of me) of
      1:   --- scale handling

        set delta = the mouseH - the startHPoint of me

        -- sizeCheck
        if (the scale of member (the memRef of me) > 5) AND (the scale of member (the memRef of me) < 2400) then
          set the scale of member (the memRef of me) = the startScale of me + (0.01*delta)
        else
          set the scale of member (the memRef of me) = 5
        end if -- sizeCheck

        -- deal with shrinking and enlarging the bounding box (a.k.a. defaultRect)
        set LF = the left of the defaultRect of member (the memref of me)
        set TP = the top of the defaultRect of member (the memref of me)
        set RT = the right of the defaultRect of member (the memref of me)
        set BM = the bottom of the defaultRect of member (the memRef of me)

        set LF = LF-(.2*delta)
        set TP = TP-(.2*delta)
        set RT = RT+(.2*delta)
        set BM = BM+(.2*delta)

        -- bbox check
        if (the width of the defaultRect of member(the memRef of me) >= 10) AND (the width of the defaultRect of member(the memRef of me) <= 4800) then

          set the defaultRect of member(the memRef of me) = rect(LF,TP,RT,BM)
        else
          set the defaultRect of member (the memRef of me) = rect(0,0,10,10)

        end if -- bbox check

      2:   --- rotate handling
        set delta = the mouseH - the startHPoint of me
        set the rotation of member (the memRef of me) = integer(the startRot of me + (0.5*delta))

      3:  --- position handling
        set deltaH = (the mouseH - the startHPoint of me)
        set deltaV = (the mouseV - the startVPoint of me)
        set the loc of sprite (the spriteNum of me) = the startPt of me + point(deltaH, deltaV)

    end case

    updateStage

  end repeat

  set the button_active of me = TRUE
end

on mouseUp me
    set the startPt of me = the loc of sprite (the spriteNum of me)
    set the startRot of me = the regPoint of member (the memRef of me)
    set the startScale of me = the scale of member (the memRef of me)
    set the button_active of me = false
end

---

on beginSprite me
  set the button_active of me = false
  -- puppetSprite the spriteNum of me, TRUE
end

on endSprite me
  -- puppetSprite the spriteNum of me, FALSE
end

on getPropertyDescriptionList
  if the currentspritenum = 0 then
    set memdefault = 0
  else
    set memref = the member of sprite the currentspritenum
    set castlibnum = the castlibnum of memref
  end if

  set p_list = [ #memref: [ #comment: "Use member:",     #format: #flash,     #default:   memRef]     ]
  return p_list
end

on getBehaviorDescription
  return "Makes a flash sprite interactivly editable. Hold 'S' to scale, 'R' to rotate, and 'P' to position the flash content. Then click and drag."
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail