# How to save a text locally when a button is clicked?

**URL:** <https://forum.kirupa.com/t/how-to-save-a-text-locally-when-a-button-is-clicked/331884>\
**Category:** flash\
**Created:** [November 15, 2013, 9:25pm UTC](https://forum.kirupa.com/t/how-to-save-a-text-locally-when-a-button-is-clicked/331884 "2013-11-15T21:25:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![razer56](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@razer56](https://forum.kirupa.com/u/razer56)\
**Post date:** [November 15, 2013, 9:25pm UTC](https://forum.kirupa.com/t/how-to-save-a-text-locally-when-a-button-is-clicked/331884/1 "2013-11-15T21:25:25Z")

</div>

[COLOR=#000000][FONT=Arial]I want to make a button where once the button is clicked it changes a dynamic text field from 100 to 0, and if clicked again from 0 to 100. When I exit the game, I want it to save what the user’s last number was. If he exited with a “0” I want a 0 to show up the next time the user opens the game. I have made the following code:[/FONT][/COLOR]

```auto
import flash.events.MouseEvent;import flash.media.SoundChannel;
import flash.ui.Mouse;

var onoff:Number;
onoff = 100
options_mc.onoff_txt.text = String(onoff);
options_mc.sound_btn.addEventListener(MouseEvent.CLICK, mute);
options_mc.test3.addEventListener(MouseEvent.CLICK, test3);
function mute(event:MouseEvent)
{
    var so:SharedObject = SharedObject.getLocal("options");
    if(so.data.onoff == 100)
    {
    so.data.onoff = 0
    options_mc.onoff_txt.text = String(onoff);
    so.flush();
    }
    else if(so.data.onoff == 0)
    {
    so.data.onoff = 100
    options_mc.onoff_txt.text = String(onoff);
    so.flush();
    }
    
}
function test3(event:MouseEvent)
{
    var introTween = new Tween(startMenu,"x",Strong.easeInOut,startMenu.x,(startMenu.width)*.5,1,true);
    startMenu.visible = true;
}

```

[COLOR=#000000][FONT=Arial]My problem with this code is that it’s not changing the text field when the button is clicked! Could you please help on what I have done wrong?[/FONT][/COLOR]
