Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- Formatting my post
- PHP: add a download as pdf file button in report page
- How to blend adsense inside your post?
- Notepad++ - Add C++ compiler
- PHPWind-- A PHP forum script applcaition in China
- PHP connect IBM db2 database in XAMPP
- Datatable export excel wraptext and newline
- phpexcel toggle expand and hide column in EXCEL and summary
- Renew SSL certificate from StartSSL
- Sweet Alert JS library - beautiful replacement of JavaScript Alert
Wednesday, October 3, 2012
Draw a tree only using actionscript
There are two ways to create a flash:
Draw in Flash CS5 or Create flash using Actionscript.
I am a programmer rather than an artisit. I tend to create flash only using actionscript.
Draw a tree only using actionscript demo:
Steps:
1) Open new document in Flash CS5, select actionscript 3.0
2) Press F9, paste the following code:
var sec:Sprite=new Sprite();
var mc = sec.graphics;
function dl(ax, ay, bx, by) {
mc.moveTo(ax, ay);
mc.lineStyle(0, 0x008000, 100);
mc.lineTo(bx, by);
}
function lzh(x, y, l, angle, n) {
if (n>0) {
var a_l, a_r, x1, x1_l, x1_r, y1, y1_l, y1_r, x2, x2_l, y2, y2_l, x2_r, y2_r;
x1 = x+0.5*l*Math.cos(angle*Math.PI/180);
y1 = y-0.5*l*Math.sin(angle*Math.PI/180);
x2 = x+l*Math.cos(angle*Math.PI/180);
y2 = y-l*Math.sin(angle*Math.PI/180);
dl(x, y, x2, y2);
a_l = angle+30;
a_r = angle-30;
l = l*2/3;
lzh(x2, y2, l, angle-Math.random()*10, n-1);
lzh(x1, y1, l*2/3, a_l, n-1);
lzh(x1, y1, l*2/3, a_r, n-1);
lzh(x2, y2, l*2/3, a_l, n-1);
lzh(x2, y2, l*2/3, a_r, n-1);
}
}
lzh(300, 400, 120, 90, 6);
addChild(sec);
var AuthorInfo:TextField=new TextField();
AuthorInfo.selectable=false;
AuthorInfo.autoSize=TextFieldAutoSize.CENTER;
AuthorInfo.text="@Jiansen Lu";
AuthorInfo.x=200-AuthorInfo.width/2;
AuthorInfo.y=330;
addChild(AuthorInfo);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment