如何用Flash代码得到幻灯片效果?
想做一个Flash相册,只要循环播放就行不需要按钮控制.图片的展示切换效果也就是简单的缩放和淡入淡出,类似于Vista的MediaCenter幻灯片演示.图片比较多,可以...
想做一个Flash相册,只要循环播放就行不需要按钮控制.
图片的展示切换效果也就是简单的缩放和淡入淡出,类似于Vista的Media Center幻灯片演示.
图片比较多,可以放到库内,播放也可以不用随机.
总之怎么简单怎么做,希望能给些代码参考一下.谢谢啊
感谢各位热心的帮助!
可是我对Action相当陌生,看了满屏的代码更是一头雾水.所以对效果要求不高,代码简单点就好.
能否在一些关键代码的后面做一下解释?或者说明一下它的工作原理?我想这样能更好地将这些代码根据自己的需求来修改.
麻烦各位了,事后一定加分! 展开
图片的展示切换效果也就是简单的缩放和淡入淡出,类似于Vista的Media Center幻灯片演示.
图片比较多,可以放到库内,播放也可以不用随机.
总之怎么简单怎么做,希望能给些代码参考一下.谢谢啊
感谢各位热心的帮助!
可是我对Action相当陌生,看了满屏的代码更是一头雾水.所以对效果要求不高,代码简单点就好.
能否在一些关键代码的后面做一下解释?或者说明一下它的工作原理?我想这样能更好地将这些代码根据自己的需求来修改.
麻烦各位了,事后一定加分! 展开
4个回答
展开全部
这是我写的一个简单例子。
代码是as2.0。直接新建一个as2.0另存一下,然后将代码复制到主时间轴的第一帧上。再复制几个jpg图片到你存这个flash的文件夹下,取名为1.jpg,2.jpg,3.jpg ...。然后ctrl+enter运行测试即可。
修改代码中的defaultNum 和 totalNum值,可以确定显示从第几到第几的图片。
Stage.align = "TL";
Stage.scaleMode = "noScale";
import mx.transitions.*;
import mx.transitions.easing.*;
var defaultNum = 1;
var totalNum = 4;
var oldName:String = "";
//
var mcl_obj:Object = new Object();
mcl_obj.onLoadInit = function(target_mc:MovieClip) {
//_root.lock = true;
//
target_mc._width = Stage.width;
target_mc._height = Stage.height;
var myTween:Tween = new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true);
var R:Number = randRange(0, 3);
if (R == 0) {
TransitionManager.start(target_mc, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:None.easeOut, xSections:40, ySections:40});
} else if (R == 1) {
TransitionManager.start(target_mc, {type:Blinds, direction:Transition.IN, duration:2, easing:None.easeNone, numStrips:30, dimension:0});
} else if (R == 2) {
TransitionManager.start(target_mc, {type:Wipe, direction:Transition.IN, duration:2, easing:None.easeNone, startPoint:1});
} else if (R == 3) {
TransitionManager.start(target_mc, {type:Squeeze, direction:Transition.IN, duration:2, easing:Elastic.easeOut, dimension:0});
}
target_mc.onRelease = function() {
if (defaultNum+1>totalNum) {
defaultNum = 1;
} else {
defaultNum++;
}
my_mcl.loadClip(defaultNum+".jpg", _root.createEmptyMovieClip("img"+defaultNum+"_mc", _root.getNextHighestDepth()));
};
//
myTween.onMotionFinished = function() {
if (defaultNum-1 == 0) {
_root["img"+totalNum+"_mc"].removeMovieClip();
} else {
_root["img"+(defaultNum-1)+"_mc"].removeMovieClip();
}
oldName = "img"+defaultNum+"_mc";
};
};
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.addListener(mcl_obj);
my_mcl.loadClip(defaultNum+".jpg", _root.createEmptyMovieClip("img"+defaultNum+"_mc", _root.getNextHighestDepth()));
//
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
var stageListener:Object = new Object();
stageListener.onResize = function() {
_root[oldName]._width = Stage.width;
_root[oldName]._height = Stage.height;
};
Stage.addListener(stageListener);
代码是as2.0。直接新建一个as2.0另存一下,然后将代码复制到主时间轴的第一帧上。再复制几个jpg图片到你存这个flash的文件夹下,取名为1.jpg,2.jpg,3.jpg ...。然后ctrl+enter运行测试即可。
修改代码中的defaultNum 和 totalNum值,可以确定显示从第几到第几的图片。
Stage.align = "TL";
Stage.scaleMode = "noScale";
import mx.transitions.*;
import mx.transitions.easing.*;
var defaultNum = 1;
var totalNum = 4;
var oldName:String = "";
//
var mcl_obj:Object = new Object();
mcl_obj.onLoadInit = function(target_mc:MovieClip) {
//_root.lock = true;
//
target_mc._width = Stage.width;
target_mc._height = Stage.height;
var myTween:Tween = new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true);
var R:Number = randRange(0, 3);
if (R == 0) {
TransitionManager.start(target_mc, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:None.easeOut, xSections:40, ySections:40});
} else if (R == 1) {
TransitionManager.start(target_mc, {type:Blinds, direction:Transition.IN, duration:2, easing:None.easeNone, numStrips:30, dimension:0});
} else if (R == 2) {
TransitionManager.start(target_mc, {type:Wipe, direction:Transition.IN, duration:2, easing:None.easeNone, startPoint:1});
} else if (R == 3) {
TransitionManager.start(target_mc, {type:Squeeze, direction:Transition.IN, duration:2, easing:Elastic.easeOut, dimension:0});
}
target_mc.onRelease = function() {
if (defaultNum+1>totalNum) {
defaultNum = 1;
} else {
defaultNum++;
}
my_mcl.loadClip(defaultNum+".jpg", _root.createEmptyMovieClip("img"+defaultNum+"_mc", _root.getNextHighestDepth()));
};
//
myTween.onMotionFinished = function() {
if (defaultNum-1 == 0) {
_root["img"+totalNum+"_mc"].removeMovieClip();
} else {
_root["img"+(defaultNum-1)+"_mc"].removeMovieClip();
}
oldName = "img"+defaultNum+"_mc";
};
};
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.addListener(mcl_obj);
my_mcl.loadClip(defaultNum+".jpg", _root.createEmptyMovieClip("img"+defaultNum+"_mc", _root.getNextHighestDepth()));
//
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
var stageListener:Object = new Object();
stageListener.onResize = function() {
_root[oldName]._width = Stage.width;
_root[oldName]._height = Stage.height;
};
Stage.addListener(stageListener);
博思aippt
2024-07-20 广告
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景。ai生...
点击进入详情页
本回答由博思aippt提供
展开全部
这是一个带有按钮的代码,你参考一下吧,可以实现淡出淡入,
//注意加载图片文件大小问题
loadmc._alpha =0;
pic =1;
next.onRelease = function() {
if (pic <6 && !fadein && !fadeout ){
pic ++ ;
fadeout = true;
input =pic;
}
}
back.onRelease = function () {
if ( pic >1 && !fadein && !fadeout){
pic --;
fadeout =true ;
input =pic;
}
}
_root.onEnterFrame =function (){
if (loadmc._alpha>10 && fadeout ){
loadmc._alpha -=10;
}
if (loadmc._alpha < 10){
loadMovie("images/image"+pic+".jpg","loadmc");
loadmc._width=288;
loadmc._height=209
//z注意此处因为用了width和height属性,所以loadmc的内容不可以为空。
fadeout =false;
fadein = true;
}
if (loadmc._alpha <100 && fadein &&!fadeout){
loadmc._alpha +=10;
}else {
fadein =false;
}
if (input >6){
input =6;
}
}
//注意加载图片文件大小问题
loadmc._alpha =0;
pic =1;
next.onRelease = function() {
if (pic <6 && !fadein && !fadeout ){
pic ++ ;
fadeout = true;
input =pic;
}
}
back.onRelease = function () {
if ( pic >1 && !fadein && !fadeout){
pic --;
fadeout =true ;
input =pic;
}
}
_root.onEnterFrame =function (){
if (loadmc._alpha>10 && fadeout ){
loadmc._alpha -=10;
}
if (loadmc._alpha < 10){
loadMovie("images/image"+pic+".jpg","loadmc");
loadmc._width=288;
loadmc._height=209
//z注意此处因为用了width和height属性,所以loadmc的内容不可以为空。
fadeout =false;
fadein = true;
}
if (loadmc._alpha <100 && fadein &&!fadeout){
loadmc._alpha +=10;
}else {
fadein =false;
}
if (input >6){
input =6;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不错。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
//我也写一个.
//新建一FLASH把代码放在第一侦 保存. 然后在此目录建一个image目录.在把图片放在 image 这个目录里取名1.jpg,2.jpg,3.jpg....
var obj:Object = new Object();
var randomNum:Number = 6;//随即图片总数
var imageWidth:Number = 400;
var imageHeight:Number = 300;
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(obj);
_root.createEmptyMovieClip("mc",_root.getNextHighestDepth());
obj.onLoadProgress = function(target:MovieClip, byteLoaded:Number, byteTotals:Number) {
trace(Math.round(byteLoaded/byteTotals*100)+"% loaded");
};
obj.onLoadInit = function(target:MovieClip) {
target._width = imageWidth;
target._height = imageHeight;
switch (random(3)) {
case 0: transImage_1(target);break;
case 1: transImage_2(target);break;
case 2: transImage_3(target);break;
}
};
setInterval(changeImage,2000);
function changeImage() {
url = "image/"+random(randomNum)+".jpg";
mcLoader.loadClip(url,mc);
}
function transImage_1(target_mc:MovieClip) {
target_mc._alpha = 0;
target_mc.onEnterFrame = function() {
this._alpha += 5;
if (target_mc._alpha == 100) {
delete this.onEnterFrame;
}
};
}
function transImage_2(target_mc:MovieClip) {
target_mc._width = 0;
target_mc.onEnterFrame = function() {
this._width += 35;
if (target_mc._width >= imageWidth) {
delete this.onEnterFrame;
}
};
}
function transImage_3(target_mc:MovieClip) {
target_mc._height = 0;
target_mc.onEnterFrame = function() {
this._height += 35;
if (target_mc._height >= imageHeight) {
delete this.onEnterFrame;
}
};
}
/////
//新建一FLASH把代码放在第一侦 保存. 然后在此目录建一个image目录.在把图片放在 image 这个目录里取名1.jpg,2.jpg,3.jpg....
var obj:Object = new Object();
var randomNum:Number = 6;//随即图片总数
var imageWidth:Number = 400;
var imageHeight:Number = 300;
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(obj);
_root.createEmptyMovieClip("mc",_root.getNextHighestDepth());
obj.onLoadProgress = function(target:MovieClip, byteLoaded:Number, byteTotals:Number) {
trace(Math.round(byteLoaded/byteTotals*100)+"% loaded");
};
obj.onLoadInit = function(target:MovieClip) {
target._width = imageWidth;
target._height = imageHeight;
switch (random(3)) {
case 0: transImage_1(target);break;
case 1: transImage_2(target);break;
case 2: transImage_3(target);break;
}
};
setInterval(changeImage,2000);
function changeImage() {
url = "image/"+random(randomNum)+".jpg";
mcLoader.loadClip(url,mc);
}
function transImage_1(target_mc:MovieClip) {
target_mc._alpha = 0;
target_mc.onEnterFrame = function() {
this._alpha += 5;
if (target_mc._alpha == 100) {
delete this.onEnterFrame;
}
};
}
function transImage_2(target_mc:MovieClip) {
target_mc._width = 0;
target_mc.onEnterFrame = function() {
this._width += 35;
if (target_mc._width >= imageWidth) {
delete this.onEnterFrame;
}
};
}
function transImage_3(target_mc:MovieClip) {
target_mc._height = 0;
target_mc.onEnterFrame = function() {
this._height += 35;
if (target_mc._height >= imageHeight) {
delete this.onEnterFrame;
}
};
}
/////
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询