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!