3 Replies Latest reply on Jun 15, 2013 4:03 PM by kglad

    Script slowing computer message

    JonnyDL Level 1

      I had written a script a while ago, that I got to work with no problems, I wanted to make it a bit better/dynamic (boxes can transition left to right or top to bottom), but Im having a problem. I start the script and the tweens start, but I get the error waring me the script wil slow down my computer. I hadn't change the script that drastically so Im not sure why its not working. I tried removing clips, different test but I can't see/trace the problem.

       

      can anybody help?

       

      stop();

      import mx.transitions.Tween;

      import mx.transitions.easing.*;

       

       

       

       

      Block = new Array();

       

       

      var Xposition:Number = 0;

      var Yposition:Number = 0;

      var verticalCount:Number=Math.ceil(Stage.height/30);

      var horizontalCount:Number=Math.ceil(Stage.width/30);

      var fadeit:Tween;

      var scaleitx:Tween;

      var scaleity:Tween;

      var n:Number = 0;

      var valueFromArray:Number

      var arrayToRandom:Array = new Array();

      var nextSet:Number = 0;

      this.createEmptyMovieClip("mcholder", this.getDepth());

      //mcholder.swapDepths(1000);

       

       

      /////places them onto the stage this configuration is sky skyscraper/ reverse for leader

      function leftToright ()

      {

                for (r=0; r<(verticalCount); r++)

                {

                          for (c=0; c<(horizontalCount); c++)

                          {

                                    var particle = mcholder.attachMovie("block","block_"+r+c ,mcholder.getNextHighestDepth());

                                    particle._y = Yposition

                                    particle._x = Xposition

                                    Block[n] = particle;

                                    //trace(particle._name)

                                    Xposition = Xposition + 30;

                                    n++

                          }

                          Xposition = 0;

                          Yposition=Yposition+30;

                }

                          for(var i:Number = 0; i<=horizontalCount-1; i++)

                {

                          arrayToRandom.push(i);

                }

                //RandomArrayToTween ()

      }

       

       

      ////////////////////////

      function topTobottom ()

      {

                for (r=0; r<(horizontalCount); r++)

                {

                          for (c=0; c<(verticalCount); c++)

                          {

                                    var particle = mcholder.attachMovie("block","block_"+r+c ,mcholder.getNextHighestDepth());

                                    particle._y = Yposition

                                    particle._x = Xposition

                                    Block[n] = particle;

                                    //trace(particle._name)

                                    Yposition = Yposition + 30;

                                    n++

                          }

                          Yposition = 0;

                          Xposition=Xposition+30;

                }

                ///builds an array with a given number of empty pockets to use as a recrence for random numbers

                //not repeating

                for(var i:Number = 0; i<=verticalCount-1; i++)

                {

                          arrayToRandom.push(i);

                }

                RandomArrayToTween ()

       

       

      }

       

       

       

       

      //leftToright ()

      topTobottom ()

      trace(arrayToRandom.length)

      trace(arrayToRandom[2])

       

       

      function randomarray (u)

      {

      for(var i:Number = 0; i<=numOfChoices-1; i++)

                {

                          arrayToRandom.push( (i+u));

                }

                RandomArrayToTween ()

      }

       

       

       

       

       

       

      ///////////////////////////

      function RandomArrayToTween ()

      {

                if (arrayToRandom.length > 0)

                          {

                          var randomPos:Number = Math.floor( Math.random() * arrayToRandom.length );

                          var valueFromArray = arrayToRandom.splice(randomPos, 1);

                          var numberRand = parseInt(valueFromArray);

                          tweenblock(numberRand);

                          }

                          else

                          {

                          nextSet=nextSet+arrayToRandom.length

                          stop();

                          randomarray(nextSet);

                          }

       

       

      }

       

       

       

       

       

       

      function tweenblock(n):Void

      {

       

       

                var fadeit = new Tween(Block[n], "_alpha", Strong.easeInOut, 100, 0, .5, true);

                var scaleitx = new Tween(Block[n], "_xscale", Strong.easeInOut, 100, 0, .5, true);

                var scaleity = new Tween(Block[n], "_yscale", Strong.easeInOut, 100, 0, .5, true);

                fadeit.onMotionChanged = function() {

                          onEnterFrame = function ()

                          {

                                    if (n !== Block.length)

                                    {

                                              delete onEnterFrame;

        //removeMovieClip.Block[n];

                                              RandomArrayToTween ()

                                    }

                                    //else

                                    //{

                                              //delete onEnterFrame;

                                              //stop();

                                              //gotoAndPlay(2);

                                    //}

       

       

                          }

      }

       

       

      }