Skip navigation
Sailem12
Currently Being Moderated

Remember my Number

May 28, 2012 3:28 AM

Tags: #save #number #remember #counting #remember_number

Hey guys,

Maybe simple question but I dont find any solution right now...

 

I have a number counting up from 0 to 86400.

When I'm pressing a key, I want to get the CURRENT number to be saved into a new variable. This new variable has to be static (not counting).

But the Basic counting have to go on.

 

Hope you know what I mean and can help me =)

 
Replies
  • Currently Being Moderated
    May 28, 2012 4:39 AM   in reply to Sailem12

    To get a key to trigger something you need to make use of a KeyboardEvent listener

     

    stage.addEventListener(KeyboardEvent.KEY_UP, assignValue);

     

    function checkText(event:KeyboardEvent):void {
         yourVar = currentCount;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    May 28, 2012 5:32 AM   in reply to Sailem12

    Maybe you should show your code then, because if you do not know how to assign a new variable but can deal with the keyboard end of things, there is a disconnect with what your ability appears to be and what you say it is.

     
    |
    Mark as:
  • Currently Being Moderated
    May 28, 2012 6:10 AM   in reply to Sailem12

    I answered your question yeaterday regarding how to get the seconds (you should mark that posting as answered).  You should clean up that code so that it is not doing things that you don't need done - which appears to be most of the date functions you run. 

     

    Also, you should never nest function within other functions.  So you should separate the HerdOn function from being inside the timeHandler function.

     

    If you want another variable, then outside any function declare a new variable, and then assign the secs value to it inside your keyboard handler function.

     
    |
    Mark as:
  • Currently Being Moderated
    May 28, 2012 8:03 AM   in reply to Sailem12

    I think you could use a Global Array.

     

    var laps:Array=new Array();  //out of all functions

     

     

    laps.push(value);    // inside your "HerdOn"

     

    Each time you press a correct key is that mark would add to the array, you would have ordered marks and delete would use:

     

    laps=new Array();

     
    |
    Mark as:
  • Currently Being Moderated
    May 28, 2012 9:10 AM   in reply to Sailem12

    Declare your variable outside any functions so that it is available outside of any function if you need it to be, juist like the rest of the vars you declared.  If you need to store different values at different times and want to retain them all, use an array to store them in.

     
    |
    Mark as:
  • Currently Being Moderated
    May 28, 2012 9:37 AM   in reply to Sailem12

    you're welcome 

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points