首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AS3: setChildIndex of targetSection + "_mc“to FRONT / accessing on alpha:0 MC

AS3: setChildIndex of targetSection + "_mc“to FRONT / accessing on alpha:0 MC
EN

Stack Overflow用户
提问于 2013-05-03 20:06:56
回答 1查看 320关注 0票数 1

我目前正在使用AS3 &Greensock的TimelineMax在闪存CS5中制作一个定制应用程序。

导航基于Snorkl.TV Bullet proof portfolio,它使用TimeLineMax跳到时间线中的标签,并使用alpha跳到适当的MC中。所有的MC Garment_mc,Size_mc,Design_mc,Ink_mc,Options_mc,Checkout_mc都坐在舞台上不同层的同一空间上,当他们的按钮被点击时,从x:-100开始补间。

这意味着当SWF发布在最上面的层并且MC覆盖其他MC时,当您导航到较低的MC时,它们显示在alpha:0 MC的下面,因此最上面的MC的按钮/功能仍然可以点击并影响之前的选择(选择服装,下一节,单击该MC上的某些东西,它会注册在最上面的MC上)。

我需要NavClick函数包含如下内容...setChildIndex(targetSection + "_mc",0),但我得到了1067:隐式强制错误。

有没有人能给出什么建议?或者我应该从这里做什么?我正在赶着我最后的交接日期,所以任何帮助都是很好的,谢谢!

启动代码。

代码语言:javascript
复制
// all the section clips are fully visible on the stage
//we don't want to see them when the swf starts
//set up an array of section clips so that we can start them all with alpha=0;
var Panel_clips = [Garment_mc,Size_mc,Design_mc,Ink_mc,Options_mc,Checkout_mc];

for (var j:Number = 0; j < Panel_clips.length; j++)
{
    Panel_clips[j].alpha = 0;
}

////

var tl:TimelineMax = new TimelineMax({});
tl.timeScale = 1;


tl.addLabel("Garment_in", tl.duration);
tl.append(TweenMax.to(Garment_mc, 0, {alpha:1, immediateRender:false}));
tl.append(TweenMax.from(Garment_mc, .5, {x:-100, y:0, ease:Quart.easeOut}));

tl.addLabel("Garment_complete", tl.duration);
tl.append(TweenMax.to(Garment_mc, .5, {alpha:0}));



tl.addLabel("Size_in", tl.duration);
tl.append(TweenMax.to(Size_mc, 0, {alpha:1, immediateRender:false}));
tl.append(TweenMax.from(Size_mc, .5, {x:-100, y:0, ease:Quart.easeOut}));

tl.addLabel("Size_complete", tl.duration);
tl.append(TweenMax.to(Size_mc, .5, {alpha:0}));



tl.addLabel("Design_in", tl.duration);
tl.append(TweenMax.to(Design_mc, 0, {alpha:1, immediateRender:false}));
tl.append(TweenMax.from(Design_mc, .5, {x:-100, y:0, ease:Quart.easeOut}));

tl.addLabel("Design_complete", tl.duration);
tl.append(TweenMax.to(Design_mc, .5, {alpha:0}));



tl.addLabel("Ink_in", tl.duration);
tl.append(TweenMax.to(Ink_mc, 0, {alpha:1, immediateRender:false}));
tl.append(TweenMax.from(Ink_mc, .5, {x:-100, y:0, ease:Quart.easeOut}));

tl.addLabel("Ink_complete", tl.duration);
tl.append(TweenMax.to(Ink_mc, .5, {alpha:0}));


tl.addLabel("Options_in", tl.duration);
tl.append(TweenMax.to(Options_mc, 0, {alpha:1, immediateRender:false}));
tl.append(TweenMax.from(Options_mc, .5, {x:-100, y:0, ease:Quart.easeOut}));

tl.addLabel("Options_complete", tl.duration);
tl.append(TweenMax.to(Options_mc, .5, {alpha:0}));


tl.addLabel("Checkout_in", tl.duration);
tl.append(TweenMax.to(Checkout_mc, 0, {alpha:1, immediateRender:false}));
tl.append(TweenMax.from(Checkout_mc, .5, {x:-100, y:0, ease:Quart.easeOut}));

tl.addLabel("Checkout_complete", tl.duration);
tl.append(TweenMax.to(Checkout_mc, .5, {alpha:0}));


//SET UP THE NAV

NavMc.addEventListener(MouseEvent.MOUSE_OVER, navOver);
NavMc.addEventListener(MouseEvent.MOUSE_OUT, navOut);
NavMc.addEventListener(MouseEvent.CLICK, navClick);
NavMc.buttonMode = true;

NavMc.GarmentBtn.ID = "Garment";
NavMc.SizeBtn.ID = "Size";
NavMc.DesignBtn.ID = "Design";
NavMc.InkBtn.ID = "Ink";
NavMc.OptionBtn.ID = "Options";
NavMc.CheckBtn.ID = "Checkout";

function navOver(e:MouseEvent):void
{
    //TweenMax.to(e.target, .5, {tint:0x00CCFF});
    e.target.nextFrame();
    //e.target.GotoAndStop(e.target.NextFrame);
    //trace("Rolled");
}

function navOut(e:MouseEvent):void
{
    //TweenMax.to(e.target, .5, {tint:null});
    //trace(e.target.ID);
    e.target.gotoAndPlay(1);
}



function navClick(e:MouseEvent):void
{
    trace(e.target.ID);
    targetSection = e.target.ID;
    if (targetSection != currentSection)
    {
        e.target.gotoAndPlay(2);
        --> ?? //setChildIndex(targetSection + "_mc", 0)    <--------??????
        tl.tweenFromTo(targetSection + "_in", targetSection + "_complete");
        currentSection = targetSection;


    }else{
        trace("you are already at " + currentSection);
        }

}


//play through to home1_complete automatically on first run
tl.tweenTo("Garment_complete");


//
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-03 20:32:34

navClick function中,更改以下行:

代码语言:javascript
复制
targetSection = e.target.ID;

如下所示:

代码语言:javascript
复制
targetSection = e.target;

因为作为第一个参数的setChildIndex函数需要子电影本身,而不是他的名字/id。

编辑:在你的情况下,可能是你也应该尝试一下:

setChildIndex( getChildByName(e.target.ID + "_mc"),0);

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16358571

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档