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 8029035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:18:59+00:00 2026-06-05T00:18:59+00:00

So currently I am able to save 1-9 AS3 variables depending on what the

  • 0

So currently I am able to save 1-9 AS3 variables depending on what the user wants, they are saved as text strings into an XML file however when the user saves again the old xml information remains in the file and the new information is added.
However I want the new information to either write over the old information or set a function to clear/delete the information in the xml file before the new settings are saved.

Here is my current save function:

var soundVAR;
var conditionVAR;
var soundtoXML:XML; 
var conditiontoXML:XML; 
var test = 1;
var playingCounter = 0;
var xml:XML = <saved>
        </saved>;


//1.Button event listener
btn_Save.addEventListener(MouseEvent.CLICK, saveXML);
//2.The saveurl function which opens a URL.
function saveXML(event:MouseEvent):void {


var conditionsArray = new Array(play1Condition, play2Condition, play3Condition, play4Condition, play5Condition, play6Condition, play7Condition, play8Condition, play9Condition)

for (var i=0; i < conditionsArray.length; i++){
trace(conditionsArray[i])
if(conditionsArray[i] == true)
{
    soundVAR = soundsName[i];
    conditionVAR = conditionsArray[i];


    playingCounter++;    
} else {

    trace('no sounds are playing');
}

while (xml.item.length() < playingCounter ){
    var soundString:String =  '<sound>' + soundVAR + '</sound>';
    var conditionString:String = '<condition>' + conditionVAR + '</condition>';
    soundtoXML = new XML(soundString);
    conditiontoXML = new XML(conditionString);

    var item:XML = <item />
    item.@id = xml.item.length().toString();
    xml.appendChild(item);

    var sound:XML = xml.item[xml.item.length() - 1];
    var condition:XML = xml.item[xml.item.length() - 1];
    sound.appendChild(soundtoXML);
    condition.appendChild(conditiontoXML);
}
}
writeXML();
trace(xml);
}

function writeXML(){

var savedSounds:SharedObject = SharedObject.getLocal( 'savedSounds');
savedSounds.data.soundsxml = xml; // your variables
savedSounds.flush(); // stores data into disk


}

Thanks in advanced.

  • 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-05T00:19:00+00:00Added an answer on June 5, 2026 at 12:19 am

    Short answer: you want to call xml.item.setChildern(''); before the while loop. Longer answer: I don’t understand the last 4 lines of the while loop. Can you explain what was the intent behind writing them?

    If I understood your code correctly, then the while loop could look like so:

    var i:int = xml.item.length();
    while (i < playingCounter)
    {
        xml.* += <item id={ i }>
              <sound>{ soundVAR }</sound>
          <condition>{ conditionVAR }</condition>
        </item>;
        i++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello Currently i am able to parse the xml file if it is saved
Currently, I am running into a problem where I am not able to save
I'm using: https://github.com/blueimp/jQuery-File-Upload Basically, I need to be able to save the current done
I am currently able to export my MySQL query to a tab delimited text
I'm currently implementing functionality in Tridion 2009 SP1 where the user is able to
I'm currently trying to create a database on eclipse. The user will be able
I'm currently trying to create a database on eclipse. The user will be able
I'm currently working on a project where I need to save data depending upon
I want to be able to save the contents of a rich text box
For Javascript application I need to be able to let the user save the

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.