Variable maintained along the timeline?
I am creating a game in which the user has to click on objects within the room to pick them up (the buttons are made invisible and then a movie clip of the inventory is made visible) but every time they return to the frame, the button to pick up that object returns. I have tried using boolean variables to make them disappear but I'm not doing it right.
Here is the code I tried to use:
(the blue button is the "inventory" made visible & the pink button is the button that makes the inventory visible)
stop();
var pink_clicked:Boolean = false;
blue_btn.visible=false;
blue1.addEventListener(MouseEvent.CLICK, f2_ClickToGoToAndStopAtFrame);
function f2_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
gotoAndStop(2);
trace ("next clicked")
}
pink_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
function fl_MouseClickHandler_2(event:MouseEvent):void
{
blue_btn.visible=true;
trace("Pink clicked");
pink_clicked=true;
pink_btn.visible=false;
}
if (pink_clicked == true)
{
pink_btn.visible=false
}
When I return to the first frame from the second the variable is made false again so the pink button is still visible.
Please help!