On key press with variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjero
    New Member
    • Jun 2007
    • 1

    On key press with variables

    Hi

    I have 5 buttons. I want each one to be played from the keyboard with a key, but i need the specific key to each button to be a variable read from a txt file. I can load the file and store the variables but i can't pass a variable to On Keypress == variable...

    any thoughts?

    Thanks in advance,

    Shahar Zrihen
  • Atran
    Contributor
    • May 2007
    • 319

    #2
    Originally posted by manjero
    Hi

    I have 5 buttons. I want each one to be played from the keyboard with a key, but i need the specific key to each button to be a variable read from a txt file. I can load the file and store the variables but i can't pass a variable to On Keypress == variable...

    any thoughts?

    Thanks in advance,

    Shahar Zrihen
    Hello:
    If your button is a button symbol: you cant play the button by keypressing.
    But if your button is a MovieClip Symbol: you can play the button by keypressing.
    And read this code:
    [This code for pressing specific key]
    Code:
    var keyListener:Object = new Object();
    keyListener.onKeyDown = function() {
    	if (Key.SPACE) {
    		trace("You pressed Space key.");
    		//Start your code from here.
    	}
    	if (Key.SHIFT) {
    		trace("You pressed Shift key.");
    		//Start your code from here.
    	}
    };
    Key.addListener(keyListener);
    Hope this help you.

    Comment

    Working...