2 Replies Latest reply on Feb 18, 2013 7:49 AM by Gug88

    For Loop Problem


      Hey guys can you please help me out cause i dont know whats wrong(btw im a Flex noob)


      Is it possible to have 2 variable conditions in a loop like the following




      for (var i:int = 1; j<100 ; i++)



                                                        PartProduced = Sertime1*i

                                                        j= 100*(ArrivalParts/PartProduced)






      Servtime and arrival parts are declared before as 14 and 100


      The loop is suppose to stop when i=8 since j will be 89 and hence exit the loop,but it is not doing so and stops when i=2


      Please Help me and thanks for your help

        • 1. Re: For Loop Problem

          Maybe you should do a while instead of a for loop.


          Something like this:



               <fx:Number id="Servtime">100</fx:Number>

               <fx:Number id="ArrivalParts">18</fx:Number>

              <fx:Number id="Part Produced">0</fx:Number>





          private yourFunction ():void{

               var j:int = 0;

               var i:int = 1;


               while (j < 100) {

                    Part Produced = Servtime *  i;

                    j = 100 (ArrivalParts / PartProduced);






          • 2. Re: For Loop Problem
            Gug88 Level 1

            Thanks for your help


            I used your code and still noticed that the answer was incorrect ! turns out i had the inequality wrong !


            Thanks a mill ,Made me fix it