A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: setFocus

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    26

    setFocus

    I need to force focus on a input field. What I learned from the Flash help is listed below:
    Code:
    // Function Name: onRelease
    // Parent: Symbol 1 <begin_btn>
    // Use: When the begin button is released, advange the movie to the second frame and set the input focus to aNumber
    on (release) { 						// Start of function
    	gotoAndStop(2);					// Advance movie to the second frame and stop
    	Selection.setFocus("aNumber");	// Set focus to aNumber
    }
    This is attached to a button on a tittle page, when the buttone is release, I want it to proceed to the second frame, which it does, and for the text field aNumber to get the focus, which it does not. My publish setting are for Flash 10 and Action Script 2.0. Sorry about the extra comments in the code, I tend to over comment my code. Thanks for any help. Troy.
    Last edited by tlmarker; 09-07-2012 at 09:32 PM. Reason: Corrected typos

  2. #2
    Junior Member
    Join Date
    Sep 2012
    Posts
    26
    Okay, this is weird. After testing the movie a couple time, I discovered that aNumber text ares was getting the focus, however, the first problem when I run the program is marked as wrong, when I know it is not. I thought it strange that setFocus would affect a math problem, but I commentted o ut the line, re-ran the program, and the first problem was marked correct as it should be. I should mention that only the first probllem is marked as incorrect when the setFocus line is not commented out. Does anyne have any ideas? As always, thanks for any help. Troy.

  3. #3
    Member
    Join Date
    Aug 2012
    Posts
    55
    i would use
    on (release){
    gotoAndStop(2);
    aNumber.onSetFocus = function(){
    Selection.setSelection(0, aNumber.text.length);
    }
    }

    or else in the main stage of 2, put stage.focus = aNumber;

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    post your fla or all of the code here

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