邮件订阅
5ucms教程,一个用纯AS写的正态曲线画法
作者: 来源: 日期:2017/4/10 8:44:00 浏览量:30(滞后) 人气:LOADING...(实时) 【

5ucms教程,一个用纯AS写的正态曲线画法我的这段AS写了不少有用的函数,如画按钮函数,画坐标轴函数,画框架函数.这些函数都有很强的移植性,以后都可以直接拿来用; //================按钮和坐标轴上的文字=====================//
mytxt = ["开始", "暂停", "清除", "全屏", "退出", "继续"];
myNum = ["-30", "-20", "-10", "0", "10", "20", "30", "X", "Y"];
//=====画按钮(type不为0时按钮为凸起状态type=0时按钮为凹下状态)=====//
CommandButt0", "o =", "1"];
for (i=0; i<4; i++) {
_root.createTextField("v"+i, 800+i, x+i*35, y, 30, 16);
if (i%2) {
_root["v"+i].type = "input";
_root["v"+i].border = true;
_root["v"+i].text = alpha[i];
} else {
_root["v"+i].autoSize = "right";
_root["v"+i].selectable = false;
_root["v"+i].text = alpha[i];
}
}
};
//======写标题========//
headline = function (x, y, txt, dx) {
_root.createTextField("title", 900, x, y, 0, 0);
title.autoSize = true;
title.selectable = false;
title.text = txt;
mytxf = new TextFormat();//创建一个文本格式对象;
mytxf.size = dx;//太小
mytxf.color = 0xff0000;//颜色
mytxf.underline = true;//下划线
title.setTextFormat(mytxf);
};
//=====开始画线函数====//
startDraw = function () {
m = Number(v1.text);
n = Number(v3.text);//把v1,v3文本框中的值给m,n;
x = -200;
_root.createEmptyMovieClip("xian", 300);
xian.moveTo(-200, 100);
xian._x = 275;
xian._y = 193;
_root.onEnterFrame = function() {
a = -(100/(Math.sqrt(2*Math.PI)*25*n))*Math.exp((-(Math.pow((x-100*m), 2)))/ (2*Math.pow(25*n, 2)));//这个为正态曲线公式,根椐这个公式来画线;
with (xian) {
lineStyle(2, 0xE001E0, 100);
lineTo(x, 50*a+100);//画线
if (x<=200) {//画线范围
x += 3;//3为画线速度,建议设小一点,fps设大一点,这样使画出的线更平滑;
}
}
};
_root.btn1.enabled = 1;//暂停按钮可用
_root.btn5.enabled = 1;//继续按钮可用
};
//========继续画线========//
continueDraw = function () {
xian.moveTo(x-3, 50*a+100);//x,a继承上面函数的值,从当前位置画
_root.onEnterFrame = function() {
a = -(100/(Math.sqrt(2*Math.PI)*25*n))*Math.exp((-(Math.pow((x-100*m), 2)))/ (2*Math.pow(25*n, 2)));
with (xian) {
lineStyle(2, 0xE001E0, 100);
lineTo(x, 50*a+100);
if (x<=200) {
x += 3;//同上
}
}
};
};
//========暂停和清除函数==========//
pause_clear = function (k) {//不为0时为暂停,为0时为清除;
_root.onEnterFrame = function() {
x += 0;//x值不增加
};
if (k) {
xian.clear();//清除xian
_root.btn1.enabled = 0;
_root.btn5.enabled = 0;
}
};
_root.onLoad = function() {
headline(230, 20, "正态曲线", 20);
for (i=0; i<3; i++) {
_root.createEmptyMovieClip("frame"+i, 400+i);
}
display(_root.frame0, 40, 55, 470, 270, "显示", 0xE6E1CC);
display(_root.frame1, 40, 350, 160, 40, "变量", 0xDCE6ED);
display(_root.frame2, 220, 350, 290, 40, "操作", 0xDCE6ED);
coordinate(275, 295);
inputBoxs(50, 365);
_root.attachMovie("formula", "formula", 500);
formula.useHandCursor = false;//鼠标不变手形
formula._x = 42;
formula._y = 57;
for (i=0; i<6; i++) {
_root.createEmptyMovieClip("btn"+i, 700+i);
CommandButton(_root["btn"+i], mytxt[i], 1);//用循环来画按钮;
_root["btn"+i]._x = 230+55*i;
_root["btn"+i]._y = 360;
_root.btn5._x = 230+55*1;
_root.btn5._y = 360;
_root.btn5._visible = 0;//设置按钮位置,并把暂停和继续按钮放在一起;且开始时继续不可见
}
_root.btn1.enabled = 0;//开始时暂停不可用
};
_root.onEnterFrame = function() {//以下为按上每个按钮的动作;
_root.btn0.onPress = function() {
CommandButton(_root.btn0, mytxt[0], 0);//按鼠标时按钮凹下;
_root.btn1._visible = 1;//暂停按钮可见
_root.btn5._visible = 0;继续按钮不可见
startDraw();//调用开始画线函数;
};
_root.btn0.onRelease = function() {
CommandButton(_root.btn0, mytxt[0], 1);//松开鼠标时按钮凸起;
};
_root.btn1.onPress = function() {
CommandButton(_root.btn1, mytxt[1], 0);
pause_clear(0);//调用暂停
};
_root.btn1.onRelease = function() {
CommandButton(_root.btn1, mytxt[1], 1);
_root.btn1._visible = 0;
_root.btn5._visible = 1;//按了暂停按钮时,变成继续按钮;
};
_root.btn2.onPress = function() {
CommandButton(_root.btn2, mytxt[2], 0);
pause_clear(1);//调用清除函数;
};
_root.btn2.onRelease = function() {
CommandButton(_root.btn2, mytxt[2], 1);
};
_root.btn3.onPress = function() {
CommandButton(_root.btn3, mytxt[3], 0);
fscommand("fullscreen", true);//全屏
};
_root.btn3.onRelease = function() {
CommandButton(_root.btn3, mytxt[3], 1);
};
_root.btn4.onPress = function() {
CommandButton(_root.btn4, mytxt[4], 0);
fscommand("quit");//退出
};
_root.btn4.onRelease = function() {
CommandButton(_root.btn4, mytxt[4], 1);
};
_root.btn5.onPress = function() {
CommandButton(_root.btn5, mytxt[5], 0);
continueDraw();//调用继续画线函数;
};
_root.btn5.onRelease = function() {
CommandButton(_root.btn5, mytxt[5], 1);
_root.btn5._visible = 0;
_root.btn1._visible = 1;//按继续按钮时,变成暂停按钮;
};
_root.formula.onRollOver = function() {
formula._xscale = formula._yscale=330;//放大尺寸;
};
_root.formula.onRollOut = function() {
formula._xscale = formula._yscale=100;//尺寸还原
};
};


选择5ucms.org 选择未来

本站推荐: 5ucms模板下载 5ucms插件下载 仿站联系Q3876307       [复制给好友] [打印] [关闭] [返回] [顶部]
上一篇:5ucms插件,flash action 详解(3)
下一篇:5ucms教程,flash action 详解(6)
本站声明:本网站所载文章等内容,目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权及其它问题,请在30日内与本网联系(Email:3876307#qq.com),我们将在第一时间删除内容。若原创内容转载请注明出处。
5ucms教程,一个用纯AS写的正态曲线画法的关键词:
评论信息
相关分类
本周热门
本月热门
关于我们 - 版权/免责 申明 - 建站服务 - 网站地图 - 稿件投递 - 联系我们 - 5ucms
Copyright © 2008-2015 www.5ucms.org