Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I assign values to the buttons in AS3?

New Here ,
Feb 10, 2017 Feb 10, 2017

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!

642
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 10, 2017 Feb 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.

Translate
Community Expert ,
Feb 10, 2017 Feb 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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2017 Feb 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 10, 2017 Feb 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 10, 2017 Feb 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2017 Feb 10, 2017

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 10, 2017 Feb 10, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines