3 Replies Latest reply on Feb 8, 2012 1:07 PM by kglad

    Parsing out a string I need help

    aidensger

      Below is the actionscript that I am using... As of now I can hard code the string and it will parse those numbers out.  And work  perfectly.

      var myNum:String = "10-22-33-14-25-36-17-28-09-30";


      Ok so my question I replace the numbers in the string and I put in “root.loaderInfo.parameters.example”  it doesn’t work

      var myNum:String = " root.loaderInfo.parameters.example";

       

       

      how do I parse the information that is in "root.loaderInfo.parameters.example so  it will be dynamic instead of hard coded


      (that file has a string of numbers)

      What am I doing wrong?

       

       

       

       

       

      for (bo = 1; bo < 91; bo++)

      {

                _root["b" + bo]._visible = false;

      }

      amount = 11;

      contador = 0;

      k = 0;

      i = 0;

      j = 1;

      sig.sig2.next = "";

      output = "";

       

      var myNum:String = "10-22-33-14-25-36-17-28-9-30";

      var inputBalls:Array = myNum.split("-");

      var ball:Array = new Array;

       

      trace("Size of inputBalls: " + inputBalls.lenght);

      trace("Contents of inputBalls: " + inputBalls);

       

      for (i=0; i < 10; i++)

      {

      ball[j] = Number(inputBalls[i]);

      trace("Show me the numbers: " + ball[j]);

      j++;

      }

       

       

      var t:Number = setInterval(drawBall, 4000);

       

       

       

       

      function drawBall():Void

      {

       

       

       

                contador++;

                if (contador >= 11)

                {

                          gotoAndPlay(3);

                          clearInterval(t);

                }

                else

                {

                          k = random(amount);

                          while (ball[k] == "")

                          {

                                    k = random(amount);

                          }

                          sig.sig2.next = ball[k];

                          _root["b" + ball[k]]._visible = true;

                          sombra._x = _root["b" + ball[k]]._x;

                          sombra._y = _root["b" + ball[k]]._y;

                          sig.gotoAndPlay(2);

                          ball[k] = "";

                }

      }

        • 1. Re: Parsing out a string I need help
          kglad Adobe Community Professional & MVP

          that's as3 code using flashvars.

           

          with as2, you can access the variables directly from the main timeline, if you're defining them correctly.

          1 person found this helpful
          • 2. Re: Parsing out a string I need help
            aidensger Level 1

            Can you assist me with with " as2, you can access the variables directly from the main timeline, if you're defining them correctly."  This is what is on the main timeline?

             

            how do I define or what am I defining?

            • 3. Re: Parsing out a string I need help
              kglad Adobe Community Professional & MVP

              the top part of your code showed how to parse flashvars using as3 code.  flashvars variables are passed from the swf's embedding html so i can't tell if you're doing that correctly with seeing your html.

               

              but, even more important, it's not clear you should be using flashvars.  do you have a reason to define your variables in the embedding html?  is there some reason they're not defined on the timeline with the rest of your code?

              1 person found this helpful