dcsimg
A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: setFocus() for touch screen device?

  1. #1
    Senior Member
    Join Date
    Jan 2004
    Posts
    141

    setFocus() for touch screen device?

    Hi.

    I'm using setFocus() to set the focus onto a button (Flash Lite 2.0):

    setFocus(this.myButton);

    When I emulate my FlashLite app on a non-touch screen device (Nokia N95, say) it works fine. However if I try to emulate my app on a touch screen device (say, Nokia 5800 XPress) the button doesn't receive the focus?

    Any help would be appreciated here, as I'm stumped.

  2. #2
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Quite surprising, I got this to work on both touch screen as well as non-touch screen devices. I had applied following code:

    PHP Code:
    myFocus = eval(mcNext.next_btn);
    Selection.setFocus(myFocus); 
    I had one movie clip named 'mcNext' and inside that I had a button named next_btn. My publish version was FlashLite 2.1 and actionscript version set to AS 2.0
    As ever,
    Vinayak Kadam

  3. #3
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    Vinayak,

    I repeated your code on the root timeline, as as you said it worked. But this didnt solve my problem. Check out the attachment on this post. For me (unless I'm going mad) when the SWF loads initially, the focus works on the button contained within the MovieClip. Then when I click 'Menu 1' and it goes to frame 2 (which contains a replica Movie Clip) it doesnt work!! What's happening!!!???
    Attached Files Attached Files

  4. #4
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    I am sorry but not clearly understood your probs.....what you wana happen once your file goes to frame 2. Now it shows a green obect which is a movie clip.
    As ever,
    Vinayak Kadam

  5. #5
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    Hi Vinayak.

    I'm just trying to illustrate my problem.

    On frame 1 I have a movie clip, which contains another movie clip, which contains a button. When you load the swf this button gets focus successfully.

    On frame 2 I have the identical movie clip (which contains another movie clip, which contains a button). But when the timeline moves to frame 2 (via a button click) the button doesnt get focus? And I'm not sure why?

  6. #6
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    Okay cool...

    I just tested this on a Windows Mobile 5 installed with FlashLite 2.1 and the things worked fine for me. When the file went to second frame it automatically showed focus on the button. Device obviously was a touch screen device.

    This is really strange why this is not heppening with you. Can you tell me what you need to do to get the focus on button when ur file goes to 2nd frame?
    As ever,
    Vinayak Kadam

  7. #7
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    On non touch screen u r selecting mh1 to call the funtion to go to frame 2 and in touch screen u r hitting the button which is focused.

    Try to hit the mh1 on touch screen to go to frame 2.

    All will go correct.

    marlopax

  8. #8
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    Marloplex, I'm not doing that myself.

    Touchscreen: I load swf, button in frame one is in focus, I click the 'Menu 1' button, it goes to frame 2, button on frame 2 IS NOT focussed.

    non-Touchscreen: I load swf, button in frame one is in focus, I NAVIGATE UP one, click the 'Menu 1' button, it goes to frame 2, button on frame 2 IS focussed.


  9. #9
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    I am testing on Nokia 5800 (touchscreen) and Nokia N95.

  10. #10
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    I've simplified it even more now (see attachment). There is 1 button and one movie clip in the library. On touch screen device (5800), the button in frame one gets focus. when i click the MC in frame 1 to go to frame 2, the button in frame 2 doesnt get focus!! Is anybody else getting this or is there something wrong with my device profile???

    Attached Files Attached Files

  11. #11
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    Hmmm. Maybe my device profile is stuffed. I just did a:

    trace("focus result: " + Selection.getFocus())

    ....on frame 2 and it resolved correctly to the button. The button just didn't appear to receive focus!!

  12. #12
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    OK.....still on setFocus().....who can tell me how to set focus to a Movie Clip straight away when the app loads? At the moment, I've put a MC on the root of the stage (instance name 'mclip'). In frame 1, I have:

    Code:
    _focusrect = true;
    test = eval(_root.mclip)
    Selection.setFocus(test)
    I was hoping for a yellow box to appear around my MC, but it doesnt? And Selection.getFocus() returns null?? Arrrrgggghghhhh!! This should be simple!! I must be missing something.....

  13. #13
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    make a button inside of the root mclip and give a name instance of that button, say myBtn
    so your code will be

    Code:
    _focusrect = true;
    test = eval(_root.mclip.myBtn)
    Selection.setFocus(test)
    thank you

    marlopax
    Last edited by marlopax; 09-13-2009 at 06:34 PM.

  14. #14
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    ...but apparently setFocus should take a movie clip as a parameter too, but setting focus to a MC doesnt work for me? Forget about the button for now please. How can I set focus to a movie clip? Because using setFocus() isnt working for me?

  15. #15
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    Code:
    mclip.tabEnabled = true; 
    mclip.focusEnabled = true;
    test = eval(_root.mclip); 
    Selection.setFocus(test);

  16. #16
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    ...worked like a charm. I'm gonna go investigate tabEnabled now. I wasn't even aware of focusEnabled - I just used focusRect. I'll have to find what the difference is there too i think.....

    Thanks for your help!

  17. #17
    Senior Member
    Join Date
    Jan 2004
    Posts
    141
    Marlo, you seem to know what you're talking about re: focussing components etc. Going back to my post number 10 in this thread, is there any way to get the button in frame 2 to focus?

    You'll notice that the button in frame 1 focusses fine, but when i click the menu button to go to frame 2, the button on frame 2 doesnt get focus.


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