Having a flash game that allows the user to choose a language - actionscript-3

I'm creating a flash game (adobe animate and actionscript 3), and after the splash screen it should ask the user for a preferred language (choosing between two), and then it will take them to the home screen that's in the chosen language, and since I'm new to this field, I'm not sure how I'm supposed to implement it? any tips, please.

Create a localization data file (XML or JSON or CSV format, whichever is easy for you to work with). Develop your app so that all texts are obtained from that file via some kind of ids and none (not strictly, some initial texts like "Loading..." can still be in code) are hardcoded. When time is right, make a copy of localization file and translate the texts but leave the ids.
For example, en.xml:
<language>
<entry id="game">Game</entry>
<entry id="go">Go!</entry>
</language>
Then, ru.xml:
<language>
<entry id="game">Игра</entry>
<entry id="go">Вперёд!</entry>
</language>
The files have the same structure, same ids, everything, but the texts. When your app starts it should decide which one of the files is to load (or maybe load all of them and which one is to use), thus all the app texts will feature the appropriate language.

Related

How to read a text file, parse it to a web interface and store changes

I am looking for a way to read an unformatted UTF-8 text file from disc and parse its content to fields on a web page / web interface, allowing a user to make edits and in return, store these edits to the text file.
The text file and the web interface will be running on a Raspberry Pi 3. I am very new to this, so I'm basically looking for any starting point or even hint, if my approach is heading in the right direction.
As for now, I have considered using Node.js with the File System Module, which unfortunately only gets me as far as reading the text file. My question therefore mainly aims towards:
is node.js the right approach for this scenario?
if so, how can i parse individual blocks of this text file to a web interface and ...
... store edits on this web interface back to my file
thanks a lot

CK Editor JSON file creation for inserting images

I am using CK Editor on my web site and have built a simple uploader script in php to add images to my server. I am using the image browser plugin to enable the inclusion of images into my text. The image browser seems to work using a JSON file which must list all images in the image folder.
I am completely new to JSON and to get around learning how to build a JSON file I created a PHP file which simply reads the names of my images from a database and includes them in the JSON file.
This, as a workaround seems to be perfectly functional, however it is reliant on my upload script having to add the image names to the database (an unnecessary step) and it is also bad practice.
I am looking for a good tutorial or explanation on how to make a very simple JSON file which lists the images in my uploads folder in the correct format for CK Editor so that I can free myself from my image names database and program like a big boy.
Any and all help would be apreciated.

Some way to change text of SWF without having Flash?

I have a FLA with some text but the person that will be sending the SWF doesn't have Flash and doesn't know anything about Flash either.
Is there some way to build the FLA so that the text can be changed simply by modifying the SWF somehow? Due to company policy, the SWF cannot read from external files.
We tried programming into the FLA that it read an XML in another server, but that's not allowed. I also cannot send the SWF with another file (ie. an xml file).
Thanks.
Use FLASM or SWFMILL which are free command line assembler/disassembler for swf files. Use any of the one to disassemble your swf. You can open the result file in any of the text editor, find and replace your text and assemble it as swf again. Hope it helps.
It is a strange logic to try to modify a FLA file without Flash. A FLA file is a binary file, you'll need an editor to read it and I'm pretty sure Adobe isn't allowing 3rd party editors legally.
But yes, it's fine to have a dynamic TextField where you can send the parameter and change the data. Please note - you need to send the data. Means it has to come from outside.
What are the options? Well, actually, there are few:
Loading from an external file or getting it from a server side script. You said it's not allowed, let's omit this method.
Read FlashVars. If you publish it within a HTML page, you can actually feed some data via FlashVars. Not only 1 variable, but as many as you want. And it's fine for small strings, but if you plan to pass a text larger than a sentence… Don't do it.
As a funny hack you could try naming your file with the text you want and read the URL of the SWF thus showing it's name and using it as a text data. But don't do it :)^
If you want to try it, you can access the URL with stage.loaderInfo.url, just make sure you have a stage defined - call in the document class or after the display object you're calling from is added to stage.
Use ExternalInterface to communicate with, for example, JavaScript and get the variables from JavaScript. It's actually not so bad, since your text will be tidily stored in a .js file and you can modify it on the run. That of course is a separate file and you need to have the SWF embedded in HTML for that, but it is one of the options you have.
Other than that you could have an external file that will hold the data and embed it in the SWF. Look more on embedding here: http://flashgamedojo.com/wiki/index.php?title=Embedding_XML_in_AS3 . It is about embedding XML data, but you can use the technique for any data, even binary.
Embedding data is a great thing, but you'll need to re-compile each time you make a change in the file, since it isn't loading the file dynamically, but embeds it into to the SWF itself on compile time.
Hope that helps!
JPEXS Decompiler can change text in an SWF pretty easily. It's still actively developed as of 2021.

Store Data in an HTML file

Wanted to know if the following scenario is possible -
I have some data that is in an excel file. I want to make an html page which will have this data inside it (no other source of data). And inside the Html page, will I be able to put textfields, buttons etc for a user to input data and based on that, i need to write queries (jqueries i guess) to show the data that is the result of those queries
Can this be done? I have not done anything so far. I just wanted to know if this is possible and please someone point me in the right direction for me to start. I wanna learn on my own how to do this.
Thanks in advance.
HTML is a markup language - it is the structure of a webpage, and has no mechanisms for storing or processing dynamic data.
You will have to use a client-side language JavaScript + cookies, or a server-side language like PHP + MySQL.
You want to look at using JavaScript in the page. On the server (I presume) you need to read the Excel file, and generate JS objects on the page that hold the values. That is, the JS when run creates a collection of JS objects with the values in it. This script can be embedded in the page so that no other data access is needed.
You can then write more JS linked to the buttons that select data out of these objects, and displays them on the page. You probably don't want to do this from scratch -- there are good JS libraries and frameworks to leverage. Consider either GWM or YUI.
Perhaps the simplest way is to open the file in Excel and save it as text (tab-separated; comma-separated would do, too), then insert this text data into your HTML document between the tags <script type="text/plain"> and </script>. You can then write, in a rather straighforward way, JavaScript code that reads the content of this element and constructs a JavaScript array of objects (or some other suitable data structire) from it. It will then be easy to access the data in JavaScript.
This will make it possible to run queries and display data. Modifying the data would be a completely different matter.

Saving several images (and metadata for each) in a single file using Adobe Air

Is it possible, via Adobe Air, to save multiple types of data in a single file? For example, an application would allow the user to load in external images, position them on stage and label them. This data would be then be stored in a ByteArray (I guess) using BitmapData for the images and probably XML for the metadata.
I would then like to write this to a single file, with a bespoke file extension that could be associated with said Air app.
I've asked this on various forums and never received a single reply.
You can add everything to a byte array and write it to file - but defining boundaries and extracting individual entities back from the file would take some effort. How about writing them to normal files, zipping them to a single file and deleting the originals? This way you can still have a single file and deal with the individual items more easily.
This article describes some ActionScript zip libraries. I've used nochump in the past and it was easy - this page has some sample code
If you want some individuality for your files, you can rename the zipped file to whatever extension you want - that's what Firefox extensions do, they have .xpi extension, but they're plain zip files renamed.