Flash AS3 make a teacup vibrate GIF animation effect

Source: Internet
Author: User
Tags rand

The following small series for everyone to introduce the Flash AS3 make a teacup animated GIF animation effect, the tutorial is very good oh, but also very simple, together to learn!

The effect is as follows: (with the mouse pointing to the right teapot can see the vibration effect)

The production process is as follows:

First prepare a picture as the background, as follows:

Then create a new layer, import a teapot material, then turn it into a movie clip, and then name the instance.

There are currently two layers, and then we create a new layer with the action, the code is as follows:

The

code is as follows: var coordx:number = shaker_mc.x;


var coordy:number = shaker_mc.y;


var timer:timer = new Timer (TEN);</p> <p>shaker_mc.buttonmode = true;</p> <p>shaker_ Mc.addeventlistener (Mouseevent.roll_over,startshake);


Shaker_mc.addeventlistener (Mouseevent.roll_out,stopshake);


Timer.addeventlistener (Timerevent.timer, shakeimage);





function Startshake (e:mouseevent): void{


Timer.start ()


}function Stopshake (e:mouseevent): void{


Timer.stop ();


shaker_mc.x = COORDX;


shaker_mc.y = Coordy;


shaker_mc.rotation = 0;


}function shakeimage (event:event): void {


shaker_mc.x = coordx+ getminusorplus () * (Math.random () *5);


shaker_mc.y = coordy+ getminusorplus () * (Math.random () *5);


shaker_mc.rotation = Getminusorplus () * Math.random () *6;


} function Getminusorplus (): int{


var rand:number = Math.random () *2;


if (rand<1) return-1


else return 1;


}

Try the effect!

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.