dcsimg
A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Dynamic text in flash AND standard HTML

  1. #1
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377

    Dynamic text in flash AND standard HTML

    Hi,
    I just finished a flash site for a client that loads a dynamic txt file for each page. The client would now like to have a simple HTML version of the site for slower users. My question is..

    Is there a way to have the txt file shared between the flash site and the HTML version? This would be nice for the client so they would only have to update one file instead of two everytime there was a change. I tried using an 'iFrame' to call the txt file but I couldn't format the text. Any ideas?

  2. #2
    Flash Vet
    Join Date
    Oct 2000
    Posts
    19
    I recently completed a site for Goodwill that is same as what you're talking about. Check out: http://www.goodwillsew.com

    At the bottom of the page there is a link that takes you to the text version which has all the same content.

    I am using ASP to dynamically load the content to each page. If you are using .txt files, that might be slightly trickier. How is your text file formatted?
    Check out www.FakeSports.com!

    Make it a Piece of Cake!
    www.mypieceofcake.com

  3. #3
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377
    Hmmm, my web host doesn't support ASP - just PHP and Pearl. Anybody have any other ideas? Thanks.

  4. #4
    Senior Member webcorps's Avatar
    Join Date
    Jul 2000
    Posts
    264
    no, the method should be the same for php and asp on the flash end...

    if you want to use the loaded file, I suggest you change your text files to html and select the html option on the flash dynamic text field. This way you can also call that html page within another through php by passing the variable and displaying the content that way. I wish I knew more about php to help you further, but I dont.

  5. #5
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377
    does anybody know how to accomplish webcorps idea?

  6. #6
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377
    still not having much luck on this one. Any other ideas out there?

  7. #7
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi you just need to write some PHP to read the contents of the text file (check http://uk.php.net/manual/en/function.fread.php ) once PHP has this information it can then be displayed with some simple html/css

  8. #8
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377
    Catbert,
    Thanks for the link above. It looks simple enough but I can't get it to work. Would you mind looking at my html below and tell me what I'm doing wrong? Thanks.

    Code:
    <html>
    <head>
    <title>Test PHP</title>
    </head>
    <body>
    <?php
    // get contents of a file into a string
    $filename = "/home.txt";
    $handle = fopen ($filename, "r");
    $contents = fread ($handle, filesize ($filename));
    fclose ($handle);
    ?> 
    </body>
    </html>

  9. #9
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    You would need to echo the content of $contents to display it in the page, however this would just show the exact contents of the file including the variable names used within it.

    A simple fix could be something like this,

    Code:
    <html>
    <head>
    <title>Test PHP</title>
    </head>
    <body>
    <?php
    // get contents of a file into a string
    $filename = "/home.txt";
    $handle = fopen ($filename, "r");
    $contents = fread ($handle, filesize ($filename));
    fclose ($handle);
    
    // an array to store the variables found with home.txt
    $homeVars = array();
    // take the contents of home.txt and store the variables within it in $homeVars
    parse_str($contents, $homeVars);
    // now loop though $homeVars and write each variable to the page (add extra html/css formatting as needed)
    foreach ($homeVars as $h) {
        echo "<p>$h</p>";
    }
    
    ?> 
    </body>
    </html>

  10. #10
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377
    hmm, sorry catbert I still can't get it to work. The text I am calling is in the same folder as my html doc. I tried a direct path to it and it still didn't work. The variable name in the home.txt is 'home'. So the home.txt file looks something like..

    home=My home text here. blah blah blah.

    Am I doing something wrong? Thanks again for the help.

  11. #11
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    if the file home.txt is in the same directory as your PHP page maybe try changing the $filename variable to be,

    $filename = "./home.txt";

    perhaps you could also try some error checking to see if there is an error attempting to open the file by replacing,

    $handle = fopen ($filename, "r");

    with

    PHP Code:
    if (!$handle fopen ($filename"r")) {
        die(
    "couldn't open file");


  12. #12
    eveningtidemusic.com tristankelley's Avatar
    Join Date
    Jul 2003
    Posts
    377
    got it! Thanks Catbert, you've also got the solution!

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