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
You’ve 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 it’s time to test the
component.
Ideally, you would test the component as you work, especially while you’re 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 component’s FLA file.
When you’ve completely finished a component, export it as a SWC file. For more
information, see “Exporting and distributing a component” on page 182.