Greensock 的液体面积问题盖亚

发布于 2024-11-03 12:13:17 字数 2780 浏览 4 评论 0原文

我有一个 Flash 文件,我正在尝试更改每个页面的背景。背景本身变化很好,但我在让背景缩放到舞台大小时遇到​​问题。我正在使用 Greensock 的液体区域来尝试处理它,它在单一背景下表现良好,但当我引入更多内容时,我的代码就卡住了。

package com.picturesite.pages
{
    import com.gaiaframework.api.*;
    import com.gaiaframework.debug.*;
    import com.gaiaframework.events.*;
    import com.gaiaframework.templates.AbstractPage;
    import com.greensock.TweenMax;
    import com.greensock.easing.*;
    import com.greensock.layout.*;

    import flash.display.*;
    import flash.events.*;

    public class IndexPage extends AbstractPage
    {   
        public var bg1:MovieClip;
        public var bg2:MovieClip;
        public var bg3:MovieClip;
        public var bg4:MovieClip;
        public var bg5:MovieClip;
        public var bg6:MovieClip;
        public var newBG:MovieClip;
        public var bBar_mc:MovieClip;   


        var releaseGaia:Function = Gaia.api.afterTransitionOut(onAfterTransitionOut, true);

        public function IndexPage()
        {
            super();
            alpha = 0;

        }
        override public function transitionIn():void 
        {
            super.transitionIn();
            bg2.visible=bg3.visible=bg4.visible=bg5.visible=bg6.visible=false;
            TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});     

            var ls:LiquidStage = new LiquidStage(this.stage, 960, 760, 960, 760);
            var area:LiquidArea = new LiquidArea(this, 0, 0, 960, 760);
            area.attach(newBG, ScaleMode.PROPORTIONAL_OUTSIDE);
            ls.update();
        }

        override public function transitionOut():void 
        {
            super.transitionOut();
            TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
            Gaia.api.removeAfterTransitionOut(onAfterTransitionOut);
        }

        private function onAfterTransitionOut(e:GaiaEvent):void
        {
            var newBG:MovieClip;

            switch(Gaia.api.getCurrentBranch())
            {
                case Pages.HOME :
                    newBG = bg1;
                    break;

                case Pages.PACKAGES :
                    newBG = bg2;
                    break;

                case Pages.PHOTOS_SAMPLES :
                    newBG = bg3;
                    break;

                case Pages.VIDEOS_SAMPLES :
                    newBG = bg4;
                    break;

                case Pages.TESTIMONIES :
                    newBG = bg5;
                    break;

                case Pages.CONTACT :
                    newBG = bg6;
                    break;

            }

            TweenMax.allTo([bg1,bg2,bg3,bg4,bg5,bg6], .5, {autoAlpha:0});
            TweenMax.to(newBG, .5, {alpha:1, onComplete:releaseGaia});  

        }

    }
}

I have a flash file that I'm trying to change backgrounds for each page. The background itself changes nicely but I'm having a problem getting the background to scale to the stage size. I'm using Greensock's Liquid Area to try and handle it and it does well with a single background but as soon as I introduced more my code choked..

package com.picturesite.pages
{
    import com.gaiaframework.api.*;
    import com.gaiaframework.debug.*;
    import com.gaiaframework.events.*;
    import com.gaiaframework.templates.AbstractPage;
    import com.greensock.TweenMax;
    import com.greensock.easing.*;
    import com.greensock.layout.*;

    import flash.display.*;
    import flash.events.*;

    public class IndexPage extends AbstractPage
    {   
        public var bg1:MovieClip;
        public var bg2:MovieClip;
        public var bg3:MovieClip;
        public var bg4:MovieClip;
        public var bg5:MovieClip;
        public var bg6:MovieClip;
        public var newBG:MovieClip;
        public var bBar_mc:MovieClip;   


        var releaseGaia:Function = Gaia.api.afterTransitionOut(onAfterTransitionOut, true);

        public function IndexPage()
        {
            super();
            alpha = 0;

        }
        override public function transitionIn():void 
        {
            super.transitionIn();
            bg2.visible=bg3.visible=bg4.visible=bg5.visible=bg6.visible=false;
            TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});     

            var ls:LiquidStage = new LiquidStage(this.stage, 960, 760, 960, 760);
            var area:LiquidArea = new LiquidArea(this, 0, 0, 960, 760);
            area.attach(newBG, ScaleMode.PROPORTIONAL_OUTSIDE);
            ls.update();
        }

        override public function transitionOut():void 
        {
            super.transitionOut();
            TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
            Gaia.api.removeAfterTransitionOut(onAfterTransitionOut);
        }

        private function onAfterTransitionOut(e:GaiaEvent):void
        {
            var newBG:MovieClip;

            switch(Gaia.api.getCurrentBranch())
            {
                case Pages.HOME :
                    newBG = bg1;
                    break;

                case Pages.PACKAGES :
                    newBG = bg2;
                    break;

                case Pages.PHOTOS_SAMPLES :
                    newBG = bg3;
                    break;

                case Pages.VIDEOS_SAMPLES :
                    newBG = bg4;
                    break;

                case Pages.TESTIMONIES :
                    newBG = bg5;
                    break;

                case Pages.CONTACT :
                    newBG = bg6;
                    break;

            }

            TweenMax.allTo([bg1,bg2,bg3,bg4,bg5,bg6], .5, {autoAlpha:0});
            TweenMax.to(newBG, .5, {alpha:1, onComplete:releaseGaia});  

        }

    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

天荒地未老 2024-11-10 12:13:17

我不太确定这件事,但是这句话:

TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});

也许会淡出一切。如果我在图书馆的主页上看到它,那么该代码隐藏了所有内容,因为代码在 0.3 秒内将 alpha 设置为 0。是这样吗?如果是这样,如果您想淡出 newBG 对象,则可以将 this 更改为 newBG。到目前为止,你似乎淡出了整个事情。

所以:

TweenMax.to(newBG, 0.3, {alpha:0, onComplete:transitionOutComplete});

或者在 onAfterTransitionOut 中,输入

this.alpha = 1;

希望这对您有帮助或给您一些想法。

I'm not really sure about the thing, but this line:

TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});

maybe fades out everything. If I saw it well on the library's homepage, that code hides everything, because the code sets alpha to 0 in 0.3 secs. Is that right? If so, then maybe change this to newBG, if you want to fade the newBG object out. So far it seems you fade out the whole thing.

So:

TweenMax.to(newBG, 0.3, {alpha:0, onComplete:transitionOutComplete});

Or in onAfterTransitionOut, put

this.alpha = 1;

Hope this helps or gives you some idea.

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