Wait Seconds Behavior

Date: Tue, 17 Mar 1998 16:02:30 -0500
From: "Eric S. Coker" 
Subject: Wait Seconds Behavior
When I first learned about behaviors, my gut reaction was that it was something for the newbies. But there's some really cool stuff you can do with them. I just finished an interactive project where there were no scripts attached to graphic cast members. All interaction was handled through behaviors.

I have also created lots of handy behaviors for use in the script channel. I'm including a simple "for instance" below. It does the same thing as a delay in the tempo channel, but it lets you specify any amount of time (including floating point numbers), and it allows animations and interactivity to continue while the delay takes place.



--WAIT
--SECONDS

--Created by Eric S. Coker 

property MySecondsToWait, MyStartTime

on GetPropertyDescriptionList
  set description = [:]
  
  AddProp description, #MySecondsToWait, ¬
          [ #default: 1.0, ¬
            #format:  #float, ¬
            #comment: "Seconds To Wait:" ]
  
  return description
end GetPropertyDescriptionList


on GetBehaviorDescription
  return ¬
"WAIT SECONDS BEHAVIOR:" & RETURN & ¬
"Created by Eric S. Coker " & RETURN & RETURN & ¬
"Waits for a specified amount of time. Loops on a frame rather than pausing
as in Director's tempo channel." & RETURN & RETURN & ¬
"PARAMETERS:" & RETURN & ¬
"* Seconds To Wait - The amount of time to wait as an integer or a floating
number (1.5, 2.25, etc.)." & RETURN
  
end GetBehaviorDescription

on BeginSprite
  set MyStartTime = float(the timer)
end BeginSprite

on ExitFrame me
  if float(the timer) > ¬
   ( float(MyStartTime) + (float(60) * float(MySecondsToWait)) ) then
    go to the frame + 1
  else
    go to the frame
  end if
end ExitFrame