Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7760757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:58:26+00:00 2026-06-01T13:58:26+00:00

I’ll explain a little before asking my question … I’ve created numerous games which

  • 0

I’ll explain a little before asking my question … I’ve created numerous games which load and unload off a main menu.

The player enters their name on the main menu before playing any games and when the player completes a game I want to save their time (taken to complete the game) and unload this time back into the main menu.

Is there any way of saving the times using AS3 to a word document or something like this? I can’t send the times to my website with php because the games will be used within a competition and it all needs to work with the internet.

Any ideas guys?

Edit:

    var dataloader:URLLoader = new URLLoader();
    var dataarray:Array = new Array(); // do this where you intialise other vars

    function preparesave() 
    {
        dataloader.load(new URLRequest("savedata.txt"));
    }

    dataloader.addEventListener(Event.COMPLETE,savedata);

    function savedata (event:Event) 
{
    dataarray = event.target.data.split(/\n/);
    dataarray.push(MyTimer);

    var bytes:ByteArray = new ByteArray();
    var fileRef:FileReference = new FileReference();

    for (var i = 0; i < dataarray.length;i++) 
    {
        bytes.writeMultiByte(dataarray[i] + "\n", "iso-8859-1");
        bytes.writeMultiByte('English Game Time: ',"iso-8859-1");
        bytes.writeMultiByte(HourText.text.toString(),"iso-8859-1");
        bytes.writeMultiByte(':',"iso-8859-1");
        bytes.writeMultiByte(MinuteText.text.toString(),"iso-8859-1");
        bytes.writeMultiByte(':',"iso-8859-1");
        bytes.writeMultiByte(SecondText.text.toString(),"iso-8859-1");
    }

    fileRef.save(bytes,"savedata.txt")
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:58:28+00:00Added an answer on June 1, 2026 at 1:58 pm

    For small amounts of data, you’re best-off just going with automaticoo’s solution by using SharedObjects.. they take minimal time to set up and are an efficient way of storing small amounts of data.

    However, if it’s not for you, you could always load/save to a text file. You can do this using ByteArrays and FileReferences.

    Since you brought up saving to a word file, I would suggest saving to a text file would be the best way of achieving your goal (although other than your word doc. suggestion, i’m not sure.. your aim is sort of unclear)

    Here is a seriously quick demonstration of saving to a text file.. If you need help loading it too, let me know.

    function savedata() {
    var bytes:ByteArray = new ByteArray();
    var fileRef:FileReference = new FileReference();
    bytes.writeMultiByte(playername + "\n", "iso-8859-1");
    bytes.writeMultiByte(playerscore.toString(),"iso-8859-1");
    fileRef.save(bytes,"savedata.txt");
    }
    

    This is pretty simply.. By using writeMultiByte, we can write as much data as needed before saving our text file! This is especially useful if you have arrays of data you need to save.

    Anyway, the “iso-8859-1” is simply a reference to the character set / file-format being used.. I’m not sure if you can simply write utf-16 etc. instead.. I’ve always just used it as it is written above.

    The result in the text file here will be the following:

    Peter

    9547 (but up one line)

    To load, you can just split data by line, resulting in an array full of strings and ints/numbers (however your scores may work). Again, let me know if you need help doing that.

    I’m not sure if this is the most efficient method of achieving what you’re after since your goal isn’t entirely clear to me, but it has been a very useful way for myself in storing large amounts of data, which I’m guessing you are wanting to do if you are compounding all the scores of players.

    edit:

    Okay, to the questions you posed below:

    1. To save more than one user’s score is simple. Simply have a single array which loads the data from the text file (if the text file exists), then adds the new score to the end of the array, then saves back to the text file.

    Here is an example:

    var dataloader:URLLoader = new URLLoader();
    var dataarray:Array = new Array(); // do this where you intialise other vars
    
    function preparesave() {
        dataloader.load(new URLRequest("savedata.txt"));
    }
    
    dataloader.addEventListener(Event.COMPLETE,savedata);
    function savedata (event:Event) {
        dataarray = event.target.data.split(/\n/);
        dataarray.push(playername);
        dataarray.push(playerscore);
        var bytes:ByteArray = new ByteArray();
        var fileRef:FileReference = new FileReference();
        for (var i = 0; i < dataarray.length;i++) {
            bytes.writeMultiByte(dataarray[i] + "\n", "iso-8859-1");
        }
        fileRef.save(bytes,"savedata.txt")
    }
    

    What this does is take any existing save data, pushes it to an array (where one line on your save file is one array data entry), adds your appropriate data, and pushes it back out to the save file.

    (2) To load this in whilst in the main menu, simply place this code in the frame of the main menu..

    dataloader.load(new URLRequest("savedata.txt"));
    dataloader.addEventListener(Event.COMPLETE,loaddata);
    function loaddata (event:Event) {
        dataarray = event.target.data.split(/\n/);
    }
    

    This will load all your existing data into an array. What you do from then on is up to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.