Skip to main content
tarikv81354015
Participant
February 10, 2017
Answered

How can I assign values to the buttons in AS3?

  • February 10, 2017
  • 2 replies
  • 750 views

Hi everyone,

I am using Adobe Flash CS6 ActionScript3. I am building some kind of a game and I need to assign values to some buttons. There are buttons that are wrong answers and right ones. At the end scene player needs to see how many wrong answers did he get and also how many correct ones, also I have math formula that should be applied to calculate final score.

How the math is going?

Correct answer=r

Incorrect answer=w

Tatal= w+r=x

Every answer weight=100/x=y

Y*incorrect=Q

Final grad=Q-100

Math for this screen(example):

R = 10

W = 10

10 + 10 = 20

100/20 = 5

3* 5 = 15

100-15 = 85

Thanks in advance!

This topic has been closed for replies.
Correct answer Nick Gioia

This tutorial should help you.

http://stackoverflow.com/questions/17035379/best-way-of-passing-values-from-a-button-with-as3-event

actionscript 3 - Best way of passing values from a button with as3 event - Stack Overflow

To add values to a button you have to use the buttons instance name in front of the values you want to add it.

2 replies

Nick GioiaCommunity ExpertCorrect answer
Community Expert
February 10, 2017

This tutorial should help you.

http://stackoverflow.com/questions/17035379/best-way-of-passing-values-from-a-button-with-as3-event

actionscript 3 - Best way of passing values from a button with as3 event - Stack Overflow

To add values to a button you have to use the buttons instance name in front of the values you want to add it.

tarikv81354015
Participant
February 10, 2017

Thank you

Legend
February 10, 2017

A button should be nothing but a button. Any higher-level logic should go in its event handler.

kglad
Community Expert
Community Expert
February 10, 2017

to start, that's not actionscript so there's not much to say about it.

if i had to critique the abstraction you posted, i would say it must represent a case-insensitive language (unlike actionscript 3) because Y = y.  otherwise, you changed a 10 into a 3 which is unexplained.  the last few lines should probably be:

10*5=50;

100-50=50;

tarikv81354015
Participant
February 10, 2017

Thank you, but can you tell how can I assign values to buttons?

I can send you file if you want so you could understand better.

kglad
Community Expert
Community Expert
February 10, 2017

you can't do much with simple buttons except assign them a name that can be parsed to determine points.  most of us use movieclip buttons which are much more flexible and can be assigned a dynamic property (eg, points):

btn1.points = 5;

btn2.points = 10;

on the other hand, all your buttons appear to have the same point value so there's no need for that.  you just need to tally the number of correct (or incorrect) answers.