Loading ARRAY From A Text File ?
Is it possible to load an array from a text file ???
Thanx for your help !
FlashKit > Flash Help > Flash MX
Posted on: 10-28-2002, 10:18 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Loading An Array Of File Names From A Text File.
Basically I want to do the following.
Create an array of
Image[x] = "x.jpg"
from a text file where the images are listed as
x.jpg
y.jpg
z.jpg
I can't figure out how to load these in an array and I haven't been able to produce this from the closest examples I have found.
Any suggestions?
Loading Text File Into Array
Hi all.
I've been looking around for ages and can't see how to do this, so I hope someone can help.
I have a dictionary.txt file that lists a word on each line. I want to load each word into an array so that I can then do checks against it. Y'know. spellchecking type thing.
I read alot but everything I come across is about XML. I managed to load the file using URLLoader but the rest of the info is how to process XML not text.
I've managed to load the text like this...
ActionScript Code:
//initLoader()
private function initLoader(){
theLoader = new URLLoader();
var theRequest = new URLRequest("dictionary.txt");
theLoader.load(theRequest);
theLoader.addEventListener(Event.COMPLETE, loadComplete);
}
// loadCoplete()
private function loadComplete(theEvent:Event){
xml = new XML();
xml = XML(theEvent.target.data);
trace(xml);
}
the trace traces the entire file. So now I just want to get each line into seperate elements of an array.
Can anyone help? Pretty please
Loading Data From A Text File Into An Array?
I thought I had it working but alas no I don't.
I've got an Array called
mun = new Array();
I some dynamic text fields that I have called mun[0] mun[1] and so on....
I have a text file that has
mun[0]=Toronto&mun[1]=Barrie...and so on
when I run my flash file I can see that the textfields get filled in with the loaded data properly but I also have a button that when you rollover it, it executes the action
municipality = mun[0];
I have a text field named municipality but it seems my rollover doesn't work with the loaded variables.. But it does work when I create the array within flash...
mun = new Array("Toronto","Barrie");
Help me pleasee....
thanks
Jason
Loading In A Array Of Values From A Text File
OK, I think I know how to load values using the loadVar command...but how do I go about loading an array of values from a text file? For example, the text file will be this format:
name = file1 size = 10 descrip = roses
name = file2 size = 12 descrip = tulips
name = file3 size = 13 descrip = daisies
And so I want three arrays, name[], size[], descrip[] to hold all these values...how do I set that up? And the code to do the loading from the textfile would be nice, newbie that I am .
Loading In Array Data From A Text File.
I'm trying to use a text file to load in some configuratin data (using actionscript 3) I have it working ok for simple stuff like gamename=Chess&gamescore=100 , etc... but some of the data needs to be in an array. Can someone please point me in the right direction to how I can read in an array from a text file?
Thanks!
Loading Numeric Array From Text File.
var inc = 0;
move = new Array(100,105,110,115,120);
onEnterFrame = function()
{
inc += 1;
_root.mc1._x = move[inc];
if(inc > 4) {inc = 1};
}
__________________________________________________ _____________
The code above works fine and mc1 moves. But I'm attempting(erm? failing) to load the data in the array from a text file in the same directory as the swf. The code below doesn't work.The text file loads and the string of values and commas look correct in a textfield. But the var's are not getting passed to the array, which remains undefined.
__________________________________________________ _____________
var inc = 0;
var loadDataFromText = new LoadVars();
loadDataFromText.onLoad = function(ok)
{
if(ok)
{
loadedData = loadDataFromText.myData;
move = new Array(loadedData);
}
}
loadDataFromText.load("file.txt");
onEnterFrame = function()
{
_root.mc1._x = move[inc];
inc += 1;
if(inc > 10){inc = 1};
}
_______________________________________
The data in the "file.txt" is formatted like this...
&myData=100,105,110,115,120
Please help. Where am I going wrong?
Loading Variables Into An Array From A Text File
hello fellow flashers
i've been asked bya a friend to make a flash movie that shows a list of words on the stage, one by one, each filling the stage as much as possible.
my original idea was to make individual textfields for each word (custom sized to spread them accross the stage) and place each textfield in their appropriate frame, letting the file fly swiftly over each one. but i've been wondering if there is a smarter alternative.
i'm fairly new to ActionScript, so i'm not familiar with many of its terms and restrictions, but lately i've made some progress and came accross the loadVariables method. is there a way to use this method or something like it to load a list of words in a text file into an array? i was thinking that afterwards i could simply make a loop that went along the array printing the words on the screen, instead of making the million and a half textfields i was talking about. of course, that would still leave me with the stage-covering dilemma, but it would certainly be a start... :-P
thanks for the help
(yay! first post! hi mom!)
Loading Data From Text File To Multidimensional Array
New to Actionscript here so please bear with me, I'm trying to learn. I'm developing a simple application which loads specific information based on user input. The code below works fine and does exactly what I want, however, I want to be able to load the raceInfo multidimensional array information from an external text file. I've read alot about doing this but have not been successful and am somewhat frustrated. Can someone help me and teach me how to get that information from a text file? Thanks in advance!
//Multidimensional Array
raceInfo=[["1","Bob Smith","Fast","Slow as Lightening"],["2","John Doe","Speedy Car","Running Fast"]];
var testText1 = testText1_txt.text;
var testText2 = testText2_txt.text;
//trace(testText1);
//trace(testText2);
loadBtn.onRelease = function () {
for(i=0;i<raceInfo.length;i++) {
if(testText1 == raceInfo[i][0]) {
_root.createEmptyMovieClip("container1",1);
container1.loadMovie("/scoutpics/" + testText1 + ".jpg");
container1._x = 150;
container1._y = 150;
scoutName1_txt.text = raceInfo[i][1];
carNumber1_txt.text = raceInfo[i][0];
carName1_txt.text = raceInfo[i][2];
slogan1_txt.text = raceInfo[i][3];
}
}
for(i=0;i<raceInfo.length;i++) {
if(testText2 == raceInfo[i][0]) {
_root.createEmptyMovieClip("container2",2);
container2.loadMovie("/scoutpics/" + testText2 + ".jpg");
container2._x = 650;
container2._y = 150;
scoutName2_txt.text = raceInfo[i][1];
carNumber2_txt.text = raceInfo[i][0];
carName2_txt.text = raceInfo[i][2];
slogan2_txt.text = raceInfo[i][3];
}
}
resetBtn.onRelease = function () {
testText1_txt.text = "";
testText2_txt.text = "";
container1._visible = false;
container2._visible = false;
scoutName1_txt.text = "";
scoutName2_txt.text = "";
carNumber1_txt.text = "";
carNumber2_txt.text = "";
carName1_txt.text = "";
carName2_txt.text = "";
slogan1_txt.text = "";
slogan2_txt.text = "";
}
}
[MX04] Loading Variables From Text File Into Array And Combo Box
Haven't been here for a while, but I will try and reciprocate any help.
I'm loading a long list of variables from a text file (delineated by "|" and line breaks) into an array, and populating a combo box dynamically. Everything works fine locally, but when playing off of the server, only the first line is loaded from the text file.
This code is running in the first and only frame of a child movie to the root. I've experimented with moving the code to the root, over multiple frames, and using loadVariables with onLoad--all variations work locally but not on the server.
-----------------------
_lv = new LoadVars();
_lv.onLoad = function() {
// clean up text sting
var_temp_array = unescape(this).split("=&onLoad=");
var_temp_string = var_temp_array[0].split('
').join('
');
// make array
var_temp_array = var_temp_string.split('
');
_global.devs = new Array();
for (a=0; a < var_temp_array.length; a++) {
devs.push(var_temp_array[a].split('|'));
box.cbNew.addItemAt(a, (a+1)+". "+devs[a][1], a);
}
}
_lv.load("data_post.txt");
---------------------
Any help is much appreciated.
Load Variables From Text Then Loading Image File With The Filename Given In Text File
The problem is, that i need flash to load variable from text file, eg: info.txt, with image=gt.jpg in it.
Then I want flash movie to load a gt.jpg into a blank movie.
The point is that after i change filename in txt file, i want movie to load that img.
I wrote AS:
loadVariablesNum("info.txt", 0);
loadMovieNum(image, 0);
but it's not working
After i traced variable image, debugger showed that this variable undefined, but if i put textbox with image as variable, it shows "gt.jpg".
Please help
Please Help W/ Loading Array From Txt File
I have this array:
move = new Array("c1+1", "p2=4","c1=3", "p4=3","cT+1","p8=2","c5+1");
How can I load this from a txt file?
I use loadVariables and it doesn't load anything.
Loading .txt File Into Array
I have a .txt file that looks like this (there's hundreds more numbers, i just listed the first few):
&pubVals=
30838
30848
107683
112636
689454
690334
etc...
I'm able to place all these numbers into an Array, and when I trace the Array I see all the numbers. But when I trace the Array's length it's only one. What am I doing wrong?
code:
var pubArray = [];
var lv = new LoadVars();
lv.onLoad = function(ok) {
if (ok) {
pubArray = this.pubVals.split(" ");
//trace(pubArray);
trace(pubArray.length);
for (i=0; i<pubArray.length; i++){
//trace(pubArray[i]);
}
}
};
lv.load("site_ids.txt");
Array -- Loading From .txt File
I've been trying to use the example from the actionscript.org library, namely:
Code:
Array.prototype.fromFile = function(file) {
this.__proto__.__proto__ = LoadVars.prototype;
this.load(file);
};
produce = [];
produce.fromFile("array.txt");
for (i=0; i<produce.length; i++) {
produce.sort();
trace(produce[i]);
}
My array.txt looks like this: &produce=milk, bread, water, oil&eof=true
When I go to Debug/List Variables, I can see the variables loaded from my text file into level0. But when I try to do the trace action in order to see the contents of my "produce" array, I see nothing in the output window. What am I doing wrong?
Loading Array From .txt File
Hi,
Im having trouble trying to load in some external variables. I am trying to load a multidimensional array from a .txt.
The txt is formatted like this:
&deck[0]='card1',80,10,70,40
&deck[1]='card2',40,90,10,70
&deck[2]='card3',10,10,10,10
&deck[3]='card4',60,20,95,30
I am thinking maybe this is not possible? I have tried making the array, then loading the variables, I have tried making the deck a loadvars object. nothing seems to work.
Can anyone shed sme light on this for me?
Thanks
Loading An Array From .txt File
Hello Kirupians!
I'm currently trying to figure out how to load an array from a .txt file into my flash presentation.
The point is that people need to be able to edit a list of products without needing the .FLA movie (or they will mess it up).
The .txt file looks as followed:
PHP Code:
[["Company1","3"],["Brandname1","Productname1","Productname2","Productname3"],["Brandname2","Productname1","Productname2"]],[["Company2","4"],["Brandname1","Productname1","Productname2"],["Brandname2","Productname1","Productname1"]]
And this is where I want it to be.
But I know I can't just open a file and put it down there, so does anyone have a suggestion how to do this?
PHP Code:
var LIST:Array = [ *SHOULD BE IMPORTED HERE*];
I would REALLY appreciate it.
Thanks a lot in advance,
Ferdi
Loading XML File Through Array
Hi to all,
I created a two button back, previous and also dynamic text box. When i click on the next button dynamic text box text have to change for xml array according to back and previous button click.
Please help me are give some code
Thaks in advance
Array Loading From Txt File
i load an array from txt file with loadvariables command;
first write a container variable and comma seperate array variables;
foo=123&den=a,b,c,d,e&foo2=345
then load it within first frame. 3. frame split container variable to an array;
larray=den.split(",");
i hope it help someone.
Osman
Loading An Array From An External File
Hi there
does anyone know if it is possible to load an array of data into flash from an external text file. Basically what I want to do is have one or multiple files with contact details that anyone else can easily update, and pull in those details on a flash map, so when you click on a region, the contacts there will show in a text field. There may be between 10 and 20 contacts in each region, and I want it to loop through the array, see how many there are and list all of them in the text field. Is this easily do-able?
Cheers
Sam
Problem Loading From File Into Array?
I have an array in my script that I create like so:
ActionScript Code:
this.pArray = ["1.jpg", "2.jpg", "3.jpg"];
Now I want instead to load the array values from a file. So I replaced the above lines of code with those below, but the arry now comes up as undefined. How can I get the values from the file into this.pArray?
ActionScript Code:
myLoadVars = new LoadVars();
myLoadVars.load("slides.txt");
myLoadVars.onLoad=function()
{
for(i=0;i<2;i++){
this.pArray[i] =_root.myLoadVars["pic"+i];
}
}
[AS3] Loading 2D Array From External File
Hello,
This is not really a question about loading, its a question about saving. Lets say I have this 2D array, used in a certain project of mine, and I want to be able to load it from an external file later on, so naturally I'd place it in a file of my choosing, but what would be the easiest to deal with, from a loading perspective*? Should I save it as a XML file and modify it in any specific manner, or perhaps just raw data in a .txt document? Other suggestions are welcome as well.
* Meaning, if I saved it as raw data (for example) I could get to do more complex parsing than dealing with XML.
Thanks for your time.
Loading Images Into An Array From An External File
Hey, this has probably been asked before but I got an external file that has some URLs for some images. I want to load the images into an array so I can easily advance the array and place the images where they need to be.
I just need help with importing the images from the text file and what the text file should contain.
Thanks
Loading Data Into Flash Array From An XML File
Hi,
To keep things simple I will just ask the question verses explaining why I want this functionality.
Say I have:
var sString:String = "1,2,3,4,5,6"
var aArray:Array = new Array(sString)
When I trace the aArray.length, obviously it is 1. What I would like is if aArray would see the string as if I did this:
var aArray:Array = new Array("1","2","3","4","5","6")
I understand that I could run a for loop on the string and with each iteration put in the data, but this seems sloppy, is there a better way?
Thanks,
waffe
Loading Data Into Flash Array From An XML File
Hi,
To keep things simple I will just ask the question verses explaining why I want this functionality.
Say I have:
var sString:String = "1,2,3,4,5,6"
var aArray:Array = new Array(sString)
When I trace the aArray.length, obviously it is 1. What I would like is if aArray would see the string as if I did this:
var aArray:Array = new Array("1","2","3","4","5","6")
I understand that I could run a for loop on the string and with each iteration put in the data, but this seems sloppy, is there a better way?
Thanks,
waffe
Loading JPEG File Name In An Array And Using This As Para For LoadMovi
I am trying to make a photo album, but I just do not want to add images expilicitly... I want them to come out of an array.... and moreover I need to use the LoadMovieNum method to access the Images.
It wuould be great If i did not have to load the pictures in the Arrray too.... it should be dynamic there too.. I mean that It should take all the Jpeg files form a particular Dir. and load in it in the array.
Sleepless nights because of this,
Thanx in advance
Arash.
Text File Into Array
All Right, I am building this sweet thing, I will post the .fla soon. I have a text file I want to turn into an array.
For example I have in the current fla
a = "one.swf"
b = "two.swf"
c = "three.swf"
movies = New Array = (a,b,c)
But if I wanted to add a d = "four.swf" I would have to open the .fla and change it up, is there a way where I can have a text file. I think it would be something like
&one.swf&two.swf&three.swf, Correct me if I am wrong on that.
Then I would like to loadvariable movies.txt then splice each "&" so, when it read the text file the swf know that
movies= New Array(movie.txta,movie.txtb,movie.txtc)
Thank in Advance,
JuniorWil
Text File To An Array
hi,
if I want to load a text file and use its contents to populate an array what is the best way to go about it?
mark
Text File >> Array ?
Hi
How can I read from a text file and store each line in an array position?
I am working on a movie that allow scripting and would like to store the script outside...
Thanks!
Text File Into Array
I have read this text in one forum.
I have try but it didnīt work. can you tell me why? or can you make a source file ? i want to load a text file(*.txt) into an array
[i]Be sure to put the load variable action on the second frame instead of the first or flash will not load the values.
Then on the 3rd frame, add in the array functions.
To summarize a more cleaner code:
In text file put.
Code:
value1="My"&value2="First"&value3="Array!"
Frame 2:loadvariable("array.txt", 0)
Frame 3:
Code:
for (i=1; i<4; i++) { myarray = new Array() myarray[i] = this["value"+i] trace (myarray) } stop ();
From Text File Into Array & Integers
External Text file
task1=10,20
Code
task1=task.split(",");
How do I get the split values into a array? I've tried EVERYTHING. This is annoying the hell outa me. PLEASE HELP
Array For Saved Text File ?
Hello,
Could anyone point me in the right direction for saving multiple text files with a single button? I can populate a single form with several different variable txt files with diff buttons, but on that form, I would like to be able to save the information that is loaded to the correct variable file with one button. I do not understand the use of arrays well. I was thinking that I could assemble an array of the text files, but not sure how to code the button to detect which text file is loaded and to be saved to. Thinking out loud..........
Array of txt files to be loaded
Code:
myInfo = new Array();
myInfo[0] = "A1.txt";
myInfo[1] = "A2.txt";
myInfo[2] = "A3.txt";
myInfo[3] = "A4.txt";
myInfo[4] = "A5.txt";
Then to load the variable text file, depending on which button is selected.......
Code:
on (release) {
loadVariablesNum ("myInfo[0]", 0);
}
Then, to save it to the correct variable txt file if information is updated or changed.........
Code:
on (release) {
fscommand ("save", "myInfo"+".txt");
gotoAndPlay ("DELAY");
}
I am not real sure how to use the array information in the button code. It works with a single txt file without an array, ie (fscommand ("save", "A1.txt");, but how to use multiple txt files with one dynamic save button?
Thx in advance for any ideas
Regards
~GD~
Importing Array From Text File
Hi all,
I'm trying to import an array from a text file
the array is written as such
myArray=[a,b,c,d,e,f,g]
when I "LoadVariablesNum" it loads the variable as, I think, a string. ie if you then trace myArray.length it gives 15, which is the number of characters including brackets and commas.
can anyone tell me how to import the thing properly?
thanks in advance
Output Array To Text File
This seems like it should be really basic, but is there any way to output an array created in flash to a file that can be read by an external script?
I am using flash 5.0. I have checkboxes generating boolean values that that are then organized into an array, and I have a script that will parse through that data and use it to do great things. The only problem is that I do not know how to access the array that I am creating. Any information someone can offer will be so helpful. I am left with this feeling that the answer is painfully, painfully simple.
thanks,
J
Saving Array To A Text File? Help
I've just finished a Flash project that collects data throughout its runtime and stores it all in an array. My question is how I can access that information. I've spent hours today trying to figure out how to save it to a text file, but I don't think it's possible (is it?). I've seen people talking about back ending with PHP (or something like that?). The thing is that I'm pretty far at the beginner stage of programming (started three weeks ago), and I have no idea what that means or how to do it. So would someone mind explaining to me how I can access the text in this array? Thanks!
[F8] Writing An Array In A Text File
I am trying to read in a text file into flash 8. I want to read in the text file so that flash recognizes it then the output product is the same text but in flash. How do I accomplish this?
[F8] Load Array From Text File
Im trying to load an array from a txt file into my flash game (tile based). But the map just wont build, is there something special i have to do?
Importing An Array From A Text File?
Hi All
is it possible to import an array variable from a text file?
lets say i have
myarr=[["dave","jones",20],
["steve","smith",30],
["bob","wilkes",15]]
now could i have a text file with just the delimited values then import that into flash some how to build up the array?
I know i could do it like
name1=dave&sur1=jones&age1=20&name2=steve....etc.. .
but then the text file just looks harder to manage than the array itself
Does anyone know of a way of just being able to read in comma delimted data or am i asking too much?
regards
Harvey
Load An Array From A Text File?
I am trying to create a Flash File that displays current standing of teams in the local area.
The Flash file currently has an array that it pulls data from in the format of school name, wins, losses, and rank... i.e....
array1 = [["SchoolA",9,0,1],["SchoolB",6,3,2],["SchoolC",5,4,3],["SchoolD",1,8,4],["SchoolE",1,8,4]];
The Flash file works great, however, the person updating the weekly standings does not have Flash on their computer. I need them to be able to update the standings without opening Flash. The best way I could think of to do that was to have the array load from an external source, such as a .txt file, however I can't figure out how to do that... a little help PLEASE.
Thanks!
Load Array From Text File
When I use loadVars to load from a text file, I always get a string. Is there a way I can load data from the text file as an array? I ask because my text file is 17000+ words, and it takes 30 seconds to load it, and another 60 seconds to turn split it into an array. Loading it as an array would save a lot of time.
Reading In An Array From A Text File
I'm trying to use a text file to load in some configuratin data (using actionscript 3) I have it working ok for simple stuff like gamename=Chess&gamescore=100 , etc... but some of the data needs to be in an array. Can someone please point me in the right direction to how I can read in an array from a text file?
Thanks!
Creating An Array From A Text File....
Please can someone tell me where I'm going wrong here?
I'm close I'm sure of it but it's telling me that it cannot convert the file to an Array....
//MAKE AN ARRAY FROM TEXT FILE.......
//var trackNames:Array = ["", "They.mp3", "Lullabye.mp3", "Out of the Dark.mp3", "Sunshine Master.mp3", "Defender.mp3"];
var trackNames:Array
var mp3Array:TextField = new TextField();
var mp3ArrayRequest:URLRequest = new URLRequest("mp3Array.txt");
var mp3ArrayLoader:URLLoader = new URLLoader();
mp3ArrayLoader.load(mp3ArrayRequest);
mp3ArrayLoader.addEventListener(Event.COMPLETE, mp3ArrayReady);
function mp3ArrayReady(event:Event):void
{
trackNames = event.target.data;
}
Thanks for your help,
DGL
How To Load Text From A Txt File To An Array?
Hi guys,
I'm working with a Flash gallery that loads picture description from the actionscript that looks like this:
import mx.controls.CheckBox;
function title_name() {
bigname_arr = new Array();
bigname_arr[1] = ["SOME TEXT HERE FOR PIC 1"];
bigname_arr[2] = ["ANOTHER TEXT FOR PICTURE 2"] ;
} //bigname_arr[insert photo#] = ["INSERT PHOTO DESCRIPTION"]; (to add more images copy the code and past on above. To remove photo and description, delete code from above)
title_name();
My question is how do I load instead of SOME TEXT... my own custom text from the txt file?
Now, for changing the description of the images I have to change the script itself.
It is Flash 8 Actionscript.
Any help would be much appreciated! Thank you!!!
External Array In Text File
Last edited by conspirisi : 2006-03-30 at 04:01.
I want to externalise an Array which I used to have within the flash movie.
It used to exist in my Fla as:
ActionScript Code:
var swfArrayL1:Array = ["movL101.swf", "movL102.swf"];
I want to use the loadVars class so I want to stick the above in an external text file.
But how do I format/write the above code in a text file?
|