与Greensock&amp ;;盖亚

时间:2011-04-26 09:13:24

标签: flash actionscript-3 gaia

我有一个Flash文件,我正在尝试更改每个页面的背景。背景本身变化很好但是我在将背景缩放到舞台大小时遇到​​了问题。我正在使用Greensock的Liquid Area来尝试处理它并且它在单个背景下运行良好但是只要我介绍了更多我的代码就会被阻塞..

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});  

        }

    }
}

1 个答案:

答案 0 :(得分:2)

我不太确定这件事,但这一行:

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

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

所以:

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

或者在onAfterTransitionOut中,添加

this.alpha = 1;

希望这会有所帮助或给你一些想法。