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
Hold for X seconds if no input is given
cXtraDialogs
Drop File
Frogger by J.R.D.R.
Making Multiple Animated Buttons
MailTo Xtra
Preload Frames
simODBC Xtra
Buddy Saver
Xtrema - Unicode String Class [ public beta ]
 

 

 

Behavior Control Buttons for DirectMedia Sprite

Added on 6/12/2000

 

Compatibilities:
behavior D7 D8 PC

This item has not yet been rated

Author: KumarK

Control Buttons for DirectMedia Sprite

---- written for Director 8 ---
---- Kumar.K kumark@icode.com ----
------ Custom Properties ------
property  DirectmediaSprite,MyAction,WhereTo,thedirectmediaspritelist,StandardImage,RolloverImage,ClickedImage,firstparam,Secondparam,thirdparam
property spritenum

---- Get Behaviour Description List ------
on getBehaviorDescription me
  return \
  "This Behavior will control a DirectMedia Sprite " & RETURN & RETURN & \
  "Parameters." & RETURN & \
  "*  DirectMedia Sprite" & RETURN & \
  "*  Action Like[Play,Pause,rewind] etc" & RETURN & \
  "*  First Parameter: if the Action is Seek than this parameter contains the seek to time (in milliseconds). For the PlaySegment action this parameter contains the starting time of the segment to play (in milliseconds)"& RETURN &"*  Second Parameter: Used with the PlaySegment action. Contains the ending time of the segment to play (in milliseconds)" & RETURN & \
" * Third Parameter :Used With StepBackword/StepForward contains with how many frames it should step" & RETURN & \
  "*  Where To Assign this Script"
end getBehaviorDescription
---- Get Behaviour Description List ------

------ Get Behavior Description List ------
on getPropertyDescriptionList me
  set description = [:]
  thedirectmediaspritelist=searchDirectmediaSprites(me)
  actionlist=["Play","Pause","Rewind","Seek","PlaySegment","StepBackward","StepForward"]
  if the currentspritenum = 0 then
    set memdefault = 0
  else
    set memref = the member of sprite the currentspritenum
    set memdefault = member (the membernum of member memref + 1)
    set memdefault2 = member (the membernum of member memref + 2)
  end if
  if thedirectmediaspritelist.count() > 0 then
    SetaProp description, #DirectmediaSprite, [#comment:"Directmedia Sprite",#format:#integer,\
    #range: thedirectmediaspritelist,#default: thedirectmediaspritelist[1]]
  else
    SetaProp description, #DirectmediaSprite, [#comment:"Wait for Which Directmedia Sprite",#format:#integer,\
    #default: 1]
  end if
  SetaProp description, #MyAction, [#comment: "Action :", #format:#String, #range:actionlist,#default:actionlist[1]]  
  SetaProp description, #firstparam, [#comment: "First Parameter(Use With Seek or PlaySegment) :", #format:#Integer,#default:"enter value in miliseconds"]    
  SetaProp description, #Secondparam, [#comment: "Second Parameter(Use With PlaySegment) :", #format:#Integer,#default:"enter value in miliseconds"]
  SetaProp description, #thirdparam, [#comment: "Step with How many Frames(Use With StepForward/StepBackward) :",format:#Integer,\
  #range:[#min:1,#max:500],#default:50]        
  SetaProp description, #RolloverImage, [#comment: "Rollover Image :",format:#Graphic,#default:memdefault]  
  SetaProp description, #ClickedImage, [#comment: "Clicked Image :",format:#Graphic,#default:memdefault2]  
  if the currentspritenum = 0 then
    SetaProp description, #WhereTo, [#comment: "Where To Attach" ,#format:#String, \
    #range:["On EnterFrame","On ExitFrame"],#default:"On EnterFrame"]
  else
    SetaProp 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 getPropertyDescriptionList
------ Get Behavior Description List ------

---- Can be attached both frame script and sprite script ------
on isOKToAttach (me, aSpriteType, aSpriteNum)
  case aSpriteType of
    #script:
      return true
    #graphic:
      return true      
  end case
end isOKToAttach
---- Can be attached both frame script and sprite script ------

------ Search for DirectMedia Member on the Stage ------
on searchDirectmediaSprites me
  set thedirectmediaspritelist = []
  repeat with i=1 to the lastchannel
    if sprite(i).member.type = #TBDIRECTMEDIA then
      thedirectmediaspritelist.append(i)
    end if
  end repeat
  return thedirectmediaspritelist
end
------ Search for DirectMedia Member on the Stage ------

-- Events --
on beginsprite me
  set standardImage  = the member of sprite the spriteNum of me
end

on EnterFrame me
  if WhereTo = "On EnterFrame" then
    controlit
  end if
end EnterFrame

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

on MouseUp
  set the member of sprite spritenum = StandardImage
  if WhereTo = "On MouseUp" then
    controlit
  end if
end MouseUp

on MouseDown
  set the member of sprite spritenum = ClickedImage  
  if WhereTo = "On MouseDown" then
    controlit
  end if
end MouseDown

on MouseEnter
  set the member of sprite spritenum = RolloverImage
  if WhereTo = "On MouseEnter" then
    controlit
  end if
end MouseEnter

on MouseLeave
  set the member of sprite spritenum = StandardImage  
  if WhereTo = "On MouseLeave" then
    controlit
  end if
end MouseLeave
-- Events --

--- Control DirectMedia Sprite --
on controlit
  if member (sprite(DirectmediaSprite).member).type = #TBDIRECTMEDIA then
    case MyAction of:
      "Play": videoplay(sprite DirectmediaSprite)
      "Pause": videopause(sprite DirectmediaSprite)
      "Rewind": videoseek(sprite DirectmediaSprite, the segmentstart of sprite DirectmediaSprite)
        videoplay(sprite DirectmediaSprite)
      "Seek":videoseek(sprite DirectmediaSprite, firstparam)
        videoplay(sprite DirectmediaSprite)
      "PlaySegment":videoplaysegment(sprite DirectmediaSprite, firstparam, secondparam)
      "StepForward":videopause(sprite DirectmediaSprite)
        videoseek(sprite DirectmediaSprite, the currenttime of sprite DirectmediaSprite + thirdparam)
        videoplay(sprite DirectmediaSprite)
      "StepBackward":videopause(sprite DirectmediaSprite)
        videoseek(sprite DirectmediaSprite, the currenttime of sprite DirectmediaSprite - thirdparam)              
      videoplay(sprite DirectmediaSprite)
    end case    
  end if
end
--- Control DirectMedia Sprite --

 


Contact

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

Send e-mail