AS3 - (Very) Simple Text Adventure - actionscript-3

I've been trying to find a source code or tutorial or anything that I can work with, but so far I haven't had any luck. The closest I've come was using haXic, but without a way to change how the input box looks (I was able to fix this in the open source files, but without being able to change the compiler, the fix won't stick in the resulting .swf), I can't achieve the desired font and color.
So I'm turning to Actionscript 3 / Flash, as I have some knowledge of it, although mostly used for constructing websites. The goal is to create a very, very, very simple game based on traditional text adventure structure. When I say simple, I mean really simple. I don't need maps, I don't need NPCs, I don't need items, I don't even need to have a list of commands that can be accessed at any time. All I need is to display some text, accept a specific input, and then display some more text based on what that input is.
Here's an example of what I'm trying to achieve: The .swf loads up, the user sees some text imitating a POST. This isn't an actual preloader, just some fancy "everything is starting up" text. At the end of the animation, the user is instructed to press any key to continue, and doing so removes the existing text and loads in the next set. From there I'd like to have various steps requiring certain input (i.e. asking users for a username, requiring the input of username: , but this doesn't actually have to store the username, just have the valid format of username: name detected before continuing to the next step) and either outputting additional text or wiping the existing text and simulating the start of a new program.
I'm guessing that this mostly involves calling various functions based on input, and then changing what the expected inputs are within those functions, but I really don't have any idea where to get started. I've also noticed in what few examples I've seen, that input text is submitted through the use of a button. Is there any way to get this to work with just the enter key, to simulate a command console?
I'm certainly not expecting a complete source code, just a few pointers. Any help is appreciated, thanks! I'm also open to suggestions other than Actionscript, however the resulting game needs to be able to run in a web browser, and some form of animation for the text is preferred.

While this is definitely possible to do in Flash, I would highly recommend using plain HTML5/Javascript for this task. This way you're almost guaranteed to have the widest platform adoption (XBOX browser, iOS safari). Javascript can be just as effective here for animations.
For using Flash, I would start with the TextField class for the input and TextArea component for output.
For HTML, it's as simple as a form input field and using javascript to update a div area for the output.
Good luck on your project.

Related

How do I NOT update a displayed image when it is changed on the backend?

I'm looking for a way for my website to not change the image displayed to the user when the image is changed on the backend (assuming they do not refresh the page). Is there an easy way to do this?
Context/more detail:
I'm designing a plotting utility to be used by students which should display an image made based on their entered data (through a form fed to a PHP script).
However, they may be using this tool simultaneously, and if another student makes a plot, the first student's plot will be overwritten, even if they don't refresh the page.
I would like to make this not occur, so students can "keep" their plots. But, all my searching yields ways to force a refresh, not to force NOT refreshing.
The page in question is HTML (mostly a PHP script that takes their data inputs from a form and makes an image of it, and then the image tag).
Is there some sort of standard solution that I (as a non-web-developer) could easily implement?
(Also, since they are repeatedly making plots, I would prefer to do this without caching their old plots.)

Is there a way to implement emoticon packs into HTML?

I am making a social networking site and would like emoticons to be available to users to click, and view a whole range of standard emoticons. I have seen around the web, and have not come up with any concrete information whether this can be done, and how.
The way I imagine the emoticons to be is similar to what WhatsApp have adopted. An emoticon icon, which, on click, displays a whole range of icons. Just wondering whether it is possible and if so, how?
It can be done, you would need a java-script widget for it though and depending on the rest of your framework it could be fully integrated or it would require some additional files.
Here is one example of such a widget, not sure if it is precisely what you need but you can get the idea there:
https://www.npmjs.com/package/emoticons-js
Umm, you can have a set of icons what you can display?
Or use the unicode entry points for the emojis?
http://apps.timwhitlock.info/emoji/tables/unicode
Then you need one element with some onclick handler in Javascript which opens up a floating div showing a selection of emojis.

How to stop users from copying or printing text from my web page?

I have a web page (on .Net platform, with C#) with text content and I would like to block users from copying the text or printing the document.
If the user is hard out on attaining a copy of the page, I know he can. But I would like to make it as hard as possible.
I have found a few points on it.
Using Java Script to block user from copying text. Downside is user can easily copy text from source.
Do not make the text into 1 big image, as user can print it out in one go.
Use a plugin to show text as scrollable in a defined viewport size without the ability to copy text. Then the user has to take pain to print every bit he can fit in the window viewport, which is fine for me. Use Flash in this case.
I have seen ionCube's (php) solution where you cant copy or view source text, but the downside is it can be printed easily. I would like to see a asp's encoding solution here along with ability to block user from printing the page :)
Scribd is not a solution because if you chose to stop users from copying text from your scribd document, it converts the text to a tough to read image.
There could be more solutions out there I am unaware of.
Can you please let me know the best solution in this case?
There is no solution. Any webpage has to be represented as a DOM in memory and there are no shortage of tools to let people manipulate that and extract text from it.
DRM is ineffective at best, and when HTML is involved "the best" is a long, long way away.
You can use the initial solutions and use a CSS rule for hiding all in the print version:
<style type="text/css" media="print">* { display: none;}</style>
Of couse, as Quentin said, theres no definitive way of doing this, but blocking the selection, using an encoded version of the text that gets writen in the page by javascript and using this CSS snippet you can get about 80% of the users.
document.getElementById('elementId').innerHTML = unescape(escapedTextGoesHere);

Removing HTML from user input in Perl and Catalyst

I'm using Catalyst for my Perl web app. What is the accepted way of removing HTML from user input?
Currently I'm leaning towards using HTML::FormatText. But it seems strange to me that I can't find a utility built into Catalyst to do this common task. Have I just not found it? Also, it seems these modules for removing input take like 5 lines of code. I was hoping for a simple "deHTMLify()" method. I guess I can roll my own but didn't want to reinvent the wheel.
I think the form validation modules like HTML::FormFU do this for you, but I am hoping to avoid that complexity. My forms are short and simple. Is this decision wrong headed?
Am I doing it right?
I'd argue you aren't doing it right. The right way to do this is to accept the text as sent from the server. Then to process all values received from the database with the html, or html_entities filter in your view (probably TT). Why is this the right way? Well, if you don't want to support HTML now, you can still hack the filter to make a subset of HTML work later on. This also lets the user see their input -- just escaped -- rather than having it stripped thereby losing track of what they sent and some potentially valuable information.
Your way also seems to make some assumptions about the output mechanism (HTML), that I'm uncomfortable with. Why would you want to sanitize on input for just one output format?
I'm using HTML::Scrubber, but that's where I want to actually allow a subset of elements/attributes.

HTML printing - what methods are there to make an html based printout? What are the pros and cons?

I have a report I need to print out in an application I'm usually doing maintenance for. My question, which interests me beyond the scope of this task is, what are the ways to format an HTML page for printing? What are the pros and cons of each?
Note that the page is meant only to be printed. I'm not asking about an HTML page that looks ok also when printed.
Generally speaking, I know I can either rely heavily on <table>s or on <div>s, but I don't know which way to go.
I would also appreciate some resources to get me started, or to help with known problems, in any method you suggest.
Thanks,
Asaf
As you can certainly see, printing and web presentation are two different creatures. The main issue is the bounds of the printed page, which does not exist in a web page. Even if you think you have a page laid out in a manner that will fit a printed page, then you need to deal with the fact that the font you are using may not work or scale correctly on the user's printer.
I know of three ways to deal with this issue:
Use fixed-sized fonts (like Courier), limit yourself to an 80 column width, and only use font characters: meaning use something like asterisks for borders, etc. This is VERY old school - your reports look simple and old and plain. But, they will always print they way you intended.
Convert your report to an image. Images can be made to confirm to a specific size which can fit on a page. However, you can still have issues due to printer margin settings.
Let another application do the work for you. What I mean by this is put your report into a PDF or a spreadsheet. Both PHP and Perl have easy to use modules for creating a PDF - with no licensing needed. Perl has a fantastic spreadsheet module. This route takes a little learning up front, but frees you from having to be an expert on printing (which can be a real pain).
In case you DO want to have a page that also looks good when viewed in a browser, consider multiple stylesheets for different medias.