一个有互动的效果

效果:按每个字都会动,按"闪"就可以拖动,后面的字跟随,放开"闪"后,又恢复原来的运动 

 

/*作者:梦自在*/
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( " " " " " 2 " " 0 " " 0 " " 8 " " " " " " " " " );
this .createEmptyMovieClip( " container " this .getNextHighestDepth());
/*旋转*/
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))*Math.PI/180);
  container[
"ball"+i]._y = 225+r*(Math.abs(4.5-i))*Math.sin((135-(Math.floor((i/5))*180))*Math.PI/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)*Math.PI/180);
   
this._y = 225+r*(Math.abs(4.5-this.i))*Math.sin(((135-(Math.floor((this.i/5))*180))+p)*Math.PI/180);
   p 
= p+0.5;
  }
;
  container[
"ball"+i].onPress = function() {
   var myTween:Tween 
= new Tween(this"_xscale", Elastic.easeOut, 1002001true);
   var myTween:Tween 
= new Tween(this"_yscale", Elastic.easeOut, 1002001true);
  }
;
  container[
"ball"+i].onRelease = function() {
   var myTween:Tween 
= new Tween(this"_xscale", Elastic.easeOut, 2001001true);
   var myTween:Tween 
= new Tween(this"_yscale", Elastic.easeOut, 2001001true);
  }
;
}

}

start_func();
/*拖动跟随*/
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;
/*拖动后才能恢复*/
if(num==1){
  start_func();
  num
=0;
}

}
;
Mouse.addListener(mouseListener);
源文件下载: http://space.flash8.net/bbs/attachment.php?aid=338597
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值