# Checking if a button has been pressed in a previous scene

**URL:** <https://forum.kirupa.com/t/checking-if-a-button-has-been-pressed-in-a-previous-scene/256252>\
**Category:** flash\
**Created:** [April 1, 2008, 10:18am UTC](https://forum.kirupa.com/t/checking-if-a-button-has-been-pressed-in-a-previous-scene/256252 "2008-04-01T10:18:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![punky79](https://avatars.discourse-cdn.com/v4/letter/p/ecb155/32.png) [@punky79](https://forum.kirupa.com/u/punky79)\
**Post date:** [April 1, 2008, 10:18am UTC](https://forum.kirupa.com/t/checking-if-a-button-has-been-pressed-in-a-previous-scene/256252/1 "2008-04-01T10:18:41Z")

</div>

[COLOR=black]I have created a variable called “pressed” and assigned it to “false”[/COLOR]

```php
var pressed;
  pressed = false;

```

[COLOR=black]When audio off button is pressed the audio is turned off and the text box visability is turned to true. I then set “pressed” to “true”.[/COLOR]

```php
on (release){
              pressed = true;
              x.stop();
              var p;
              p = Math.floor(x.position/1000);
              my_text._visible = true;
  }

```

[COLOR=black]When audio on button is pressed the audio is started and the text box visability is turned to false.[/COLOR]

```php
on (release){
              pressed = false;
              x.stop();
              x.start(p,0)
              my_text._visible = false;}

```

On scene 2 I then check to see if pressed is equal to false or true to either start or stop the new sound….

```php
if (pressed = false){
  x.stop();
  var x = new Sound();
  x.attachSound("2");
  x.start(0,0);
  }
   
  else if (pressed = true){
              x.stop();
  }

```

Or make the text box visable or invisible…….

```php
if (pressed = false){
  my_text._visible = false;
  loadVariables("DOF 2.txt", this);
  }
   
  else if (pressed = true){
  my_text._visible = true;
  loadVariables("DOF 2.txt", this);
  }

```

But it does not work……

When I check the variable pressed in scene 1 it works correctly between true and false but when I move to scene 2 the variable changes to “true” even if I have not clicked audio off button???

Can anyone help???

Thanks [FONT=Wingdings]J[/FONT]
