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
zWinVer Xtra
Resolution Xtra 2.0
VideoCodecCheck
Billenium Transitions Xtra v1.1
3D Watcher
Windows NT and Audio
Generic Countdown Timer
List Maker
Using Acrobat on a CD
Color Dialog behavior
 

 

 

Behavior Field Slinky

Added on 6/7/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: PatrickMcClellan

1) Enter your text & gotoNetPage parameters in a Field Member (not a TEXT member) 2) Attach the FieldSlinky Behavior to the Sprite. 3: Add the startMovie & stopMovie instructions to your startMovie & stopMovie scripts. on startMovie sendAllSprites (#prepList) end startMovie on stopMovie sendAllSprites (#restoreText) end stopMovie 4) Create a field member named "format". Type "new link", type RETURN, type "visited link". Select line 1 and assign it the color in which you want new links to appear. Select line 2 and assign it the color in which you want visited links to appear. This field MUST be named "format". NOTE: On startMovie, this behavior changes the text you have input into the field. On stopMovie, the text is restored. However, I recommend making a backup copy of the text field BEFORE running this behavior

property whichLine, dataList, dataString, lastLine, lineList, topItem, formatList, linkColor, XlinkColor

on mouseDown me
  set the topItem of me = the scrollTop of member the member of sprite the spriteNum of me
end mouseDown

on mouseUp me
  set selectedLine = getAProp (the lineList of me,the mouseLine)
  if not voidP(selectedLine) then
    set thisLineList = getAProp (the dataList of me, selectedLine)
    set thisLineLevel = getAProp (thisLineList, #level)
    --  if thisLineLevel = 1 then
    if getAProp(thisLineList,#selected) = 0 then
      setAProp (thisLineList,#selected,1)
      setaProp(the dataList of me, selectedLine,thisLineList)
    else
      setAProp (thisLineList,#selected,0)
      setaProp(the dataList of me, selectedLine,thisLineList)
      --    end if
    end if
    put getAProp(thisLineList,#function) into myFunction
    put getAProp(thisLineList,#argument) into myArgument
    if myFunction<> "nothing" then
      if myArgument <> "nothing" then
        put myFunction & "," & myArgument into myAction
      else
        put myFunction into myAction
      end if
      do myAction
      setAProp (thisLineList, #link, 2)
      setAProp (the dataList of me,selectedLine,thisLineList)
    end if
    slinkyWrite me
    if the height of member the member of sprite the spriteNum of me > the height of sprite the spriteNum of me then
      set the scrollTop of member the member of sprite the spriteNum of me to the topItem of me
    end if
  end if
end

on prepList me
  set the linkColor of me = the forecolor of line 1 of field "format"
  set the XlinkColor of me = the forecolor of line 2 of field "format"
  set the dataList of me = [:]
  sort the dataList of me
  set the dataString of me = the text of member the member of sprite the spriteNum of me
  set the lastLine of me = the number of Lines in the dataString of me
  repeat with i = 1 to the lastLine of me
    set thisLine = line i of the dataString of me
    set thisLineList = [:]
    repeat with j = 1 to 8 -- up to 8 levels of hierarchy
      set thisChar = char j of thisLine
      if thisChar = ">" then
        next repeat
      else        
        addProp thisLineList,#level,j
        exit repeat
      end if
    end repeat
    if j > 1 then -- change ">" hierarchy indicators to spaces (5 spaces per ">")
      repeat with k = (j - 1) down to 1
        put "     " into char k of thisLine
      end repeat
    end if
    set thisLineText = ""
    put item 1 of thisLine into thisLineText
    if item 2 of thisLine > "" then
      put item 2 of thisLine into thisLineFunction
    else
      put "nothing" into thisLineFunction
    end if
    if item 3 of thisLine > "" then
      put item 3 of thisLine into thisLineArgument
    else
      put "nothing" into thisLineArgument
    end if
    if word 1 of thisLineFunction = "goToNetPage" then
      addProp (thisLineList,#link,1)
    else
      addProp (thisLineList,#link,0)
    end if
    addProp thisLineList,#selected, 0
    addProp thisLineList,#string,thisLineText
    addProp thisLineList, #function, thisLineFunction
    addProp thisLineList, #argument, thisLineArgument
    addProp the dataList of me, i,thisLineList
  end repeat
  slinkyWrite me
end

on slinkyWrite me
  set the formatList of me = [:]
  set the lineList of me = [:]-- in the format [currentLine#:originalLine#]
  sort the lineList of me
  set newLineNum = 1
  set procText = "" -- the processed text
  set writeLevel = 1
  repeat with i = 1 to the lastLine of me
    set thisLineList = getAt(the dataList of me, i)
    set theLevel = getAProp(thisLineList,#level)
    if theLevel = writeLevel then
      put getAProp(thisLineList,#string) & RETURN after procText
      setAProp (the lineList of me,newLineNum,i)
      set linkFormat = getaProp(thisLineList, #link)
      case linkFormat of
        1: addProp (the formatList of me, newLineNum, #newLink)
        2: addProp (the formatList of me, newLineNum, #visitedLink)
        otherwise
          nothing
      end case
      set newLineNum = newLineNum + 1
      if getAProp(thisLineList,#selected) then
        set writeLevel = writeLevel + 1
      end if
    else if theLevel < writeLevel then
      put getAProp(thisLineList,#string) & RETURN after procText
      setAProp (the lineList of me,newLineNum,i)
      set linkFormat = getaProp(thisLineList, #link)
      case linkFormat of
        1: addProp (the formatList of me, newLineNum, #newLink)
        2: addProp (the formatList of me, newLineNum, #visitedLink)
        otherwise
          nothing
      end case
      set newLineNum = newLineNum + 1
      set writeLevel = theLevel
      if getAProp(thisLineList,#selected) then
        set writeLevel = writeLevel + 1
      end if
    end if
  end repeat
  put procText into member the member of sprite the spriteNum of me
  set linesDisplayed = the number of lines in procText
  formatText me, linesDisplayed
end slinkyWrite


on formatText me, linesDisplayed
  repeat with i = 1 to linesDisplayed
    set thisLineFormat = getAProp (the formatList of me,i)
    if thisLineFormat = #newLink then
      set the fontStyle of word 1 to 10 of line i of member the member of sprite the spriteNum of me to "underline"
      set the foreColor of line i of member the member of sprite the spriteNum of me to the linkColor of me
    else if thisLineFormat = #visitedLink then
      set the fontStyle of word 1 to 10 of line i of member the member of sprite the spriteNum of me to "underline"
      set the foreColor of line i of member the member of sprite the spriteNum of me to the XlinkColor of me
    end if
  end repeat
end formatText

on restoreText me
  put the dataString of me into member the member of sprite the spriteNum of me
end restoreText

on getBehaviorDescription
  return "FieldSlinky, written by Patrick S. McClellan, copyright 1997.  You may use this in whole or in part in your programs in exchange for an e-mail message: pat@mcclellan.com.  I am a freelance multimedia producer, located in Oakland, CA, serving the needs of corporate and agency clients throughout the US.  Please visit my site at http://mcclellan.com." & RETURN & RETURN & "1) Enter your text & gotoNetPage parameters in a Field Member (not a TEXT member), following the format shown in field " & quote &"theData" & quote & ".  (Your field member may be named anything.)" & RETURN & RETURN & "2) Attach the FieldSlinky Behavior to the Sprite." & RETURN & RETURN & "3: Add the startMovie & stopMovie instructions to your startMovie & stopMovie scripts." & RETURN & RETURN & "4) Select colors for net links by assigning colors to lines 1 and 2 of field " & quote &"format" "e &".  This field MUST be named " & quote &"format" "e &"."& RETURN & RETURN & "NOTE: On startMovie, this behavior changes the text you have input into the field.  On stopMovie, the text is restored.  However, I recommend making a backup copy of the text field BEFORE running this behavior."
end getBehaviorDescription

 


Contact

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

Send e-mail