[转载]方便调用27种flash图片切换特效(转)
广告投放★自助友情CMS落伍广告联盟晒乐广告联盟脉动广告联盟品味广告联盟
广告位可自定样式联系QQ:4285248个文字广告月20元广告联系QQ:428524广告位可自定样式
8个文字广告月20元黄金广告位每月20元广告位可自定样式联系QQ:428524广告位可自定样式
左旋肉碱、全国包邮
买二送一、无效退款

文章浏览→建站指南代码特效→[转载]方便调用27种flash图片切换特效(转)

[转载]方便调用27种flash图片切换特效(转)
[转载]方便调用27种flash图片切换特效(转)

网上一直都是说,用flash做的课件功能比PPT强大些,但是用flash做课件时,其实面临着一个尴尬的问题,就是遇上课件中需要切换显示大量图片时,做起来相当麻烦,至少比在PPT中做时要麻烦许多,网上也流传着用transitions 及tween类切换图片,但要么不实用,要么效果单调,经过慢慢分析这两种类的用法后,牺牲一个下午终于在flash中把flash中切换显示图片这个另人头痛的问给解决了,共27种图片切换特效,以后做课件又可以省不少力了,直接准备好图像文件调用即可,代码帖出如下:

//首先准备十四张图片在 .fla 文件相同目录下,文件名分别为: 1.jpg ,2.jpg,...,14.jpg
//该段代码在第一个关键帧复制过去即可
//该段代码在理解时,要弄清flash as 中的数组时面向对象的,否则该段程序可能有些不好懂的哦

import mx.transitions.*;
import mx.transitions.easing.*;
fscommand("fullscreen", true); //全屏

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

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

//定义数组存储27种图片切换参数,其中各特效具体参数还可直接在其中更改
var str_array = new Array(27); //flash中的数组是面向对象的,大家学了C后这点变通应该没有问题吧
//遮帘(纵向、横向)
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 (i=0; i<=13; i++) {
mc_array[i] = _root.createEmptyMovieClip("mc"+String(i+1),i+1);
mc_array[i].loadMovie(String(i+1)+".jpg", i+1);
}

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

//设置定时器调用图片切换函数
setInterval(showImages,4000);  
//图片切换函数
function showImages() {
mx.behaviors.DepthControl.bringToFront(mc_array[showID]); //将下一个要切换的 mc 置顶
mx.transitions.TransitionManager.start(mc_array[showID],str_array[random(27)]); //随机特效将图片按顺序切换
if (showID++ == 13) {
   showID = 0;
}
}

所属分类:建站指南代码特效    作者:荡凯网络    时间:2010-6-28 5:46:00

文章导航