在Flash中做推导三角形面积效果(纯AS)

资讯 驱动中国 somesun 912 次阅读 0 条评论
分享 Q

[思路]
先创建一个三角形,然后复制一个并旋转移动与原图拼成一个平行四边形,平行四边形面积=底×高,所以三角形面积=底×高÷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、把上面元件拖入到主场景中合适的位置。
版权声明:本文由驱动中国整理发布,转载需注明出处与原文链接。如有疑问请联系 editor@qudong.com
本文价值 成为第一个评分的人
登录后为本文打分
网友评论0 条评论
正在回复 的评论取消
评论加载中…
🔐

登录后参与互动

评论、点赞均可赚积分
连续签到、邀请好友也有奖励 🎁

电脑端: 微信扫码登录 微信内: 一键登录

微信扫一扫

打开微信「扫一扫」,分享本文到朋友圈或好友