11 Replies Latest reply on Sep 17, 2012 8:01 PM by Dean Utian

    My dropdown list code no longer works in D11.5?

    Professor S. Level 1

      I have been using this script in an educational App with a field containing the word Select for several years using D8 and D10.   It still works in the older versions of Director, but now I have been forced to use 11.5 because my code no longer works on Mac OS X 10.7 and up (since Rosetta was removed). I found this code nearly 10 years ago and don't really understand how it creates the dropdown.  I did modify it and it has done the job, but it will no longer drop down in 11.5 . Can you please tell me how to fix this script? If you attach it to a field in D8 or D10 with the contents Select, it will drop down and show the words Effective and Ineffective.  In 11.5 it no longer drops down.  Please help thanks.

       

      on mouseDown

        set me = the castNum of sprite (the clickOn)

        --  Prep the dropdown list:

        set dropList = ["Effective", "Not_effective"]

        set temp = EMPTY

        repeat with x in dropList

          put x & RETURN after temp

        end repeat

        --  Remove the trailing "RETURN":

        delete char (length (temp)) of temp

        put temp into field me

        --  Enter main repeat loop:

        set oldLine = 0

        repeat while the stilldown

          if the mouseCast = me then set newLine = the mouseLine     

          else set newLine = 0

          if oldLine <> newLine then

            if newLine then hilite line (newLine) of field me

            else put temp into field me

            set oldLine = newLine

          end if

        end repeat

        --  Clean up and close out:

        if newLine then put (line (newLine) of field me) into field me

        else put "Select" into field me

        if field me = "Effective" then

          sprite(35).visible = TRUE

          sprite(36).visible = TRUE

          sprite(37).visible = TRUE

          sprite(38).visible = 0

          sprite(39).visible = 0

          sprite(69).visible = TRUE

          sprite(70).visible = TRUE

          sprite(71).visible = 0

          sprite(72).visible = 0

        else if field me = "Not_effective" then

          sprite(35).visible = TRUE

          sprite(36).visible = TRUE

          sprite(37).visible = TRUE

          sprite(38).visible = TRUE

          sprite(39).visible = TRUE

          sprite(69).visible = TRUE

          sprite(70).visible = TRUE

          sprite(71).visible = TRUE

          sprite(72).visible = TRUE

       

        else if field me = "Select" then

          sprite(35).visible = 0

          sprite(36).visible = 0

          sprite(37).visible = 0

          sprite(38).visible = 0

          sprite(39).visible = 0

          sprite(69).visible = 0

          sprite(70).visible = 0

          sprite(71).visible = 0

          sprite(72).visible = 0

        end if

      end mouseDown

        • 1. Re: My dropdown list code no longer works in D11.5?
          Sean_Wilson Adobe Community Professional

          Not exactly what you were asking, but I suggest you look in the Library Palette -> Controls library for a behavior named "Dropdown List". It does what you describe and should work with D11.5+

          • 2. Re: My dropdown list code no longer works in D11.5?
            Professor S. Level 1

            To clarify, the dcr file has five drop down boxes and is written in D8. The main app is in D11.5 so it will run on Mac 10.7 and after. The file with the dropdown boxes gets called by the main app and so I can't use Library Palette you are referring to. If you notice my code, if the user selects "Effective" the script does:

                sprite(35).visible = TRUE

                sprite(36).visible = TRUE

                sprite(37).visible = TRUE

                sprite(38).visible = 0

                sprite(39).visible = 0

                sprite(69).visible = TRUE

                sprite(70).visible = TRUE

                sprite(71).visible = 0

                sprite(72).visible = 0

             

            If the user selects "Ineffective" the script does another group of visibles  and so on. I suppose I could rewrite the script entirely, but I can't find the code in the 11.5 List.  Maybe I am missing something, but I am seeing a "Component" Library that has a "List" that appear to be a Flash component.  Is that what you are reffering to or is there a specific "Dropdown List"?   If it is a behavior, I tried dragging the List component onto a field I created, but no properties popped up and the List moved itself down one cell in the Score (as if to suggest I could not copy to the cell which held my field). I have never had much success using Flash components and so I cnnot find the related behavior code.  If I could maybe I could figure out where to copy visible groups and get the thing to work. But, right now I cannot figure out how to even get the Flash component to function let along get it to execute my code. I would prefer to keep my old code if you could just tell me why my code the list won't drop down any more? I even tried the Help for the Flash component List, but it does not provide any useable example or ways to customize the script.  Sorry, but I am still stuck.

            • 3. Re: My dropdown list code no longer works in D11.5?
              Production Monkey Level 3

              If you add an "updateStage" to the end of the repeat loop it should work again.

               

                repeat while the stilldown

                  if the mouseCast = me then set newLine = the mouseLine    

                  else set newLine = 0

                 

                  if oldLine <> newLine then

                    if newLine then hilite line (newLine) of field me

                    else put temp into field me

                    set oldLine = newLine

                  end if

                 

                  updateStage  -- *** ADD UPDATE STAGE HERE  ****

                end repeat

              • 4. Re: My dropdown list code no longer works in D11.5?
                Sean_Wilson Adobe Community Professional

                I'm pretty sure 'updateStage' has been deprecated on recent Macs (Snow Leopard+ ?)

                 

                I would be inclined to unroll the repeat loop (and update some of the syntax...)

                • 5. Re: My dropdown list code no longer works in D11.5?
                  Dean Utian Adobe Community Professional

                  I agree with Sean in avoiding 'updateStage' and updating much of your syntax.


                  I started writing some exampels of syntax and loop improvments and ended up going through almost your entire script..Here goes

                  on mouseDown

                      set me = the castNum of sprite (the clickOn)

                   

                  could be replaced with

                    on mouseDown me

                      myMember = sprite(me.SpriteNum).member

                   

                  You can remove all the 'set' words, like the above and:

                    dropList = ["Effective", "Not_effective"] 

                    temp = EMPTY

                   

                  Replace the following (assuming you used the myMember statement above):
                    put temp into field me

                   

                  with

                    member(myMember).text = temp

                   

                  There are 2 if.. then conditions in the repeat while the stillDown loop that look wrong:

                    if the mouseCast = me then set newLine = the mouseLine

                    else set newLine = 0

                   

                  I would expect it to be:
                    if the mouseCast = me then
                      newLine = the mouseLine

                    else
                      newLine = 0
                    end if

                   

                   

                  You can get away from the 'repeat will the stilldown' by adding the code to an exitFrame event that can be within this behavior:

                    on exitFrame me

                      if the mouseDown then

                      --

                      if the mouseCast = myMember.number then

                      newLine = the mouseLine 

                      else
                      newLine = 0
                      end if

                     --

                    if oldLine <> newLine then

                      if newLine then
                        member(myMember).line[newLine].hilite()
                      else
                        member(myMember).text = temp

                      end if

                      oldLine = newLine

                    end if

                  --

                    end if

                  end

                   

                  Taking the approach of having multiple events in 1 script and having variables shared in each, it would be best to make thise variables property variables, declaring them as such at teh top of the script.


                  Then for the 'clean up and close out' code, yu could put that into an on MouseUp event.

                   

                  In Lingo 1 is TRUE, 0 is FALSE. Since, you're using 0 when setting the visible property, I'd say use 1 instead of TRUE.

                   

                  Dean

                   

                  Message was edited by: Dean Utian

                  1 person found this helpful
                  • 6. Re: My dropdown list code no longer works in D11.5?
                    Dean Utian Adobe Community Professional

                    I edited my above message as noticed I left out an 'end if'. So changed the code to help identify each end if, changed all Lingo to blue. Also noticed I had kept one of the old 'me's which I had replaced with myMemer.

                     

                    I actually had to look up 'the mouseCast' as it's not all that common these days. Is not in the Lingo dictionary. It does work in D11.5 (I tested it).

                     


                    regards
                    Dean

                    • 7. Re: My dropdown list code no longer works in D11.5?
                      Sean_Wilson Adobe Community Professional

                      The following should do what you ask:

                      property spriteNum
                      property my
                      property myMember
                      property myDropText
                      property myRolledLine
                      property _dropped
                      
                      on beginSprite me
                        my = sprite(spriteNum)
                        myMember = my.member
                        myRolledLine = 0
                        _dropped = 0
                        myDropText = "Effective" &RETURN& "Not_effective"
                      end
                      
                      on endSprite me
                        myMember.text = "Select"
                      end
                      
                      on enterFrame me
                        if _dropped then
                          if rollOver(spriteNum) then newLine = the mouseLine     
                          else newLine = 0
                          if newLine <> myRolledLine then
                            myRolledLine = newLine
                            if myRolledLine then myMember.line[myRolledLine].hilite()
                            else myMember.text = myDropText
                          end if
                        end if
                      end
                      
                      on mouseDown me
                        _dropped = 1
                        myMember.text = myDropText
                        myRolledLine = 0
                      end
                      
                      on mouseUpOutside me
                        me.mouseUp()
                      end
                      
                      on mouseUp me
                        _dropped = 0
                        --  Clean up and close out:
                        if myRolledLine then myMember.text = myMember.text.line[myRolledLine]
                        else myMember.text = "Select"
                        myMember.line[2].hilite()
                      
                        case myMember.text of
                          "Effective":
                            sprite(35).visible = TRUE
                            sprite(36).visible = TRUE
                            sprite(37).visible = TRUE
                            sprite(38).visible = 0
                            sprite(39).visible = 0
                            sprite(69).visible = TRUE
                            sprite(70).visible = TRUE
                            sprite(71).visible = 0
                            sprite(72).visible = 0
                          "Not_effective":
                            sprite(35).visible = TRUE
                            sprite(36).visible = TRUE
                            sprite(37).visible = TRUE
                            sprite(38).visible = TRUE
                            sprite(39).visible = TRUE
                            sprite(69).visible = TRUE
                            sprite(70).visible = TRUE
                            sprite(71).visible = TRUE
                            sprite(72).visible = TRUE
                          "Select":
                            sprite(35).visible = 0
                            sprite(36).visible = 0
                            sprite(37).visible = 0
                            sprite(38).visible = 0
                            sprite(39).visible = 0
                            sprite(69).visible = 0
                            sprite(70).visible = 0
                            sprite(71).visible = 0
                            sprite(72).visible = 0
                        end case
                      end
                      
                      1 person found this helpful
                      • 8. Re: My dropdown list code no longer works in D11.5?
                        Dean Utian Adobe Community Professional

                        Hi Sean,

                         

                        So you went one step further tham me and rewrote the entire script

                         


                        I see you still have:

                            if rollOver(spriteNum) then newLine = the mouseLine    

                            else newLine = 0

                         

                         

                        no 'end if'

                         

                        I thought you could have
                           if a = b then whatever

                         

                        without an 'end if', but always thought you'd need an 'end if' when an else is added, so the conditional no longer is on a single line.

                         

                        Dean

                        • 9. Re: My dropdown list code no longer works in D11.5?
                          Dean Utian Adobe Community Professional

                          Hi again

                           

                          Sean has provided a very good behavior - improved syntax and structure.

                           

                          if rollOver(spriteNum)

                          replaces

                          if the mouseCast = me

                           

                          The '_dropped' variable detects if the mouse is still down, I suggested 'if the mouseDown', which essentially does the same thing.

                           


                          And having
                          myDropText = "Effective" &RETURN& "Not_effective"

                           

                          simplifies using
                          dropList = ["Effective", "Not_effective"]
                          and then extra code to merge the 2 items in the list.

                           

                          Good code is where it is clear and simple. And Sean definitely achieves that.

                           

                          Dean

                          • 10. Re: My dropdown list code no longer works in D11.5?
                            Professor S. Level 1

                            Thanks everyone for all of your replies and not reprimanding me for placing my question in the wrong forum. It should have been entered in Director Lingo (a moderator would have moved it and said some unkind things, but hey, who's counting.) Now for the problem at hand. Is it possible for me to award Correct points to multiple people?  If not, I will be faced with judging alternate solutions considering workability and elegance.. The solution proposed by Production Monkey does work and it appears to be the easiest for me to implement. I saw it this afternoon and so I tested it out using D11.5 on Windows and then published it to a dcr, which I tested on the Mac side of my MacBook Pro running 10.6.  It works and so I asked one of my students with a Mac running 10.8 to test it.  I was then going to assign a Correct to Production Monkey after being tied up in meetings all afternoon and preparing for tomorrows classes tonight.  Now, I see a warning about updateStage and some alternate scripts. I must admit that my script is old and that it had to be updated in seven places because I have seven dropdown boxes.  A behavior is definitely a better way to implement a dropdown box. Interestingly, there was a very good dropdown box example movie using a behavior on the Macromedia and possibly Adobe web site, but they are now gone (as well as the Technotes and a lot of other very good code examples). I should probably post it to this thread in case some other user is trying to research dropdown boxes and can figure out how to use it (I coud not initially, but with some time - which I don't have enough of lately- I could figure it out). Now, I must test out Dean's and Sean's suggestions to see if I can make them work. What if all three work?  Who gets the points? Can I award points to all three of you?

                            • 11. Re: My dropdown list code no longer works in D11.5?
                              Dean Utian Adobe Community Professional

                              @Professor S
                              Thanks for your concern in giving a fair amount of points to people on here. Most people don't bother with the points even if they have been given correct or helpful answers.

                               


                              To your point dilemma
                              - I say, don't give points to Sean. He already has lots so doesn't need more .  Of course, I am kidding.

                               

                              If you want, you can just click the posts that were helpful. Every helpful answer gets 5 points. I think there can only be one correct answer in terms of each thread in this forum. In reality, there are often multiple correct answers as in the case here. So, I say - don't worry about judging which answer is the 'most' correct or best, just click 'Yes' to 'Was this helpful?' on all posts that have helpful information to your understanding and your final solution.

                               

                              Dean