Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

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.

0
Fatlog
Asked:
Fatlog
  • 5
  • 3
1 Solution
 
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=
0
 
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?
0
 
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...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
FatlogAuthor Commented:
could you give me an example of this??
0
 
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=








0
 
FatlogAuthor Commented:
is it possible to read in one line at a time instead of the whole document?
0
 
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=
0
 
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
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now