最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
flash实现苹果菜单效果代码
时间:2022-07-02 17:04:51 编辑:袖梨 来源:一聚教程网
代码如下:
package com.TangWeiChun.MenuClass{
import flash.display.MovieClip;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class AppleMenu extends MovieClip {
public var IcoArray:Array=[];
public var scalelimit:Array=[0.2,0.5];
public var time:Timer=new Timer(1000/35);
public var Target_Obj:Object;
public var BM_ori_wid:Number;
public var buffer:Boolean;
//缓冲?
public var f_mc:MovieClip=new MovieClip();
public var ori_all_wid:Number;
public var beishu=3;
//有效距离3倍的单个图标宽度 可调
public function AppleMenu(target_mc:Object,IcoArr) {
Target_Obj=target_mc;
IcoArray=IcoArr;
init();
addIco(target_mc);
}
public function init() {
time.addEventListener(TimerEvent.TIMER,Func);
buffer=false;
f_mc.x=mouseX;
f_mc.y=mouseY;
time.start();
}
public function addIco(target_obj:Object) {
for (var j=0; j
var BMD=new IcoArray[j](0,0);
var BM:Bitmap=new Bitmap(BMD);
BM_ori_wid=BM.width;
var p:Number=scalelimit[0];
BM.width=BM.width*p;
BM.height=BM.height*p;
BM.smoothing=true;
var mc0:MovieClip=new MovieClip();
BM.x=-BM.width/2;
BM.y=-BM.height/2;
mc0.addChild(BM);
var mc:MovieClip=new MovieClip();
mc.addChild(mc0);
ori_all_wid=mc.width*(IcoArray.length-1);
mc.x=BM.width*j;
target_obj.addChild(mc);
mc.ori_x=mc.x;
mc.ori_y=mc.y;
mc.ori_stage_x=mc.x+mc.parent.x;
mc.ori_stage_y=mc.y+mc.parent.y;
mc.ori_width=mc.width;
mc.ori_height=mc.height;
mc.name="Ico_"+j;
mc.links="http://www.www.com/"+j+".html";
mc.addEventListener(MouseEvent.MOUSE_DOWN,MD_event);
}
}
public function MD_event(e:MouseEvent) {
trace(e.target.parent.links);
}
public function Func(event:TimerEvent) {
event.updateAfterEvent();
if (buffer) {
f_mc.x+=(mouseX-f_mc.x)/7;
f_mc.y+=(mouseY-f_mc.y)/7;
} else {
f_mc.x=mouseX;
f_mc.y=mouseY;
}
var all_wid=0;
for (var j=0; j
var T_x:Number=Target_Obj.getChildByName("Ico_"+j).ori_stage_x;
var T_y:Number=Target_Obj.getChildByName("Ico_"+j).ori_stage_y;
var wid:Number=Target_Obj.getChildByName("Ico_"+j).ori_width;
all_wid+=Target_Obj.getChildByName("Ico_"+j).width;
if (f_mc.x>=T_x&&f_mc.x-T_x<=wid* beishu) {
Target_Obj.getChildByName("Ico_"+j).width=wid+((wid* beishu)-(f_mc.x-T_x))/(wid* beishu)*(scalelimit[1]*BM_ori_wid-wid);
Target_Obj.getChildByName("Ico_"+j).height=wid+((wid* beishu)-(f_mc.x-T_x))/(wid* beishu)*(scalelimit[1]*BM_ori_wid-wid);
} else if (f_mc.x
Target_Obj.getChildByName("Ico_"+j).width=wid+((wid* beishu)-(T_x-f_mc.x))/(wid* beishu)*(scalelimit[1]*BM_ori_wid-wid);
Target_Obj.getChildByName("Ico_"+j).height=wid+((wid* beishu)-(T_x-f_mc.x))/(wid* beishu)*(scalelimit[1]*BM_ori_wid-wid);
} else {
Target_Obj.getChildByName("Ico_"+j).width=wid;
Target_Obj.getChildByName("Ico_"+j).height=wid;
}
}
Target_Obj.getChildByName("Ico_"+0).x=Target_Obj.getChildByName("Ico_"+0).ori_x-((all_wid-Target_Obj.getChildByName("Ico_"+0).width)-ori_all_wid)/2;
for (var jj=1; jj
Target_Obj.getChildByName("Ico_"+jj).x=Target_Obj.getChildByName("Ico_"+(jj-1)).x+Target_Obj.getChildByName("Ico_"+(jj-1)).width/2+Target_Obj.getChildByName("Ico_"+(jj)).width/2;
}
}
}
}
import flash.display.MovieClip;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class AppleMenu extends MovieClip {
public var IcoArray:Array=[];
public var scalelimit:Array=[0.2,0.5];
public var time:Timer=new Timer(1000/35);
public var Target_Obj:Object;
public var BM_ori_wid:Number;
public var buffer:Boolean;
//缓冲?
public var f_mc:MovieClip=new MovieClip();
public var ori_all_wid:Number;
public var beishu=3;
//有效距离3倍的单个图标宽度 可调
public function AppleMenu(target_mc:Object,IcoArr) {
Target_Obj=target_mc;
IcoArray=IcoArr;
init();
addIco(target_mc);
}
public function init() {
time.addEventListener(TimerEvent.TIMER,Func);
buffer=false;
f_mc.x=mouseX;
f_mc.y=mouseY;
time.start();
}
public function addIco(target_obj:Object) {
for (var j=0; j
var BM:Bitmap=new Bitmap(BMD);
BM_ori_wid=BM.width;
var p:Number=scalelimit[0];
BM.width=BM.width*p;
BM.height=BM.height*p;
BM.smoothing=true;
var mc0:MovieClip=new MovieClip();
BM.x=-BM.width/2;
BM.y=-BM.height/2;
mc0.addChild(BM);
var mc:MovieClip=new MovieClip();
mc.addChild(mc0);
ori_all_wid=mc.width*(IcoArray.length-1);
mc.x=BM.width*j;
target_obj.addChild(mc);
mc.ori_x=mc.x;
mc.ori_y=mc.y;
mc.ori_stage_x=mc.x+mc.parent.x;
mc.ori_stage_y=mc.y+mc.parent.y;
mc.ori_width=mc.width;
mc.ori_height=mc.height;
mc.name="Ico_"+j;
mc.links="http://www.www.com/"+j+".html";
mc.addEventListener(MouseEvent.MOUSE_DOWN,MD_event);
}
}
public function MD_event(e:MouseEvent) {
trace(e.target.parent.links);
}
public function Func(event:TimerEvent) {
event.updateAfterEvent();
if (buffer) {
f_mc.x+=(mouseX-f_mc.x)/7;
f_mc.y+=(mouseY-f_mc.y)/7;
} else {
f_mc.x=mouseX;
f_mc.y=mouseY;
}
var all_wid=0;
for (var j=0; j
var T_y:Number=Target_Obj.getChildByName("Ico_"+j).ori_stage_y;
var wid:Number=Target_Obj.getChildByName("Ico_"+j).ori_width;
all_wid+=Target_Obj.getChildByName("Ico_"+j).width;
if (f_mc.x>=T_x&&f_mc.x-T_x<=wid* beishu) {
Target_Obj.getChildByName("Ico_"+j).width=wid+((wid* beishu)-(f_mc.x-T_x))/(wid* beishu)*(scalelimit[1]*BM_ori_wid-wid);
Target_Obj.getChildByName("Ico_"+j).height=wid+((wid* beishu)-(f_mc.x-T_x))/(wid* beishu)*(scalelimit[1]*BM_ori_wid-wid);
} else if (f_mc.x
Target_Obj.getChildByName("Ico_"+j).height=wid+((wid* beishu)-(T_x-f_mc.x))/(wid* beishu)*(scalelimit[1]*BM_ori_wid-wid);
} else {
Target_Obj.getChildByName("Ico_"+j).width=wid;
Target_Obj.getChildByName("Ico_"+j).height=wid;
}
}
Target_Obj.getChildByName("Ico_"+0).x=Target_Obj.getChildByName("Ico_"+0).ori_x-((all_wid-Target_Obj.getChildByName("Ico_"+0).width)-ori_all_wid)/2;
for (var jj=1; jj
}
}
}
}
导入类:
import com.TangWeiChun.MenuClass.AppleMenu;
//导入类
var IcoArr:Array=[T贝贝,T欢欢,T2008,T晶晶,T妮妮,T迎迎];
//图标类名数组
var myAppleMenu:AppleMenu=new AppleMenu(Container_mc,IcoArr);
//创建一个实例
myAppleMenu.buffer=true;
//导入类
var IcoArr:Array=[T贝贝,T欢欢,T2008,T晶晶,T妮妮,T迎迎];
//图标类名数组
var myAppleMenu:AppleMenu=new AppleMenu(Container_mc,IcoArr);
//创建一个实例
myAppleMenu.buffer=true;
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20