473,422 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,422 software developers and data experts.

Import a Text File in Flash

88
Hi,

I'm developing a flash game and need to read data from a text file (about 100k). I do not want to read it from an external file.

-Is it possible to somehow import a text file into flash and compile swf without a need for an external file to read at runtime?

-How about putting the huge data into a string object defined in an .as file? Or is there a specific class to handle such data?

Let me know the right direction to do it.

FYI, the text file contains a list of words (I'm making a word game) and I split the list into an array.
May 23 '09 #1
6 5089
Markus
6,050 Expert 4TB
Create an array of the words in a AS file that is compiled with the program.

However, I don't recommend this; what if you want to give updates to the word list, or what if you wanted to allow the user to add their own words? A separate file would be best.
May 24 '09 #2
serdar
88
Do you mean hardcoding thousands of words (by copy/paste of course) as:

Expand|Select|Wrap|Line Numbers
  1. var wordList:Array = new Array("apple", "orange", "banana");
I'm trying to protect the word list and don't like to do encryption in the text file.

With this method I still can have an external file for users to add new words (I don't think it's likely so in this kind of a game though) and append it to the compiled array.
May 24 '09 #3
Anybody can see the source code for your flash object, so putting it inside the script won't make much difference. If you want to keep your word list safe, you have to use an encrypted SSL communication and a server side script to supply words.
With that said, there are hundreds of scripting languages (Python comes to mind) that can write the code for you from the word list. It would take <1min to write one.
May 26 '09 #4
serdar
88
I just need to hide it from the average people who like to add the game into their website. I don't like the idea to include a plain text file to the zip archive.

Maybe I should also add a simple encryption to make it harder to get the words by viewing the binary code of the swf (or by using decompilers?), but it's not that much important actually.

About using a scripting language; do you mean generating the .as file from the plain text file? I do have some 'filtering' scripts (PHP) to pick appropriate words in a larger word list so I can easily use them to generate the .as file too.
May 26 '09 #5
Yes, this is exactly what I mean by "scripting". You would have to do something like this pseudo code:

Expand|Select|Wrap|Line Numbers
  1. echo "var wordList:Array = new Array( ";
  2. while(! word_list.empty() )
  3. {
  4.      echo "\"";
  5.      echo word_list[0];
  6.      echo "\", ";
  7.      word_list.erase(0);
  8. }
  9. echo " );";
You don't have to generate the whole .as, just the long and boring part that is easy to automate.

As for keeping people from putting your flash on their website... don't bother, it won't happen. The biggest corporations can't figure out how to keep binary machine code executable warped through the 9 circles of hell (read: SecuROM) from being mass copied, so your Flash object stands no chance. Some basic URL checks will be effective enough against people who know too little to rip the decryption key out of the dissembled script.

If you still want to go through it, you will probably want to take a look at http://code.google.com/p/as3crypto/
May 26 '09 #6
serdar
88
Okay, that's how I thought when I think how to convert the word list into an actionscript array.

As for keeping people from putting your flash on their website
Actually, I do want them to download and use the game in their site (probably with high scores functionality disabled etc.). Just not prefer to deliver a plain text file.
May 26 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dave | last post by:
I don't think the text file is caching. The information in the text file is called upon manually by the user of the flash movie. Odd that the variable in which the text is stored doesn't clear...
1
by: DCM Fan | last post by:
Access 2K, SP3 on Windows 2K, SP4 All, I have an import spec set up with quoted Identifiers and comma-separated values. The text file is produced by a 3rd-party program of which I have no...
1
by: mark | last post by:
In Access 2000 and 2002, I have created an import specification to import the fixed-width recordset below into an existing table. I am having strange problems with the import of the date and time...
1
by: Dan | last post by:
Could someone please help me with auto importing a series of data files into an Access table. I tried to follow code given below in a previous messagebut i'm getting error messages. Here's my...
3
by: deko | last post by:
I've been trying to use the Access Import Wizard to expedite importing data into my mdb. The nice thing about the wizard is that I can import from different file formats - txt, xls, even Outlook -...
1
by: ghadley_00 | last post by:
Hi, I have a MS access database table for which I regularly need to import fixed width text data. At present I have to to cut and paste the text data from its source to a text file, save the...
3
by: brianwalker | last post by:
hello all. I have a text document that stores text for use in a flash movie. I'm also using PHP to displace the same text on another page. However the text document includes 2 tags for use by...
2
elamberdor
by: elamberdor | last post by:
Hi All! Well, i'm modifying a dynamic map, with lat and long datapoints, my problem is it loads in text perfectly onto exact points I specify on the map, ..well now I want to load in...
0
by: whochrisporter | last post by:
Hi, thanks for reading and helping me first of all. Now to the question.. I need to load external images into a scrolling slideshow (its like a sliding rotating banner) flash file using an...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.