A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: any way to have mc.onkeypress?

  1. #1
    setVariable kinx's Avatar
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    239

    any way to have mc.onkeypress?

    Hi again!!

    I have an mc acting as a button with the code set like so:

    Code:
    next_butt.onPress = function(){
    	if (_root.all_buttons_active == true) {
    	//do stuff
    	}
    }
    os there a way to have the enter key assigned to the same mc to do the same thing? I can only find the on (keypress) thang for buttons but this is a movieclip.

    Cheers

  2. #2
    Senior Moderator
    Join Date
    Apr 2000
    Location
    Sheffield, UK
    Posts
    3,881
    just use:

    Code:
    Key.addListener(next_btn)
    next_btn.onKeyUp=function()
    {
        if(Key.getCode() == Key.ENTER)
        {
            this.onPress()
        }
    }

  3. #3
    setVariable kinx's Avatar
    Join Date
    Oct 2000
    Location
    Scotland
    Posts
    239
    Thanks mate, much appreciate it.

    Bit of a bizarre thing happening tho.

    I put the following code on the 2nd fram of the mc after a loading mc

    Code:
    back_next_bar_mc.next_butt.onPress = function(){
    	if (_root.all_buttons_active == true) {
    	_root.fadeUpWhite("input_income")
    	}
    }
    Key.addListener(back_next_bar_mc.next_butt);
    back_next_bar_mc.next_butt.onKeyUp = function() {
    	trace("Key.getCode() = "+Key.getCode())
    	if (Key.getCode() == Key.ENTER) {
    		
    		this.onPress();
    	}
    };
    the on press works for the 'next_butt' but the listener doesnt 'trigger' till the next frame or after the next_but has been pressed, very strange.

    Is there anything you can think of that might be causing this?

    Thanks again.

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