6 Replies Latest reply on Jun 19, 2006 5:37 AM by chitchatonline

    adding a Username (global)

    chitchatonline
      hi guys... i have googled all day yesterday to figure this out... and i'm a nOOB... big time.. so please can someone help me with this by giving me step by step instructions???

      i have a project with about 10 .dir files... and i'm trying to create a field on the header of each file that says "Name"

      i have created a field and i can input "Name" however how do i display that name throughout the whole project???

      i read that global variable would do this trick... i have tried some tutorials... and don't understand parts of it...

      can someone please help me with this?

      step by step on how to set up a global variable... thanks
        • 1. Re: adding a Username (global)
          Level 7
          As I understand, you have a field where the user can input a name, and
          you'll need a script to save that name in a global variable, so you can use
          it later on.
          On a button you can use:

          global gName --your variable
          on mouseUp me
          --setting the variable
          gName = member("yourFieldMemberName").text
          end

          Or in a framescript you can use:

          global gName --your variable
          on exitFrame me
          --setting the variable
          gName = member("yourFieldMemberName").text
          end

          To use the variable on another fieldmember later on (also in another movie),
          you can use the following script on the field sprite:

          global gName ----your variable
          on beginSprite me
          -- using the variable that was set before
          sprite(me.spriteNum).member.text = gName
          end


          Try also opening the Message window (ctrl-m on windows), and write:
          put gName
          press return, and you'll see the output

          >>step by step on how to set up a global variable... thanks
          Well, just remeber to declare it in the script (typically in the top) where
          you set it, and also where you need it again.


          • 2. Re: adding a Username (global)
            Level 7
            I'm not sure what you mean by a header. Do you mean a location on the
            stage? Or do mean the title bar of the movie itself?

            Are you attempting to display something that the user types in? Or do
            you want to show a title, or something like that, on the stage, and use
            the same information for each movie?

            You mentioned that you have created a field. This is a good first step
            if you want to display text on the stage area. If you drag an instance
            of this field member to the stage, you can position it as you like. Then
            you can stretch that sprite in the score across as many frames as you
            like. If your sprite is stretched across the entire length of your
            movie's score, then it will be displayed for the whole movie.

            You could just copy and paste this sprite into each movie and it will
            show up. If the information needs to change, if its user input, for
            instance, then you will need to use a common cast to hold this field
            cast member. To do this, you will need to create a new, external, cast.
            You can name this cast anything that you like, "shared", for instance.
            Link this new external cast to your current movie. Drag the field member
            into this new cast. Save everything. Director will remember that this
            cast member belongs to this external cast.

            When you open a new movie, link this same external cast to the new
            movie. Do this for each movie. Now you can use this field member in each
            movie.

            You could use a global variable, but the process is more complex.

            --
            Rob
            _______
            Rob Dillon
            Adobe Community Expert
            http://www.ddg-designs.com
            412-243-9119

            http://www.macromedia.com/software/trial/
            • 3. adding a Username (global)
              chitchatonline Level 1
              Anders and Rob... Thank you both...

              i think i'm very close to getting this...

              i have followed ander's instruction...
              created my editable field and then created a button with the first script in his post

              This is what i want to do
              i am taking the data from "Evan" field and using the button "GO"

              i want to be able to paste Evan in the field next to it... when i had entered the second piece of code

              i got error
              • 4. Re: adding a Username (global)
                chitchatonline Level 1
                WOW... i finally got it...

                i think the new field that i created needed a memberName...

                but one small glitch..

                if i do not enter the name i notice that it keeps giving me the error on my previous post...

                if i enter a name it works fine...

                can in that case the script check to see if there is a name and if so.. then display that name.. and if no name then don't display any name... ???

                i don't know.. but this is great... lol i am excited...
                • 5. Re: adding a Username (global)
                  Level 7
                  can in that case the script check to see if there is a name and if so.. then
                  > display that name.. and if no name then don't display any name... ???

                  If you did use this script for the field member:

                  global gName ----your variable
                  on beginSprite me
                  -- using the variable that was set before
                  sprite(me.spriteNum).member.text = gName
                  end

                  Then change the line to:
                  if NOT voidP(gName) then sprite(me.spriteNum).member.text = gName

                  now it will only process, if gName contains a variable


                  >i don't know.. but this is great... lol i am excited
                  Perfect....:)



                  • 6. Re: adding a Username (global)
                    chitchatonline Level 1
                    This is Exactly what i wanted to do...

                    thank you Anders.

                    My problem solved. I can use this in the future in other projects...