I have a nice photo gallery which uses an array like this:
photos = ["portraits/1.jpg", "portraits/2. jpg", "portraits/3. jpg", "portraits/4. jpg", "portraits/5. jpg", "portraits/6. jpg"];
All is well in the world but now I need to import the array data form a .txt file which has been created by php.
It writes the data exactly as it is above (without "photos ="). It creates the hard brackets, commas, misses out the last comma
and inserts a hard bracket and a semi colon. (cool php from a dynamically changing images folder...)
So the string in the .txt file is:
["portraits/1.jpg", "portraits/2. jpg", "portraits/3. jpg", "portraits/4. jpg", "portraits/5. jpg", "portraits/6. jpg"];
On the main timeline (have to add lots of code afterwards to make the gallery work) how can I set the variable
"photos" and then import the string from the .txt file as it's value?
I'm using Flash 8 and AS2 (but I guess the player will handle 2 & 3 mixed together)
All and any help much appreciated
You do not want to be dressing the array up as if you plan to equate it to the array in the code. All you need to do is get the data in Flash using the LoadVars class, as a single string of filenames with commas separating the names and then operate on the string using the split method....
portraits/1.jpg,portraits/2.jpg,portraits/3.jpg,portraits/4.jpg,portraits/5.jpg,portraits/ 6.jpg // file content
let's say the data string is captured as the variable txtData
photos = txtData.split(",");
Look up LoadVars in the AS2 documentation. It should be easy for you to implement.