Solved

FLash and File PRocessing

Posted on 2003-11-19
8
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

632 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