12 Replies Latest reply on Apr 24, 2012 4:25 PM by MAC800

    1,000 text fields question

    MAC800

      First off:  Windows XP, D11

       

       

       

      Perhaps missed in a Tutorial.. but I did not see it

       

      How can you easily create and auto name 1,000 cast members

       

       

      Lets say I want to have 1,000 text members with names GoldCard01 ending with GoldCard1000

       

      Do I have to create them one by one?  or use some Lingo Script ?

       


        • 1. Re: 1,000 text fields question
          Sean_Wilson Adobe Community Professional
          Do I have to create them one by one?  or use some Lingo Script ?

          It's your choice, really.

           

          If you want to create them with Lingo, you could use something like the following in a #movie script:

          on mCreateMembers aType, howMany, aNamePrefix
            -- insert error checking of parameters here
            repeat with n = 1 to howMany
              tMember = _movie.newMember(aType)
              tMember.name = aNamePrefix & n
            end repeat
          end
          

          and call this by executing mCreateMembers(#text, 1000, "GoldCard") from your message window

          • 2. Re: 1,000 text fields question
            MAC800 Level 1

            So I searched for an old topic I started

             

            I can't get this work....ahhhhhhh

             

            Can someone type it put exactly how it would look? I'm getting errors :(

            • 3. Re: 1,000 text fields question
              Mister MUX

              I am curious as to why you would need to create 1000 text cast members. I would hazard a guess that there is a more efficient means to accomplish your goal.

               

              But in any case, you should at least post the error you are getting.

              • 4. Re: 1,000 text fields question
                MAC800 Level 1

                I'd welcome new ideas, of there's a better way than creating 1,000 cast members

                 

                But each member would be storing / keeping track of a users "points"

                 

                 

                As far as the code here is what I wrote

                 

                On mCreateMember field, 1000, goldcard

                Repeat with n = 1 to 1000

                tMember = _movie.newmember(field)

                tMember.name = goldcard & n

                End repeat

                End

                 

                Also not sure about how to call it: re: "and call it excuting mCreateMembers(#field, 1000, goldcard) from your message window"

                 

                Basically I'm in authoring mode, was curious if I could wright code, press the play head so it would run the code....and bammm have 1000 created castmembers

                • 5. Re: 1,000 text fields question
                  Mister MUX Level 2

                  Myself, I would be storing data in a single list variable.

                   

                  OK, I see where you went wrong. The handler Sean gave you was more flexible than your modified one. I would suggest you stick with that one. It can do what you want it to. Yours would work if it as written correctly but it is far less flexible.

                   

                  Take Seans code and put it in a movie script. Then open the Message Window and type this in, followed by ENTER.

                   

                        mCreateMembers(#text, 1000, "GoldCard")

                   

                  That's all you have to do, no need to run the movie. You should see all of the cast members get created.

                  • 6. Re: 1,000 text fields question
                    MAC800 Level 1

                    #ahhhhhh

                     

                    Script error: Handler not defined

                     

                    MCreateMembers(#field,100, "accnt")

                     

                    #mCreateMembers

                    • 7. Re: 1,000 text fields question
                      Mister MUX Level 2

                      Did you add the handler mCreateMembers as a movie script (and not a parent script or behavior)?

                      • 8. Re: 1,000 text fields question
                        MAC800 Level 1

                        Short of copy&paste, I wrote what he has word for word.... Am I doing something wrong?

                        • 9. Re: 1,000 text fields question
                          Mister MUX Level 2

                          Please confirm that it is a MOVIE script and not a behavior or parent script. Do you know how to tell the difference?

                          • 10. Re: 1,000 text fields question
                            MAC800 Level 1

                            I do not... All I've done so far is scripts that run with the movie plays.....

                             

                            Sent from my iPad

                            • 11. Re: 1,000 text fields question
                              Mister MUX Level 2

                              There are 3 types of script members in Director: movie, behavior, and parent. The type of script member that you create is extremly important. Handlers that are defined in a movie script are available globally. Handlers defined in a behavior script are available only to the sprite to which the behavior is attached. Handlers that are defined in a parent script are available to the child object that is instantiated from the parent script (a bit of an advanced topic).

                               

                              So when you get the error "Handler not defined" trying to execute mCreateMembers (your handler, aka function or method) it is because you did NOT define the handler in a movie script. In all likelihood you put it in a behavior or possibly a parent script. BTW, is doesn't matter that you are calling the handler from the message window. You would get the exact same error if you were calling the handler from some code within your movie ("scripts that run with the movie plays" as you called it).

                               

                              When you open the script window, look in the top left title bar area, what does it say? Movie Script? Parent Script? Behavior Script? If it is not the type you are wanting (movie script in this case) then click on the properties button (letter i) or press ctrl+i (assuming windows). When the Property Inspector displays you can change the scriptType by clicking the drop down button and choosing the one you want.

                               

                              I guarantee you that if you create your handler in a movie script you will not get the "Handler not defined" error when you call it.

                              • 12. Re: 1,000 text fields question
                                MAC800 Level 1

                                That was a very good, lengthy answer. Thank You

                                 

                                Got it working

                                 

                                Played around with it a little with the following ..... Just to understand it better

                                MovieScript: on keyDown ... Case 18... Beep..... Pretty cool no matter where in the movie I press the #1 key,, the PC makes a beep...using that simple MovieScript test

                                 

                                So do you think it would be more intuitive if the behavior type was identified when you wright the handler? Identified before.....

                                 

                                Such as....