# Button adds to total score (Noobie question)

**URL:** <https://forum.kirupa.com/t/button-adds-to-total-score-noobie-question/301093>\
**Category:** flash\
**Created:** [December 3, 2009, 12:56pm UTC](https://forum.kirupa.com/t/button-adds-to-total-score-noobie-question/301093 "2009-12-03T12:56:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaimytron](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@Jaimytron](https://forum.kirupa.com/u/Jaimytron)\
**Post date:** [December 3, 2009, 12:56pm UTC](https://forum.kirupa.com/t/button-adds-to-total-score-noobie-question/301093/1 "2009-12-03T12:56:06Z")

</div>

Hey guys, first of all I want to say hi and all that, considering this is my first post here. I pretty much registered 'cause of this issue, because I couldn’t find any help online so I figured one of you guys might help me.

Okay, basically, I’m new to actionscript in general. I can find my way in Actionscript 2.0, but 3.0’s hell for me. I’ve been following a bunch of tutorials and I suppose I understand the ‘basics’, although I’m beating myself over this 'cause most of you will probably consider this basic aswell.

Anyway.

The problem at hand : I made a few movieclips, that have a transparant button on the first frame inside of them, and on layers below it an animation that starts once you click it, then stops at the last frame.

(Example : You see a snail, you click it(but really click the transparant button that’s above it) and the movieclip starts playing, showing a snail that crawls back inside it’s shell, then it stops. Pretty simple, but it’s a fun and easy way to have multiple interactive graphics on a page.)

The task at hand : Somehow make a score system that allows you to see how many of them you’ve clicked, meaning everytime you click a snail (for this example, anyway) there’s a +1 function somewhere.

Currently, inside the movieclip (the transparant button) I have :

stop();

alpha\_btn.addEventListener(MouseEvent.CLICK, nextClick);

function nextClick(event:MouseEvent):void{  
gotoAndPlay(2);  
}

Which is pretty straight forward. alpha\_btn is the button that makes the animation inside the movieclip play. At frame 30, there’s a stop(); function.

Then, there’s the main timeline.

function scorePoints(myPoints:Number):void {  
if (Number(scoreBoard.text)) {  
scoreBoard.text = String(myPoints);  
} else {  
scoreBoard.text = String(Number(scoreBoard.text) + myPoints);  
}  
}

snail.addEventListener(MouseEvent.CLICK, puntClick);

function puntClick(event:MouseEvent):void{  
scorePoints(100);  
}

It works, but only once. After the snail is clicked, I have it looped (no stop(); at the end of the moveclip, but it moves to the first frame again. Meaning, the button’s there again and it’s clickable again.) but everytime I click it after that, there’s no points added to it.

So I’ll break it down to this : I need simple button that, when clicked, adds a number of points to the scoreBoard.

😃

Jaimytron
