0 Replies Latest reply on Oct 9, 2015 12:25 PM by PHP Daddy

    Property Scripts(?)

    PHP Daddy Level 1



      I was researching a way to get my movie to do hilite several words in a text field string that are the

      result of a search, when I came across the sample movie 'handy 185'.

      I downloaded the file and looked at the scripts to get an idea of what I needed to do.


      I do not like to simply 'copy' code from something. The scripts use 'property this' and 'property that'.


      I haven't gotten that far in my Director self-training yet. I label everything a 'global' and take the long road, IMO.


      This is a 'commented by me' sample of the code from 'handy 185':


      property pMemRef --I guess this is the search word

      property pStartColor --the original color of the field text

      property pHiliteColor --the color that the creator want to use to hilite

      property pWholeWord --the checkbox for whole word searches

      property pStatusMem --a line of text acting as the search field



      on beginSprite me

        pMemRef = sprite(me.spriteNum).member --the cat member of the search field

        pStartColor = pMemRef.color --capturing the original text color

        pHiliteColor = color(#rgb, 255, 0, 0) --the new color 

        pStatusMem.text = EMPTY --A line of text to display the results

        me.resetMyColor() --the orders to change the text color





      on setWholeWordSearch me, flag

        pWholeWord = flag --if whole word is selected then remember that for the search




      on resetMyColor me

        pMemRef.color = pStartColor --storing the original text color






      on hiliteWord me, wordSearch


        if not voidP(wordSearch) then --if the search result in not void then

          if wordSearch <> EMPTY then --if the result has matches then

            me.resetMyColor() --execute the color reset

            tempStr = pMemRef.text --temporarily store the search word

            hiliteList = [] --a list to store the results

            counter = 0 --the count of an empty list


            repeat while offset(wordSearch, tempStr)


              startChar = offset(wordSearch, tempStr) --if there is a match this returns 1

              endChar = startChar + wordSearch.char.count - 1 --identifying the last character of the search word



              flag = true --when whole word is chosen


              if pWholeWord then --if whole word is chosen then

                prevChar = tempStr.char[startChar-1] --identifying the last character before the search result

                nextChar = tempStr.char[startChar+wordSearch.char.count] --identifying the first character after the search result

                charString = "abcdefghijklmnopqrstuvwxyz" --the alphabet

                if charString contains prevChar or charString contains nextChar then --if the characters before or after the match are anything other than blank

                  flag = false

                end if

              end if



              if flag then

                hiliteList.append( [counter + startChar, counter + endChar] ) --add to the list the number of the match and what the start and end characters of the match are

              end if


              delete char 1 to endChar of tempStr

              counter = counter + endChar


            end repeat


            if hiliteList.count > 0 then --if there are results then

              repeat with i in hiliteList --repeat for the number of list contents

                pMemRef.char[i[1]..i[2]].color = pHiliteColor -make each of the results characters the new color

              end repeat

              if hiliteList.count = 1 then --if the result was just one

                pStatusMem.text = "There was 1 match."       

              else --or more than one

                pStatusMem.text = "There were" && hiliteList.count && "matches."

              end if

            else -- or none

              pStatusMem.text = "There were no matches."

            end if 


          end if


        end if 




      on getPropertyDescriptionList

        return [#pStatusMem: [#format: #text, #default: 0, #comment: "Selet status text member:"]] --not sure about this line


      I can't access what this code and the rest of the code is doing. With my globals I can see everything.

      Can someone kindly put me on the track to either understanding how this code works or possibly

      giving me a non-property workaround?