Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Checking if a button has been pressed in a previous scene

Options
  • 01-04-2008 11:27am
    #1
    Registered Users Posts: 45


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

    [PHP]var pressed;
    pressed = false;[/PHP]

    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]on (release){
    pressed = true;
    x.stop();
    var p;
    p = Math.floor(x.position/1000);
    my_text._visible = true;
    }[/PHP]

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

    [PHP]on (release){
    pressed = false;
    x.stop();
    x.start(p,0)
    my_text._visible = false;}[/PHP]

    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();
    }[/PHP]

    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);
    }[/PHP]


    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


Comments

  • Registered Users Posts: 54 ✭✭ejvilla


    Off the top of my head...

    if (pressed = false) < - your logic looks flawed. This should read:

    if (pressed == false) or if (!pressed)

    And the same goes for all of your if/else if statements..

    Otherwise you are testing whether the operation of assigning the value 'false' to the variable 'pressed' is true.. which it enevitably will be...

    Also, I'm not sure what you mean by 'scene'? Are scene 1 and 2 seperate pages? If so, perhaps you should investigate Sessions, specifically storing state across a session.

    Apologies if any of this is incorrect, haven't looks at JS for a while.


    Jordan79 wrote: »
    I have created a variable called “pressed” and assigned it to “false”

    [PHP]var pressed;
    pressed = false;[/PHP]

    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]on (release){
    pressed = true;
    x.stop();
    var p;
    p = Math.floor(x.position/1000);
    my_text._visible = true;
    }[/PHP]

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

    [PHP]on (release){
    pressed = false;
    x.stop();
    x.start(p,0)
    my_text._visible = false;}[/PHP]

    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();
    }[/PHP]

    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);
    }[/PHP]


    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


  • Registered Users Posts: 2,031 ✭✭✭colm_c


    I think this is a flash question?

    Avoid using Scenes - use separate movies instead and load them as required, saves loading the entire website/application for someone just wanting to view a small section.


Advertisement