var n:Number = 0; var slowSquish:Number = 0; var theRate:Number; stop(); frame_rate_txt.text = String(stage.frameRate); increase_btn.addEventListener(MouseEvent.CLICK, onIncreaseRateClick); decrease_btn.addEventListener(MouseEvent.CLICK, onDecreaseRateClick); play_btn.addEventListener(MouseEvent.CLICK, playBall); stop_btn.addEventListener(MouseEvent.CLICK, stopBall); slowSquish_btn.addEventListener(MouseEvent.CLICK, slowSq); function playBall(evt:MouseEvent):void { play(); } function stopBall(evt:MouseEvent):void { stop(); } function slowSq(evt:MouseEvent):void { trace("The slowSquish value is: " + slowSquish); if (slowSquish == 1) { slowSquish = 0; } else { slowSquish = 1; // slowSquish = not slowSquish; } // ---------------- DOES NOT WORK!!! } function onIncreaseRateClick(evt:MouseEvent):void { stage.frameRate += 5; frame_rate_txt.text = String(stage.frameRate); } function onDecreaseRateClick(evt:MouseEvent):void { if (stage.frameRate > 5) { stage.frameRate -= 5; } frame_rate_txt.text = String(stage.frameRate); }
frame_rate_txt.text = String(stage.frameRate); count_txt.text = String(n++); // <-- hard to understand Note: count_txt.text = String(n); // <-- works fine too! n = n + 1; // ... and is easier to understand.
if (slowSquish == 1) { theRate = stage.frameRate; stage.frameRate = 5; frame_rate_txt.text = String(stage.frameRate); }
if (slowSquish == 1) { stage.frameRate = theRate; frame_rate_txt.text = String(stage.frameRate); }
gotoAndPlay("startBounceFrame");