9 Replies Latest reply on May 2, 2006 4:02 AM by Newsgroup_User

    lots of little questions

    _pb_
      1. I was wondering how to call on a sprite when a button is pressed, i do not want the page to chnge but have sprite show up on the current page.

      2. How to link two sprites on stage, so when a user moves one they both move at the same time.

      3. Is there a way to have a clock i saw a behavior for a count down timer but Ineed a clock and digital one.

      4. This is probly my most complicated one.
      How would I allow a user to type in commands that are checked against a list of allowed commands. If the user types a correct command something happens (IE it goes to the page he typed in), but if not it just displays back a error message.

      Would i have to do a really long and complicated if statment, where is checks each input and if its false then it just moves down the list and keeps checking untill it finds the correct one?
        • 1. Re: lots of little questions
          Level 7
          In article <e2s707$7ef$1@forums.macromedia.com>,
          "_pb_" <webforumsuser@macromedia.com> wrote:

          > 1. I was wondering how to call on a sprite when a button is pressed, i do not
          > want the page to chnge but have sprite show up on the current page.


          SendSprite 3, #doSomething, 123 -- that's sort of calling on a sprite

          would invoke the on doSomething me, inValue haldler passing 123 to
          inValue


          > 2. How to link two sprites on stage, so when a user moves one they both move
          > at the same time.


          One can copy a couple of channels in the score, paste them into the cast
          to create a film loop member containing a group of objects that would be
          tied together.

          Here's a little (untested) script that would mirror a click-drag

          on mouseDown me
          startPos = the mouseLoc
          slaveOffset = sprite(5).loc - sprite(me.spriteNum).loc
          repeat while stillDown()
          sprite(me.spriteNum).loc = the mouseLoc
          sprite(5).loc = the mouseLoc + slaveOffset
          updateStage
          end repeat
          end


          > 3. Is there a way to have a clock i saw a behavior for a count down timer
          > but
          > Ineed a clock and digital one.

          You can embedd an LED style font in the director file, assign it to a
          text member.

          member("timeDisplay").text = the time


          > 3. This is probly my most complicated one.
          > How would I allow a user to type in commands that are checked against a list
          > of allowed commands. If the user types a correct command something happens
          > (IE
          > it goes to the page he typed in), but if not it just displays back a error
          > message.

          you could store the command dictionary in a list or field.

          commandList = ["go", "stop", "standconfused"]

          if getPos(commandList, member("commandEntery").text then -- good to go

          Some list comparison calls are some of thge rare case sensitive
          functions in director, might hve to convert user's command to all lower
          case to gurantee match.

          stored in a field:

          go
          stop
          standconfused


          just oarcing line by line is a typical way to lookup, this is fine for
          only dozens of commands, there may be a noticable delay with hundreds or
          thousands of commands.

          enteredCMD = member("commandEntery").text
          dictText = member("commandDictionary").text
          repeat with i = 1 to dictText.line.count
          if dictText.line = enteredCMD then return true -- report match
          end repeat
          return false -- ending loop without return-exit indicates no match





          You can just use returns to delimit each command, one trick to avoid
          parcing line by lin, be sure there is an empty line at the top and
          bottom of the field so each line is bracketed the same way.


          if offset(member("commandDictionary").text, return &
          member("commandEntery").text & return) then --- command in dictionary

          surrounding with returns prevents the offset function from tagging GO
          when searching for GO TO
          • 2. Re: lots of little questions
            James Newton, ACP Level 3
            NOTE ON FORMAT TAGS IN THIS FORUM

            It looks like the line...

            if dictText.line = enteredCMD then return true -- report match

            ... in JB's reply should be:

            if dictText.line.getAt(i) = enteredCMD then return true -- report match

            If you use an 'i' inside [] square brackets, this is understood as an italics tag, and neither the square brackets nor the i will appear. The workaround is to us '.getAt(i)' instead of the brackets notation.
            • 3. Re: lots of little questions
              Level 7
              Hi,

              Not sure your level of Lingo or programming so JB's suggestions may sound like
              good pointers or may be unclear and scary. So, just to give you some additional
              info (well links to more info):

              Inter-behavior Communication - Using sendSprite, sendAllsprites & call commands
              http://www.fbe.unsw.edu.au/learning/director/Lingo/sendSprite.asp

              Using Lists - The Power of Lists - List Lingo
              http://www.fbe.unsw.edu.au/learning/director/Lingo/lists.asp

              User Tracking with Lists
              http://www.fbe.unsw.edu.au/learning/director/Lingo/usertracking.asp

              Have more tuts at:
              http://www.fbe.unsw.edu.au/learning/director/

              Hope they help.

              regards
              Dean

              Director Lecturer / Consultant
              http://www.fbe.unsw.edu.au/learning/director
              http://www.multimediacreative.com.au

              • 4. Re: lots of little questions
                Level 7
                On Fri, 28 Apr 2006 08:23:25 GMT, openspark posted in
                macromedia.director.lingo:

                > If you use an 'i' inside square brackets, this is understood as an
                > italics
                > tag, and neither the square brackets nor the i will appear. The
                > workaround is to us '.getAt(i)' instead of the brackets notation.

                Another work around that works from NNTP posters that can be read on the Web
                forum:

                if dictText.line[ i ] = enteredCMD then return true -- report match

                (bracket space i space bracket)

                or

                if dictText.line[n] = enteredCMD then return true -- report match

                Nothing works for people reading newsgroups from Web forum posts. Nothing in
                square brackets gets posted to the NNTP server. (see my recent tests in the
                .test group)


                --
                Mark A. Boyd
                Keep-On-Learnin'
                • 5. Re: lots of little questions
                  Level 7
                  "Mark A. Boyd" wrote:

                  > Another work around ...

                  From my discussions with others on this topic is also bad.
                  'i' tends to be used more than 'b' but they both refer to formatting.

                  regards
                  Dean

                  Director Lecturer / Consultant
                  http://www.fbe.unsw.edu.au/learning/director
                  http://www.multimediacreative.com.au


                  • 6. Re: lots of little questions
                    _pb_ Level 1
                    Ok one more question. I have sprite1 on page 1 and sprite on page 2.
                    no when a user clicks from page 1 to page to sprite 2 needs to be in the same place that sprite 1 was. I cant just line them up on top of each other because they have behaviors that allow the user to movie the sprites around the screen.
                    • 7. Re: lots of little questions
                      James Newton, ACP Level 3
                      Why don't you use the same sprite, stretched across both pages, and change its member when you jump to page 2?
                      • 8. Re: lots of little questions
                        _pb_ Level 1
                        Started doing that, but sprite 1 and sprite 2 have diffferent data on it.Because sprite 1 and sprite 2 each show different data
                        • 9. Re: lots of little questions
                          Level 7
                          Change your behaviour a little bit on those sprites so that when the
                          sprite ends, it saves a global variable with the location that it was
                          on. then, then the sprite begins, it starts at that same location...


                          --on sprite 1

                          global gSpriteLoc

                          on endSprite me
                          gSpriteLoc=sprite(me.spriteNum).loc)
                          end

                          ---------------

                          --on sprite 2

                          global gSpriteLoc

                          on beginSprite me
                          sprite(me.spriteNum).loc=gSpriteLoc
                          end