A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 41

Thread: External TXT file ONLY on specific dates

  1. #1

    External TXT file ONLY on specific dates

    Hello everyone!

    Have a few questions, i'm not much cop with the programming side of flash so youll have to treat me like the stupid monkey i am!

    So, for my latest task at work, oh what joy, i have to create a small banner thing which reads data from a text file... BUT... it only reads from the text file IF there is a text file present which i labeled TODAYS date!

    So i was hoping someone could help me do the following...

    Get todays date
    IF there is a file present in a certain directory which is called todays date.txt (ie. 02042006) then it reads the info in that text file and prints it into a certain area in the flash file.
    If there is nothing present it just displays the default stuff!!


    Hope that makes sense! Thanks SO MUCH for your help!

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Im not realy sure how you wante dthe text file name to be formatted..

    day, month year? month, day, year? any kind of seperators? (I put dashes in mine so you can tell the different values.)

    Code:
    //Get DATE:
    myDate = new Date();
    date = myDate.getDate();
    month =["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
    year = myDate.getFullYear();
    file = month[myDate.getMonth()]+"-"+date+"-"+year+".txt";
    trace(file);
    
    // Load text file of same name as DATE:
    myVars = new LoadVars();
    myVars.onLoad = function (success) {
    	if (success) {
    		_root.textBox.html = true;
    		_root.textBox.htmlText = (myVars.info);  //info = variable in text file
    	} else {
    		_root.textBox.htmlText = "Error loading text file";
    	}
    }
    
    myVars.load(file);
    the ONLY thing Im not sure on is how to pull the OLD data back if not current data is there.. (maybe nothing..and the text field just wont update at all)

    this was fun for me..LOL

    thanks

  3. #3
    Thats so nice of you thanks!

    Ill check it out tommorrow at work and see how its goes! Thanks so much for putting your time in for no real benefit to yourself! Class A Person

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    no problem..lik I said I had fun..my first time with arrays really.

    still not sure how this part works...

    month[myDate.getMonth()]

    I man I understand the individual parts of it.. just not the variableName[var.function] part

    I think I'll ask about it.. LOL


    update: nevermind..I tink that is the index [] part of it (Im foolish) LOL

  5. #5
    Quote Originally Posted by whispers
    no problem..lik I said I had fun..my first time with arrays really.

    still not sure how this part works...

    month[myDate.getMonth()]

    update: nevermind..I tink that is the index [] part of it (Im foolish) LOL

    Hmm, hello again! And many thanks again! I have a dynamic text box where the content of the text has to go into, but at the moment it just says

    _level0.instance3.textBox xxxxxxxxxxxx CORRECTION, ignore, please read below!

    Any ideas? Do i need to change the name of the dynamic box, at the moment i called it textBox? Also, is there a way to change the date formatting so its shown the english way ( 4-1-2006.txt ) no big deal if i can't!



    THANKS!!!
    Last edited by domdino; 01-04-2006 at 07:40 AM.

  6. #6
    oh and finally... heres the FLA file currently that will probably make life easier so you can see what i'm doing, or not doing as the case may be!

    http://www.petendom.co.uk/portfolio/EADT.fla

  7. #7
    Here i am again, being a pest
    Its not putting _level0.instance3.textBox in the dynamic text box anymore after i whacked it down to publish for flash 5... i had to remove the instance name cos it wasn't supported, so i guess it has something to do with that!
    So... I need to figuire out how to print this text to that dynamic text box!
    Reuploaded the FLA: http://www.petendom.co.uk/portfolio/EADT2.fla

    Anyone online who can help out would be top notch!

  8. #8
    me again... haha... another thing unrelated to current problems, wondering if anyone knows if its possible to antialias text coming from an external source/dynamic text?

    Been trying to figuire out how the code works more now, and it seems to load the file but the section :

    // Load text file of same name as DATE:
    myVars = new LoadVars();
    myVars.onLoad = function (success) {
    if (success) {
    _root.textBox.html = true;
    _root.textBox.htmlText = (myVars.info); //info = variable in text file
    } else {
    _root.textBox.htmlText = "Error loading text file";
    }
    }

    myVars.load(file);

    Anyone know whats going on here? I'm trying to print it to a dynamic text box, and the text files do start with textBox=....any help? God i'm dumb. AKKK



    Thanks again and again againg.!!!
    Last edited by domdino; 01-04-2006 at 07:36 AM.

  9. #9
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    are you using FLASH 5?

    if so..none of this will work..you shoudl have stated that in the beginning.


    ALWAYS state your version of FLASh that you are using.. "AND" post code/.FLA when starting an initial post.

    or it just wastes EVERYONES time.


    also..if you LOOK at the code..and read the comments after the line..you will see that the text files has to have &info= NOT &textBox=


    _root.textBox.htmlText = (myVars.info); //info = variable in text file

    but you said you were using FLASH 5....didnt you? so this wont work for you anyways.

  10. #10
    hi again!

    Im using flash 8 but i'm publishing to flash 5, otherwise it might have compatability issues. Ill take another look at the text file thanks

  11. #11
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    you need to at LEAST publish to flash 6 (MX) and I doubt you'll have any compatibility issues there..maybe with flashplayer 8...9but even then it would say you need the newest plug-in)

    anyways... change the text file to be info= and publilsh/save as AT LEAST FLASH PLAYER 6 (MX)

    once we get that far..I'll show you how to chnage the file NOT loaded part to do whatever it is you want to accomplish!

    good luck Im on my way to work..so I wont respond for about an hour or so.

  12. #12
    if i put in
    _root.gotoAndStop("a frame number");
    instead of _root.textBox.htmlText = "Error loading text file";

    will that throw the flash to the right place if there is no text file present?


    I've put info= at the start of the text document now, still doesn't seem to be showing up... i named the text file 1-4-2006.txt and just put this inside it: info= TEST ETSTESRPOTMSPLKREMt

    Also tried it with &info= at the start but didn't seem to make any difference

    Sorry for being a dumby but i really do suck at coding anything :/

    And thanks again for taking time to help me out!

  13. #13
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    are still trying to publish to FLASH 5? Im telling you that is yoru problem..that code doesnt exsist in FLASH 5

    You are ALSO trying to talk/target a textField by a NAME!!! which didnt exsist in FLASH 5 either.

  14. #14
    I'm publishing to flash 7 now! ahhh... i really am dumb i'm so sorry...
    i didn't call the text box anything i just made the var= textBox...
    SORRY!
    Works now, kinda, only problem is the size of the font is huge but should be able to figuire that out somehow!

    THANKJYOU!!!

  15. #15
    HOORAY it works!!
    THanks SOOO much for your help!
    _root.gotoAndStop("a frame number");
    seems to work to!

    Dom!

  16. #16

  17. #17
    hiya, my question was just that the fonts weren't working properly...
    But i've discovered you have to embed them to get them to work if its dynamic text! Thanks for popping in anyway!
    Only other thing i want to be able to do now is simply make the file not appear if the user doesn't have flash, as opposed to telling them to install it, and i need to do it without editing the header of the HTML, just where the flash itself goes...
    Thanks again so much for all your help!

  18. #18
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    you can use some detection script/code in your HTML page that will detect this for you... and show an image (or whatever) insteadof the flash movie if the plyer is not deteteced.

  19. #19
    hello again...
    bit of a weird problem going on...
    the file is now at http://www.eadt.co.uk/content/eadt/default/EADT3.swf
    but sometimes the text doesn't appear, and it seems to be totally random whether or not it decides to appear.... this is the page it appears on: http://www.eadt.co.uk/content/eadt/d...efault_pp.aspx
    sometimes it loads the text file, other times it just ignores it and doesn't bother!? If it wasn't loading the txt file and showing the alternate message that would make sense but it just comes up blank..... hmmmmf. Confused!
    Dom

  20. #20
    is there a way to make it force load the txt file, or if for some reason it thinks the text file is blank revert to the other frame display or something? its really odd...

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