Solved

FLash and File PRocessing

Posted on 2003-11-19
8
194 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
 

Author Comment

by:Fatlog
ID: 9795784
could you give me an example of this??
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HTML 5 or Flash 7 476
YouTube Link 10 347
free flash maker 5 197
Could you point a workaround on how to open this Adobe Flash documents? 5 101
This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now