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:
- (suggested) Build a server-side script that receives the information via a POST request and emails it to the address of your choosing.
- (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.