Copy link to clipboard
Copied
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 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.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
A button should be nothing but a button. Any higher-level logic should go in its event handler.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now