Button
Software:Flash MX 2004
Effect:We want to do a flexible button, the mouse moved to the button, it will be flexible, the mouse moved away, the opposite.
http://bbs.flash8.net/bbs/UploadFile/2005-5/2005518213136939.swf
principle:First, we need to set the maximum value of the mouse on the MC, setting the initial value. The elastic setting of resistance, the speed of elasticity. Set the initial value of the effect, and then calculate the size of the loop is to make the button elastic rather than not without elasticity of the slowly become larger.
Practice:
Draw a square (random what shape) to save as an MC (movie clip),
Onclipevent (load) {
Function abc () {
Xskal = 150;
Yskal = maximum value of 150;//mouse on MC
SX = 0;
SY = 0;//Set initial value
Multiplikator = 0.9;//The bigger the drag, the more it bounces.
Ratio = 0.3;//speed
}
function CBA () {
Xskal = 100;
Yskal = 100;
SX = 0;
SY = 0;
Multiplikator = 0.9;
Ratio = 0.3;
}
function dy () {
Onenterframe = function () {
SX = sx*multiplikator+ ((xskal-this._xscale) *ratio);
SY = sy*multiplikator+ ((yskal-this._yscale) *ratio)//Size loop (that is, elasticity) =0x resistance + ((MC Max-MC Scaling property) x speed)
This._xscale = THIS._XSCALE+SX;
This._yscale = this._yscale+sy;//The Scaling property of the MC =MC the scaling Property + elasticity
};
}
}
On (rollover) {//Mouse move to button
This.swapdepths (2)//Bouncing button on top, see AS2.0 dictionary
ABC ()//Execution function ABC ()
DY ();//execute function dy ()
}
On (RollOut) {//mouse move off button
This.swapdepths (1)//No Bouncing button in the lower level
CBA ()//executive function CBA ()
DY ();//execute function dy ()
}