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
Set ViewScale Property of a Flash Member
Digital Video
Catpure Source Read And Save ASF File
Object Browser
Compound Interest
Dir Player
Royalty free Music and Loops
Toggle Static Property of a Flash sprite
Shockwave Stand Alone Installer
Distance Sensitive Button
 

 

 

Behavior Set the location of Sprite

Added on 6/6/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: KumarK

Sets the loc of a sprite

---- written for Director 8 ---
---- Kumar.K ----
---- kumark@icode.com ----
------ Custom Properties ------

property WhichSprite,HPos,Vpos,WhereTo

-- Get Behavior Parameters --
on getPropertyDescriptionList
  set description = [:]
  addProp description, #WhichSprite, [#format:#Integer, #comment: "Which Sprite ?", #default:1,
  #range:[#Min:1,#Max:the lastchannel]]
  addProp description, #HPos, [#format:#Integer, #comment: "Set the Horizontal Position of Sprite to :", #range:[#Min:1,#Max:800],#default:100]
  addProp description, #VPos, [#format:#Integer, #comment: "Set the Vertical Position of Sprite to :", #range:[#Min:1,#Max:600],#default:100]
  if the currentspritenum = 0 then
    addProp description, #WhereTo, [#comment: "Where To Attach ?" ,#format:#String, #range:["On EnterFrame","On ExitFrame"],#default:"On EnterFrame"]
  else
    addProp description, #WhereTo, [#comment: "Where To Attach ?" ,#format:#String, #range:["On MouseUp","On MouseDown","On MouseEnter","On MouseLeave"],#default:"On MouseUp"]    
  end if      
  return description
end

-- Can be attached to both Sprite and Frame Scripts --
on isOKToAttach (me, aSpriteType, aSpriteNum)
  case aSpriteType of
    #graphic:
      return True
    #script:
      return True
  end case
end isOKToAttach

-- Get Behavior description --
on getBehaviorDescription
  return "This Behavior Controls Location of  Sprite." & RETURN & RETURN &
  "Parameters" & RETURN &
  "*Sprite Number." & RETURN &
  "* Horizontal position." & RETURN &
  "* Vertical position." & RETURN &
  "* Where to attach this Script"
end

-- Events --
on EnterFrame me
  if WhereTo = "On EnterFrame" then
    controlLoc
  end if
end EnterFrame

on ExitFrame me
  if WhereTo = "On EnterFrame" then
    controlLoc
  end if
end ExitFrame

on MouseUp
  if WhereTo = "On MouseUp" then
    controlLoc
  end if
end MouseUp

on MouseDown
  if WhereTo = "On MouseDown" then
    controlLoc
  end if
end MouseDown

on MouseEnter
  if WhereTo = "On MouseEnter" then
    controlLoc
  end if
end MouseEnter

on MouseLeave
  if WhereTo = "On MouseLeave" then
    controlLoc
  end if
end MouseLeave

-- Custom Handler to Control Location of a Sprite --
on controlLoc
  sprite(WhichSprite).loc=point(Hpos,Vpos)
  updatestage
end
-- Custom Handler to Control Location of a Sprite --

 


Contact

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

Send e-mail