Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checking if a button has been pressed in a previous scene

    I have created a variable called “pressed” and assigned it to “false”

    PHP Code:
    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”.

    PHP Code:
    on (release){
        
    pressed true;
        
    x.stop();
        var 
    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.

    PHP Code:
    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 Code:
    if (pressed false){
    x.stop();
    var 
    = new Sound();
    x.attachSound("2");
    x.start(0,0);
    }

    else if (
    pressed true){
        
    x.stop();

    Or make the text box visable or invisible…….

    PHP Code:
    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

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    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.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •