FLash and File PRocessing

Does Flash, more so ActionScript, have FIle Processing capabilities.

I know it can be done with any other technology such as Java Servlets/Applets or PHP but can Flash do it on its won.

FatlogAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MikehdCommented:
What do you mean by "file processing"?

Flash can read in a .txt file with variables if that is what you mean. the variables must be separated by "&" like this:

myVar1="hey now"&myVar2="testing"&   ect...

It can also accept xml

M=
FatlogAuthor Commented:
i mean if i had a text file and i wanted flash to access its contents with only actionscript

can flash open and read the contents of the file?
MikehdCommented:
Though I may be wrong, I believe flash can only read text files that are formated in the way I mentioned above.

with the & separating variables ect...
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

FatlogAuthor Commented:
could you give me an example of this??
MikehdCommented:
The simplest way is to use this

loadVariablesNum ("data.txt", 0);

this will load the data.txt on the root level of you movie. Note: This is assuming the data.txt is in the same directory, if the text file is in a different directory you will have to point it there of xourse.

the text file could be something like this:

&myVar1=whatever&myVar2=more whatever

Then in the flash movie just reference them with

_root.myVar1;
_root.myVar2;


There is one problem with this way. If you try to reference the variables before the data has finished loading, it won't work. If this happens then do it this way, still easy, but a tad more involved:


In flash:
create a movieclip on the stage and give it an instance name of, for example "dataHolder"

In the frame you want to load the data add this code:

loadVariables ("data.txt", "dataHolder");
stop();

This will stop your movie and load the data to the dataHolder movie clip.

Now, click on the movieclip "dataHolder", we are going to add a clip Event to this.

onClipEvent (data) {
    _root.gotoAndPlay(4);//or wherever
}

the "onClipEvent (data)" fires when data is finished loading. This has nothing to do with the text file name by the way.

Then just reference the variables like this:

_root.dataHolder.myVar1;
_root.dataHolder.myVar2;


If this doesn't make sense, I can email you a txt file and fla I set up to test all this.


M=








FatlogAuthor Commented:
is it possible to read in one line at a time instead of the whole document?
MikehdCommented:
The problem with that is that for this to work, there can't be any line breaks, so I think the answer is no.

In my test, if you put in a line break flash stops loading the file.

Flash does better with an xml document, but it is a lot more difficult, at least for me it is.

M=
MikehdCommented:
If you are interested in the XML way, here is a link to a question about it, and code is fairly simple:

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20806458.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.