|
推导三角形面积(纯AS) |
http://www.xxqqss.com 学习轻松网 点击量:14866
|
|
|
[思路] 先创建一个三角形,然后复制一个并旋转移动与原图拼成一个平行四边形,平行四边形面积=底×高,所以三角形面积=底×高÷2。
[演示]
[过程]
1、创建一个影片剪辑,在帧上写如下代码:
this.createEmptyMovieClip("sjx0", 1); with (sjx0) { lineStyle(2, 0x000000); beginFill(0xFF0000); moveTo(0, 0); lineTo(0, 0); lineTo(60, 100); lineTo(-100, 100); } duplicateMovieClip(sjx0, "sjx1", 2); sjx1._x = 0; sjx1._y = 0; my_txt.text = ""; sjx1.onEnterFrame = function() { delete this.onRelease; if (this._rotation<180) { this._rotation += 5; } else { this._rotation += 0; if (this._y<100) { this._y += 5; this._x += 3; } if (this._y == 100) { this._y += 0; this._x += 0; createTextField("my_txt", 3, 50, 20, 80, 20); my_txt.text = "点击重来"; my_txt.selectable = false; my_txt.autoSize = true; my_txt.textColor = 0xFFFFFF; this.onRelease = function() { my_txt.text = ""; this._x = 0; this._y = 0; this._rotation = 0; }; } } };
2、把上面元件拖入到主场景中合适的位置。
来源:闪吧 作者:qinz
|
|
|
|