Click to browse this file
The function of the calculator is to perform data calculation. In the calculator, it is mainly used to use the important components in Flash - buttons. We can see that a large number of buttons are neatly distributed in the panel of the calculator, including the digital buttons of the input data and the symbol buttons for the data processing. We can add relevant Actions for each button to implement the mouse click to interact with the calculator. We can add a script corresponding to its function for each button, such as the number button "1" to add the following script:
On (Release) {Display = DISPLAY 1;}
The above statement implementation Click the button "1" to add the function of the digital 1 in the data display area, and have not considered the original characters in the display area " ", "-", "*", "/", etc. Case. Use this method to write scripts for each button will be cumbersome and meaningless. 1. Making calculator casing
This example is not only a work with computing function, but also makes it beautiful, so the production of calculator enclosure is first detailed.
(1) Start Flash MX, set its document size to 450 × 500 pixels, and set to black.
(2) Press the shortcut key Ctrl F8 to create a new graphic component and name Face, which is created below.
(3) Select the rectangle tool, click the button of the option area, set the "angular radius" value to 20 in the "Rectangular Settings" dialog box, plot a size of 400 × 470 pixels in the stage. Corner rectangle.
(4) Select the rounded rectangle, select the pigment tool, and press the shortcuts SHIFT F9 to open the mixing machine panel, select linear gradient and set it to blue gradient, and fill the gradient for rectangular. Then select the conversion fill tool to adjust the gradient. The gradient and filling effect of the setup are shown in Figure 2. Figure 2 sets the gradient and filling effect
(5) Create a new layer, use a pen tool to draw and use the arrow tool to edit the shape shown in Figure 3 and fill and adjust the gradient, put it in the position shown in Figure 3.
Figure 3 is a decorative shape of the calculator case
(6) Create a layer, select the rectangle tool, click the button on the option area, unvers the fillet, draw a 280 × 320 borderless rectangle, and fill it into gradient and adjust it.
(7) Create a layer, select line tool, press and hold the SHIFT button to draw a deep blue horizontal line of 278, line crude 3, and place it to step (6) The rectangular top edge position. Draw a length of 318, the line thickness of 3, and place it to the right position of the rectangle drawn by the step (6).
(8) Select the top edge of the top, hold down the CTRL button to copy one, change the copied horizontal line to white, the line is crude to 4, place it to step (6) The rectangular bottom position . According to the same method, copy the right vertical line, change it to white, rough 4, and place it to the left position of the rectangle.
(9) Create a layer, select the text tool to add text Flash MX, set its font to Chinese color cloud, and the font size is set to 30.
(10) Continuously selecting the "Modify" / "Separation" command to disperse the text, then fill the gradient, and note that click the lock button to lock the lock button in the Draw toolbar before filling the gradient. Use the Arrow Tool to select and delete the letter border, drag and drop it to the appropriate location. The final effect of the Face component is shown in Figure 4.
Figure 4 Final effect of Face components
2. Making Button Components This example The calculator includes 20 buttons, all buttons can be divided into three classes, ie the digital buttons 0 ~ 9 (including decimal points ".", Symbol buttons " ", "-", "*", "/" , "=" And "MR ", "MR -" (subtracted with the number of memories), "MRC" (number of memory numbers) and "C" (Clear). We will digital buttons And " ", "-", "*", "/", "=" are made into a style, "MR ", "MR -", "MRC", and "C" are produced into another style.
(1) Press the shortcut key Ctrl F8 to create a new graphic component, named "Buttonup".
(2) Draw the button shown in FIG. 5 in the component editing scenario, pay attention to make its edge pattern "very fine" and filled the upper side line color of the button center graphic to reflect the edge highlight effect.
Figure 5 ButtonUp elements and their parameters
(3) Press the shortcut key Ctrl F8 to create a new graphical component, named "ButtonOver".
(4) Copy one as shown in Figure 5, select "Edit" / "Paste to Current Position" command to paste it into the stage of the Buttonover component.
(5) Fill the bottom graphic as red, as a button when the mouse passes.
(6) Press the shortcut key Ctrl F8 to create a new button component, name "0"
(7) Drag the ButtonUp element to the first frame "bounce" frame "0" and align the center of the stage.
(8) Insert a blank key frame in the "Pointer" frame in the "0" frame, drag the Buttonover component to the stage and aligned.
(9) Right-click the "Bounce" frame to select the "copy frame" command in the shortcut menu; right-click the frame "Press" frame, select the "Paste Frame" command in the shortcut menu. Paste the first frame of the copy to the third frame.
(10) Insert a keyframe in the 4th frame, select the ButtonUp component in the stage, select the "Modify" / "Separation" command to separate it, then remove the underlying graph, put the upper graphic as the button of the button Area.
(11) Create a new layer, select the text tool into the number 0, set its font size to 30, and set it to white, and can be slightly pressed slightly in the property panel by adjusting the wide high value in the attribute panel. The four frames of the fabricated button 0 are shown in Figure 6.
Figure 6 button 0 and 4 frames thereof
(12) Right click on any frame of the button 0, select "Select all frame" commands, click the right mouse button again, select the "Copy Frame" command. Press the shortcut Ctrl F8 to create a new button component, name "1", right-click on its first frame, select the "Paste Frame" command to paste all frames of the button to the button 1.
(13) Select the text tool to modify the number 0 of the paste to the number 1.
(14) Making button elements "2" to "9" and "." And " ", "*", "*", "/", "=", as shown in Figure 7 according to the same method.
Figure 7 Button elements of the first style
(15) Press the shortcut key Ctrl F8 to create a new button component, named "xbutton".
(16) Edit the button Xbutton as shown in Figure 8.
Figure 8 xbutton components and their parameters
(17) Creating a button element, named "C", copy all frames of the Xbutton element and paste on the timeline of the C element. (18) Create a layer, select the text tool into the letter C.
(19) Make button "MRC", "M " and "M-" according to the same method, as shown in Figure 9.
Figure 9 Button elements of the second style
3. After all components of the layout board are made, you can lay out the calculator panel. (1) Drag and drop the Face component into the main scene. (2) Creating a new layer, dragging each button to the appropriate location in the main scene. (3) Creating a new layer, selecting a text tool to draw a text box, set it to enter text in the property panel, and other specific settings are shown in Figure 10. The layout is shown in Figure 11.
Figure 10 Sets the text attribute map 11 layout a good calculator panel 4 in the property panel. The panel of the Actions Calculator is done, but it is just a empty shell without a soul. Now we give it a soul -Actions, let it become a true calculator. (1) Create a new layer in the main scene and name it. (2) Select the first frame of the ActionS layer, open the frame action panel, add the following Actions:
STOP ();
Memory = 0;
DISPLAY = "0";
Function pressnum (NUM) {
IF (clear) {
CLEAR = false;
DOT = false;
DISPLAY = "0";
}
IF (Display == "0" and Num! = ".") {
Display = NUM DISPLAY
} else {
Display = Display Num;
}
}
Function Pressoper (OPER) {
IF (Operator == " ") {
Display = Number (Opernum) Number (Display); DISPLAY
}
IF (Operator == "-") {
Display = OPERNUM-Display DISPLAY;
}
IF (Operator == "×") {
Display = Opernum * Display;
}
IF (Operator == "÷") {
Display = Opernum / Display DISPLAY;
}
Clear = true;
DOT = false;
Operator = OPER;
Opernum = display;
IF (Oper! = "=") {
Display = OPER DISPLAY;
}
}
The function PressNum is called when the number and decimal point keys are called, and then call the function pressoper when pressing " ", "," × "," ÷ ". CLEAR indicates whether it is clear, DOT indicates whether there is a decimal point, Operator represents the current operator, and Opernum records the first operand. (3) Select the button 0 and add the following Actions in its action panel:
On (Release) {
Pressnum ("0");
}
(4) Select the button 1, add the following Actions: on (Release) {
Pressnum ("1");
}
(5) Add corresponding Actions to the buttons 2 to 9 according to the methods of step (3) and step (4). (6) Select the button "." Add the following Actions in its action panel:
On (Release) {
Pressnum (".");
}
(7) Select the button " " and add the following Actions in its action panel:
On (Release) {
PRESSOPER (" ");
}
(8) Select the button "-", add the following Actions in its action panel:
On (Release) {
Pressoper ("-");
}
(9) Select the button "×", add the following Actions in its action panel:
On (Release) {
PRESSOPER ("*");
}
(10) Select the button "÷" and add the following Actions in its action panel:
On (Release) {Pressoper ("/");
(11) Select the button "=" and add the following Actions in its action panel:
On (Release) {PRESSOPER ("=");
(12) Select the button "C" and add the following Actions in its action panel:
On (Release) {Display = "0"; DOT = false;
(13) Select the button "MR " and add the following Actions in its action panel:
On (Release) {Memory = Memory Number (Display); Display = "0";}
(14) Select the button "MR-" and add the following Actions in its action panel:
On (Release) {Memory = Memory-Number (Display); Display = "0";
(15) Select the button "MRC" and add the following Actions in its action panel:
On (Release) {Display = Memory; Memory = 0; Clear = True;
(16) Press CTRL ENTER to test, OK! A beautiful calculator is successful. Source file: Click to view this file