8 Replies Latest reply on Mar 24, 2007 2:03 PM by Greg Dove

    underdefined variable

      I have a flash movie that uses a variable that is passed in on the querystring. It's added like this:

      <object type="application/x-shockwave-flash" data="flash/header10.swf?var=value" width="920" height="104">

      This works fine. However on the same page I have this:

      <object type="application/x-shockwave-flash" data="flash/menu5.swf?var=value" width="227" height="192">

      And that one gives this result in the url:


      Where the word underdefined is should be the variable I passed in. This is really driving me nuts. Anybody have any idea why it works for one movie but not the other?

        • 1. Re: underdefined variable
          kglad Adobe Community Professional & MVP
          you can't use var for a variable name. it's a flash reservered word. what makes you think it's working in your first code sample?

          try something like

          • 2. Re: underdefined variable
            havoc73 Level 1
            Sorry. I didn't realize that. I changed the variable name to var in the post to make it easier to read. The variable name in my movie is dev. Is that a reserved word too? When the user is not looking at pages in the dev directory it is empty when in the dev directory it will contain the value dev%24f. I have different directories and secure pages in the store directory. I'm trying to avoid created 3 or 4 different movies depending on the directory.
            • 3. Re: underdefined variable
              kglad Adobe Community Professional & MVP
              dev is not reserved so that's ok to use as an author-defined variable/object.

              what do you mean by "pages"? the html file, the swf file or something else?
              • 4. Re: underdefined variable
                havoc73 Level 1
                The pages I'm talking about are PHP files with Flash movies in them. The code snippet I included was for Firefox. But, it doesn't seem to make a difference, both IE and Firefox give the same error. The first Flash movie "header10.swf" works fine. The second one "menu5.swf" doesn't. It may be gremlins. In the Flash movie I'm using the dev variable like this:

                on (press) {
                getURL(" http://www.myDomain.com/" + dev + "join.php");

                If the user is viewing a page in the dev directory the variable dev will be "dev/"
                • 5. Re: underdefined variable
                  kglad Adobe Community Professional & MVP
                  • 6. Re: underdefined variable
                    Greg Dove Level 4
                    So the problem is that you're not receiving the variable passed into the menu5.swf, right?

                    here's my guess:
                    try changing the code in the on (press)

                    on (press) {
                    getURL(" http://www.myDomain.com/" + _parent.dev + "join.php");

                    • 7. Re: underdefined variable
                      havoc73 Level 1
                      Woot! that worked GWD. Thanks for the help!
                      • 8. Re: underdefined variable
                        Greg Dove Level 4
                        You're welcome.

                        The problem was the scope for accessing the variable.You have attached the code to a button or clip inside the menu5.swf so when it was looking for the dev variable is was looking for it at that level and couldn't find it. Perhaps you did something slightly different in the header10.swf clip?

                        Actually it was more than a guess... because I've done the same thing myself before. But I tend not to code press event handlers like this anymore.

                        If you're going to use flash quite a bit it may help to start doing actionscript like this on frames... the script is only a little different, but its easier to find everything and the relationships between parent and children clips are a little more obvious.

                        To do what you have here you could have your code in a frame on your menu5.swf main timeline (where the button or movieclip that you're using for the on (press) handler exists at the same time - maybe on a different layer for example) something like:

                        ButtonOrClipInstanceName.onPress = function() {
                        getURL(" http://www.myDomain.com/" + dev + "join.php");

                        Where the ButtonOrClipInstanceName is the instance name that you gave it in the properties panel (make sure you don't use spaces in the name). In this code here you can see its just using dev without the _parent reference because the code is on your main timeline.