Flash production of simple triangular function courseware

Source: Internet
Author: User
Tags define function insert sin variable
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;
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.