4 Replies Latest reply on Feb 2, 2007 7:26 PM by kglad

    Trying to understand "var"


      This is kind of a silly question but the "var" actionscript is ment for storing a specific value ment to be used in a movieclip, but how do I use the values when I want to execute a specific task? Kind of a silly question, I know. :-)

        • 1. Re: Trying to understand "var"
          SymTsb Level 2
          var is simply used to define a variable. once that variable is declared, all you need to do is call it's name. for instance....

          var myVar:MovieClip;

          myVar = createEmptyMovieClip("dummy_mc", 1);
          • 2. Re: Trying to understand "var"
            Hompe123 Level 1
            Okey, so the set var value is not exclusive for itself. That is, you can refere to it in actionscripts written for other objects. I´m kind of new in the whole script thing. I posted a topic earlier today with an example. Its http://surface2airparis.com/pg/ and has a menu that is animated. Regardless of which menu you click the prior visited menu "goes" back to its initial position. Can you solve this problem without using var values?

            If someone could explain thorougly how you do this menu I would be very greatful.


            • 3. Re: Trying to understand "var"
              SymTsb Level 2
              I'm not exactly sure what you mean. Vars are necessary for anything of this nature. In the case of this file, they are also using XML from the looks of things to handle the loading of the sub-menus and each of these options are turned into text fields and the Tween class is probably used to bring them from 0-100 alpha. There is no way you could accomplish something like this without variables.
              • 4. Re: Trying to understand "var"
                kglad Adobe Community Professional & MVP
                a variable is used to store something. that may be a string, a number or an object (which encompasses all instances of the flash classes including, but not limited to, movieclips, textfields, dates, bitmaps etc etc etc) reference.

                when you prefix that variable's name with var, you're making that variable local to the object in which it is defined. when that's a timeline, it's no big deal. variables are local to timelines even when they are not prefixed by var.

                but when that variable is prefixed by var and defined within a function, that variable is not defined outside the function.

                so, "var" has a very specific meaning in flash and is a reserved word. a variable is a general term that has the same meaning in flash as it does in every other programming language of which i am aware and has the same meaning in mathematics: it's something that contains a reference to something else.