Question

First I should preface this by saying that I'm quite new to Flash/AS!

Long story short, I'm working on a very basic quiz game in Flash. The user will be presented with questions and must choose an answer to proceed (whether they choose the right or wrong answer).

This will be used as a training tool at my work, and we need to be able to track users' answers to determine what people got right/wrong, who needs additional training, etc.

My initial thought is to utilize SharedObjects to gather their answers (since SO are user-specific, this seemed to make sense). My question though, is there a way to access the SO data and send an email, export a text file (or something) to the managers? Possibly store the clicks in an array and export that?

The other thing is that we don't want people to be able to retake the quiz (there's an incentive for getting 90%+ questions right). My other thought was that I could write some data to the SO once the user reaches the end-screen and can be checked against at login (to see if they've already finished the game).

Anyways, that's the problem I'm running into. If emailing/exporting SO data isn't an option, what other options are there?

Was it helpful?

Solution

First, a note on using SharedObjects to store any information of importance--in your case, storing whether the quiz was completed to prevent retaking: it's not fool-proof. Any user can delete or alter their shared objects, and you no longer have that data.

As far as tracking their answers and emailing them, that's completely doable. Storing them in a shared object is unnecessary unless you intend on letting the users take the quiz over the course of multiple sessions (partially completing the quiz, and returning to it at a later time). Anything you would store in a shared object during a single "session" could just as easily be stored in memory while the application is running.

Finally, you mentioned that you're using scenes. Most developers would recommend against that. It's an outdated mode of developing flash applications. If you're at a point in your development process right now where you can strip those out, I highly recommend you do.

Caveats aside, here is how you would do it:

// in your first Scene (here, labeled "Scene 1"), grab a reference to a SharedObject, I named mine "quiz"
var so:SharedObject = SharedObject.getLocal("quiz");

// set up any necessary data structure for the data you plan to store 
if(!so.data.results){
    so.data.results = {};
}

// you can check to see if data has already been written to the shared object, if so, you can use this to determine the flow of the quiz
if(so.data.results.scene1Results){
    trace("scene 1 already completed: ",so.data.results.scene1Results);
}
else{
    so.data.results.scene1Results = "some value";
    so.flush();
    trace("scene 1 data stored");
}

In your other scenes, you can grab a reference to the shared object the same way as before: SharedObject.getLocal("quiz"); and add data to it as the quiz proceeds.

As for mailing the result, you have two options:

  1. (suggested) Build a server-side script that receives the information via a POST request and emails it to the address of your choosing.
  2. (not recommended) Generate a mailto url that contains the result of the quiz as the body of the email. The problem with this is that it allows the user to edit the results within their own mail client before sending it to the intended recipient.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top