Actionscript - 从左到右滚动图像

发布于 2024-07-09 15:06:07 字数 1274 浏览 8 评论 0原文

我制作了一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

节枝 2024-07-16 15:06:07

您可以创建具有渐变 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文