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
Scroll Buttons
EZIO
Pad Number with Zeros
Puzzling!
simODBCPro Xtra
3D games online. Developed with Macromedia Director.
MediaMacros Devcon Presentation 2002 - Imaging Lingo
MAAD FTP Xtra
Set Cast member Properties of a QuickVrMovie
Animate Text Shadow
 

 

 

Behavior Watcher Window Behavior

Added on 3/20/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: AdamKane

Tired of losing all your settings in the watcher window when you restart Director? Drag this behavior onto a text field, enter the values you"d like to watch in the property description dialog, and it"ll act like a watcher window (but the settings persist across sessions).

--WTCHR
--BEHAV

-- For support for the behavior, mail:  papakane@papakane.com
-- p.s. if anyone knows how to kill the flicker, please let me know.

on getBehaviorDescription  
  -- init description string
  txt=""  
  -- build description string  
  txt=txt & "Drag this behavior onto a text field and it'll act like the watcher window"  
  txt=txt & return & return  
  txt=txt & "Please let me know if you have any problems or suggestions. "  
  txt=txt & return & return
  txt=txt & "papakane@papakane.com"  
  -- return description string
  return txt  
end

--
property State
-- Text field sprite
property Spr, Mbr
-- vars to watch
property Vars
-- list of globals we'll need to declare
property Globals
-- timing stuff
property Fps, RefreshTime
-- wrap
property Visible, Wrap
-- todo
-- make watcher handle example: "the actorList"
-----------------------------------------------------------------------
-- GetProps
-----------------------------------------------------------------------
on GetPropertyDescriptionList me
  set props = [:]
  props[#Visible]=[#comment:"Watcher is visible", #format:#boolean, #default:True]
  props[#Vars]=[#comment:"Variables to watch.  Example: gColor, gFlavor, gMode", #format:#string, #default:""]
  props[#fps]=[#comment:"Framerate for watcher window refresh", #format:#float, #range:[#min:0, #max:5], #default:1]
  props[#wrap]=[#comment:"Word wrap field text", #format:#boolean, #default:False]  
  return Props  
end

-----------------------------------------------------------------------
-- BeginSprite
-----------------------------------------------------------------------
on BeginSprite me
  -- Sprite settings
  Spr=sprite(me.spriteNum)
  Spr.moveableSprite=True
  -- visibility
  if Visible then
    Spr.visible=True
  else
    Spr.visible=False
  end if
  -- Bail if there are no variables to watch
  if Vars="" then exit --•
  -- Startup stuff
  me.Init()
  -- Create dynamic script member
  me.CreateField()
  -- Buildscript
  me.BuildScript()
  -- Activate stepframe
  (the actorList).add(me)
end

-----------------------------------------------------------------------
-- Init
-----------------------------------------------------------------------
on Init me
  -- timing stuff
  RefreshTime=the milliseconds
  -- member settings
  Mbr=Spr.member
  Mbr.name="Watcher"
  Mbr.border=1
  Mbr.alignment="left"
  Mbr.boxType=#fixed
  
  Mbr.margin=3
  Mbr.font="verdana"
  Mbr.fontsize=9
  Mbr.text=""
  
  -- set wrap mode
  if Wrap then
    Mbr.wordWrap=True
  else
    Mbr.wordWrap=False
  end if
  
  -- Convert vars string list to its value
  oldDelimiter=the itemDelimiter
  the itemDelimiter=","
  temp=[]
  totalGlobals=the number of items in Vars
  repeat with i=1 to totalGlobals
    thisGlobal=item i of Vars
    thisGlobal=me.trimSpaces(thisGlobal)
    temp.add(thisGlobal)
  end repeat
  Vars=temp
  
end


-----------------------------------------------------------------------
-- CreateField
-----------------------------------------------------------------------
on CreateField me
  
  mbrType=#script
  mbrName="temp"
  cst=1
  
  -- Bail if specified cast member already exists
  if (the number of member mbrName of castLib cst) > 0 then exit
  
  -- otherwise create member
  mbr=new(mbrType, castLib 1)
  mbr.name=mbrName
  
end


-----------------------------------------------------------------------
-- BuildScript
-----------------------------------------------------------------------
on BuildScript me
  
  txt=""
  
  -- declare globals
  globals=[]
  repeat with var in Vars
    if var contains "." then
      oldDelimiter=the itemDelimiter
      the itemDelimiter="."
      var=item 1 of var
      the itemDelimiter=oldDelimiter
    end if
    
    -- hack
    if findPos(globals, var) <= 0 then
      globals.add(var)
      txt=txt & "global " & var & return
    end if
    
  end repeat
  
  member("Watcher").text=""
  -- start script
  txt=txt & "on temp" & return
  txt=txt & me.ParseQuotes("-- Here is a comment line") & return
  
  -- script guts
  repeat with i=1 to Vars.count
    
    thisName=string(getAt(Vars, i))
    thisVal=Vars[i]
    -- " & quote & "
    
    -- txt=txt & me.parseQuotes("put '" & thisName & " = ' & " & thisVal & return)  
    txt=txt & me.parseQuotes("member('Watcher').text=member('Watcher').text &  '" & thisName & " = ' & " & thisVal )  
    txt=txt & " & return" & return
    
  end repeat
  
  -- end script
  txt=txt & "end temp" & return
  
  -- dump to text field
  member("temp").scriptText=txt
  
end


-----------------------------------------------------------------------
-- MouseDown
-----------------------------------------------------------------------
on MouseDown me
  
  -- Pull debug sprite to top
  Spr.locZ=1000
  
end


-----------------------------------------------------------------------
-- StepFrame
-----------------------------------------------------------------------
on StepFrame me
  
  if the milliseconds < RefreshTime then exit
  RefreshTime=the milliseconds + (1000.0/Fps)
  
  member("Watcher").text=""
  temp
  
end


-----------------------------------------------------------------------
-- ExitFrame
-----------------------------------------------------------------------
on ExitFrame me
  go to the frame
end


-----------------------------------------------------------------------
-- StopMovie
-----------------------------------------------------------------------
on StopMovie me
  the actorList=[]
end



on ParseQuotes me, var
  
  oldchar= "'"
  newchar=quote
  
  temp=""
  
  if oldchar.char.count>0 then
    oldchar=oldchar.char[1]
    repeat with i=1 to var.char.count
      if var.char[i]=oldchar then
        temp=temp&newchar
      else
        temp=temp&var.char[i]
      end if
    end repeat
  end if
  
  return temp
end



on trimSpaces me, inString
  set outString = inString
  repeat while char 1 of outString = SPACE
    delete char 1 of outString
  end repeat
  repeat while the last char of outString = SPACE
    delete the last char of outString
  end repeat
  return outString
end

 


Contact

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

Send e-mail