Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. function PrepareImages() {
  2. images[0] = this.addChild(new Image1());
  3. images[1] = this.addChild(new Image2());
  4. images[2] = this.addChild(new Image3());
  5. images[3] = this.addChild(new Image4());
  6. images[4] = this.addChild(new Image5());
  7. images[5] = this.addChild(new Image6());
  8. images[6] = this.addChild(new Image7());
  9. images[7] = this.addChild(new Image8());
  10. images[8] = this.addChild(new Image9());
  11. images[9] = this.addChild(new Image10());
  12. for (var i: int = 0; i < ImageCount; i++) {
  13. images[i].addEventListener(MouseEvent.MOUSE_OVER, HighlightImage);
  14. images[i].tag = i;
  15. }
  16. }
  17. PrepareImages();
  18.  
  19.  
  20. function HighlightImage(e:MouseEvent):void {
  21. HighlightedImage = e.target.Tag;
  22. }
  23.  
  24. const ImageCount:int = 10,
  25. FPS:int = 25,
  26. ImageWidth:int = 200,
  27. ImageY:int = 50,
  28. MovementDelay:int = 5;
  29. var images:Array = new Array(ImageCount);
  30. highlightedImage:int =
  31.  
  32. var GameTimer:Timer=new Timer(1000 / FPS);
  33. GameTimer.addEventListener(TimerEvent.TIMER, Update);
  34.  
  35. function Update(evt:TimerEvent) {
  36. for (var i:int = 0; i < images.length; i++) {
  37. var targetX:Number = 50 + i * 50;
  38. if (i > HighlightedImage) targetX += ImageWidth;
  39. images[i].y = ImageY;
  40. images[i].x = (images[i].x * MovementDelay + targetX) / (MovementDelay + 1);
  41. }
  42. }
  43.  
  44. GameTimer.start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement