03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void {<br />

mc.lineStyle(2, 0xFF0000, 100);<br />

mc.moveTo(x+r, y);<br />

mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x,<br />

Math.sin(Math.PI/4)*r+y);<br />

mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y);<br />

mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x,<br />

Math.sin(Math.PI/4)*r+y);<br />

mc.curveTo(-r+x, Math.tan(Math.PI/8)*r+y, -r+x, y);<br />

mc.curveTo(-r+x, -Math.tan(Math.PI/8)*r+y, -Math.sin(Math.PI/4)*r+x, -<br />

Math.sin(Math.PI/4)*r+y);<br />

mc.curveTo(-Math.tan(Math.PI/8)*r+x, -r+y, x, -r+y);<br />

mc.curveTo(Math.tan(Math.PI/8)*r+x, -r+y, Math.sin(Math.PI/4)*r+x, -<br />

Math.sin(Math.PI/4)*r+y);<br />

mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y);<br />

}<br />

pow (Math.pow method)<br />

public static pow(x:Number, y:Number) : Number<br />

Computes <strong>and</strong> returns x to the power of y.<br />

Parameters<br />

x:Number - A number to be raised to a power.<br />

y:Number - A number specifying a power the parameter x is raised to.<br />

Returns<br />

Number - A number.<br />

Example<br />

The following example uses Math.pow <strong>and</strong> Math.sqrt to calculate the length of a line.<br />

this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth());<br />

var mouseListener:Object = new Object();<br />

mouseListener.onMouseDown = function() {<br />

this.origX = _xmouse;<br />

this.origY = _ymouse;<br />

};<br />

mouseListener.onMouseUp = function() {<br />

this.newX = _xmouse;<br />

this.newY = _ymouse;<br />

var minY = Math.min(this.origY, this.newY);<br />

var nextDepth:Number = canvas_mc.getNextHighestDepth();<br />

var line_mc:MovieClip =<br />

canvas_mc.createEmptyMovieClip("line"+nextDepth+"_mc", nextDepth);<br />

line_mc.moveTo(this.origX, this.origY);<br />

388 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!