Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
BehaviorChecker
Complete Idiots Guide to Macromedia Flash 5
DirectInteraction Xtra
tea Xtra
MUSTARD
Echo Vibes
Drop File
Rotate-a-Sprite
Sound Play/Stop
Rollover Fader-Alphamania
MediaMacros Xtras Mall
 

 

 

Behavior Digital Video Button Control

Added on 7/9/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: ScottMarion

Digital Video Button Control Use on graphic sprites for Rewind, Pause, Play, Play/Pause (toggle), FastForward, and FastReverse digital video button controls Use in conjunction with the "Button With Rollover Effect" behavior Can also be used with the Cycle_Graphics behavior (just as the "Button With Rollover Effect" behavior can)

-- Digital Video Button Control
-- Use on graphic sprites for Rewind, Pause, Play, Play/Pause (toggle), FastForward, and FastReverse digital video button controls
-- Use in conjunction with the 'Button With Rollover Effect' behavior
-- Can also be used with the Cycle_Graphics behavior (just as the 'Button With Rollover Effect' behavior can)

on getBehaviorDescription me
  return "DIGITAL VIDEO BUTTON CONTROL"&RETURN&RETURN&"Make the sprite act like a digital video button control."&RETURN&RETURN&"PARAMETERS:"&RETURN&"* Digital Video Sprite"&RETURN&"* Video Control Type (#rewind, #pause, #play, #playpause, #fastforward, #fastreverse)"
end


on getBehaviorTooltip me
  return "Use with graphic sprites."&RETURN&RETURN&"Make the sprite act like a digital video button control."&RETURN&RETURN&"Use in conjunction with the 'Button With Rollover Effect' behavior."&RETURN&RETURN&"Use this behavior on a button to control a digital video"&RETURN"The button can be a Rewind, Pause, Play, Play/Pause (toggle), Scan FFW, or ScanRW control"
end getBehaviorTooltip



-- HISTORY --

-- May, 2000 by Scott Marion, Pinnacle Interactive

property spritenum
property pSprite             -- reference to my sprite
property pMovieRate          -- current movie rate
property cyclegraphics       -- am I currently cycling graphics
property pActive             -- activity flag
property pScanRate           -- rate to scan FFW and FRW
property pPlayPause          -- used as a boolean toggle when control type is #playpause
-------------------------------   (play=true, pause=false)


-- user defined properties

property pVideoSprite        -- sprite number of the digital video
property pControlType        -- type of video control of this instance of the behavior
--    (valid values : #rewind, #pause, #play, #playpause, #fastforward, #fastreverse)

on beginSprite me
  pSprite = sprite(me.spriteNum)
  
  pMovieRate = 1  -- initalize to normal speed
  
  if pControlType = #playpause then
    pPlayPause =  not the pausedAtStart of member (sprite(pVideoSprite).member)
  end if
  
  pActive = false
  
end


on prepareFrame me
  
  mUpdateMe me
  
end


on mUpdateMe me
  
  
  case (pControlType) of
      
    #play:
      if sprite(pVideoSprite).movieRate = 0 then
        
        -- call cycleGraphics to turn off the play button
        sendSprite((the spritenum of me), #CycleGraphics_ToggleLoop, false)
        
      else
        
        -- see if the play button is currently cycling
        -- if it is, we can ignore doing the cycle_graphics call
        
        if not the cyclegraphics of me then
          
          -- tell all other video controls to turn themselves off
          sendAllSprites(#allVideoControlsTurnOff, me)
          
          -- call cycleGraphics to turn on the play button
          sendSprite((the spritenum of me), #CycleGraphics_ToggleLoop, true)
        end if
        
      end if
      
      
    #pause:
      
      if sprite(pVideoSprite).movieRate <> 0 then
        
        -- call cycleGraphics to turn off the pause button
        sendSprite((the spritenum of me), #CycleGraphics_ToggleLoop, false)
        
      else
        
        -- see if the pause button is currently cycling
        -- if it is, we can ignore doing the cycle_graphics call
        
        if not the cyclegraphics of me then
          
          -- tell all other video controls to turn themselves off
          sendAllSprites(#allVideoControlsTurnOff, me)
          
          -- call cycleGraphics to turn on the pause button
          sendSprite((the spritenum of me), #CycleGraphics_ToggleLoop, true)
        end if
        
      end if
      
      
    #playpause:
      
      
      
    #fastforward:
      if pActive then
        
        if the mouseDown then
          
          vTime = sprite(pVideoSprite).movieTime + pScanRate
          if vTime > sprite(pVideoSprite).duration then
            vTime = sprite(pVideoSprite).duration
          end if
          sprite(pVideoSprite).movieTime = vTime
          
        else
          sprite(pVideoSprite).movieRate = pMovieRate
          pActive = false
          pScanRate = 0
          
        end if
        
      end if
      
    #fastreverse:
      if pActive then
        
        if the mouseDown then
          
          vTime = sprite(pVideoSprite).movieTime - pScanRate
          if vTime < 0 then
            vTime = 0
          end if
          sprite(pVideoSprite).movieTime = vTime
          
        else
          sprite(pVideoSprite).movieRate = pMovieRate
          pActive = false
          pScanRate = 0
          
        end if
        
      end if
      
  end case
  
end


on mouseDown me
  
  if the blend of sprite pSprite = 100 and not the cyclegraphics of me then
    
    case (pControlType) of
        
      #rewind:
        pActive = true
        
        
      #pause:
        pActive = true
        
        
      #play:
        pActive = true
        
        
      #playpause:
        pActive = true
        
        
      #fastforward:
        -- scan fast forward
        pMovieRate = sprite(pVideoSprite).movieRate
        sprite(pVideoSprite).movieRate = 0
        pScanRate = 60
        vTime = sprite(pVideoSprite).movieTime + pScanRate
        if vTime > sprite(pVideoSprite).duration then
          vTime = sprite(pVideoSprite).duration
        end if
        sprite(pVideoSprite).movieTime = vTime
        pActive = true
        
      #fastreverse:
        -- scan fast reverse
        pMovieRate = sprite(pVideoSprite).movieRate
        sprite(pVideoSprite).movieRate = 0
        pScanRate = 60
        vTime = sprite(pVideoSprite).movieTime - pScanRate
        if vTime < 0 then
          vTime = 0
        end if
        sprite(pVideoSprite).movieTime = vTime
        pActive = true
        
        
    end case
    
  end if
  
  pass
  
end


on mouseUp me
  
  if the blend of sprite pSprite = 100 and not the cyclegraphics of me then
    if pActive then
      
      case (pControlType) of
          
        #rewind:
          sprite(pVideoSprite).movieTime = 0
          pActive = false
          
        #pause:
          pMovieRate = sprite(pVideoSprite).movieRate
          sprite(pVideoSprite).movieRate = 0
          pActive = false
          
        #play:
          sprite(pVideoSprite).movieRate = pMovieRate
          pActive = false
          
        #playpause:
          pPlayPause = not pPlayPause
          if pPlayPause then
            -- play
            sprite(pVideoSprite).movieRate = pMovieRate
          else
            -- pause
            pMovieRate = sprite(pVideoSprite).movieRate
            sprite(pVideoSprite).movieRate = 0
          end if
          pActive = false
          
        #fastforward:
          sprite(pVideoSprite).movieRate = pMovieRate
          pActive = false
          pScanRate = 0
          
        #fastreverse:
          sprite(pVideoSprite).movieRate = pMovieRate
          pActive = false
          pScanRate = 0
          
      end case
      
    end if
    
  end if
  
end mouseUp


on mouseUpOutside
  
  if pActive then
    case (pControlType) of
      #fastforward, #fastreverse:
        pScanRate = 0
        pActive = false
      otherwise:
        pActive = false
    end case
  end if
  
end


on mouseEnter
  
  if pActive then
    case (pControlType) of
      #fastforward, #fastreverse:
        pScanRate = 60
    end case
  end if
  
end


on mouseLeave
  
  if pActive then
    case (pControlType) of
      #fastforward, #fastreverse:
        pScanRate = 0
    end case
  end if
  
end

-- user defined handlers

--on pi_ButtonMouseDownInitiated me, initiatingSprite
--  
--  -- another button on this frame has initaited a mouseDown event
--  -- set anotherButtonActive property to true
--  -- ignore mouse events until the current mouse activity is complete
--  
--  if initiatingSprite <> me.spritenum then
--    set the pAnotherButtonActive of me = true
--  end if
--  
--end
--
--
--on pi_ButtonMouseDownComplete me
--  
--  -- another button on this frame has completed a mouseDown event
--  -- set anotherButtonActive property to false
--  -- begin accepting mouse events again
--  set the pAnotherButtonActive of me = false
--  
--end
--

on allVideoControlsTurnOff me, who
  
  if who <> me then
    sendSprite((the spritenum of me), #CycleGraphics_ToggleLoop, false)
    if not pActive then sendSprite((the spritenum of me), #resetMe)
  end if
  
  
end


on CycleGraphics_ToggleLoop me, trueOrFalse
  
  -- this method is for using this behavior along with the CycleGraphics behavior
  -- if this sprite is currently cycling graphics (such as a flashing button)
  -- then the cyclegraphics property is set to true so that the behavior won't interfere
  -- with the flashing of the sprite
  
  if voidP (trueOrFalse) then
    cyclegraphics = not cyclegraphics
  else if ilk (trueOrFalse) <> #integer then
    -- Error check
    return #invalidTypeError
  else
    cyclegraphics = trueOrFalse
  end if
  
end


on getPropertyDescriptionList
  if the currentSpriteNum = 0 then exit
  
  return [  #pVideoSprite:  [ #comment: "Digital Video Sprite?", #format:  #integer, #default:  1 ], #pControlType: [#comment: "Control Type?", #format:  #symbol, #range:  [#rewind, #pause, #play, #playpause, #fastforward, #fastreverse], #default:  #rewind]]
end getPropertyDescriptionList

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail