js| Create
Draw a scale in flash. The principle is relatively simple, if you use the authoring tool (draw tick marks, text ...). ), it seems a little cumbersome;
If you use JSFL words, it is more convenient, because it is only to solve the draw some tick marks and create some text.
Here I write a sequence of commands that is very simple to use, as shown in the figure:
The code is as follows:
function Drawruler () {
var _width = number (result.width);
var _height = number (result.height);
var _grad = number (Result.grad);
var grad_length;
var start =-1;
Dom.addnewline ({x:0,y:0},{x:_width,y:0});
Dom.addnewline ({x:_width,y:0},{x:_width,y:_height});
Dom.addnewline ({x:_width,y:_height},{x:0,y:_height});
Dom.addnewline ({x:0,y:_height},{x:0,y:0});
for (var i=_grad*2; i<=_width; I+=_grad) {
Start + +;
if (start% = = 0 | | start = = 0) {
Grad_length = _height/2.5;
Dom.addnewtext ({left:i-5, top:grad_length, right:i+5, bottom:grad_length+10});
Dom.settextstring (START/10);
Dom.setelementtextattr (' size ', 12);
Dom.setelementproperty (' alignment ', ' center ');
Dom.setelementtextattr (' bold ', false);
Dom.setelementtextattr (' italic ', false);
Dom.setelementtextattr (' face ', ' The Times New Roman ');
else if ((start% 5) = = 0) {
Grad_length = _HEIGHT/3;
} else {
Grad_length = _HEIGHT/5;
}
Dom.addnewline ({x:i, y:0}, {x:i, y:grad_length});
}
Dom.selectnone ();
}
var dom = Fl.getdocumentdom ();
var lib = dom.library;
var result = Dom.xmlpanel ("File:///ruler.xml");
if (Result.dismiss = = "Accept") {
Fl.outputPanel.clear ();
Drawruler ();
}
Where the XML file:
<dialog buttons= "Accept, Cancel" title= "scale" >
<vbox>
<label value= "Wide:" control= "width"/>
<textbox id= "width" value= "450" size= "5"/>
<label value= "Gao:" control= "height"/>
<textbox id= "Height" value= "5" size= "/>"
<label value= "scale:" control= "Grad"/>
<textbox id= "Grad" value= "5" size= "5"/>
</vbox>
</dialog>
enjoy!