Polyline Motion Effect:
Create a new MC component and write the following code on the MC timeline:
this._x = this._y = 0;
Total = 5;
MyColor = random (0XFFFFFF);
Speed = 5;
for (i = 0; i < total; i++) {
Createemptymovieclip ("MC" + I, I);
This["MC" + i]._y = random (stage.height);
This["MC" + i]._x = random (stage.width);
This["MC" + I].XSP = random (speed) + 5;
This["MC" + I].YSP = random (speed) + 5;
}
Onenterframe = function () {
r = Math.floor (random (5));
g = Math.floor (random (10));
b = Math.floor (random (20));
MyColor + + R << + g << + b;
MyColor &= 0xFFFFFF;
for (i = 0; i < total; i++) {
With (this["MC" + I]) {
_x = _x + xsp;
_y = _y + YSP;
if (_x > Stage.width | | _x < 0) {
XSP =-XSP;
MyColor + + R << + g << + b;
MyColor &= 0xFFFFFF;
}
if (_y > Stage.height | | _y < 0) {
YSP =-YSP;
MyColor + + R << + g << + b;
MyColor &= 0xFFFFFF;
}
}
}
Createemptymovieclip ("Xian", 100);
With (Xian) {
LineStyle (2, MyColor, 100);
Start_pt_x = (mc0._x + this["MC" + (TOTAL-1)]._x)/2;
Start_pt_y = (mc0._y + this["MC" + (TOTAL-1)]._y)/2;
MoveTo (start_pt_x, start_pt_y);
for (i = 0; i < total-1; i++) {
ctl_pt_x = this["MC" + i]._x;
ctl_pt_y = this["MC" + i]._y;
end_pt_x = (this["MC" + (i + 1)]._x + this["MC" + i]._x)/2;
End_pt_y = (this["MC" + (i + 1)]._y + this["MC" + i]._y)/2;
Curveto (ctl_pt_x, ctl_pt_y, end_pt_x, end_pt_y);
}
ctl_pt_x = this["MC" + (TOTAL-1)]._x;
ctl_pt_y = this["MC" + (TOTAL-1)]._y;
end_pt_x = (this["mc0"]._x + this["MC" + (TOTAL-1)]._x)/2;
End_pt_y = (this["mc0"]._y + this["MC" + (TOTAL-1)]._y)/2;
Curveto (ctl_pt_x, ctl_pt_y, end_pt_x, end_pt_y);
}
};
In the home view, drag three of the components, the effect is as follows:
Curve Motion Effect:
The code to draw the polyline is as follows:
this._x = this._y = 0;
Total = 6;
MyColor = random (0XFFFFFF);
Speed = 5;
for (i = 0; i < total; i++) {
Createemptymovieclip ("MC" + I, I);
This["MC" + i]._y = random (stage.height);
This["MC" + i]._x = random (stage.width);
This["MC" + I].XSP = random (speed) + 5;
This["MC" + I].YSP = random (speed) + 5;
}
Onenterframe = function () {
r = Math.floor (random (5));
g = Math.floor (random (10));
b = Math.floor (random (20));
MyColor + + R << + g << + b;
MyColor &= 0xFFFFFF;
for (i = 0; i < total; i++) {
With (this["MC" + I]) {
_x = _x + xsp;
_y = _y + YSP;
if (_x > Stage.width | | _x < 0) {
XSP =-XSP;
MyColor + + R << + g << + b;
MyColor &= 0xFFFFFF;
}
if (_y > Stage.height | | _y < 0) {
YSP =-YSP;
MyColor + + R << + g << + b;
MyColor &= 0xFFFFFF;
}
}
}
Createemptymovieclip ("Xian", 100);
With (Xian) {
LineStyle (2, MyColor, 100);
MoveTo (mc0._x, mc0._y);
for (i = 0; i < total-1; i++) {
LineTo (this["MC" + i]._x, this["MC" + i]._y);
}
LineTo (mc0._x, mc0._y);
}
};