Actionscript - 从左到右滚动图像
我制作了一个 Flash 画廊,可以从 xml 文件加载图像并使它们淡入和淡出。 然而,我被要求让它们从左到右淡入(即隐藏一些图像,同时慢慢地显示整个图像)。 代码如下:
_root.onEnterFrame=function () {
var picLoaded = thisLoader.getBytesLoaded(), picBytes = thisLoader.getBytesTotal();
if (isNaN(picBytes) || picBytes < 4)
return;
updateLoader( (picLoaded/picBytes)*100 );
if ( picLoaded / picBytes >= 1 ) {
endLoader();
setButtonOn( eval("_level0.NavContainer.btnContainer.btn_"+(currentPicture)+".lbl_"+(currentPicture)) );
centerMovie( thisLoader );
swapPlace();
alphaTween = new mx.transitions.Tween(thisLoader, "_alpha", mx.transitions.easing.Regular.easeIn,0,100,2,true);
timerInterval = setInterval( imageGen, hold*1000 );
updateDescription();
lastPicture = ( currentPicture > 1 ? currentPicture - 1 : 1 );
currentPicture = ( currentPicture == maxPicture ? 1 : currentPicture + 1 );
if( maxPicture>1 ){
eval("_container.movie"+( showing == 2 ? 1 : 2 ))._alpha = 0;
}
btn_previous.enabled = true;
btn_next.enabled = true;
delete this.onEnterFrame;
}
}
I have made a flash gallery that loads images from an xml file and fades them in and out. However I have been asked to make it so they fade in from left to right (i.e. hiding a bit of image while slowly revealing the whole image). Code is below:
_root.onEnterFrame=function () {
var picLoaded = thisLoader.getBytesLoaded(), picBytes = thisLoader.getBytesTotal();
if (isNaN(picBytes) || picBytes < 4)
return;
updateLoader( (picLoaded/picBytes)*100 );
if ( picLoaded / picBytes >= 1 ) {
endLoader();
setButtonOn( eval("_level0.NavContainer.btnContainer.btn_"+(currentPicture)+".lbl_"+(currentPicture)) );
centerMovie( thisLoader );
swapPlace();
alphaTween = new mx.transitions.Tween(thisLoader, "_alpha", mx.transitions.easing.Regular.easeIn,0,100,2,true);
timerInterval = setInterval( imageGen, hold*1000 );
updateDescription();
lastPicture = ( currentPicture > 1 ? currentPicture - 1 : 1 );
currentPicture = ( currentPicture == maxPicture ? 1 : currentPicture + 1 );
if( maxPicture>1 ){
eval("_container.movie"+( showing == 2 ? 1 : 2 ))._alpha = 0;
}
btn_previous.enabled = true;
btn_next.enabled = true;
delete this.onEnterFrame;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建具有渐变 Alpha 值的蒙版,然后使用补间动画将其在图像上移动。 使用正确的混合模式,这将使其按照您想要的方式淡入。
You could create a mask with a gradient alpha value and then use a motion tween to move it across the image. With the right blend mode this will cause it to fade in like you want.