class Cat extends MovieClip { //variables var scrollSpeed:Number = 8; var i:Number = 0; var collision:Boolean= false; var scrollStop:Boolean = false; var meow:Sound; var n:Number; //functions function setCatsPosition () { this.attachMovie ('cat_mc','cat'+i,i); this['cat'+i]._x=300; this['cat'+i]._y=2400; i++; this.attachMovie ('cat_mc','cat'+i,i); this['cat'+i]._x=150; this['cat'+i]._y=4100; i++; this.attachMovie ('cat_mc','cat'+i,i); this['cat'+i]._x=300; this['cat'+i]._y=5850; i++; this.attachMovie ('cat_mc','cat'+i,i); this['cat'+i]._x=300; this['cat'+i]._y=6000; this['cat'+i].gotoAndPlay (15); } function collisionTest () { trace(collision); if (collision==false) { for (i=0;i<4;i++) { if (this['cat'+i].hitTest(_root.sprite.hit1x,_root.sprite.y1,true)) //top left hit { collision = true; if (_root.sprite.spin) { catDies(); } else { _root.sprite.topLeft (); _root.ground.lifeChange = 2; _root.ground.lifeHandler(); collision = false; } } else if (this['cat'+i].hitTest(_root.sprite.hit2x,_root.sprite.y1,true)) //top right hit { collision = true; if (_root.sprite.spin) { catDies(); } else { _root.sprite.topLeft (); _root.ground.lifeChange = 2; _root.ground.lifeHandler(); collision = false; } } else if (this['cat'+i].hitTest(_root.sprite.hit3x,_root.sprite.y2,true)) //center left hit { collision = true; if (_root.sprite.spin) { catDies(); } else { _root.sprite.topLeft (); _root.ground.lifeChange = 2; _root.ground.lifeHandler(); collision = false; } } else if (this['cat'+i].hitTest(_root.sprite.hit4x,_root.sprite.y2,true)) //center right hit { collision = true; if (_root.sprite.spin) { catDies(); } else { _root.sprite.topLeft (); _root.ground.lifeChange = 2; _root.ground.lifeHandler(); collision = false; } } else if (this['cat'+i].hitTest(_root.sprite.hit5x,_root.sprite.y3,true)) //bottom left hit { collision = true; if (_root.sprite.spin) { catDies(); } else { _root.sprite.topLeft (); _root.ground.lifeChange = 2; _root.ground.lifeHandler(); collision = false; } } else if (this['cat'+i].hitTest(_root.sprite.hit6x,_root.sprite.y3,true)) //bottom right hit { collision = true; if (_root.sprite.spin) { catDies(); } else { _root.sprite.topLeft (); _root.ground.lifeChange = 2; _root.ground.lifeHandler(); collision = false; } } } } } function catDies () { meow.start(); for (n=0;n<200;n++) { this['cat'+i]._x=this['cat'+i]._x-n; this['cat'+i]._y=this['cat'+i]._y-n; collision = false; } } //handlers function onEnterFrame () { if (_root.ground.scrollStop == false) { this._y -= scrollSpeed; collisionTest (); } } //constructor function Cat() { setCatsPosition (); meow = new Sound(); meow.attachSound ('meow'); } }