A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Selection.setFocus concatenate

  1. #1
    Bob (the singing sock)
    Join Date
    Aug 2000
    Location
    Århus, Denmark
    Posts
    472

    Selection.setFocus concatenate

    Hi All,

    I have textfields named 'strText' inside 10 movieclips named 'field0', 'field1', 'field2' .... and so on!


    I'm trying to chech whether a field is empty or not and then set the selection to the first empty textfield.

    But this doesn't work?

    PHP Code:
    function setFocus () {
        for(
    i=0;i<10;i++) {
            if([
    "field"+i].strText.text eq "") {
                
    Selection.setFocus(["field"+i].strtext);
                break;
            }
        }

    Give it up ...
    //pod

  2. #2
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Probably because break doesn't do what you think! It is exclusively used in Switch with ActionScript.
    PHP Code:
    function setFocus () {
        for(var 
    i=0;i<10;i++) {
            if(
    this["field"+i].strText.text != "") {
                
    Selection.setFocus(this["field"+i].strText);
                
    i=10;
            }
        }


  3. #3
    Bob (the singing sock)
    Join Date
    Aug 2000
    Location
    Århus, Denmark
    Posts
    472
    hmm ... still doesn't work ...

    I have attached a sample file if you care to take look?

    btw: the 'break' command DOES work
    Code:
    myNum=5;
    for(i=0;i<10;i++) {
    	trace(i);
    	if(i==myNum) {
    		break;
    	}
    }
    Attached Files Attached Files

  4. #4
    Senior Member
    Join Date
    Feb 2002
    Location
    Lebanon
    Posts
    573
    hmmm..
    I think you are wrong.. a break can be used in loops as well.

  5. #5
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Fair cop.

    Next time I'll check the syntax guide.

  6. #6
    Bob (the singing sock)
    Join Date
    Aug 2000
    Location
    Århus, Denmark
    Posts
    472
    field0.strtext.tabIndex = 1;
    field1.strtext.tabIndex = 2;
    field2.strtext.tabIndex = 3;
    field3.strtext.tabIndex = 4;
    field4.strtext.tabIndex = 5;
    field5.strtext.tabIndex = 6;
    countrydrop.tabIndex = 7;
    field6.strtext.tabIndex = 8;
    field7.strtext.tabIndex = 9;
    field8.tabIndex = 10;

    once I assigned tabindexes everything worked fine

    //pod

  7. #7
    Senior Member
    Join Date
    Feb 2002
    Location
    Lebanon
    Posts
    573
    maybe because you got many fields..

    nice note.. thanks for the info.

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