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
Play Sound of Member
Export Text for proofing
Clipboard Xtra
DisplayMode Xtra
Generic behavior to emulate a Keystroke
ToolTip Xtra
Detect MS Media Player v9
Generic Slider w/Text
File Read/Write
Hex Display
 

 

 

Behavior Label Search code

Added on 12/10/1999

 

Compatibilities:
behavior D6_5 D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: DebbieWhite

It creates a search engine that searches your labels for a word, then lists it. The user then types in the label they want to go to, then hit a "go to" button to be taken there.

--It creates a search engine that searches your labels for a word, then lists it.  The user then types in the label they want to go to, then hit a "go to" button to be taken there.  You need two fields and two buttons.  "Search Field" is a fixed, editable field where the user types in the search word or phrase.   "Output" is a fixed, non-editable field where the results of the search are placed.  The Search button should call the searchText on mouseUp. The Go To button should call jumpLoc on mouseUp.  The "on keyDown me" bit of code should be put in the "Search Field" sprite lingo.
--Copyright 1999 Deborah White

on searchText
  set searchWord = the text of field "Search Field"
  set returnList = [:]
  set the text of field "Output" to ""
  set numList =  (the number of lines of the labelList) - 1
  if searchWord = "" then
    alert "Please enter a word"
  else
    repeat with i = 1 to numList
      set testWord to line i of the labelList
      set theOffset = offset(searchWord, testWord)
      if theOffset <> 0 then
        put testWord into returnList
        put returnList after member "Output"
        put RETURN after member "Output"
      end if
    end repeat
    if returnList = [:] then
      alert "This word was not found."
    end if
  end if
end

on jumpLoc
  set searchWord = the text of field "Search Field"
  set numList =  (the number of lines of the labelList) - 1
  repeat with i = 1 to numList
    set testWord to line i of the labelList
    if testWord = searchWord then
      set goWord = the text of field "Search Field"
      go to frame goWord
      set the text of field "Output" to ""
      set the text of field "Search Field" to ""
    end if
  end repeat
  if goWord <> SearchWord then
    alert "The page does not exist.  Check to make sure you entered the
complete page title correctly"
  end if
end

on keyDown me
  if the key = return then
    searchText
  else
    pass
  end if
end

 


Contact

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

Send e-mail