[此文来源于互联网,牛C网只负责收集整理]

[思路]

先创建一个三角形,然后复制一个并旋转移动与原图拼成一个平行四边形,平行四边形面积=底×高,所以三角形面积=底×高÷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、把上面元件拖入到主场景中合适的位置。

        

            


作者:gdgzboy@牛C网
地址:http://www.niuc.net/post/1938/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!



评论(0) | 引用(0) | 阅读(210)
发表评论
昵称 [注册]
密码 游客无需密码
网址
电邮
打开HTML 打开UBB 打开表情 隐藏 记住我