A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: PLEASE needs urgent help on timer on game

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    1

    PLEASE needs urgent help on timer on game

    hi, i am having a problem with my flash animation game timer and nothing seems to work
    i want it so that when the time reaches 60 seconds and the score is over 200 it will go to the frame gameWon if its below it will go to gameLost.

    i also am struggling to make the timer show up on the animation game.

    i would be so grateful if you could help.. heren is my code...
    PHP Code:
    stop();
    var 
    score:Number=0;
    addEventListener(Event.ENTER_FRAME,testHit);
    function 
    testHit(e:Event){
    if (
    kissBoy.hitTestObject(kissGirl)){
    trace("Hit");
    score+=5;
    scoreDisplay.text="score:"+score
    }
    }
    function 
    reached60Seconds(e:TimerEvent):void {
    if (
    score>200) {
    gotoAndStop("gameWon");
    } else {
    gotoAndStop("gameLost");
    }
    }
    var 
    myTimer:Timer=new Timer(60000,1);
    myTimer.addEventListener(TimerEvent.TIMER,reached6 0Seconds);
    myTimer.start();
    function 
    reached60seconds(event:TimerEvent):void{
    trace("TimerTriggered");
    }
    function 
    runalltime(evt:Event):void{
    if (
    kissBoy.hitTestPoint(kissGirl.x,kissGirl.y,true)) {
    kissGirl.x=Math.random()*400;
    kissGirl.y=Math.random()*300;
    }
    }

    function 
    keydetect(evt:KeyboardEvent):void{
    if(
    evt.keyCode==Keyboard.RIGHT){
    kissBoy.x+=10;
    }

    if(
    evt.keyCode==Keyboard.LEFT){
    kissBoy.x-=10;
    }

    if(
    evt.keyCode==Keyboard.UP){
    kissBoy.y-=10;
    }

    if(
    evt.keyCode==Keyboard.DOWN){
    kissBoy.y+=10;
    }
    }


    stage.addEventListener(Event.ENTER_FRAME,runalltim e);
    stage.addEventListener(KeyboardEvent.KEY_DOWN,keyd etect); 
    Last edited by sstalder; 04-18-2009 at 06:27 PM. Reason: Please use the php / code tags when posting code.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You have the function reached60seconds twice in your script. The latest function will be executed. delete the latest one.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center