Name

Math.PI Property — the ratio of a circle’s circumference to its diameter, approximately 3.14159

Availability

Flash 5; may be used when exporting Flash 4 movies

Synopsis

Math.PI

Description

The PI property represents the constant π, the ratio of the circumference of a circle to its diameter.

Example

Math.PI is most famously used in calculating the area of a circle:

function circleArea (radius) {
  // PI times the radius squared could also be 
  // written as Math.PI * Math.pow(radius, 2)
  return Math.PI * (radius * radius);
}

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.