dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: load different texts in different text fields through one .txt file?

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    19

    load different texts in different text fields through one .txt file?

    Hi!
    If i have different text fields in one flash page like price, description.. is it possible to load different variables like "&price", "&description" from one .txt file?
    If you take a look at my example there are 2 text fields:
    the first one loads simple text.
    the second one is called dayNames and had to show this .txt content:

    "&dayNames=Sunday,Monday,Tuesday,Wednesday,Thursda y,
    Friday,Saturday"

    when i test the movie those contents are shown in the output panel (it was a tutorial) but it's not what i was looking for!
    how can i load different texts in different text fields through one .txt file?
    Attached Files Attached Files

  2. #2
    Junior Member
    Join Date
    Aug 2011
    Posts
    13
    rename your text field from dayNames to day_Names because the first one is reserved by AS3, then your last function on layer 3 frame 1 should look like this:
    Code:
    function loadText(event:Event):void
    {
    my_txt.text = my_loader.data;
    var loader2:URLLoader = URLLoader(event.target);
    var variables:URLVariables = new URLVariables(loader2.data);
    day_Names.text = (variables.dayNames);
    }

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    13
    I forgot to say, that yes you can load various variables from one .txt file just start the name of each of them with "&" and then the code should look like this
    Code:
    function loadText(event:Event):void{
    my_txt.text = my_loader.data;
    var loader2:URLLoader = URLLoader(event.target);
    var variables:URLVariables = new URLVariables(loader2.data);
    day_Names.text = (variables.dayNames);
    test_text.text = (variables.test);
    a.text = (variables.abcd);
    }
    if I had the .txt file with
    Code:
    &dayNames=safsfds &test=dfsdfds &abcd=sfsdf
    then it should show up in those text field correctly.

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    19
    IT WORKED GREAT!!!!
    Thank you very much for your help! I really appreciated it! i can sleep fine now!
    Have a nice day! Thanks!!!!!!!

  5. #5
    Junior Member
    Join Date
    Feb 2010
    Posts
    19
    just a question..with this method, is it possible to add links too?

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