Calculator

11 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€64.91
List Price:  €92.74
You save:  €27.82
£55.84
List Price:  £79.77
You save:  £23.93
CA$95.73
List Price:  CA$136.76
You save:  CA$41.03
A$105.88
List Price:  A$151.27
You save:  A$45.38
S$94.74
List Price:  S$135.35
You save:  S$40.60
HK$546.74
List Price:  HK$781.10
You save:  HK$234.35
CHF 63.47
List Price:  CHF 90.67
You save:  CHF 27.20
NOK kr758.86
List Price:  NOK kr1,084.13
You save:  NOK kr325.27
DKK kr484.32
List Price:  DKK kr691.91
You save:  DKK kr207.59
NZ$116.44
List Price:  NZ$166.35
You save:  NZ$49.91
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳8,192.12
List Price:  ৳11,703.53
You save:  ৳3,511.41
₹5,845.24
List Price:  ₹8,350.71
You save:  ₹2,505.46
RM331.19
List Price:  RM473.15
You save:  RM141.96
₦101,684.97
List Price:  ₦145,270.47
You save:  ₦43,585.50
₨19,468.63
List Price:  ₨27,813.52
You save:  ₨8,344.89
฿2,574.93
List Price:  ฿3,678.63
You save:  ฿1,103.70
₺2,254.33
List Price:  ₺3,220.61
You save:  ₺966.27
B$360.86
List Price:  B$515.53
You save:  B$154.67
R1,285.96
List Price:  R1,837.17
You save:  R551.20
Лв126.94
List Price:  Лв181.36
You save:  Лв54.41
₩95,732.56
List Price:  ₩136,766.67
You save:  ₩41,034.10
₪261.33
List Price:  ₪373.34
You save:  ₪112.01
₱4,047.59
List Price:  ₱5,782.52
You save:  ₱1,734.93
¥10,909.97
List Price:  ¥15,586.34
You save:  ¥4,676.37
MX$1,171.54
List Price:  MX$1,673.70
You save:  MX$502.16
QR255.51
List Price:  QR365.03
You save:  QR109.52
P951.34
List Price:  P1,359.12
You save:  P407.77
KSh9,168.69
List Price:  KSh13,098.69
You save:  KSh3,930
E£3,292.89
List Price:  E£4,704.33
You save:  E£1,411.44
ብር4,020.45
List Price:  ብር5,743.75
You save:  ብር1,723.29
Kz58,375.85
List Price:  Kz83,397.65
You save:  Kz25,021.80
CLP$64,835.23
List Price:  CLP$92,625.73
You save:  CLP$27,790.50
CN¥506.35
List Price:  CN¥723.39
You save:  CN¥217.04
RD$4,074.29
List Price:  RD$5,820.67
You save:  RD$1,746.37
DA9,399.01
List Price:  DA13,427.73
You save:  DA4,028.72
FJ$158.92
List Price:  FJ$227.04
You save:  FJ$68.12
Q544.02
List Price:  Q777.21
You save:  Q233.18
GY$14,649.16
List Price:  GY$20,928.27
You save:  GY$6,279.10
ISK kr9,756.60
List Price:  ISK kr13,938.60
You save:  ISK kr4,182
DH701.90
List Price:  DH1,002.76
You save:  DH300.86
L1,242.81
List Price:  L1,775.52
You save:  L532.71
ден3,996.50
List Price:  ден5,709.54
You save:  ден1,713.03
MOP$563.52
List Price:  MOP$805.07
You save:  MOP$241.54
N$1,287.85
List Price:  N$1,839.87
You save:  N$552.01
C$2,577.61
List Price:  C$3,682.46
You save:  C$1,104.85
रु9,354.77
List Price:  रु13,364.54
You save:  रु4,009.76
S/258.41
List Price:  S/369.18
You save:  S/110.76
K271.72
List Price:  K388.19
You save:  K116.47
SAR262.50
List Price:  SAR375.02
You save:  SAR112.51
ZK1,916.71
List Price:  ZK2,738.27
You save:  ZK821.56
L323.04
List Price:  L461.50
You save:  L138.46
Kč1,610.16
List Price:  Kč2,300.33
You save:  Kč690.17
Ft25,114.33
List Price:  Ft35,879.15
You save:  Ft10,764.82
SEK kr760.20
List Price:  SEK kr1,086.05
You save:  SEK kr325.84
ARS$61,800.59
List Price:  ARS$88,290.35
You save:  ARS$26,489.75
Bs483.82
List Price:  Bs691.20
You save:  Bs207.38
COP$272,193.39
List Price:  COP$388,864.37
You save:  COP$116,670.97
₡35,883.99
List Price:  ₡51,265.04
You save:  ₡15,381.05
L1,730.53
List Price:  L2,472.30
You save:  L741.76
₲524,817.92
List Price:  ₲749,772.03
You save:  ₲224,954.10
$U2,694.96
List Price:  $U3,850.11
You save:  $U1,155.14
zł278.08
List Price:  zł397.28
You save:  zł119.19
Already have an account? Log In

Transcript

Hello, and welcome to this new video tutorial brought to you by our Roja media. In this tutorial, we will create a basic functioning arithmetic calculator using Flash drawing tools like input and output text fields, buttons, and lots of ActionScript. This simple calculator will perform addition, subtraction, multiplication, and division. To get started, take a new Flash file with ActionScript 3.0. named the very first layer as an object, we will need to input text fields to level them. Take a static text firstly on stage and type input one. And now take an input text box in front of this text.

This will be the first box to enter the first figure to be calculated from profit panel, keep each behavior to single line and click on the option for show border around text. So to view the border as an input box, now, we need to choose the embedding characters. So click on embed, and choose only two options, numerals for numbers, and punctuation for decimal points. Set the maximum characters to 999. Also give it an instance name as input one underscore txt to use in ActionScript. Similarly, we will need a second input box.

So hold down the Alt key and drag the about text and text box downwards to duplicate it, as seen in the video. Now, rename this text to input two Rename the instance name of input text field to input to underscore txt. Rest all the properties will remain the same for this input box. So this is done. Now, we need an output box to view the calculated figure. So again, duplicate the about text and text box.

Rename this new text box level to output select this text box, change this type to dynamic text and also modify the instance name to output underscore txt for this to the same character embedding should be used. So these are the basic input and output text box fields required. Now we move to the buttons to do the arithmetic calculation. So let's get them to go to Windows components. I'll simply press Ctrl plus f7. In the user interface options here, we have ready made buttons available.

Click and drag one button on stage. We don't need such a big button for calculator signs. So let's resize it from the Properties panel. set its width to 35 and let the height to 20. To open the component inspector and change its level two plus sign also name its instance as ad underscore btn from the Properties panel. Here we are ready with the plus button.

Similarly, we need three more buttons besides this. So again, hold the Alt key to duplicate this button. Place it exactly besides the previous one Change the label for this to minus sign and also rename the instance name to sub underscore btn. Make one more copy of the button. Now this is supposed to be a multiplication button label name to star sign, which represents multiplication. So rename the instance name to multi underscore btn.

And next duplication is for the division button. For this, rename the level to slash and the instance name to div underscore btn. That is di v underscore btn. So finally, we are ready with all the design elements for the basic arithmetic calculator along with their instance names. You can modify its look and feel as per your choice. Let's save our file as calculator.

Now we move to the ActionScript part. Before this, let's take the file we have worked on till now. Press Ctrl plus Enter to publish the swf, we are able to enter the values in the input boxes, just the operations are not working because our ActionScript is not done yet. So, let's start add a new layer of actions and press f9 to get the action panel. First thing we need to do is define the global variables. global variables are the variables which can be used a number of times in coding, those are defined outside the function first, num, one variable is to store the entered value in the first input textbox Similarly, num to variable is taken to store the entered value in the second input text box.

And the third result variable to view the result in the output text box. Every time on addition, subtraction, multiplication and division function, input one and input two values are captured, and then processed as per the assigned function. For all of these, let's give a common function named capture. No data types will be applied to it. In this assign input one values to num one variable and input two values to num two variable Now let's add a function for addition. In this, we need to first capture the input values.

So let's call the capture function here. Now, the actual additional process should happen and the result value should be assigned to the output textbox. This value will be viewed in result variables String class type. Now, let's go this addition file. On the Add button, add underscore btn is the instance name for it. Let's say it's the movie for the addition function, put any values in both input boxes and then click on the Add button, we get the proper calculated result in the output box.

So, we can say we are done for additional scripting. Similarly, let's do it for the rest three buttons as well. function for the subtraction part is also the same. In this the capture function is called to capture the values from the input text boxes. Just the difference is applied in the result part. That is num one minus num two and the output text box is applied the result value.

Similarly, we work on the multiplication factor The capture function is called here num one and num two multiplication is stored in the result variable. And this result value is assigned to the output text field. A similar function is added for division, just a result value will be actual division of num one and num to this result string value is assigned to the output text. Here all the function part is done. Earlier we have already assigned the above addition function to the Add button below. Similarly, we called on the subtraction function on sub underscore btn.

That is the subtraction button also called the multiplication function on multi underscore btn that is multiplication button and the division function on d iV underscore btn. That is division button. So it's time to test the movie now. Press Ctrl plus Enter to export the SWF. Let's insert 144 into input one, and 12 in input two. Now, first press the Add button, we get a proper result of 144 plus 12 in the output at the same time, click on the minus button and we again get a proper result of 144 minus 12.

Now click on the multiplication button and see again we get the correct result of input one into input to now click on the last divide button. Again it shows the exact result of input one divided by input two. This is how we created a simple but perfect arithmetic calculator in Flash using ActionScript 3.0. As mentioned Before you can have your own look and feel to this you can experiment with the design out of the media is glad to get you this useful video tutorial. Thanks for watching

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.