A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Dynamic variable name with text file

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    3

    Dynamic variable name with text file

    hello guy,
    is it possible to make dynamic text field name dynamic name?
    example
    here is a simple text file containing the variable names (mytext.txt)
    sentence1=mytext1
    &sentence2=mytext2
    &sentence3=mytext3
    &sentence4=mytext4
    and so on..

    action script:

    loadVariables("mytext.txt", "_root");

    in the main stage i have a dynamic text field with var name "sentence"

    i need something like this:
    sentence="sentence"+._currentframe
    so if ._currentframe = 2 the text box should display "mytext2" not "sentence2"

    any help is appreciated
    Thank you

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Remove the quotes so you don't use the String "sentence" but the variable. Ex:
    sentence=sentence+_currentframe;

    Also remove the dot before _currentframe. Use it only if you add a path, ec: this._currentframe.

    gparis

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    3
    i need the the dynamic text field read the value from the loaded text file not from flash, i am using eval function but it return undefined.
    sentence=eval ("sentence"+_currentframe);

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