6 Replies Latest reply on Mar 20, 2008 4:07 PM by rlc5611

    What's wrong with this conditional?

    GraphicsGeezer Level 1
      As an Actionscript newbie, I'm trying to get a Flash menu to go to a particular frame when a site is on a particular page, defined by a PHP variable which appears after the menu address (such as index.php?readme=419). Seems to work sporadically and the Flash menu, which is 10 frames long, hangs on various frames. Here's the bit of script:

      if (readme == 419 || readme == 431) {
      gotoAndStop(10);
      } else {
      stop();
      }

      Thanks for any help.
        • 1. Re: What's wrong with this conditional?
          rlc5611 Level 1
          is readme string or number?
          • 2. Re: What's wrong with this conditional?
            GraphicsGeezer Level 1
            It's a number. I've added this bit to initiate it:
            var readme:Number=1;
            if (readme == "419" || readme == "431") {
            gotoAndStop(10);
            } else {
            stop();
            }

            • 3. Re: What's wrong with this conditional?
              rlc5611 Level 1
              Strong typing in AS2 is not strong. If you assign text to a number, it becomes text.

              But you say readme is a number and yet you are now checking (your last post) to see if it is a string.

              Why did you change from number in the first post to string in the second?

              Just try running this script

              Why don't you put

              trace("my name is readme and my value is " + readme + " and I am a " + typeof(readme));

              right before your conditional and test the movie

              • 4. Re: What's wrong with this conditional?
                Level 7
                Hello rlc5611,

                > Strong typing in AS2 is not strong. If you assign text to a number, it
                > becomes text.
                >
                > But you say readme is a number and yet you are now checking (your
                > last post) to see if it is a string.
                >
                > Why did you change from number in the first post to string in the
                > second?
                >
                > Just try running this script
                >
                > Why don't you put
                >
                > trace("my name is readme and my value is " + readme + " and I am a "
                > + typeof(readme));
                >
                > right before your conditional and test the movie
                >
                > var readme:Number=1;
                > trace(typeof(readme));
                > anynumber = "1";
                > readme = anynumber;
                > trace(typeof(readme));


                Why not to do even more simple?

                if (Number(readme) == 419 || Number(readme) == 431) {
                gotoAndStop(10);
                }else{
                stop();
                }


                Also check whether your "gotoAndStop(10);" point correctly to a necessary
                destination MC.


                • 5. Re: What's wrong with this conditional?
                  GraphicsGeezer Level 1
                  Thanks for your help so far and my confusion over putting quotes around a variable. I'd send you the URL for the site but I'm not using the Flash menu now. When I did have it on the site, I used a dyamic test box on the root timeline to show the value of the variable 'readme' and it seemed the Flash file knew what the value was. I also numberd each frame so I could tell where the Flash movie stopped. Even though the Flash file knew what 'readme' was worth, it wasn't going to the right frame all the time, just most of the time. In other instances it would stop at an intermediate frame where there was nothing going on but tweening. If I took that conditional script out, it worked fine. For what it's worth, here's the url for the Flash menu by itself: http://www.wordpix.ca/stewsnews/flashmenu.html

                  Thanks again.
                  • 6. Re: What's wrong with this conditional?
                    rlc5611 Level 1
                    How can you number each frame? I'm not sure what that means. Are you putting in numbers for frame labels? If so, it would be gotoAndStop("10"); because a label is a label (i.e. text);