Reputation: 511
I would like to check the event type of a listener. This gives me an error:
messagefield.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, newLayout);
function newLayout(event:Event=null) {
if(event.type == SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE){
trace("OK")
}
}
How to do check for it?
Upvotes: 1
Views: 433
Reputation: 2101
Since your newLayout function can accept null parameter, You should check if event is null before use it
function newLayout(event:Event=null) {
if (event && event.type == SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE) {
trace("OK")
}
}
Upvotes: 1