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
Bevel Follow Mouse or Sprite-Alphamania
To activate previous instance and quit
Light Up Game Controller
Director and online database interaction
Importing Externally Linked Flash members
Simple Character Substitution
Custom Check and Radio Buttons
Emboss trick
import and play sound file (during runtime)
Can't change field value - Valentina
 

 

 

Behavior UpDown Timer

Added on 6/7/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: PatMcClellan

NOTE: you may want to add a startMovie or endMovie handler which clears the actorList.

property pstartMin
property pstartSec
property pCountUp -- time up (1) or count down (0) (default is down)
property pStopTime -- a switch for the timer
property pSecNow
property pMinNow


on getPropertyDescriptionList
  set p_list = [
  #pCountUp: [ #comment: "Click for count UP:",
  #format: #boolean,
  #default:  0 ],
  #pStartMin: [ #comment: "Starting Minutes:",
  #format: #integer,
  #default:  0 ,
  #range: [min:0,max:59]],
  #pStartSec: [ #comment: "Starting Seconds:",
  #format: #integer,
  #default:  0,
  #range: [min:0,max:59]]
  ]
  return p_list
end

on beginSprite me
  set pStopTime = FALSE
  add the actorList, me
  if NOT pCountUp then
    set pStartMin = pStartMin - 1
    set pStartSec = pStartSec + 60
  end if
  startTimer
end

on stepFrame me
  if NOT pStopTime then
    if pCountUp then
      countUp me
    else
      countDown me
    end if
  end if
end

on countUp me
  set secondsElapsed = the timer/60
  set pSecNow = secondsElapsed mod 60
  set pMinNow = the timer/3600
  displayTime me
end

on countDown me
  set secondsElapsed = the timer/60
  set pSecNow = pStartSec - (secondsElapsed mod 60)
  set pMinNow = pStartMin - (the timer/3600)
  if pSecNow > 60 then
    set pMinNow = pMinNow + 1
    set pSecNow = pSecNow - 60
  end if
  displayTime me
  if pMinNow = 0 and pSecNow = 0 then
    set pStopTime = TRUE
  end if
end

on displayTime me
  if pSecNow = 60 then
    put pMinNow + 1 & ":00" into showTime
  else if pSecNow < 10 then
    put pMinNow & ":0" & pSecNow into showTime
  else
    put pMinNow & ":" & pSecNow into showTime
  end if
  put showTime into field "timer"
end

 


Contact

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

Send e-mail