class Potion extends MovieClip { //variables var scrollSpeed:Number = 8; var i:Number = 0; var n:Number = 0; var collision:Boolean; var smallerSound:Sound; var hit:Boolean = false; var time:Number; var smallerTime:Number; var aliceIsSmall:Boolean = false; var frameNumber:Number = 0; var frameString:String; //functions function setPotionPosition () { this.attachMovie ('potion_mc','potion'+i,i); this['potion'+i]._x=400; this['potion'+i]._y=4600; i++; this.attachMovie ('potion_mc','potion'+i,i); this['potion'+i]._x=400; this['potion'+i]._y=7200; } function collisionTest () { //trace (hit); if (hit==false) { for (n=0;n<2;n++) { if (this['potion'+n].hitTest(_root.sprite)) { this['potion'+n]._visible=false; time=getTimer()+10000; hit=true; makeAliceSmaller (); } } } if (time < getTimer()) { hit=false; } } function makeAliceSmaller() { smallerSound.start(); aliceIsSmall=true; smallerTime=getTimer()+5000; _root.sprite._width=_root.sprite._width * .5; _root.sprite._height=_root.sprite._height * .5; } function makeAliceBigger () { smallerSound.start(); aliceIsSmall=false; _root.sprite._width=_root.sprite._width * 2; _root.sprite._height=_root.sprite._height * 2; } //handlers function onEnterFrame () { if (_root.ground.scrollStop == false) { this._y -= scrollSpeed; collisionTest (); if (aliceIsSmall==true) { frameNumber=Math.floor((smallerTime - getTimer())/1000); //trace (frameNumber.toString()); frameString=frameNumber.toString() _root.potionIndicator.gotoAndPlay (frameString); if (smallerTime < getTimer()) { makeAliceBigger (); } } } } //constructor function Potion() { setPotionPosition (); smallerSound=new Sound (); smallerSound.attachSound('smaller'); } }