Link to home
Start Free TrialLog in
Avatar of ping1234
ping1234

asked on

MX2004 - conflict on combo component and keyPress?

I am working on a combo component and a button with keyPress feature. but the keyPress feature is not working after I drag the combo to the stage, please help.
Avatar of Montoya
Montoya

What kind of error are you getting? What happens when you drag the combo?
Avatar of ping1234

ASKER

I've got no error to put the combo to stage, but after the combo is on the stage, the keypress feature of the button MC did not work any more
can we see your keypress code?
Sure. I found it can be found even in a simple Flash MX 2004 fla: (export in ActionScript 2.0)

A button MC ->
on(keyPress "<Left>" ){
      trace("haha");
}

A Cobmo component ->
no script at all

then keypress on the button will trace nothing.

i'd suggest the problem is the fact that the movie clip doesn't have focus when you have another component on the stage, so i'd suggest you use an event listener.

blu.
could you please give me some sample code? just in the case that I mentioned? as I am not quite familiar with the event listener in Flash. Thanks
what exactly are you trying to achieve?
a keypress function workable in a button with a combo menu exist in the same frame at the stage.
no, what I mean is why do you want the keypress on the button?

what is supposed to happen when you press? are you trapping for other keys or just left, need the bigger picture to define the best solution.
ok, I am working on a drawboard application, I want to have a keypress function as an action teminator, the combo is just for choosing tool type.
in that case rather use a KeyListener, as in...

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
      if (Key.getCode() == Key.ENTER) {//you can check whichever key you want here.
            trace("like an obedient listener will do what you tell it here.");
      } };
Key.addListener(keyListener);
Sorry, where should I put these code? does it need to attach to a movie?
no, just on the timeline.
but there is no trace echo after I press Enter..
ASKER CERTIFIED SOLUTION
Avatar of blue-genie
blue-genie
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi blue,

Thanks for your help, any key code can suit my case.