A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: dynamic test using text file

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Posts
    24

    dynamic test using text file

    I am new at flash so please bare with me. I am trying to load names, adddress, and a link from a text file. I wanted to start from the last person and display this information, along with a clickable link to their website. How would I go about doing something like this?

    I have read a few thread when they say that they have taken a dynamic txt and placed it within a movie. What exactly does that mean?

  2. #2
    That web bloke Stoke Laurie's Avatar
    Join Date
    Jan 2006
    Location
    England
    Posts
    869
    If you click on help in Kool moves, and search on dynamic text you should find all you need. If you need more help beyond this come back here and we should be able to answer your specific question.

  3. #3
    Super Moderator
    Join Date
    Jun 2000
    Posts
    3,512
    If you want the entire contents of the text file to be loaded into a dynamic text object, you can use Load Dynamic Text action. If you want pieces of the file to be loaded, it is a very different story.

  4. #4
    Junior Member
    Join Date
    Feb 2006
    Posts
    24
    Quote Originally Posted by Bob Hartzell
    If you want the entire contents of the text file to be loaded into a dynamic text object, you can use Load Dynamic Text action. If you want pieces of the file to be loaded, it is a very different story.
    I guess I would be in the different story category. I would need it to bring in three variables of data at a time and then wait 5 secs and then go to the next one in order.

  5. #5
    That web bloke Stoke Laurie's Avatar
    Join Date
    Jan 2006
    Location
    England
    Posts
    869
    If these variable have fixed names, simply create a dynamic text box, and in the configuration pannel give the text box that variable name. Do this for each of the variables. Set the frame to run for the required time then on the next frame set up a return to the origonal frame and your variables will refresh.

  6. #6
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Sounds like he wants to page through three entries at a time from an array of many. Paging.

  7. #7
    Junior Member
    Join Date
    Feb 2006
    Posts
    24
    Quote Originally Posted by Stoke Laurie
    If these variable have fixed names, simply create a dynamic text box, and in the configuration pannel give the text box that variable name. Do this for each of the variables. Set the frame to run for the required time then on the next frame set up a return to the origonal frame and your variables will refresh.
    Won’t the variables start at the beginning of the text file if I tell it to goto the 1st frame?

  8. #8
    Junior Member
    Join Date
    Feb 2006
    Posts
    24
    Quote Originally Posted by Chris_Seahorn
    Sounds like he wants to page through three entries at a time from an array of many. Paging.
    Yes, the correct. Data might look like something like this.

    47. Joe Tell City, IN www.yahoo.com
    46. fred Lombard, Il www.deathtouchhorrors.com
    etc....

    It might have to bring the data in three or four at a time if you could the number. Which just says when they were entered into the database.

  9. #9
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    entered into the database.
    Database. You pulling the main array from MySQL? If so...post your table structure (dump it from phpmyadmin or similar) but DO NOT POST THE DATA. I only need the table structure...not the data.

  10. #10
    Junior Member
    Join Date
    Feb 2006
    Posts
    24
    Quote Originally Posted by Chris_Seahorn
    Database. You pulling the main array from MySQL? If so...post your table structure (dump it from phpmyadmin or similar) but DO NOT POST THE DATA. I only need the table structure...not the data.
    No, I am sorry. I didn't mean database as far as MySQL. I am not ready for that yet. I am just planning on using a txt file.

  11. #11
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Then I'm sure someone will post a solution. This way they know what you want and you can also search "paging" or similar in flash.

    I would also explore xml since your entries have attributes. Both are fitting and can run locally. Good luck!

  12. #12
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    You could use a csv file to store the data.
    Here's a thread about it
    http://board.flashkit.com/board/showthread.php?t=681535

    When you have all entries in an array you can use the onEnterFrame or setInterval to create a 5 sec timer that will loop through the array and display one record at a time.

  13. #13
    Junior Member
    Join Date
    Feb 2006
    Posts
    24
    Ok, I have learned a little bit about doing dynamic text. I have an small example here. www.gravemaker.info I was able to take 3 names into the spot from a txt file. Now, is there a way to name each one of the fist like txt1,.....txt26 and then use a for next statement to count down from 26 to 1. So I can copy the variable in txt26 and put it in the dynamic text box. And just go down the line to 1. How would the foumula be for something like that. Would it be like A = txt(t) with t being the for next statement? Probably won't work if it is a direct address. Anyone have any suggestions?

  14. #14
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    I don't know exactly what you want to do but here's a little example that shows how you could use a for loop.
    Code:
    myData = '1,5,3,6,8,5,3,54,7,12,6,84,34,89,0';
    
    myDataArray = myData.split(',');
    
    createTextField('myTextField',1,0,0,100,50);
    myTextField.wordWrap = true;
    
    for (i=10;i>0;i--){
     myTextField.text += i + '=' + myDataArray[i] + ' ';
    }

  15. #15
    Junior Member
    Join Date
    Feb 2006
    Posts
    24
    Quote Originally Posted by w.brants
    I don't know exactly what you want to do but here's a little example that shows how you could use a for loop.
    Code:
    myData = '1,5,3,6,8,5,3,54,7,12,6,84,34,89,0';
    
    myDataArray = myData.split(',');
    
    createTextField('myTextField',1,0,0,100,50);
    myTextField.wordWrap = true;
    
    for (i=10;i>0;i--){
     myTextField.text += i + '=' + myDataArray[i] + ' ';
    }

    I guess my data would look something like this.

    &txt29=Mark Sloat
    &tit29=Lombard, Illinois
    &txt28=Joe Smile
    &tit28=Chicago, Illinois
    Etc....

    I have it setup in mine that txt would be setup for html so I can link that to a site.

    I guess I was hoping that I could have a var a= 29 or total number of entries and then have a for next statement count down to 1 as it is printing out these variables.

    Like txt(t) and tit(t) t being the for next loop.

    Can I do it this way?

  16. #16
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Code:
    for (t = 29; t > 0; t--){
     myTextField.text += eval('txt'+t) + '\n';
     myTextField.text += eval('tit'+t) + '\n';
    }
    + '\n' is used to add a newline character.

  17. #17
    Junior Member
    Join Date
    Feb 2006
    Posts
    24
    Thank you very much W. Brans. Is there a dwell time I can put in there or some type of wait time?

  18. #18
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    You can use an interval
    Code:
    tt = 29;
    t = tt;
    
    display = function(){
     myTextField.text  = eval('txt'+t) + '\n';
     myTextField.text += eval('tit'+t) + '\n';
     t--;
     if (!t) t = tt;
    }
    
    display();
    
    setInterval(display,2000);
    This one uses an interval of 2 seconds.

  19. #19
    Junior Member
    Join Date
    Feb 2006
    Posts
    24
    Ok, so I got it to work with the code below, but I tried to put the variable tx=10 into the txt file and relay that information to tt but it didn't work. I think that the code thinks it as ascii, so tt=tx; isn't the way to do it. I guess I need to change tx into a string. How would I do that?



    tt = 10;
    t = tt;

    display = function(){
    top = eval('txt'+t) + '\n';
    bottom = eval('tit'+t) + '\n';

    t--;
    hot = t + 1
    if (!t) t = tt;
    }

    display();

    setInterval(display,4000);

  20. #20
    Junior Member
    Join Date
    Feb 2006
    Posts
    24
    I just wanted to thank everyone for their help. I got it work. I got the variable to work by enclosing it in &....&. It had no problems after that. www.gravemaker.info

    Now I just need to be able to switch from reading it from a text file to database. I am able to read all the variables in, I just need to reformat, I guess.
    Last edited by msloat; 07-14-2006 at 06:15 AM.

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