Create a custom scale ruler in Flash with JSFL

Source: Internet
Author: User
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!



Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.