Guest User

Untitled

a guest
Jun 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public function setupWidgets():void
  2.         {
  3.             //loop through the widgets and display them in the scrollPane
  4.             for (var i:int = 0; i < arrayOfWidgets.length; i++)
  5.             {
  6.                 scrollPane.addChild(arrayOfWidgets[i]);
  7.             }
  8.            
  9.             var startXPosition:int = 5;
  10.             var startXPosition:int = 0;
  11.            
  12.             var startYPosition:int = 0;
  13.            
  14.             //loop through the widgets and position them in the scrollPane
  15.             for (var j:int = 0; j < arrayOfWidgets.length; j++)
  16.             {
  17.                 //start positioning the x value first
  18.                 if (j == 0)
  19.                 {
  20.                     //position the x value
  21.                     arrayOfWidgets[j].x = startXPosition;
  22.                    
  23.                     //position the y value
  24.                     arrayOfWidgets[j].y = startYPosition;
  25.                 } else
  26.                 {
  27.                     //position the x value
  28.                     arrayOfWidgets[j].x = arrayOfWidgets[j - 1].x + arrayOfWidgets[j].width + 10;
  29.                    
  30.                     //if the number is divisible by 4 increase the layer variable
  31.                     if (j % 4 == 1)
  32.                     {
  33.                         startYPosition++;
  34.                     }
  35.                    
  36.                     //position the y value
  37.                     arrayOfWidgets[j].y = startYPosition;
  38.                 }
  39.             }
  40.            
  41.            
  42.         }
Add Comment
Please, Sign In to add comment