:confused:
I'm trying to implement a simple countdown timer so that when 3 minutes is up, the paddle and the pong block stop moving. At the moment, my coding is like this:
ActionScript Code: //Process this code on each frameonClipEvent(enterFrame){ //if the UP key is pressed, move the left paddle up if(Key.isDown(Key.UP)){ this._y-=5; } //if the DOWN key is pressed, move the left paddle down if(Key.isDown(Key.DOWN)){ this._y+=5; } //if the paddle moves below the stage area, move it back to the bottom of the stage if((this._y+this._height)>Stage.height){ this._y=Stage.height-this._height; } //if the paddle moves above the stage area, move it back to the top of the stage if(this._y<0){ this._y=0; } //Check if the paddle hits the pong block if(this.hitTest(_root.pongblock)){ //set the pong block to move in the opposite direction _root.pongblock.xspeed*=(-1); //move the pong block to the edge of the paddle _root.pongblock._x=this._x+this._width; }}_root.leftpaddle.onEnterFrame=function(){var timeLeft:Number = new Number(180);var myClockID:Number = setInterval(clock, 1000);function clock(){ timeLeft = timeLeft -= 1; _root.timeLeft_box.text = timeLeft.toString(); if (timeLeft <= 0) { clearInterval(myClockID); speed = 0; _root.leftpaddle.stop(); _root.pongblock.stop(); }}}
However, I get told that the statement on line 27 (_root.leftpaddle.onEnterFrame=function()):confuse d: must appear within on/onClipEvent handler, but I'm not sure how to implement that so that the countdown timer works. Any ideas how to solve this problem?
How can I add this to an on/onClipEvent event handler?
Monday, May 7, 2012
[Action Script] How can I add this to an on/onClipEvent event handler? May,2012
Posted by Bimo Hery Prabowo at 11:13 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment