A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: simple load text question, i hope

  1. #1
    Junior Member
    Join Date
    Dec 2002
    Posts
    7

    simple load text question, i hope

    I am loading random quotes into a text field by aplying the following code onto Frame 1 of my movie:

    //

    stop();

    var word = new Array("quotes here",
    "quotes here",
    "quotes here");

    var randomWord = Math.floor(Math.random()*36);
    _root.text = _root.word[randomWord];


    //


    I would like to know how to load the random quotes from an external text file. And how do you set up the arrays in the text file?

    I'd also like to know if you can apply HTML tags to the text.
    ***I'd like a page break between the quote and the author's name.

    If you can help, I'll love you for it.

  2. #2
    feeling froggy
    Join Date
    Jul 2002
    Posts
    179
    for page breaks you can just use this : "\n"
    as for dynamically loading text:

    this is what your file will look like:

    quote0=blahblah blah&;quote1=blah blah blah&;quote2=blah blah blah

    minus the semicolon....sorry

    so, you can load them like this
    loadVariablesNum("data.txt", 0);

    and call them like this:

    var randomWord = Math.floor(Math.random()*36);
    _root.text = _root["quote" + randomWord];
    Last edited by norie40; 07-02-2003 at 12:47 PM.

  3. #3
    Junior Member
    Join Date
    Dec 2002
    Posts
    7
    I'm still getting a blank text box. Is there a problem with my .txt file?

    This is an example of the first two entries I have in the .txt file:

    quote0=Quote is written here.&
    quote1=Second quote goes here.
    Last edited by lell69; 07-02-2003 at 03:39 PM.

  4. #4
    Junior Member
    Join Date
    Dec 2002
    Posts
    7
    I'm still getting a blank text box. Is there a problem with my .txt file?

    This is an example of the first two entries I have in the .txt file:

    quote0=Quote is written here.&
    quote1=Second quote goes here.

  5. #5
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    your text file should look like
    &quote0=there is always a flash around
    &quote1=never lose your keys outside and lock yourself into the car
    &quote3=

    Also, make sure to call the random thing only after the textfile has really loaded

    Musicman

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