A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Components: Combo Box help

  1. #1
    Member
    Join Date
    Jun 2009
    Posts
    44

    Components: Combo Box help

    Hey guys,
    I have been making a game and have recently found out about the Combo Box component, I love it and it works really well, except for one thing.

    You play the game using the arrow keys, and when you press the arrow keys the character moves, AND it changes the value in the Combo Box, I do not want it to affect the combo box. Is there any way to do this, or a way around it?

    Please do not say use the WASD keys or another set of keys as this will not affect it, because this is not an option, they are already being used!

    thanks!

  2. #2
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    It is all about setting the focus on components. What AS version are you using?
    As ever,
    Vinayak Kadam

  3. #3
    Member
    Join Date
    Jun 2009
    Posts
    44
    Thanks for answering, I'm using AS2.
    would you be able to help me with the code for setting the focus?

  4. #4
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Ya I can surely help...

    Your actual requirement is that you never wanted to have the focus on combo box. Because if combo box receives the focus then it will update its value when ever navigation keys are pressed. To do so, you have a workaround: When focus is received on combo box, immidiately shift the focus to some other object like an input text box. You can place this input text box besides the stage so that it shall not be visible to the user.

    To know more about checking the focus and then shifting it, you may read the onFocus and setFocus events from Flash documentation.
    As ever,
    Vinayak Kadam

  5. #5
    Member
    Join Date
    Jun 2009
    Posts
    44
    Ok, thanks very much.

    I'll post back here if I am unable to get it working.

    Thanks!

  6. #6
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    sure...best luck...If you are not able to resolve then you may post your source FLA here and we may have a look into it and resolve if possible
    As ever,
    Vinayak Kadam

  7. #7
    Member
    Join Date
    Jun 2009
    Posts
    44
    Ok, so I've tried this:
    Code:
    Selection.setFocus(_root.dummy);
    Every frame it executes this code, dummy is an input text, and it works to begin with. But once I change my selection once in the combobox, the focus is no longer with the input text, but with the combo box.

    I dont know what is happening! Please help.

  8. #8
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    You are quite close...now you have to write a listner even on combo box which will detect focus on the combo box and immidiately transfer the focus on to teh text box....look the documentation for onSetFocus event....
    As ever,
    Vinayak Kadam

  9. #9
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Hey there,

    I have attached a sample for your requirement. Run this SWF individually in flash player (not in Flash authoring environment) and please check. Keep clicking tab and you will notice that the focus never goes on teh combo box.


    If you open the source FLA you will find some code on 1st frame. Comment that code, publish teh SWF and open it in flash player and hit the tab button and you will notice that focus then goes on to the combo box component.
    Attached Files Attached Files
    As ever,
    Vinayak Kadam

  10. #10
    Member
    Join Date
    Jun 2009
    Posts
    44
    Wow that was simple, but worked like a charm!

    Thankyou so much for your help!

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