Solved

FLash and File PRocessing

Posted on 2003-11-19
8
202 Views
Last Modified: 2010-04-03
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.

0
Comment
Question by:Fatlog
  • 5
  • 3
8 Comments
 
LVL 2

Expert Comment

by:Mikehd
ID: 9781581
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=
0
 

Author Comment

by:Fatlog
ID: 9785841
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?
0
 
LVL 2

Expert Comment

by:Mikehd
ID: 9787600
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...
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Fatlog
ID: 9795784
could you give me an example of this??
0
 
LVL 2

Expert Comment

by:Mikehd
ID: 9797254
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=








0
 

Author Comment

by:Fatlog
ID: 9797503
is it possible to read in one line at a time instead of the whole document?
0
 
LVL 2

Expert Comment

by:Mikehd
ID: 9797560
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=
0
 
LVL 2

Accepted Solution

by:
Mikehd earned 50 total points
ID: 9810931
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
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question