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
Director 8 and Lingo: Inside Macromedia Series
Spell Check Xtra
Lingo MarkUp Service
Internet Explorer 5 - PC
Attr
Fill using setPixel
Set Rotation angle of a Flash Member
Function Key Keycodes
Wait for DirectMedia Xtra Sprite v. 2.0
Get all combinations of a string
 

 

 

Behavior Button Animator on how close cursor is to it

Added on 6/10/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: StuartAcklam (website)

Animates button based on cursor distance.

--Code orgin_by Gerry Orkin (gorkin@coombs.anu.edu.au)
--Modified for my own means_Stuart M Acklam (stuart@idgruppe.de)
--Maths by Beate Fiss.

property distFull        -- distance when the final image is shown
property StartAction     -- distance when the first image change takes place
property NumOfPcts       -- number of images to cycle though                
property wchSprite       -- which sprite me is
property NameOfPct       -- name of the images i.e. "xx" NOT "xx1"
property Ldistance       -- list containing the distances at change points

on beginSprite me
  puppetsprite  the spriteNum of me, 1
  set wchSprite = the spriteNum of me  
  ---- works out the steps for changing the images -----****
  set Ldistance = []
  set distDiv = (StartAction - distFull)/(NumOfPcts-1)
  set distDivB = distFull
  addAt Ldistance, 1, distFull
  repeat with i = 2 to (NumOfPcts-1)
    set distDivB = distDivB + distDiv
    AddAt Ldistance, i, distDivB
  end repeat
  append Ldistance, StartAction
  put Ldistance
  updatestage
end

on exitFrame me -- provides the trigger for the blend updates
  sendSprite  (the spritenum of me, #blendit)
end

on blendSprite which, what -- does the blending :)
  set the blend of sprite which = what
  updatestage
end  

on blendit me
  set dv = abs((the locV of sprite the spriteNum of me) - the mousev)
  set  dH = abs((the locH of sprite the spriteNum of me) - the mouseh)
  set distance = sqrt( dV * dV + dH * dH )
  if distance < getAt(Ldistance, 1) then
    set the MemberNum of sprite wchSprite = member (NameOfPct & "1")
    exit
  else
    set dd = count(Ldistance)-1
    repeat with x = 2 to dd
      if distance < getAt(Ldistance, x) then
        set the MemberNum of sprite wchSprite = member (NameOfPct & x)
        exit
      end if
    end repeat
    if distance > getAt(Ldistance, (count(Ldistance))) then
      set the MemberNum of sprite wchSprite = member (NameOfPct & count(Ldistance))
      exit
    end if
  end if
end

on getPropertyDescriptionList
  set p_list = [¬
            #distFull:     [ #default:20,   #format:#integer, #comment:"distance for final image:",#range: [#min:0,#Max:100]] ,¬
            #StartAction: [ #default:100, #format:#integer, #comment:"Distance when start", #range: [#min:0, #Max:500]],¬
            #NumOfPcts:   [ #default:10,   #format:#integer, #comment:"How Many Pcts", #integer:""],¬
            #NameOfPct:   [ #default:"t",   #format:#string, #comment:"First image:", #string:""]]
  return p_list
end

on getBehaviorDescription
  return  "A little hack, origins = Gerry Orkin (gorkin@coombs.anu.edu.au)" &RETURN& "I just added on to that."&RETURN&"Changes the sprite depending on how close your mouse is to it"&RETURN&"Give the name of your members and how many there are."&RETURN&¬
            "Make sure that you name your members (your name) and the number i.e. image1,image2,etc.."&RETURN&¬
            "The last image must be 1. i.e. image1"
end  

 


Contact

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

Send e-mail