7 Replies Latest reply on Dec 18, 2006 10:02 AM by Newsgroup_User

    Combining MUI and Keydown

    Mike Crisp Level 1
      Hi

      I am using the script below to make sure the user is reminded to save their typed text (into multiple editable fields) before they move on to a new chapter (movie)

      This script is a behavior on a button

      on mouseup

      set theBox = new(xtra "MUI")
      set paramList= [buttons:#YesNoCancel, title:"Saved your work?", message:"Have you saved all of your files? (Click Yes to Exit without saving)", movable:1, icon:#question]
      if objectP(theBox) then
      set answer = Alert(theBox, paramList)
      case answer of
      1: go to frame 1 of Movie "Chapter 2"

      2: alert "Click the save icon in each of the 3 sections"

      3: return #cancel

      end case
      else
      alert "MUI Xtra is not available!"
      end if

      HOWEVER I want to be able to check if the user has typed anything into any of the editable fields before it asks the question - this is because it become very tedious if you are just viewing video or reading text to be asked if you want to save all the time.

      I assume it is something like:

      On mouseup

      Check if a keydown event has occured

      If not - go to new movie

      If yes - ask if want to save

      If only script were that simple !!

      Thanks in advance
        • 1. Re: Combining MUI and Keydown
          Level 7
          It should be as simple as the pseudo-code you posted. Your check for a
          keyDown event might be as simple as checking each of your 3 #text/#field
          members to see if their text is non-empty OR has been altered from its
          default

          > On mouseup
          > -- Check if a keydown event has occured
          bAltered = 0
          if member("text1").text <> EMPTY then bAltered = 1
          if member("text2").text <> EMPTY then bAltered = 1
          if member("text3").text <> EMPTY then bAltered = 1

          > if bAltered = 0 then -- go to new movie
          > else -- ask if want to save
          end if
          • 2. Re: Combining MUI and Keydown
            Mike Crisp Level 1
            Sean

            Thanks, that has worked perfectly and has made a real difference to my project.

            For anyone else who come across this topic below is the full script I have used.

            On mouseup
            -- Check if a keydown event has occured
            bAltered = 0
            if member("create_ref_1").text <> EMPTY then bAltered = 1
            if member("create_ref_2").text <> EMPTY then bAltered = 1
            if member("create_ref_3").text <> EMPTY then bAltered = 1

            if bAltered = 0 then -- go to new movie

            go to frame 1 of Movie "Support"

            end if

            if bAltered = 1 then

            -- ask if want to save

            set theBox = new(xtra "MUI")
            set paramList= [buttons:#YesNoCancel, title:"Saved your work?", message:"Have you saved all of your Getting Started files? (Click Yes to Exit without saving)", movable:1, icon:#question]
            if objectP(theBox) then

            end if

            set answer = Alert(theBox, paramList)

            case answer of

            1: go to frame 1 of Movie "User"

            2: alert "Click the save icon in each of the 3 sections"

            3: return #cancel

            end case

            end if
            • 3. Re: Combining MUI and Keydown
              Mike Crisp Level 1
              Sean

              Just trying to cut down the amount of script I need to write as I have 54 fields of text in each chapter is there a way to incorporate:

              repeat with i = 25 to 47
              if member (i).text <> EMPTY then bAltered = 1
              end repeat

              Thanks
              • 4. Re: Combining MUI and Keydown
                Level 7
                On Fri, 15 Dec 2006 12:07:55 GMT, Mike Crisp posted in
                macromedia.director.lingo:

                > repeat with i = 25 to 47
                > if member (i).text <> EMPTY then bAltered = 1
                > end repeat
                >

                54 members or 23? Anyway, if they're all named as you mentioned earlier,
                "create_ref_n" where n is a sequential number beginning with 1...

                repeat with i = 1 to 54
                if member("create_ref_" &i).text <> EMPTY then bAltered = 1
                end repeat


                --
                Mark A. Boyd
                Keep-On-Learnin' :)
                • 5. Re: Combining MUI and Keydown
                  Level 7
                  On Fri, 15 Dec 2006 16:46:39 GMT, Mark A. Boyd posted in
                  macromedia.director.lingo:

                  > repeat with i = 1 to 54
                  > if member("create_ref_" &i).text <> EMPTY then bAltered = 1
                  > end repeat

                  Or, to avoid unnecessarily looping through all 54 when one is found to be
                  altered:

                  repeat with i = 1 to 54
                  if member("create_ref_" &i).text <> EMPTY then
                  bAltered = 1
                  exit repeat
                  end if
                  end repeat


                  --
                  Mark A. Boyd
                  Keep-On-Learnin' :)
                  • 6. Re: Combining MUI and Keydown
                    Mike Crisp Level 1
                    Sorry I should have been clearer. The numbering and naming is not sequential

                    Can the same be done with cast members 25 to 47 OR
                    Everything in channel 10 (this is where each .text member is)
                    • 7. Re: Combining MUI and Keydown
                      Level 7
                      On Mon, 18 Dec 2006 08:58:11 GMT, Mike Crisp posted in
                      macromedia.director.lingo:

                      > Sorry I should have been clearer. The numbering and naming is not
                      > sequential
                      >
                      > Can the same be done with cast members 25 to 47

                      Sure, though you should specify which castLib it's in. And be careful not to
                      move those cast members around after writing the script:

                      repeat with i = 25 to 47
                      if member (i, "internal").text <> EMPTY then
                      bAltered = 1
                      exit repeat
                      end if
                      end repeat

                      If you want to avoid hard-coding the cast numbers, you could provide a list
                      of their names and loop through that list. Something like the following
                      (untested) example

                      memList = ["thisMember","thatMember","otherMember"...]
                      lCount = memList.count
                      repeat with n = 1 to lCount
                      if member(lCount[n]).text <> EMPTH then
                      bAltered = 1
                      exit repeat
                      end if
                      end repeat

                      > OR Everything in channel 10 (this is where each .text member is)

                      You could do this, but it will only apply to the current frame - it will not
                      traverse the score to figure out all of them.

                      if sprite(10).member.text <> EMPTY then



                      --
                      Mark A. Boyd
                      Keep-On-Learnin' :)