3 Replies Latest reply on May 11, 2006 7:22 PM by Newsgroup_User

    Help With lists please :)

    evkl
      Hi there, im new to director, and i am currently working on a project that is based around lists.

      Basically It is a program that shows a list of writers, so when you click the button show writers it shows the list in the text field the writers that have been put in the list. As you click one of the writers names another text box shows what number in the list they are.

      But my problem is, which i dont know how to do is. When you click the writers name i want another text box to take information from another list which will show the books the writer has wrote.

      So basically the list of writers come up when you press the button to show the list of writers. When you click a writers name the list of their books shows up in another text box.

      Hope you can help

      thanks
        • 1. Re: Help With lists please :)
          Level 7
          create a movie script like this

          ----------------
          global gAuthors

          on startMovie
          gAuthors = []
          gAuthors.add(["J.R.R Tolkien",["The Hobbit","The Fellowship of the
          Ring","The Two Towers","Return of the King"]])
          gAuthors.add(["Robert Heinlein",["StarMan Jones","Have Spacesuit, WIll
          Travel"]])
          gAuthors.add(["Stephen King ",["The Stand","The Shining","Cujo"]])
          end
          --------------

          create a text cast member called "writers" and place it on the stage
          attach this behavior to it

          --------------
          global gAuthors
          property spriteNum

          on beginSprite me
          sprite(SpriteNum).member.text = ""
          repeat with i = 1 to count(gAuthors)
          sprite(SpriteNum).member.text = sprite(SpriteNum).member.text &
          gAuthors [1]
          if i <> count(gAuthors) then
          sprite(SpriteNum).member.text = sprite(SpriteNum).member.text & RETURN
          end if
          end repeat
          end

          on mouseUp me
          lineSelected = sprite(spriteNum).pointToLine(the mouseLoc)
          member("books").text = ""
          repeat with i = 1 to count(gAuthors[lineSelected][2])
          member("books").text = member("books").text &
          gAuthors[lineSelected][2]

          if i <> count(gAuthors[lineSelected][2]) then
          member("books").text = member("books").text & RETURN
          end if
          end repeat
          end
          ---------------

          create a text cast member called "books" and place it on the stage
          attach this behavior to it

          --------------
          property spriteNum

          on beginSprite me
          sprite(spriteNum).member.text = ""
          end
          ---------------


          That's it.


          • 2. Re: Help With lists please :)
            evkl Level 1
            ok it accepts most the code apart from i get an error message saying :

            script error : operand expexted

            sprite(spritenum).member.text=
            sprite(spritenum).member.text &?


            Im not sure what this mean

            thanks for the help so far, any chance u could help me just a little bit more

            thanks

            • 3. Re: Help With lists please :)
              Level 7
              Newsreaders are notorious for breaking lines of code because they are too
              long. What should have been on one line gets word-wrapped, and creates lingo
              errors.

              If you want, you can download a small director movie with the code so that
              you can copy it better from there. The URL is
              http://home.bellsouth.net/p/s/community.dll?ep=16&ext=1&groupid=287397&ck

              Right click on author_books.dir and save the file on you computer.

              To better understand how it works, look in the Lingo help docs for the
              concept of "lists". Feel free to ask if you have a question.