Easing formula:
Sprite. x + = (targetx-Sprite. X) * easing; // easing is the easing coefficient variable.
Sprite. Y + = (targety-Sprite. Y) * easing;
Elastic formula:
VX + = (targetx-Sprite. X) * spring; // spring is the elastic coefficient.
Vy + = (targety-Sprite. Y) * spring;
Sprite. x + = (VX * = friction); // friction indicates Friction
Sprite. Y + = (Vy * = friction );
Offset elastic formula:
VaR DX: Number = Sprite. X-fixedx;
VaR DY: Number = Sprite. Y-fixedy;
VaR angle: Number = math. atan2 (dy, dx );
VaR targetx: Number = fixedx + math. Cos (angle) * springlength;
VaR targety: Number = fixedx + math. Sin (angle) * springlength;
Rotate to the mouse (or to a certain point)
DX = mousex-Sprite. X;
DY = mousey-Sprite. Y;
Sprite. Rotation = math. atan2 (dy, dx) * 180/Math. Pi;
Waveform motion:
Public Function onenterframe1 (Event: Event): void {
Ball. Y = centerscale + math. Sin (angle) * range;
Angle + = speed;
}
Heartbeat:
Public Function onenterframe1 (Event: Event): void {
Ball. scalex = centerscale + math. Sin (angle) * range;
Ball. scaley = centerscale + math. Sin (angle) * range;
Angle + = speed;
}
Center rotation:
Public Function onenterframe (Event: Event): void {
Ball. x = centerx + math. Cos (angle) * radius;
Ball. Y = centery + math. Sin (angle) * radius;
Angle + = speed;
}
Elliptical rotation:
Public Function onenterframe (Event: Event): void {
Ball. x = centerx + math. Cos (angle) * radiusx;
Ball. Y = centery + math. Sin (angle) * radiusy;
Angle + = speed;
}
The color operation returns the transparent value:
VaR T: uint = 0x77ff8877
VaR S: uint = 0xff000000
VaR H: uint = T & S
VaR M: uint = H >>> 24
Trace (m)
Convert to decimal:
Trace (hexvalue );
Convert decimal to hexadecimal:
Decimalvalue. tostring (16)
Color extraction:
Red = color24> 16;
Green = color24> 8 & 0xff;
Blue = color24 & 0xff;
Alpha = color32> 24;
Red = color32> 16 & 0xff;
Green = color32> 8 & 0xff;
Blue = color0000& 0xff;
Calculated by bit to obtain the color value:
Color24 = red <16 | green <8 | blue;
Color32 = Alpha <24 | red <16 | green <8 | blue;
Curve over control point:
// XT, yt is the point you want to draw through
// X0, y0 and X2, Y2 are the end points of the curve
X1 = XT * 2-(x0 + x2)/2;
Y1 = yt * 2-(y0 + y2)/2;
MoveTo (x0, y0 );
Curveto (x1, Y1, X2, Y2 );