今天无聊给大家讲个新玩意吧!如果有点程序基础的看看下面的,重要的我已经解释过半,flash 8.0勿试!效果:(可以用鼠标连续点击)
先看看下面的代码:
// [Action in Frame 1]
function initFlower()//init一个在开始循环序列前要计算的表达式/init(初始化)表达式
{
FLOOR_POS = flowerDot_mc._y - 1;
fNum = -1;
tipScale = growScale = tipSlow = growSlow = 0;//开始了
flower = false;//花儿
growing = true;//生长
flowerDot_mc._visible = false;
tip = new Array();//记录叶子的数组
c1 = new Array();
c2 = new Array();
m1 = new Array();
m2 = new Array();
c3 = new Array();
c4 = new Array();
this.createEmptyMovieClip("flower_mc", 0);
flower_mc._x = flowerDot_mc._x;
leafTotal = int(rnd() * 5) + 3;//rnd函数在使用中可以用语句Randomize进行初始化
leafLength = rnd() * 80 + 20;
leafWidth = leafLength / leafTotal * 3.141593 * rnd();
leafNextNum = leafNum = int(rnd() * leafColor.length);
petalNextNum = petalNum = int(rnd() * petalColor.length);
midNum = int(rnd() * midColor.length);
flower_color = new Color("flowerDot_mc");
flower_color.setRGB(leafLine[leafNum]);
} // End of the function
function newFlower()
{
flowerDot_mc._visible = true;
if (fNum == 1)
{
flower = true;
} // end if
if (fNum == 2)
{
growing = false;
return(undefined);
} // end if
fNum++;
flower_mc.createEmptyMovieClip(fNum, fNum).createEmptyMovieClip("stem_mc", -1);
flower_mc[fNum].ox = 0;
flower_mc[fNum].oy = fNum == 0 ? (FLOOR_POS) : (flower_mc[fNum - 1].oy);
tip[fNum] = new Array();
c1[fNum] = new Array();
c2[fNum] = new Array();
m1[fNum] = new Array();
m2[fNum] = new Array();
c3[fNum] = new Array();
c4[fNum] = new Array();
var _l18 = rnd() * 1.500000;
var _l17 = rnd() * 1.500000;
var _l16 = rnd() * 1.500000;
var _l14 = rnd() * 0.400000 + 0.200000;
var _l13 = rnd() * 0.400000 + 0.600000;
var _l15 = rnd() * 0.900000 + 0.100000;
if (_l15 < 0.200000)
{
_l14 = 0;
_l13 = 0;
_l15 = 0;
} // end if
if (flower)
{
var _l24 = rnd() * 80 - 100;
var _l21 = 0;
var _l23 = rnd() * 100 - 50;
var _l22 = 0;
leafTotal = int(rnd() * 7) + 3;
leafLength = rnd() * 80 + 20;
leafWidth = leafWidth + 20;
}
else
{
_l24 = rnd() * 80 - 40;
_l21 = rnd() * 40 - 20;
_l23 = rnd() * 40 - 20;
_l22 = rnd() * 30 - 15;
} // end if
tipScale = 0;
tipSlow = 0.050000;
growScale = 0.250000;
growSlow = 0.050000;
var _l1 = leafTotal;
while (_l1--)
{
var _l7 = _l1 / leafTotal * 6.283185;
tip[fNum][_l1] = new Vertex(cos(_l7) * leafLength, sin(_l7) * leafLength, _l24);
var _l8 = tip[fNum][_l1].x;
var _l6 = tip[fNum][_l1].y;
var _l12 = cos(_l7 - 1.570796);
var _l10 = cos(_l7 + 1.570796);
var _l11 = sin(_l7 - 1.570796);
var _l9 = sin(_l7 + 1.570796);
c1[fNum][_l1] = new Vertex(_l8 * _l14 + _l12 * leafWidth * _l18, _l6 * _l14 + _l11 * leafWidth * _l18, _l21);
c2[fNum][_l1] = new Vertex(_l8 * _l13 + _l12 * leafWidth * _l17, _l6 * _l13 + _l11 * leafWidth * _l17, _l23);
m1[fNum][_l1] = new Vertex(_l8 * _l15 + _l12 * leafWidth * _l16, _l6 * _l15 + _l11 * leafWidth * _l16, _l22);
m2[fNum][_l1] = new Vertex(_l8 * _l15 + _l10 * leafWidth * _l16, _l6 * _l15 + _l9 * leafWidth * _l16, _l22);
c3[fNum][_l1] = new Vertex(_l8 * _l13 + _l10 * leafWidth * _l17, _l6 * _l13 + _l9 * leafWidth * _l17, _l23);
c4[fNum][_l1] = new Vertex(_l8 * _l14 + _l10 * leafWidth * _l18, _l6 * _l14 + _l9 * leafWidth * _l18, _l21);
var _l19 = flower ? (-0.785398) : (-1.570796);
var _l20 = 0;
var _l3 = cos(_l19);
var _l2 = sin(_l19);
var _l5 = cos(_l20);
var _l4 = sin(_l20);
tip[fNum][_l1].rotate(_l5, _l4, _l3, _l2);
c1[fNum][_l1].rotate(_l5, _l4, _l3, _l2);
c2[fNum][_l1].rotate(_l5, _l4, _l3, _l2);
m1[fNum][_l1].rotate(_l5, _l4, _l3, _l2);
m2[fNum][_l1].rotate(_l5, _l4, _l3, _l2);
c3[fNum][_l1].rotate(_l5, _l4, _l3, _l2);
c4[fNum][_l1].rotate(_l5, _l4, _l3, _l2);
tip[fNum][_l1].scale(tipScale);
c1[fNum][_l1].scale(growScale);
c2[fNum][_l1].scale(growScale);
m1[fNum][_l1].scale(growScale);
m2[fNum][_l1].scale(growScale);
c3[fNum][_l1].scale(growScale);
c4[fNum][_l1].scale(growScale);
flower_mc[fNum].createEmptyMovieClip(_l1, _l1);
} // end while
} // End of the function
function updateFlower()
{
flower_mc[fNum].oy = flower_mc[fNum].oy - sin(growScale * 3.141593) * leafLength / 24;
var fx = 0;
var fy = flower_mc[fNum].oy;
var slow = flower ? (-0.000500) : (tipSlow * -0.010000);
var ax = flower_mc._xmouse * slow;
var ay = 0;
var cy = cos(ay);
var sy = sin(ay);
var cx = cos(ax);
var sx = sin(ax);
var h = abs(flower_mc[fNum].getBounds(flower_mc).yMin - fy) * 2;
with (flower_mc[fNum].stem_mc)
{
clear();
lineStyle(3, leafLine[leafNum]);
moveTo(0, fNum == 0 ? (FLOOR_POS) : (flower_mc[fNum - 1].oy));
lineTo(0, fy);
} // End of with
if (growScale < 1)
{
growSlow = growSlow * 0.950000;
growScale = growScale + growSlow;
}
else
{
growScale = 1;
} // end if
if (tipScale < 1)
{
tipSlow = tipSlow * 0.960000;
tipScale = tipScale + tipSlow;
}
else if (growing)
{
tipScale = 1;
newFlower();
} // end if
var midScale = (growScale + tipScale) / 2;
var i = leafTotal;
while (i--)
{
tip[fNum][i].rotate(cx, sx, cy, sy);
c2[fNum][i].rotate(cx, sx, cy, sy);
m1[fNum][i].rotate(cx, sx, cy, sy);
m2[fNum][i].rotate(cx, sx, cy, sy);
c3[fNum][i].rotate(cx, sx, cy, sy);
tip[fNum][i].scale(tipScale);
c2[fNum][i].scale(growScale);
m1[fNum][i].scale(midScale);
m2[fNum][i].scale(midScale);
c3[fNum][i].scale(growScale);
tip[fNum][i].perspective();
c2[fNum][i].perspective();
m1[fNum][i].perspective();
m2[fNum][i].perspective();
c3[fNum][i].perspective();
var tx = tip[fNum][i].rx;
var ty = tip[fNum][i].ry;
with (flower_mc[fNum][i])
{
clear();//清除随机绘画内容
if (flower)
{
lineStyle(growScale * leafLength / 12, midColor[midNum]);//lineStyle(粗细,RGB颜色,alpha透明度):更改当前线条样式
moveTo(fx, fy);//moveTo(x坐标,y坐标) :移动当前绘画位置。
lineTo(fx, fy - 1);//lineTo(x坐标,y坐标):开始绘制条段
} // beginGradientFill(填充类型、颜色、透明度、比率、矩阵):标识渐变填充的开始
lineStyle(growScale * 5, flower ? (petalLine[petalNum]) : (leafLine[leafNum]), 10);
moveTo(fx, fy);
beginGradientFill("radial", flower ? (petalColor[petalNum]) : (leafColor[leafNum]), [100, 100], [20, 255],
{matrixType: "box", x: -100, y: fy - h / 2, w: 200, h: h, r: 0});
if (flower)//beginGradientFill(填充类型、颜色、透明度、比率、矩阵):标识渐变填充的开始。
填充类型:字符串值,表示填充的类型。
颜色:数组,表示颜色的填充范围。
透明度:数组,表示透明度的填充范围。
比率:数组