A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] Dynamic Text loading a .txt file

  1. #1
    Senior Member
    Join Date
    Jul 2006
    Posts
    104

    [F8] Dynamic Text loading a .txt file

    I have two different .fla's. In one, loading the .txt file works great, in the other, it doesn't work for some reason. Both of them have this coding
    Code:
    loadVariables("text.txt", "_root");
    textbox.text = text1;
    While in the .txt file it says
    Code:
    &text1 = Howdy Howdy Howdy
    The only difference is that in the .fla that DOES work, the code
    Code:
    loadVariables("text.txt", "_root");
    is in a scene titled load, with the code
    Code:
    textbox.text = text1;
    is in a scene titled main.

    The flash that does NOT work has the code
    Code:
    loadVariables("text.txt", "_root");
    textbox.text = text1;
    on the same keyframe. Is there a way to make this work without using other scenes. Here is the .fla and .txt to the broken one.

    txt&fla.zip

    Any and all help would be very much appreciated.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    use a LoadVars object.
    the onLoad function executes when the data has completed loading.
    PHP Code:
    lv = new LoadVars();
    lv.load("text.txt"); // &text1 = Howdy Howdy Howdy&

    lv.onLoad = function(){
    _root.textbox.text this.text1;
    }; 

  3. #3
    Senior Member
    Join Date
    Jul 2006
    Posts
    104
    Ah, that makes a ton of sense now. I get what you mean by using a LoadVars object, and I have replaced my coding in the broken .fla with the one that you posted, and even fiddled around with it... but it doesn't work for some reason, still comes up undefined.

    I am wondering if it might be where I am placing my action script... The way the .fla has it set up is how I would like to do it, very simple like, could that be the problem?

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    file attached. hope it helps
    Last edited by a_modified_dog; 01-11-2008 at 03:21 PM.

  5. #5
    Senior Member
    Join Date
    Jul 2006
    Posts
    104
    Perfect Thx a ton for all the help.

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