Brilliant Flash animation-flash as special effects

Source: Internet
Author: User
Tags abs cos sin

The code is as follows:


import mx.transitions.*;


import mx.transitions.easing.*;


var r:number = 45;


var p:number = 0;


var drag:boolean = false;


var num:number = 0;


var name_array:array = new Array ("Flash", "Bar", "2", "0", "0", "8", "Xing", "Wang", "FA", "exhibition");


this.createemptymovieclip ("Container", this.getnexthighestdepth ());


/* Rotary * *


function Start_func () {


for (var i:number = 0; i<=9; i++) {


Container.attachmovie ("Ball", "ball" +i, I);


container[, "ball" +i]._x = 225+r* (Math.Abs (4.5-i)) *math.cos (135-(Math.floor ((I/5)) *180));


container[, "ball" +i]._y = 225+r* (Math.Abs (4.5-i)) *math.sin (135-(Math.floor ((I/5)) *180));


container["Ball" +i].txt.text = name_array[i];


container["Ball" +i].i = i;


container["ball" +i].onenterframe = function () {


var my_color:color = new color (THIS._MC);


My_color.setrgb (Math.random () *0xffffff);


this._x = 225+r* (Math.Abs (4.5-THIS.I)) *math.cos (135-(Math.floor ((THIS.I/5)) *180)) +p);


this._y = 225+r* (Math.Abs (4.5-THIS.I)) *math.sin (135-(Math.floor ((THIS.I/5)) *180)) +p);


p = p+0.5;


  };


container["ball" +i].onpress = function () {


var mytween:tween = new Tween (This, "_xscale", Elastic.easeout, MB, 1, true);


var mytween:tween = new Tween (This, "_yscale", Elastic.easeout, MB, 1, true);


  };


container["ball" +i].onrelease = function () {


var mytween:tween = new Tween (This, "_xscale", Elastic.easeout, MB, 1, true);


var mytween:tween = new Tween (This, "_yscale", Elastic.easeout, MB, 1, true);


  };


}


}


Start_func ();


* * Drag follow/


var mouselistener:object = new Object ();


Mouselistener.onmousedown = function () {


if (container["Ball" +0].hittest (_root._xmouse, _root._ymouse)) {


drag = true;


}


};


mouselistener.onmousemove = function () {


if (drag) {


num = 1;


Delete container["Ball" +0].onenterframe;


container["Ball" +0]._x = _root._xmouse;


container["Ball" +0]._y = _root._ymouse;


for (var i:number = 1; i<=9; i++) {


Delete container["Ball" +i].onenterframe;


container["Ball" +i]._x + = (container["Ball" + (i-1)]._x-container["Ball" +i]._x)/3;


container["Ball" +i]._y + = (container["Ball" + (i-1)]._y-container["Ball" +i]._y)/3;


  }


}


};


mouselistener.onmouseup = function () {


drag = false;


/* Drag to restore * *


if (num==1) {


Start_func ();


num=0;


}


};


Mouse.addlistener (MouseListener);


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.