User Guide

Building your first component 133
}
// Remove the mouse events when the drag is complete
// and clear the flag.
function mouseUpHandler()
{
dragging = false;
delete onMouseMove;
delete onMouseUp;
}
function mouseMoveHandler()
{
// Calculate the angle
if (dragging) {
var x:Number = _xmouse - width/2;
var y:Number = _ymouse - height/2;
var oldValue:Number = value;
var newValue:Number = 90+180/Math.PI*Math.atan2(y, x);
if (newValue<0) {
newValue += 360;
}
if (oldValue != newValue) {
value = newValue;
dispatchEvent( {type:"change"} );
}
}
}
}
Testing and exporting the Dial component
Youve created the Flash file that contains the graphical elements, the base classes and the class
file that contains all the functionality of the Dial component. Now its time to test the
component.
Ideally, you would test the component as you work, especially while youre writing the class
file. The fastest way to test as you work is to convert the component to a compiled clip and
use it in the components FLA file.
When youve completely finished a component, export it as a SWC file. For more
information, see “Exporting and distributing a component” on page 182.