Reputation: 1
I have this collecting item game which u have to collect enough "stars" in order to acess a button. After I clicked the "star" button, it suppose to disappear and never appear again. However, when using this script, although the button disappear once I clicked it, when I returned to the frame after going to another frame, it appeared again! pls help!
star1.addEventListener(MouseEvent.CLICK,gotstar);
function gotstar(event:MouseEvent){
stars++;
star1.x = -500;
}
Upvotes: 0
Views: 521
Reputation: 4434
star1.removeEventListener(MouseEvent.CLICK,gotstar);
star1.parent.removeChild(star1);
in the click handler code (gotstar
) should help
however posting your .fla
file might be useful for better understanding
Upvotes: 0
Reputation: 893
Are you coding on the frames themselves? If so every time you enter a frame it will run every piece of contained code, even if it has already ran once. A solution to this would be to use a document class to track the progress of the game.
Upvotes: 3
Reputation: 434
you need to remove it from the stage if I understand.
try this instead of star1.x = -500;
stage.removeChild(star1);
Upvotes: 1