User Guide
470 Appendix B: XML to UI
// check for valid input because sending 0 or undefined to
// scaleSelection() will cause the object to disappear.
var inputIsValid = true;
if (xScale == 0 || isNaN(xScale)) {
inputIsValid = false;
}
if (yScale == 0 || isNaN(yScale)) {
inputIsValid = false;
}
// Call scaleSelection to carry out the resizing command.
if (inputIsValid ) {
fl.getDocumentDOM().scaleSelection(xScale, yScale);
}
}
Second, create a file named scale.xml and place it in your Commands folder. Place the following
code into the file and save the file:
<?xml version="1.0"?>
<dialog id="scale-dialog" title="Scale Selection" buttons="accept, cancel">
<grid>
<columns>
<column/>
<column/>
</columns>
<rows>
<row align="center">
<label value="Scale x: " control="xScale"/>
<textbox id="xScale"/>
</row>
<row align="center">
<label value="Scale y:" control="yScale"/>
<textbox id="yScale" />
</row>
</rows>
</grid>
</dialog>
The scale command now appears on the Commands menu. Draw a shape on the Stage and
select it with the pointer tool. If you select the
scale command from the Commands menu, the
dialog box defined by scale.xml appears, as shown in the following figure: