Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Sử dụng thao tác dữ liệu Numerical Toán Trước đó trong bài học này, chúng tôi giới thiệu bạn để người điều khiển số, trong đó thực hiện các phép tính số học đơn giản trong cách nói của bạn. Toán lớp của Flash cho phép bạn truy cập vào một loạt các phương pháp hữu ích cho thao tác thêm số | Manipulating Numerical Data Using Math Earlier in this lesson we introduced you to the numeric operators which perform simple arithmetic in your expressions. Flash s Math class allows you to access a variety of useful methods for further manipulating numbers. We ll introduce a few of the most commonly used methods of the Math class here. You ll use many of the other methods in other lessons in this book. Common methods of the Math class include Math.abs The absolute-value method is used to return the scalar positive value of a number. For example var distance Number Math.abs here - there If subtracting the value of there from here results in a negative value for example -375 the Math.abs method will convert it to a positive value for example 375 ensuring a positive result. Math.round The round method accepts a number as a parameter and returns an integer. If the digit in the tenth placeholder of the number is 5 or greater the number is rounded to the next highest integer if it s less than 5 it s rounded to the next lowest integer. For example var cupsOfCoffee Number Math.round 3.7 Because 7 is greater than or equal to 5 this number is rounded up to the next highest integer 4. Math.floor This method works like Math.round except that it always rounds down to the next lowest integer. Math.ceil This method works like Math.round except that it always rounds up to the next highest integer. Math.sqrt The square-root method accepts a positive number as an argument and returns the square root of that number. For example var answer Number Math.sqrt 9 answer is assigned a value of 3. In this exercise using operators expressions and Math class methods you will write a simple algorithm that will convert Fahrenheit temperatures to Celsius. You will also program a thermometer to display the correct mercury level. 1. Open tempConverterl.fla in the Lesson06 Assets folder. All of the symbols and text fields have been created and are on the stage so that we can focus on ActionScript.