/src/nl/iTouch/snake/TafelHorizontal.as

https://github.com/Hu-Werring/iTouch
ActionScript | 126 lines | 119 code | 7 blank | 0 comment | 21 complexity | 66428dff12f6eaea3bbb36a6c35f070b MD5 | raw file
  1. package nl.iTouch.snake
  2. {
  3. import flash.display.Sprite;
  4. import flash.events.Event;
  5. public class TafelHorizontal extends Sprite
  6. {
  7. private const _lenght:uint = 9;
  8. private const _height:uint = 5;
  9. public var tafelParts:Array = new Array();
  10. public function TafelHorizontal()
  11. {
  12. addEventListener(Event.ADDED_TO_STAGE, init);
  13. }
  14. public function init(e:Event):void
  15. {
  16. removeEventListener(Event.ADDED_TO_STAGE, init);
  17. drawTafel();
  18. }
  19. public function drawTafel():void
  20. {
  21. for (var j:uint = 0; j < 5;j++)
  22. {
  23. for(var i:int = 0; i < 9; i++)
  24. {
  25. if(j ==0)
  26. {
  27. if(i == 0)
  28. {
  29. var tH1:TafelHoek = new TafelHoek();
  30. tH1.x = i * 15;
  31. tH1.y = j * 15;
  32. tH1.rotation = 0;
  33. addChild(tH1);
  34. tafelParts.push(tH1);
  35. }
  36. else if(i == 8)
  37. {
  38. var tH2:TafelHoek = new TafelHoek();
  39. tH2.x = i * 15;
  40. tH2.y = j * 15;
  41. tH2.rotation = 90;
  42. addChild(tH2);
  43. tafelParts.push(tH2);
  44. }
  45. else
  46. {
  47. var tR1:TafelRecht = new TafelRecht();
  48. tR1.x = i * 15;
  49. tR1.y = j * 15;
  50. tR1.rotation = 0;
  51. addChild(tR1);
  52. tafelParts.push(tR1);
  53. }
  54. }
  55. else if(j == 4)
  56. {
  57. if(i == 0)
  58. {
  59. var tH3:TafelHoek = new TafelHoek();
  60. tH3.x = i * 15;
  61. tH3.y = j * 15;
  62. tH3.rotation = -90;
  63. addChild(tH3);
  64. tafelParts.push(tH3);
  65. }
  66. else if(i == 8)
  67. {
  68. var tH4:TafelHoek = new TafelHoek();
  69. tH4.x = i * 15;
  70. tH4.y = j * 15;
  71. tH4.rotation = 180;
  72. addChild(tH4);
  73. tafelParts.push(tH4);
  74. }
  75. else
  76. {
  77. var tR2:TafelRecht = new TafelRecht();
  78. tR2.x = i * 15;
  79. tR2.y = j * 15;
  80. tR2.rotation = 180;
  81. addChild(tR2);
  82. tafelParts.push(tR2);
  83. }
  84. }
  85. else
  86. {
  87. if(i == 0)
  88. {
  89. var tR3:TafelRecht = new TafelRecht();
  90. tR3.x = i * 15;
  91. tR3.y = j * 15;
  92. tR3.rotation = -90;
  93. addChild(tR3);
  94. tafelParts.push(tR3);
  95. }
  96. else if(i == 8)
  97. {
  98. var tR4:TafelRecht = new TafelRecht();
  99. tR4.x = i * 15;
  100. tR4.y = j * 15;
  101. tR4.rotation = 90;
  102. addChild(tR4);
  103. tafelParts.push(tR4);
  104. }
  105. else
  106. {
  107. var tF:TafelFill = new TafelFill();
  108. tF.x = i * 15;
  109. tF.y = j * 15;
  110. tF.rotation = 0;
  111. addChild(tF);
  112. tafelParts.push(tF);
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }