Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.29 KB | None | 0 0
  1. package
  2. {
  3. import Box2D.Collision.Shapes.*;
  4. import Box2D.Common.Math.*;
  5. import Box2D.Dynamics.*;
  6. import flash.display.*;
  7. import flash.events.*;
  8. import flash.filters.*;
  9. import flash.media.*;
  10. import flash.text.*;
  11. import mochi.as3.*;
  12.  
  13. public class kickgame extends Sprite
  14. {
  15. private var world:b2World;
  16. private var worldScale:Number = 30;
  17. private var ballVector:Object;
  18. private var textVector:Object;
  19. private var floorVector:Object;
  20. private var ballSize:uint = 60;
  21. private var shad:shade;
  22. private var socBall:soccerBall;
  23. private var grassFloor:grass;
  24. private var trackArrow:tArrow;
  25. private var theFont:Font;
  26. private var comboCount:int = 0;
  27. private var myFormat:TextFormat;
  28. private var theGlow:GlowFilter;
  29. private var sVal:uint = 0;
  30. private var hVal:uint = 20;
  31. private var maxScore:uint;
  32. private var menuB:menuButton;
  33. private var menuButton2:menuB2;
  34. private var menuButton3:menuB3;
  35. private var menuButton4:Button4;
  36. private var menuP:menuPanel;
  37. private var theBall:b2Body;
  38. private var missHit:Boolean;
  39. private var theTitle:titleWords;
  40. private var playB:playText;
  41. private var rectangle:Shape;
  42. private var ridTitle:Boolean = false;
  43. private var firstKick:Boolean = false;
  44. private var kSound:kickSound;
  45. private var kSound2:kickSound2;
  46. private var gSound:grassSound;
  47. private var gSound1:grassSound1;
  48. private var gSound2:grassSound2;
  49. private var sChan:SoundChannel;
  50. private var wSound:wooshSound;
  51. private var sTrans:Object;
  52. private var hit:pow;
  53. private var miss:pow2;
  54. private var playSound:Boolean = true;
  55. private var lBoard:MovieClip;
  56. private var mClip:MovieClip;
  57. private var ticks:uint;
  58. private var remindText:TextField;
  59. private var hScore:Number = 0;
  60. private var maxhScore:Number;
  61. private var aSound:ambient;
  62. private var aChan:SoundChannel;
  63. private var aTrans:Object;
  64.  
  65. public function kickgame() : void
  66. {
  67. var _loc_3:* = null;
  68. this.ballVector = new Vector.<b2Body>;
  69. this.textVector = new Vector.<TextField>;
  70. this.floorVector = new Vector.<b2Body>;
  71. this.shad = new shade();
  72. this.theFont = new bubble();
  73. this.kSound = new kickSound();
  74. this.kSound2 = new kickSound2();
  75. this.gSound = new grassSound();
  76. this.gSound1 = new grassSound1();
  77. this.gSound2 = new grassSound2();
  78. this.sChan = new SoundChannel();
  79. this.wSound = new wooshSound();
  80. this.sTrans = new SoundTransform();
  81. this.hit = new pow();
  82. this.miss = new pow2();
  83. this.lBoard = new MovieClip();
  84. this.mClip = new MovieClip();
  85. this.aSound = new ambient();
  86. this.aTrans = new SoundTransform();
  87. stage.addChild(this.lBoard);
  88. stage.addChild(this.mClip);
  89. MochiAd.showPreGameAd({clip:this.mClip, id:"bfe4665090168162", res:"640x480"});
  90. MochiServices.connect("bfe4665090168162", this.lBoard);
  91. this.world = new b2World(new b2Vec2(0, 9.81), true);
  92. this.world.SetContactListener(new customContact());
  93. this.trackArrow = new tArrow();
  94. addChild(this.trackArrow);
  95. this.trackArrow.x = 0;
  96. this.trackArrow.y = 0;
  97. this.trackArrow.visible = false;
  98. this.menuB = new menuButton();
  99. this.menuB.y = 0 + this.menuB.height / 2;
  100. this.menuB.x = 640 - this.menuB.width / 2;
  101. addChild(this.menuB);
  102. this.myFormat = new TextFormat();
  103. this.myFormat.size = 18;
  104. this.myFormat.align = TextFormatAlign.LEFT;
  105. this.myFormat.font = this.theFont.fontName;
  106. var _loc_1:* = new TextField();
  107. _loc_1.defaultTextFormat = this.myFormat;
  108. _loc_1.embedFonts = true;
  109. addChild(_loc_1);
  110. _loc_1.textColor = 16777215;
  111. _loc_1.border = false;
  112. _loc_1.wordWrap = false;
  113. _loc_1.selectable = false;
  114. _loc_1.width = 10;
  115. _loc_1.autoSize = "right";
  116. _loc_1.x = 640 - _loc_1.width;
  117. _loc_1.y = this.menuB.height;
  118. _loc_1.text = "MAX COMBO: " + this.maxScore;
  119. this.textVector.push(_loc_1);
  120. this.theGlow = new GlowFilter();
  121. this.theGlow.inner = false;
  122. this.theGlow.color = 0;
  123. this.theGlow.alpha = 1;
  124. this.theGlow.blurX = 4;
  125. this.theGlow.blurY = 4;
  126. this.theGlow.strength = 15;
  127. _loc_1.filters = [this.theGlow];
  128. _loc_1 = new TextField();
  129. _loc_1.defaultTextFormat = this.myFormat;
  130. _loc_1.embedFonts = true;
  131. addChild(_loc_1);
  132. _loc_1.textColor = 16777215;
  133. _loc_1.border = false;
  134. _loc_1.wordWrap = false;
  135. _loc_1.selectable = false;
  136. _loc_1.width = 10;
  137. _loc_1.autoSize = "right";
  138. _loc_1.x = 640 - _loc_1.width;
  139. _loc_1.y = this.hVal + this.menuB.height;
  140. _loc_1.text = this.comboCount.toString();
  141. this.theGlow = new GlowFilter();
  142. this.theGlow.inner = false;
  143. this.theGlow.color = 0;
  144. this.theGlow.alpha = 1;
  145. this.theGlow.blurX = 4;
  146. this.theGlow.blurY = 4;
  147. this.theGlow.strength = 15;
  148. _loc_1.filters = [this.theGlow];
  149. this.textVector.push(_loc_1);
  150. _loc_1 = new TextField();
  151. _loc_1.defaultTextFormat = this.myFormat;
  152. _loc_1.embedFonts = true;
  153. addChild(_loc_1);
  154. _loc_1.textColor = 16777215;
  155. _loc_1.border = false;
  156. _loc_1.wordWrap = false;
  157. _loc_1.selectable = false;
  158. _loc_1.width = 10;
  159. _loc_1.autoSize = "right";
  160. _loc_1.height = 50;
  161. _loc_1.x = 640 - _loc_1.width - this.textVector[1].width;
  162. _loc_1.y = this.hVal + this.menuB.height;
  163. _loc_1.text = "COMBO:";
  164. this.theGlow = new GlowFilter();
  165. this.theGlow.inner = false;
  166. this.theGlow.color = 0;
  167. this.theGlow.alpha = 1;
  168. this.theGlow.blurX = 4;
  169. this.theGlow.blurY = 4;
  170. this.theGlow.strength = 15;
  171. _loc_1.filters = [this.theGlow];
  172. this.textVector.push(_loc_1);
  173. this.remindText = new TextField();
  174. this.remindText.defaultTextFormat = this.myFormat;
  175. this.remindText.embedFonts = true;
  176. addChild(this.remindText);
  177. this.remindText.textColor = 16777215;
  178. this.remindText.border = false;
  179. this.remindText.wordWrap = false;
  180. this.remindText.selectable = false;
  181. this.remindText.width = 200;
  182. this.remindText.height = 50;
  183. this.remindText.x = 640 / 2 + 40;
  184. this.remindText.y = -40;
  185. this.remindText.text = "SUBMIT SCORE >";
  186. this.remindText.alpha = 0.8;
  187. this.theGlow = new GlowFilter();
  188. this.theGlow.inner = false;
  189. this.theGlow.color = 0;
  190. this.theGlow.alpha = 0.8;
  191. this.theGlow.blurX = 4;
  192. this.theGlow.blurY = 4;
  193. this.theGlow.strength = 15;
  194. this.remindText.filters = [this.theGlow];
  195. this.textVector.push(this.remindText);
  196. var _loc_2:* = new b2BodyDef();
  197. _loc_2.position.Set(320 / this.worldScale, 100 / this.worldScale);
  198. _loc_2.type = b2Body.b2_dynamicBody;
  199. _loc_3 = new b2CircleShape(this.ballSize / this.worldScale);
  200. var _loc_4:* = new b2FixtureDef();
  201. _loc_4.shape = _loc_3;
  202. _loc_4.density = 1;
  203. _loc_4.restitution = 0.6;
  204. _loc_4.friction = 0.1;
  205. this.theBall = this.world.CreateBody(_loc_2);
  206. this.socBall = new soccerBall();
  207. this.theBall.SetUserData(this.socBall);
  208. this.theBall.CreateFixture(_loc_4);
  209. this.ballVector.push(this.theBall);
  210. this.theBall.GetUserData().x = this.theBall.GetPosition().x * 30;
  211. this.theBall.GetUserData().y = this.theBall.GetPosition().y * 30;
  212. this.theBall.GetUserData().height = this.ballSize * 2;
  213. this.theBall.GetUserData().width = this.ballSize * 2;
  214. addChild(this.theBall.GetUserData());
  215. _loc_2.position.Set(320 / this.worldScale, 470 / this.worldScale);
  216. _loc_2.type = b2Body.b2_staticBody;
  217. var _loc_5:* = new b2PolygonShape();
  218. _loc_5.SetAsBox(320 / this.worldScale, 10 / this.worldScale);
  219. _loc_4.shape = _loc_5;
  220. var _loc_6:* = this.world.CreateBody(_loc_2);
  221. _loc_6.CreateFixture(_loc_4);
  222. _loc_6.SetUserData("floor");
  223. _loc_2.position.Set(-10 / this.worldScale, -4600 / this.worldScale);
  224. _loc_2.type = b2Body.b2_staticBody;
  225. _loc_5.SetAsBox(10 / this.worldScale, 5080 / this.worldScale);
  226. _loc_4.shape = _loc_5;
  227. _loc_6 = this.world.CreateBody(_loc_2);
  228. _loc_6.CreateFixture(_loc_4);
  229. _loc_2.position.Set(650 / this.worldScale, -4600 / this.worldScale);
  230. _loc_2.type = b2Body.b2_staticBody;
  231. _loc_5.SetAsBox(10 / this.worldScale, 5080 / this.worldScale);
  232. _loc_4.shape = _loc_5;
  233. _loc_6 = this.world.CreateBody(_loc_2);
  234. _loc_6.CreateFixture(_loc_4);
  235. addChild(this.shad);
  236. this.shad.x = 320;
  237. this.shad.y = 100;
  238. this.shad.height = this.ballSize * 2;
  239. this.shad.width = this.ballSize * 2;
  240. this.shad.alpha = 0.5;
  241. this.hit.x = -100;
  242. this.hit.scaleX = 0.5;
  243. this.hit.scaleY = 0.5;
  244. this.miss.x = -100;
  245. this.miss.scaleX = 0.5;
  246. this.miss.scaleY = 0.5;
  247. this.debugDraw();
  248. this.grassRender();
  249. this.titleBuilder();
  250. return;
  251. }// end function
  252.  
  253. private function titleBuilder() : void
  254. {
  255. var _loc_1:* = undefined;
  256. this.rectangle = new Shape();
  257. this.rectangle.graphics.beginFill(16777215, 0.4);
  258. this.rectangle.graphics.drawRect(0, 0, 640, 480);
  259. this.rectangle.graphics.endFill();
  260. addChild(this.rectangle);
  261. this.theTitle = new titleWords();
  262. addChild(this.theTitle);
  263. this.theTitle.x = 640 / 2;
  264. this.theTitle.y = 480 / 2;
  265. this.playB = new playText();
  266. addChild(this.playB);
  267. this.playB.scaleY = 0.5;
  268. this.playB.scaleX = 0.5;
  269. this.playB.x = 640 / 2;
  270. this.playB.y = 480 * 3 / 4;
  271. this.playB.alpha = 0.8;
  272. for each (_loc_1 in this.textVector)
  273. {
  274.  
  275. _loc_1.visible = false;
  276. }
  277. this.menuB.visible = false;
  278. addEventListener(Event.ENTER_FRAME, this.titleManager);
  279. addEventListener(MouseEvent.CLICK, this.playGame);
  280. return;
  281. }// end function
  282.  
  283. private function playGame(event:MouseEvent) : void
  284. {
  285. if (mouseX >= this.playB.x - this.playB.width / 2 && mouseX <= this.playB.x + this.playB.width / 2 && mouseY >= this.playB.y - this.playB.height / 2 && mouseY <= this.playB.y + this.playB.height / 2)
  286. {
  287. this.ridTitle = true;
  288. }
  289. return;
  290. }// end function
  291.  
  292. private function titleManager(event:Event) : void
  293. {
  294. if (mouseX >= this.playB.x - this.playB.width / 2 && mouseX <= this.playB.x + this.playB.width / 2 && mouseY >= this.playB.y - this.playB.height / 2 && mouseY <= this.playB.y + this.playB.height / 2)
  295. {
  296. this.playB.gotoAndPlay(2);
  297. }
  298. else
  299. {
  300. this.playB.gotoAndPlay(1);
  301. }
  302. if (this.ridTitle == true)
  303. {
  304. this.rectangle.alpha = this.rectangle.alpha - 0.01;
  305. this.playB.alpha = this.playB.alpha - 0.01;
  306. this.theTitle.alpha = this.theTitle.alpha - 0.01;
  307. addEventListener(Event.ENTER_FRAME, this.updateWorld);
  308. if (this.rectangle.alpha <= 0 && this.playB.alpha <= 0 && this.theTitle.alpha <= 0)
  309. {
  310. removeChild(this.playB);
  311. removeChild(this.theTitle);
  312. removeChild(this.rectangle);
  313. this.gamePreparer();
  314. }
  315. }
  316. return;
  317. }// end function
  318.  
  319. private function gamePreparer() : void
  320. {
  321. var _loc_1:* = undefined;
  322. removeEventListener(Event.ENTER_FRAME, this.titleManager);
  323. removeEventListener(MouseEvent.CLICK, this.playGame);
  324. addEventListener(MouseEvent.MOUSE_DOWN, this.kickball);
  325. this.menuB.addEventListener(MouseEvent.CLICK, this.onClickHandler);
  326. this.menuB.visible = true;
  327. for each (_loc_1 in this.textVector)
  328. {
  329.  
  330. _loc_1.visible = true;
  331. }
  332. this.tipBuilder();
  333. this.playAmbient();
  334. return;
  335. }// end function
  336.  
  337. private function playAmbient() : void
  338. {
  339. this.aChan = this.aSound.play();
  340. this.aChan.soundTransform = this.aTrans;
  341. this.aChan.addEventListener(Event.SOUND_COMPLETE, this.resumeAmbient);
  342. return;
  343. }// end function
  344.  
  345. private function resumeAmbient(event:Event) : void
  346. {
  347. SoundChannel(event.target).removeEventListener(event.type, this.resumeAmbient);
  348. this.playAmbient();
  349. return;
  350. }// end function
  351.  
  352. private function tipBuilder() : void
  353. {
  354. this.myFormat = new TextFormat();
  355. this.myFormat.size = 18;
  356. this.myFormat.align = TextFormatAlign.CENTER;
  357. this.myFormat.font = this.theFont.fontName;
  358. var _loc_1:* = new TextField();
  359. _loc_1.defaultTextFormat = this.myFormat;
  360. _loc_1.embedFonts = true;
  361. addChild(_loc_1);
  362. _loc_1.textColor = 16777215;
  363. _loc_1.border = false;
  364. _loc_1.wordWrap = false;
  365. _loc_1.selectable = false;
  366. _loc_1.width = 300;
  367. _loc_1.text = "Clicking towards the edge of the" + "\n ball increases kick force";
  368. _loc_1.x = 640 / 2 - _loc_1.width / 2;
  369. _loc_1.y = 260;
  370. _loc_1.alpha = 0.5;
  371. this.textVector.push(_loc_1);
  372. this.theGlow = new GlowFilter();
  373. this.theGlow.inner = false;
  374. this.theGlow.color = 0;
  375. this.theGlow.alpha = 1;
  376. this.theGlow.blurX = 4;
  377. this.theGlow.blurY = 4;
  378. this.theGlow.strength = 15;
  379. this.theGlow.alpha = 0;
  380. _loc_1.filters = [this.theGlow];
  381. addEventListener(Event.ENTER_FRAME, this.tipManager);
  382. return;
  383. }// end function
  384.  
  385. private function tipManager(event:Event) : void
  386. {
  387. if (this.firstKick == true)
  388. {
  389. this.textVector[4].alpha = this.textVector[4].alpha - 0.001;
  390. }
  391. if (this.textVector[4].alpha <= 0)
  392. {
  393. removeChild(this.textVector[4]);
  394. this.textVector.splice(3, 1);
  395. removeEventListener(Event.ENTER_FRAME, this.tipManager);
  396. }
  397. return;
  398. }// end function
  399.  
  400. private function kickball(event:MouseEvent) : void
  401. {
  402. var _loc_2:* = mouseX / this.worldScale;
  403. var _loc_3:* = mouseY / this.worldScale;
  404. if (mouseX > this.menuB.x + this.menuB.width / 2 || mouseX < this.menuB.x - this.menuB.width / 2 || mouseY > this.menuB.y + this.menuB.height / 2 || mouseY < this.menuB.y - this.menuB.height / 2)
  405. {
  406. this.missHit = true;
  407. }
  408. else
  409. {
  410. this.missHit = false;
  411. }
  412. this.world.QueryPoint(this.queryCallBack, new b2Vec2(_loc_2, _loc_3));
  413. return;
  414. }// end function
  415.  
  416. private function negativeHit() : void
  417. {
  418. if (this.comboCount > this.maxScore)
  419. {
  420. this.maxScore = this.comboCount;
  421. this.maxhScore = this.hScore;
  422. this.textVector[0].text = "MAX COMBO: " + this.maxScore;
  423. }
  424. if (this.comboCount >= 10)
  425. {
  426. this.scoreReminder();
  427. }
  428. this.comboCount = 0;
  429. this.hScore = 0;
  430. this.textVector[1].text = this.comboCount.toString();
  431. this.textVector[1].scaleY = 1;
  432. this.textVector[1].scaleX = 1;
  433. this.textVector[1].defaultTextFormat = this.myFormat;
  434. this.textVector[1].y = this.hVal + this.menuB.height;
  435. this.textVector[1].x = 640 - this.textVector[1].width;
  436. this.sVal = 0;
  437. this.textVector[2].x = 640 - this.textVector[1].width - this.textVector[2].width;
  438. return;
  439. }// end function
  440.  
  441. private function scoreReminder() : void
  442. {
  443. this.ticks = 0;
  444. addEventListener(Event.ENTER_FRAME, this.remindManager);
  445. return;
  446. }// end function
  447.  
  448. private function remindManager(event:Event) : void
  449. {
  450. var _loc_2:* = this;
  451. var _loc_3:* = this.ticks + 1;
  452. _loc_2.ticks = _loc_3;
  453. if (this.ticks < 80)
  454. {
  455. this.remindText.y = this.remindText.y + 0.5;
  456. }
  457. if (this.ticks > 160)
  458. {
  459. this.remindText.y = this.remindText.y - 0.5;
  460. }
  461. if (this.ticks > 236)
  462. {
  463. this.remindText.y = -40;
  464. removeEventListener(Event.ENTER_FRAME, this.remindManager);
  465. }
  466. return;
  467. }// end function
  468.  
  469. private function gSoundSelector() : void
  470. {
  471. var _loc_1:* = NaN;
  472. _loc_1 = Math.random();
  473. this.sTrans.volume = 1.9;
  474. if (_loc_1 <= 0.5)
  475. {
  476. this.sChan = this.gSound1.play(500);
  477. }
  478. else
  479. {
  480. this.sChan = this.gSound2.play(400);
  481. }
  482. this.sChan.soundTransform = this.sTrans;
  483. return;
  484. }// end function
  485.  
  486. private function kSoundSelector() : void
  487. {
  488. var _loc_1:* = NaN;
  489. _loc_1 = Math.random();
  490. this.sTrans.volume = 0.75;
  491. if (_loc_1 <= 0.5)
  492. {
  493. this.sChan = this.kSound.play(20);
  494. }
  495. else
  496. {
  497. this.sChan = this.kSound2.play(20);
  498. }
  499. this.sChan.soundTransform = this.sTrans;
  500. return;
  501. }// end function
  502.  
  503. private function positiveHit() : void
  504. {
  505. var _loc_1:* = this;
  506. var _loc_2:* = this.comboCount + 1;
  507. _loc_1.comboCount = _loc_2;
  508. this.hScore = this.hScore + 0.5;
  509. var _loc_1:* = this;
  510. var _loc_2:* = this.sVal + 1;
  511. _loc_1.sVal = _loc_2;
  512. this.textVector[1].text = this.comboCount.toString();
  513. this.textVector[1].scaleY = 1 + 1 / 18 * this.sVal;
  514. this.textVector[1].scaleX = 1 + 1 / 18 * this.sVal;
  515. this.textVector[1].defaultTextFormat = this.myFormat;
  516. this.textVector[1].y = this.textVector[1].y - 0.3;
  517. this.textVector[1].x = 640 - this.textVector[1].width;
  518. this.textVector[2].x = 640 - this.textVector[1].width - this.textVector[2].width;
  519. return;
  520. }// end function
  521.  
  522. private function queryCallBack(param1:b2Fixture) : Boolean
  523. {
  524. var _loc_2:* = param1.GetBody();
  525. if (_loc_2 == this.theBall)
  526. {
  527. this.missHit = false;
  528. this.firstKick = true;
  529. }
  530. else
  531. {
  532. this.missHit = true;
  533. var _loc_3:* = this;
  534. var _loc_4:* = this.comboCount - 1;
  535. _loc_3.comboCount = _loc_4;
  536. this.hScore = this.hScore - 0.5;
  537. }
  538. this.kickImpulse(_loc_2);
  539. return false;
  540. }// end function
  541.  
  542. private function kickImpulse(param1:b2Body) : void
  543. {
  544. var _loc_5:* = NaN;
  545. var _loc_6:* = NaN;
  546. var _loc_7:* = null;
  547. var _loc_2:* = param1.GetWorldCenter();
  548. var _loc_3:* = mouseX / this.worldScale;
  549. var _loc_4:* = mouseY / this.worldScale;
  550. _loc_5 = (_loc_2.x - _loc_3) * 240;
  551. _loc_6 = (_loc_2.y - _loc_4) * 240;
  552. _loc_7 = new b2Vec2(_loc_5, _loc_6);
  553. if (param1.GetLinearVelocity().y > 0)
  554. {
  555. param1.SetLinearVelocity(new b2Vec2(param1.GetLinearVelocity().x, 1));
  556. }
  557. param1.ApplyImpulse(_loc_7, _loc_2);
  558. this.positiveHit();
  559. if (param1 == this.theBall)
  560. {
  561. if (this.playSound == true)
  562. {
  563. this.kSoundSelector();
  564. }
  565. this.hit.gotoAndPlay(1);
  566. this.hit.x = mouseX;
  567. this.hit.y = mouseY;
  568. }
  569. return;
  570. }// end function
  571.  
  572. private function debugDraw() : void
  573. {
  574. return;
  575. }// end function
  576.  
  577. private function updateWorld(event:Event) : void
  578. {
  579. var _loc_6:* = undefined;
  580. var _loc_2:* = 1 / 60;
  581. var _loc_3:* = 10;
  582. var _loc_4:* = 10;
  583. this.world.Step(_loc_2, _loc_3, _loc_4);
  584. this.world.ClearForces();
  585. this.world.DrawDebugData();
  586. var _loc_5:* = this.world.GetBodyList();
  587. while (_loc_5)
  588. {
  589.  
  590. if (_loc_5.GetUserData() == this.socBall)
  591. {
  592. _loc_5.GetUserData().x = _loc_5.GetPosition().x * 30;
  593. _loc_5.GetUserData().y = _loc_5.GetPosition().y * 30;
  594. _loc_5.GetUserData().rotation = _loc_5.GetAngle() * 180 / Math.PI;
  595. }
  596. if (_loc_5.GetUserData() == "hit")
  597. {
  598. _loc_5.SetUserData("floor");
  599. this.negativeHit();
  600. if (this.playSound == true)
  601. {
  602. this.gSoundSelector();
  603. }
  604. }
  605. if (this.missHit == true)
  606. {
  607. this.negativeHit();
  608. this.missHit = false;
  609. this.miss.gotoAndPlay(1);
  610. this.miss.x = mouseX;
  611. this.miss.y = mouseY;
  612. this.sTrans.volume = 0.8;
  613. if (this.playSound == true)
  614. {
  615. this.sChan = this.wSound.play();
  616. }
  617. this.sChan.soundTransform = this.sTrans;
  618. }
  619. _loc_5 = _loc_5.GetNext();
  620. }
  621. for each (_loc_6 in this.ballVector)
  622. {
  623.  
  624. this.shad.x = _loc_6.GetPosition().x * 30;
  625. this.shad.y = _loc_6.GetPosition().y * 30;
  626. this.shad.height = this.ballSize * 2;
  627. this.shad.width = this.ballSize * 2;
  628. this.trackArrow.x = _loc_6.GetPosition().x * 30;
  629. if (_loc_6.GetPosition().y * 30 < -60)
  630. {
  631. this.trackArrow.visible = true;
  632. continue;
  633. }
  634. this.trackArrow.visible = false;
  635. }
  636. return;
  637. }// end function
  638.  
  639. private function grassRender() : void
  640. {
  641. this.grassFloor = new grass();
  642. addChild(this.grassFloor);
  643. this.grassFloor.x = 0;
  644. this.grassFloor.y = 450;
  645. this.grassFloor = new grass();
  646. addChild(this.grassFloor);
  647. this.grassFloor.x = this.grassFloor.width - 20;
  648. this.grassFloor.y = 450;
  649. addChild(this.hit);
  650. addChild(this.miss);
  651. return;
  652. }// end function
  653.  
  654. private function onRollOverHandler(event:MouseEvent) : void
  655. {
  656. this.menuB.gotoAndPlay(2);
  657. return;
  658. }// end function
  659.  
  660. private function onRollOutHandler(event:MouseEvent) : void
  661. {
  662. this.menuB.gotoAndPlay(1);
  663. return;
  664. }// end function
  665.  
  666. private function onClickHandler(event:MouseEvent) : void
  667. {
  668. this.menuBuilder();
  669. return;
  670. }// end function
  671.  
  672. private function menuBuilder() : void
  673. {
  674. this.menuP = new menuPanel();
  675. this.menuP.x = 640 / 2;
  676. this.menuP.y = 480 / 2;
  677. addChild(this.menuP);
  678. this.menuButton2 = new menuB2();
  679. this.menuButton2.x = 640 / 2;
  680. this.menuButton2.y = 480 / 2 + 20;
  681. addChild(this.menuButton2);
  682. this.menuButton2.addEventListener(MouseEvent.CLICK, this.menuClick(this.menuButton2));
  683. if (this.playSound == false)
  684. {
  685. this.menuButton2.gotoAndPlay(2);
  686. }
  687. this.menuButton3 = new menuB3();
  688. this.menuButton3.x = 640 / 2;
  689. this.menuButton3.y = 480 / 2 + this.menuButton3.height + 25;
  690. addChild(this.menuButton3);
  691. this.menuButton3.addEventListener(MouseEvent.CLICK, this.menuClick(this.menuButton3));
  692. this.menuButton4 = new Button4();
  693. this.menuButton4.scaleY = 1.2;
  694. this.menuButton4.scaleX = 1.2;
  695. this.menuButton4.x = 640 / 2;
  696. this.menuButton4.y = 480 / 2 - 15;
  697. addChild(this.menuButton4);
  698. this.menuButton4.addEventListener(MouseEvent.CLICK, this.menuClick(this.menuButton4));
  699. removeEventListener(Event.ENTER_FRAME, this.updateWorld);
  700. removeEventListener(MouseEvent.MOUSE_DOWN, this.kickball);
  701. this.menuB.removeEventListener(MouseEvent.CLICK, this.onClickHandler);
  702. return;
  703. }// end function
  704.  
  705. private function menuClick(param1:Object) : Function
  706. {
  707. var bPressed:* = param1;
  708. var ret:* = function (event:MouseEvent) : void
  709. {
  710. var o:Object;
  711. var boardID:String;
  712. var e:* = event;
  713. if (bPressed == menuButton3)
  714. {
  715. resumeGame();
  716. }
  717. if (bPressed == menuButton2)
  718. {
  719. if (playSound == true)
  720. {
  721. playSound = false;
  722. aTrans.volume = 0;
  723. aChan.soundTransform = aTrans;
  724. menuButton2.gotoAndPlay(2);
  725. }
  726. else
  727. {
  728. playSound = true;
  729. aTrans.volume = 1;
  730. aChan.soundTransform = aTrans;
  731. menuButton2.gotoAndPlay(1);
  732. }
  733. }
  734. if (bPressed == menuButton4)
  735. {
  736. o;
  737. boardID = o.f(0, "");
  738. MochiScores.showLeaderboard({boardID:boardID, score:maxhScore * 2});
  739. }
  740. return;
  741. }// end function
  742. ;
  743. return ret;
  744. }// end function
  745.  
  746. private function resumeGame() : void
  747. {
  748. removeChild(this.menuP);
  749. this.menuB.addEventListener(MouseEvent.CLICK, this.onClickHandler);
  750. this.menuButton2.removeEventListener(MouseEvent.CLICK, this.menuClick(this.menuButton2));
  751. this.menuButton3.removeEventListener(MouseEvent.CLICK, this.menuClick(this.menuButton3));
  752. this.menuButton4.removeEventListener(MouseEvent.CLICK, this.menuClick(this.menuButton4));
  753. removeChild(this.menuButton4);
  754. removeChild(this.menuButton2);
  755. removeChild(this.menuButton3);
  756. addEventListener(Event.ENTER_FRAME, this.updateWorld);
  757. addEventListener(MouseEvent.MOUSE_DOWN, this.kickball);
  758. return;
  759. }// end function
  760.  
  761. }
  762. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement