A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Target a dynamic text field using a var

  1. #1
    Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    80

    Target a dynamic text field using a var

    Hi all

    I have a dynamic text field inside a movieclip. I need to target the text field using a variable.

    I'm loading the text and putting it into a string:
    var page:String=pageDetails.page.toString();

    I have a variable that gets updated:
    i++;
    var myVar:String="page"+i;

    I don't know how to make "myVar" dynamic:
    MovieClip(currSection).myVar.text=page;

    I hope this makes sense.
    Cheers

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    It looks like you're assigning into the variables instead of the textfield - it should be something like this:

    PHP Code:
    MovieClip(currSection).myTxtField.text myVar
    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    80
    I have a number of textfields that I wish to populate. They are named:
    page1
    page2
    page3
    page4
    page5
    and so on.

    I can name the textfield "myTxtField" and put the text into it. But I need to make "myTxtField" dynamic.
    MovieClip(currSection).myTxtField.text=page;

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Ahh - then you want a lookup:

    PHP Code:
    //MovieClip(currSection)['page1'].text = 'page1';
    MovieClip(currSection)[myVar].text page
    Please use [php] or [code] tags, and mark your threads resolved 8)

  5. #5
    Member
    Join Date
    Oct 2002
    Location
    England
    Posts
    80
    Bingo, cheers mate

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