Flash make elastic button

Source: Internet
Author: User
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 ()
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.