flash as3.0 图片切换

 

flash as3.0 图片切换

import fl.transitions.*;
import fl.transitions.easing.*;
import flash.system.fscommand;
fscommand("fullScreen", "true");//全屏

var showID:Number=0;//特效类型代码

//定义数组准备存储14个mc对象,其中每个mc对象在后面将加载图片
var mc_array=new Array(14);

//定义数组存储27种图片切换参数,其中各特效具体参数还可直接在其中更改
var str_array=new Array(27);

//遮帘(纵向、横向)
str_array[0]={type:Blinds,direction:Transition.IN,duration:2,easing:None.easeNone,numStrips:20,dimension:0};
str_array[1]={type:Blinds,direction:Transition.IN,duration:2,easing:None.easeNone,numStrips:20,dimension:1};

//淡化过渡(淡入、淡出)
str_array[2]={type:Fade,direction:Transition.IN,duration:3,easing:None.easeNone};
str_array[3]={type:Fade,direction:Transition.OUT,duration:3,easing:None.easeNone};

//飞行过渡(九个不同的方向)
str_array[4]={type:Fly,direction:Transition.IN,duration:3,easing:Elastic.easeOut,startPoint:1};
str_array[5]={type:Fly,direction:Transition.IN,duration:3,easing:Elastic.easeOut,startPoint:2};
str_array[6]={type:Fly,direction:Transition.IN,duration:3,easing:Elastic.easeOut,startPoint:3};
str_array[7]={type:Fly,direction:Transition.IN,duration:3,easing:Elastic.easeOut,startPoint:4};
str_array[8]={type:Fly,direction:Transition.IN,duration:3,easing:Elastic.easeOut,startPoint:5};
str_array[9]={type:Fly,direction:Transition.IN,duration:3,easing:Elastic.easeOut,startPoint:6};
str_array[10]={type:Fly,direction:Transition.IN,duration:3,easing:Elastic.easeOut,startPoint:7};
str_array[11]={type:Fly,direction:Transition.IN,duration:3,easing:Elastic.easeOut,startPoint:8};
str_array[12]={type:Fly,direction:Transition.IN,duration:3,easing:Elastic.easeOut,startPoint:9};

//光圈过渡
str_array[13]={type:Iris,direction:Transition.IN,duration:2,easing:Strong.easeOut,startPoint:5,shape:Iris.CIRCLE};

//渐变暴光
str_array[14]={type:Photo,direction:Transition.IN,duration:1,easing:None.easeNone};

//像素溶解
str_array[15]={type:PixelDissolve,direction:Transition.IN,duration:2,easing:None.easeNone,xSections:50,ySections:50};

//旋转过渡
str_array[16]={type:Rotate,direction:Transition.IN,duration:3,easing:Strong.easeInOut,ccw:false,degrees:360};

//挤压过渡(二个方向)
str_array[17]={type:Squeeze,direction:Transition.IN,duration:2,easing:Elastic.easeOut,dimension:1};
str_array[18]={type:Squeeze,direction:Transition.IN,duration:2,easing:Elastic.easeOut,dimension:2};

//划入划出过渡--左上,1;上中,2;右上,3;左中,4;右中,6;左下,7;下中,8;右下,9
str_array[19]={type:Wipe,direction:Transition.IN,duration:2,easing:None.easeNone,startPoint:1};
str_array[20]={type:Wipe,direction:Transition.IN,duration:2,easing:None.easeNone,startPoint:2};
str_array[21]={type:Wipe,direction:Transition.IN,duration:2,easing:None.easeNone,startPoint:3};
str_array[22]={type:Wipe,direction:Transition.IN,duration:2,easing:None.easeNone,startPoint:4};
str_array[23]={type:Wipe,direction:Transition.IN,duration:2,easing:None.easeNone,startPoint:6};
str_array[24]={type:Wipe,direction:Transition.IN,duration:2,easing:None.easeNone,startPoint:7};
str_array[25]={type:Wipe,direction:Transition.IN,duration:2,easing:None.easeNone,startPoint:8};
str_array[26]={type:Wipe,direction:Transition.IN,duration:2,easing:None.easeNone,startPoint:9};

//弹性缩放
str_array[27]={type:Zoom,direction:Transition.IN,duration:2,easing:Elastic.easeOut};

//采用数组载入全部图片,注:直接全部载入比较耗内存,如要节约内存的话,可定义两个mc采用类似双缓冲法进行改写,不过在这里重点是写出flash中内置的全部图片切换特效,以后有时间再改进
for (var i=0; i<=13; i++) {
        mc_array=new MovieClip();
        mc_array.name="mc"+String(i+1);
        addChild(mc_array);
        var request:URLRequest = new URLRequest((i+1)+".jpg");
    var loader:Loader = new Loader();
    loader.load(request);
    mc_array.addChild(loader);
}

//载入图片后,把各图片 mc 的位置摆放整齐,这里每张图片的大小都经过处理,尺寸完全一样(改变图片大小用photoshop一张张处理的话,比较麻烦,但是以前在做政务公开系统更新程序的时候,写过一个程序,来个批处理,眨几下眼的时间二、三十张图片就都处理完了。
for (i=1; i<=14; i++) {
        with (this.getChildByName("mc"+i)) {
                _x=20;
                _y=40;
                _xscale=120;
                _yscale=120;
        }
}

//设置定时器调用图片切换函数
setInterval(showImages, 4000);

//图片切换函数
function showImages() {
        setChildIndex(getChildAt(0),numChildren-1);;// 将下一个要切换的 mc 置顶
        fl.transitions.TransitionManager.start(mc_array[showID], str_array[Math.floor(Math.random()*100)%27]);//随机特效将图片按顺序切换
        if (showID++==13) {
                showID=0;
        }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值