Here's a sample of my code
//this is the code in the script block
<?xml version="1.0" encoding="utf-8"?>
case Keyboard.LEFT: //left keycode: 37
if((pattern.indexOf("content_container")) > 0)
focused_component = String(IFocusM.getFocus());
trace('Focus is now on ' + focused_component);
//this is the mxml code in the MainApplication.mxml
<s:Image id="first" width="200" height="250" source="images/charlottes_web.jpeg"/>
Please help me out if you can. If this isn't possible, let me know and i will stick to using buttons as my components
I’m not sure how to help from that code snippet. First, why do you want to set focus to an Image? Focus is for choosing which component gets keyboard input. What would the user type when focused on a component? Are you trying to implement a selection model instead? Maybe use a List or add keyboard handlers to the systemManager and draw highlights around the images.
Thanks for your help. The reason why i want to set focus on an image is because i want a user to know what is highlighted. Based on what is highlighted, i'll display the property of the image. I definitely like your suggestion about drawing an highlight on an image (i'll look into that). But the issues i am having is that i wrote my own keyboard navigation because that's the only way the user can navigate my app. So here's the scoop:
1. The focus is set to the button that has focus
2. All the buttons have their icon property set. So i used this to make the user feel they are looking at an image when it is really an image embeded in a button
3. Based on what arror key the user presses, the focus is set on the button
Do you think i can achieve the same result while using the systemManager to draw highlishts around the images? Thanks again for your help!
I wouldn’t use systemManager. I would subclass Image and add the ability to draw a highlight, then set a single keyboard event listener on systemManager and use it to change the highlights on those Image subclasses. No need to set focus to them.