...

View Full Version : Checking if a button has been pressed in a previous scene



punky79
04-01-2008, 12:21 PM
I have created a variable called “pressed” and assigned it to “false”


var pressed;
pressed = false;

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”.


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

When audio on button is pressed the audio is started and the text box visability is turned to false.


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….



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…….


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 J

gnomeontherun
04-05-2008, 08:59 AM
Instead of using true or false, I tend to use 1 or 0. I've had a similar situation in which true/false did not work but 1/0 did.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum