Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PrepareImages() {
- images[0] = this.addChild(new Image1());
- images[1] = this.addChild(new Image2());
- images[2] = this.addChild(new Image3());
- images[3] = this.addChild(new Image4());
- images[4] = this.addChild(new Image5());
- images[5] = this.addChild(new Image6());
- images[6] = this.addChild(new Image7());
- images[7] = this.addChild(new Image8());
- images[8] = this.addChild(new Image9());
- images[9] = this.addChild(new Image10());
- for (var i: int = 0; i < ImageCount; i++) {
- images[i].addEventListener(MouseEvent.MOUSE_OVER, HighlightImage);
- images[i].tag = i;
- }
- }
- PrepareImages();
- function HighlightImage(e:MouseEvent):void {
- HighlightedImage = e.target.Tag;
- }
- const ImageCount:int = 10,
- FPS:int = 25,
- ImageWidth:int = 200,
- ImageY:int = 50,
- MovementDelay:int = 5;
- var images:Array = new Array(ImageCount);
- highlightedImage:int =
- var GameTimer:Timer=new Timer(1000 / FPS);
- GameTimer.addEventListener(TimerEvent.TIMER, Update);
- function Update(evt:TimerEvent) {
- for (var i:int = 0; i < images.length; i++) {
- var targetX:Number = 50 + i * 50;
- if (i > HighlightedImage) targetX += ImageWidth;
- images[i].y = ImageY;
- images[i].x = (images[i].x * MovementDelay + targetX) / (MovementDelay + 1);
- }
- }
- GameTimer.start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement