View Full Version : text files
Hiya,
So, I know that Flash can import variables from a text file to parse as the movie plays. However, I have need to create a Flash project, and then hand it off to someone else (who knows nothing about Flash). They would be updating a news page weekly, and all other aspects of the movie would remain the same.
Basically, has anyone set Flash to pull a variable from a text file to parse into the movie? I was thinking that I can get them to type into Notepad, save/upload into the correct place, and Flash would be able to grab the 'variable' (the news update) and print it.
Now... when I do this, it would necessarily happen on one of two occasions:
1. When the movie is compiled/published. If this is the case, then it's a worthless technique for what I'm trying to do....
2. When the movie runs for the client. This is what I'm hoping..
:)
Anyone done this before? Any ideas? Problems? Suggestions?
TIA
If you set up a news update script you could overwrite the existing text file and it would read into the movie when called. This would show the new content whenever the browser reloads as long as the user has their browser set to check for a "new" version vs. cached. The other way would be to set up the new update script using php/mySQL and retrieve the data via a call to the database from the Flash movie. You can attach a randomly generated number to the request generated by the Flash movie which basically forces the browser to look everytime. This overcomes some problems that exist with the Netscape browser!
Both systems are possible and work quite nicely. I prefer the php/mySQL approach.
Hiya,
This response is kinda late so I dunno if you found a solution yet but have you considered using dynamic text boxes and a little action script?
You kinda mention it yourself, but heres what you do anyways.
When you make the flash file, use dynamic boxes for all the places where you want "updateable" news. The name of the dynamic boxes could for example be: "sportsnews" and "weather".
At the begin of the flash file put in this action script:
loadVariablesNum ("http://theirdomain.something/uploadfolder/"+somename+".txt", 0);
The news will then be in a txt file called "somename.txt", which your client can update and upload as she or he wishes. It will looks as follows:
sportsnews=Today's game was cancelled due to lack of players.&weather=Today is sunny and bright.
The only major drawback is that your client cannot use "&" anywhere in the normal news content since it is used by flash as a terminator to divide up the dynamic box contents.
Hope this help anyways,
flich
Actually, the ampersand (&) is used to designate a variable name in your text file. Like:
&news=blah, blah, blah
...sets the variable named news to the value blah, blah, blah inside your Flash script.
Hey, I've never tried it, but maybe a backslash in front of the ampersand would escape it. I doubt it, but it might be worth a try.
heheh I didn't know that about the "&".
Always thought it was the terminator.
Hehehe, it must just be flash' error checking or something that made my flash files work, because I never put a "&" before my first variable, since I thought it was a terminator.
Anyways since it is a variable designater, then I also would think that an escape character like backslash would work. At least that works with $ in PHP.
I would test it myself, but my free flashMX trial has run out. :(
flich
Maybe Flash lets you slide on that first variable since it's terminated by an equal sign. Dunno. So maybe you could think of it as a terminator/separator. (:>) Whatever works.
I always consider it a variable name thing because whatever text comes after, say "&puppysnot=", will show up in a Dynamic Text field with that same variable name.
I've got MX, but I still use 5.0 mostly. Even when I do use MX, I save to 5.0 format. I'm waiting for more people to get Flash 6 plug-in enabled, I guess.
hi flich
i just tried that flash txt update thing and it didnt work
is there something i missed here
is there more to this movie ??
im using flash5 by the way
hiya,
Did you:
Add the actionscript line to your movie?
Did you use the correct path to your text file?
Did you save the text file at right place?
Did you make sure you used dynamic boxes in your movie?
Did you make sure the name of the dynamic boxes matches the names you use in the text file?
Its kinda hard to debug your movie, without more info.
Anyways, I made a very simple sample movie, which has two dynamic boxes which loads its contents from a text file. I saved the fla file as flash 5 so you can use it.
Check it out here:
Text Reader Sample (http://jnwl.net/flash/index.html)
Btw, I tried escaping the "&" with "\", but that doesn't work.
Hope this helps!
flich
i added this
loadVariablesNum ("http://www.neutron1.com/"+somename+".txt", 0);
on the first and only frame of the movie
the text file is in the same directory
as the flash movie (htdocs)
the name of the dynamic text box is dBoxOne
the name of the text document is somename.txt
and contains this text &dBoxOne=Hello there this is box one
i couldnt find a .fla file anywhere in the zipfile
now i am confused lol
Sorry about that. Something went wrong during the zip.
I put up a proper zip file now.
Anyways, I think I know what the mistake is. Lol, and its my bad of course. :rolleyes:
The thing I forgot to tell you is that I used "somename" as a variable, so I could called different named text files. Since you don't pass the swf file a variable called somename, it can't find the file..dooh! :p
So in your case to make it work, use this line:
loadVariablesNum ("http://www.neutron1.com/somename.txt", 0);
Sorry about that!
flich
hey dont apologise
the .fla file works a treat
ive done my own version having copied the variables
i see it clearer now when i first tried it i missed out the
= sign in the text so nothing happened
hey but what a totally cool bit of script that is
ive made a few flash movies and i could have done
with this. when id updated a movie
leave one of those boxes on there set it to my site
http://etc etc
and just change the text saying update available "cool"
ill def be using this
thanks for your help
the most complicated thing i ever made with actionscript
is a search engine box
for google
actually that was cool too :)
cheers
Hey...
make sure you lable "give it a name" your Dynamic text area
to simply load a .txt file call the file using the name of the Dynamic text area and a = symbol...
Using the & is for multipul Dynamic text areas on a page each with diff names... so you only have one .txt file to call from and not several...
something like
http://www.flash-db.com
the example is like this
news=Today in ........ &weather= Today its 37c were i live ......&information=BlahBlahBlah.........
thats it...
Make sure you use the LoadVarNum and load the correct .txt file... on a button or entering a frame..
also if you enable HTML in the dynamic text area you can now embead html into the text areas... ex
links=<a href="http://www.xxx.xxx" target="_blank">Click Here</a><p> so forth and so forth.... Good luck... Its a handy tool for quickly updating an entire site.
hi
thanks for that info wpgwave
the first thing i did when flich told me about
all this was tick the html tag in the text box
and paste a page in it but it had no affect
i didnt think to make an actual link in there i just put in
a background colour of red and when it did nothing
and the html didnt appear
i assumed it wasnt going to work but yes ive just tried it
a few times and found you dont need to add the tags
<html> <body> etc
to get a link "brilliant" i get what the html box is for now
on another subject do you know how to
pass html from a textbox to a web page
so you could have a little web page builder
in flash ??
p.s. thanks for the info :)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.