User Guide
134 Creating Components
To test the Dial component:
1. In the Dial.fla file, select the Dial component in the library, open the Library context menu
(Windows: Right-click; Mac: control-click), and select Convert to Compiled Clip.
A compiled clip is added to the library with the name Dial SWF.
2. Drag Dial SWF to the Stage on the main Timeline.
3. You can resize it and set its value property in the Property inspector or the Component
Inspector. When you set its value property, the needle’s position should change
accordingly.
4. To test the value property at runtime, give the dial the instance name dial and add the
following code to Frame 1 on the main Timeline:
// position of the text field
var textXPos:Number = dial.width/2 + dial.x
var textYPos:Number = dial.height/2 + dial.y;
// creates a text field in which to view the dial.value
createTextField("dialValue", 10, textXPos, textYPos, 100, 20);
// creates a listener to handle the change event
function change(evt){
// places the value property in the text field
// whenever the needle moves
dialValue.text = dial.value;
}
dial.addEventListener("change", this);
5.
Select Control > Test Movie to test the component in Flash Player.
NOTE
If you’ve already created a compiled clip (for example, if this is the second or third
time you’re testing), a Resolve Library Conflict dialog box appears. Select Replace
Existing Items to add the new version to the document.