Function these days to help others do a triangular function courseware, in fact, the practice is very simple, mainly mathematical problems, to share with everyone. The function of this example is that you can easily enter a value of the angle to calculate its positive or Yu Yen values. At the same time, through the input of the positive spin function of amplitude A and cycle k to dynamically draw the curve of the function, OK, we have a concrete look at the following effect!
1, the scene for the default 550*400, as shown in the drawing coordinate system, coordinate origin in (50,350), the establishment of two input text, the amplitude next to the variable name Jia, the cycle next to the variable named Yu.
2. Add the following statement to the first frame of the scene:
_root.x = 0;
_root.moveto (50, 350);//Locating the start point of the drawing line, which is the coordinate origin;
Stop (); 3. Insert key frame, add in second frame://define function relation
A = _root.x+50;
b = 350-jia*math.sin (((_root.x)/180*math.pi) *yu);//Origin coordinates (50,350)
4, insert the keyframe and add in the third frame:
if (x = = 200) {//define the interval of the drawing line
Stop ();
} else {
_root.linestyle (2, 0xff0000, 100);//Specifies a line with a coarseness of 2, a red color, and a transparency of 100;
_root.lineto (A, B);//Draw line to a,b location;
Updateafterevent (),//Force refresh, Flash Force display Refresh work. The statement does not depend on the trigger of the time frame.
The smaller the x+=1;//value, the higher the precision of the drawing line, but the slower the drawing line.
gotoAndPlay (2);
Describe how to set up a calculation formula.
1, first set up two input text, respectively, the variable name set to angle and output
2, for the button to add action: positive-rotating Button added:
On (release) {
output = Int (Math.sin (angle*math.pi/180) *100000)/100000;//valid number is five bits
Yu Xian Button added: On (release) {
output = Int (Math.Cos (angle*math.pi/180) *100000)/100000;
}