AS3:targetSection的setChildIndex +“_mc”到FRONT /访问alpha:0 MC上的按钮(AS3: setChildIndex of targetSection + “_mc” to FRONT / accessing buttons on alpha:0 MC)

我目前正在使用AS3和Greensock的TimelineMax在Flash CS5中制作自定义应用程序。

导航基于Snorkl.TV Bullet证明组合 ,该组合使用TimeLineMax跳转到时间线中的标签,以及适当的MC中的alpha。 所有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:隐式强制错误。

任何人都可以提出任何建议吗? 或者我应该从这里做什么? 我正在争取最后的参与日期,所以任何帮助都会很棒,谢谢!

NAIGATION CODE。

// 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"); //

I'm currently making a customisation app in Flash CS5 using AS3 & Greensock's TimelineMax.

The navigation is based on the Snorkl.TV Bullet proof portfolio which uses TimeLineMax to jump to labels in the timeline, and alpha in the appropraite MC. All the MCs [Garment_mc,Size_mc,Design_mc,Ink_mc,Options_mc,Checkout_mc] all sit on the same space on the stage on separate layers, and tween from x:-100 when their button is clicked.

This means that when the SWF is published the top most layer and it's MC cover the other MCs, and when you navigate to lower MCs, they are displayed underneath the alpha:0 MC, so the top-most MC's buttons/functions are still clickable and affect the previous choice (choose garment, next section, click something on that MC, it registers on the top-most MC).

I need the NavClick function to include something like... setChildIndex(targetSection + "_mc", 0) But I have been getting 1067: Implicit coercion errors.

Can anyone make any suggestions as to why? Or what I should do from here? Im racing towards my final hand-in date so any help would be great, THANK YOU!!

NAIGATION CODE.

// 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"); //

最满意答案

在navClick函数中更改此行:

targetSection = e.target.ID;

喜欢这个:

targetSection = e.target;

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

编辑:在你的情况下,你应该尝试这个: setChildIndex( getChildByName(e.target.ID + "_mc"),0);

In navClick function change this line:

targetSection = e.target.ID;

like this:

targetSection = e.target;

because the setChildIndex function as first argument needs child movie itself , not his name/id.

Edited: In your case may be you should try also this: setChildIndex( getChildByName(e.target.ID + "_mc"),0);

更多推荐