Skip to main content
Participant
January 20, 2022
Question

Quantity Counter Buttons

  • January 20, 2022
  • 2 replies
  • 194 views

I'm brand new to Animate so be gentle as I have no idea what I'm doing 🙂

 

I'd like to create a way of recording a quantity on the last frame in my project by using plus and minus buttons to count up or down. 

 

Below is old code, but this is along the lines of what I'm trying to achieve:

 

add.btn.addEventListener(MouseEvent.CLICK, addone);
var count = 0;
counting.text = count;
function addone (event:Event){
count ++;
counting.text = count;
}

 

Can anyone help me figure out what I need to do? Thank you!

This topic has been closed for replies.

2 replies

JoãoCésar17023019
Community Expert
Community Expert
January 20, 2022

Are you getting any error?

 

I think your instance name may be wrong.

 

You wrote:

add.btn.addEventListener(MouseEvent.CLICK, addone);

 

But maybe it should be:

addBtn.addEventListener(MouseEvent.CLICK, addone);
add.addEventListener(MouseEvent.CLICK, addone);

 

Or something else?

 

Your way will only work if you have an instance called add and then another instance inside of it called btn.

JoãoCésar17023019
Community Expert
Community Expert
January 20, 2022

Hi.

 

What exactly are you not being able to do?

 

Please let us know.

 

Regards,

JC

Participant
January 20, 2022

Hi JC, thank you for reaching out. I can't get the code to work, and I'm not sure I've got the Actionscript right as it was from a very old Youtube tutorial here: https://www.youtube.com/watch?v=dkIDL-O1U-Q