A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Loading Text Help Please?

  1. #1
    Senior Member
    Join Date
    Feb 2002
    Posts
    375

    Loading Text Help Please?

    Hi,

    I'm trying to help someone else and I can't figure this one out, so now I'm helping myself too

    I (or this person) has a text file with a load of different variables in it. It is set up like so.

    Lx1=Here is the Lx1 variable&Lx2=Here is the Lx2 variable&Lx3=Here is the Lx3 variable&Tx1=Here is the TX1 variable&Tx2=Here is the Tx2 variable&Tx3=Here is the Tx3 variable

    Now I have two buttons on the stage and I want to load one of these variables at a time into my dynamic text boxes each time a button is pressed. Here is the code.

    code:
    var n =1

    next_button.onPress = function(){
    n++
    load_Text()
    }
    prev_button.onPress = function(){
    n--
    load_Text()
    }

    MyVars = new LoadVars()
    MyVars.load("test1.txt")

    load_Text()

    function load_Text(){
    T="Tx" add n;
    L="Lx" add n;

    myText= MyVars.T;
    mySlide= MyVars.L;

    }



    Now when I debug this the T and L variables = what they are supposed to but the myText and mySlide variables are undefined. Why is this?

    Thanks.
    Last edited by grooveepants; 11-18-2003 at 02:08 AM.

  2. #2
    Senior Member
    Join Date
    Feb 2002
    Posts
    375
    :BUMP:

  3. #3
    Senior Member
    Join Date
    Feb 2002
    Posts
    375
    ::BUMP::

  4. #4
    Senior Member
    Join Date
    Feb 2002
    Posts
    375
    :BUMP:

  5. #5
    Senior Member
    Join Date
    Feb 2002
    Posts
    375

    :BUMP:

    I'm not giving up, someone must know the answer

  6. #6
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Can you attach this test .fla and your text file?
    Zip them up and in MX only format.

  7. #7
    Senior Member
    Join Date
    Feb 2002
    Posts
    375
    Thanks oldnewbie
    Attached Files Attached Files

  8. #8
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Been looking at your code and no offense, but IMHO it's pretty shaky!

    Waisted tonight... I may proposed something completely different tomorrow...

    I'd look into filling an array from your text file, and then simply refer to that array on your previous & next buttons.

  9. #9
    Senior Member
    Join Date
    Feb 2002
    Posts
    375
    Well oldnewbie, IMHO I think its pretty shakey too

    When I debug the code though, the variables T and L do go up or down each time the buttons are pressed. ie TX1, TX2, TX3 and so on and if you change these lines of code from

    myText= MyVars.T;
    mySlide= MyVars.L;

    to

    myText= MyVars.Tx1;
    mySlide= MyVars.Lx1;

    then the text is dragged in from the txt file, so why is it that when you place a variable at the end of the code it doesn't work? Am I supposed to use something else?

    Thanks
    Last edited by grooveepants; 11-20-2003 at 05:06 AM.

  10. #10
    Senior Member
    Join Date
    Feb 2002
    Posts
    375
    :BUMP:

  11. #11
    FK's Giant Steve_w_V's Avatar
    Join Date
    Mar 2003
    Location
    San Jose, California
    Posts
    2,113
    "IMHO"?
    The other day, I bought a box of animal crackers. On the side, it said "Do Not Eat if Seal is Broken". I opened the box and sure enough...

  12. #12
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    In My Humble Opinion! IMHO!

  13. #13
    Senior Member
    Join Date
    Feb 2002
    Posts
    375
    Well for those of you who are interested, I found the answer. I asked a guy I work with (maybe I should have done this in the first place, he's a bit of a smart bugger) and he said my code is fine. Supposedly I am referring the variable to a string or something like that? so he said all I need to do is put square brackets around the T and L like so:

    code:
    myText= MyVars[T];
    mySlide= MyVars[L];



    Now it works!

  14. #14
    Senior Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    135
    I was interested.
    Well done for all the :bumps: it helped me out
    Tim
    For solutions to climate change visit www.gci.org.uk

  15. #15
    Senior Member
    Join Date
    Dec 2000
    Posts
    213
    Hey guys..

    What is so shaky with the code.. just wondering how it can be improved.. you guys are the experts.

    Thanks

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