一个用纯AS写的正态曲线画法

2016-01-29 13:03 1 1 收藏

一个用纯AS写的正态曲线画法,一个用纯AS写的正态曲线画法

【 tulaoshi.com - Flash 】

我的这段AS写了不少有用的函数,如画按钮函数,画坐标轴函数,画框架函数.这些函数都有很强的移植性,以后都可以直接拿来用; //================按钮和坐标轴上的文字=====================//
mytxt = ["开始", "暂停", "清除", "全屏", "退出", "继续"];
myNum = ["-30", "-20", "-10", "0", "10", "20", "30", "X", "Y"];
//=====画按钮(type不为0时按钮为凸起状态type=0时按钮为凹下状态)=====//
CommandButton = function (mc, t, type) {
c = 0xffffff;//按钮左和上边框颜色
c1 = 0x000000;//按钮右和下边框颜色
mc.createTextField("txt", 700, 12, 1, 27, 18);
if (!type) {
c = 0x000000;
c1 = 0xffffff; //type=0时左和上与右和下边框颜色交换;
mc.createTextField("txt", 700, 13, 2, 27, 18);//按下时文本框向左下移,使字有凹下感觉
}
with (mc) {
moveTo(0, 20);
lineStyle(1, c, 100);
beginFill(0xD1DEE9);
lineTo(0, 0);
lineTo(50, 0);
lineStyle(1, c1, 100);
lineTo(50, 20);
lineTo(0, 20);
endFill();
txt.text = t;
}
};
//===========画框架=============//
display = function (mc, x, y, w, h, txt, corl) {
with (mc) {
moveTo(x, y);
lineStyle(0.5, 0x00000, 100);
beginFill(corl, 40);
lineTo(x+w, y);
lineTo(x+w, y+h);
lineTo(x, y+h);
lineTo(x, y);
endFill();
createTextField("name", 300, x+2, y-17, 0, 0);
name.autoSize = "left";
name.selectable = false;
name.border = true;
name.background = true;
name.backgroundColor = 0x798DA6;
name.textColor = 0xffffff;
name.text = txt;
}
};
//========画坐标轴上刻度及数字==============//
dial = function (mc, len, corl, txt, type) {
with (mc) {
moveTo(0, 0);
lineStyle(0.25, corl, 100);
if (type) {//type不为0时刻度坚着画,为0时刻度横着画;
lineTo(0, len);
createTextField("num", 600, -7, len+1, 0, 0);
} else {
lineTo(len, 0);
createTextField("num", 600, len+1, -2, 0, 0);
}
num.autoSize = true;
num.selectable = false;
num.text = txt;
}
};
//========画坐标轴============//
coordinate = function (x, y) {
_root.moveTo(x-215, y);
_root.lineStyle(0.25, 0x00000, 100);
_root.lineTo(x+215, y);
_root.lineTo(x+185, y+5);
_root.moveTo(x+215, y);
_root.lineTo(x+185, y-5);
_root.moveTo(x, y+20);
_root.lineTo(x, y-220);
_root.lineTo(x-5, y-190);
_root.moveTo(x, y-220);
_root.lineTo(x+5, y-190);
for (i=0; i<19; i++) {
_root.createEmptyMovieClip("l"+i, 510+i);
if (i<13) {
!(i%2) ? dial(_root["l"+i], 5, 0xff0000, myNum[i/2], 1) : dial(_root["l"+i], 3, 0x000000, "", 1);//刻度隔一个为红色,且有数字
_root["l"+i]._x = x-198+33*i;
_root["l"+i]._y = y;
}
if (i12) {//同上
!(i%2) ? dial(_root["l"+i], 5, 0xff0000, myNum[i/2-3], 0) : dial(_root["l"+i], 3, 0x000000, "", 0);
_root["l"+i]._x = x;
_root["l"+i]._y = y-33*(i-12);
}
}
_root.createTextField("Xt", 250, x+220, y-3, 18, 18);
_root.createTextField("Yt", 260, x, y-230, 18, 18);
Xt.text = myNum;
Xt.selectable = false;
Yt.text = myNum;
Yt.selectable = false;
};
inputBoxs = function (x, y) {
var alpha = ["u =", "0", "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 = -(

来源:https://www.tulaoshi.com/n/20160129/1488731.html

延伸阅读
标签: Web开发
DreamScript是我去年1月就开始自己写的一个框架,后在6月因为换工作的原因导致无更多时间自己一人写下去,期间对他多次改进,先那出来,希望大家看看一起学习,如果有兴趣一起做的,我也很欢迎。在这里我说明一下他是一个主要使用SOAP和WebService交换数据的,这也是我的想法,只使用WS做为通信标准。在这其中我融合了很多框架的亮点,根据自己...
标签: PHP
在开始这篇文章时,作者假设读者已能够写出一个用户的登入认证程序. ---------------------------------------------------------- 记数器可完成访问 web 页的总次数,但却不能得知一个时段中访问量的动态记载,下面就来介绍如何写一个各个时段动态显示访问量的方法. 要记载访问量,首先就要在 mysql 内建立一个数据库,姑且给这...
标签: ASP
<!--#include file="../lib/filelib.asp"-- <% Response.write "<title上传文件至当前文件夹</title" Response.Write "<body bgcolor=""#D6D3CE"" leftmargin=""0"" topmargin=""0"" title = "" 请您遵守国家相关法律法规上传文件。上传前请杀毒,否则系统将会自动删除此文件!""" '**Start Encode** Action=Request("A") If ...
感情走到尽头,尽管会有不舍,但也是验证了一句话,逝去的就很难再挽回。的确,两个人最初因为相爱在一起,但最终还是会因为各种原因选择分道扬镳。这其中的各种心酸或许只有当事人才会更好知晓。下面,图老师小编从女人心理角度为大家盘点一个离婚女人的离婚感悟,一起看看什么样的男人值得嫁! 离婚感悟 1、按他的要求去做...
标签: Web开发
主要是集成了常用的扩展,包括Dom与String、Array、StringBuffer、NameSpace等,当然还少不了Ajax。体积约8k。因为严格控制体积,所以功能有限。如果只要Ajax部分,就1k而已。 这个小框架已经应用到公司的项目,并开始逐步在前端展示页面上接替prototype.js。以后将围绕这个框架做一些应用。 代码如下: /* *    My&n...

经验教程

877

收藏

24
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部