(来源:flickr.com)
大家好 :) 所以今天我试图在按钮翻转上创建一个简单的发光效果。我可能会让事情变得过于复杂,但我要解决的方法是拥有 2 个电影剪辑(默认状态和过度状态)。
首先,我将默认状态添加到舞台,接下来我将翻转状态添加到舞台,但深度为 0,alpha 也设置为 0。现在,我希望 rollOver 状态与默认状态交换深度,并使用 TweetLite 类动画到完整的 alpha,这样我就可以得到一个很好的平滑过渡。
我现在遇到错误,但这是我的代码:
import gs.TweenLite;
import fl.motion.easing.*;
import flash.display.MovieClip;
var shopButton:MovieClip;
var shopButtonRoll:MovieClip;
var maxIndex:Number = this.numChildren - 1;
// Button - places the default state onto the stage
shopButton = new ShopButton();
shopButton.name = "shopButton";
shopButton.x = 262;
shopButton.y = 207;
shopButton.stop();
thumbsMov.addChild(shopButton);
// Button Glow - places rollOver state under the default and with 0 alpha
shopButtonRoll = new ShopButtonRoll();
shopButtonRoll.name = "shopButtonRoll";
shopButtonRoll.x = 262;
shopButtonRoll.y = 207;
shopButtonRoll.alpha = 0;
thumbsMov.addChildAt(shopButtonRoll, 0);
// Listeners
shopButton.addEventListener(MouseEvent.MOUSE_UP, shopClick);
shopButton.addEventListener(MouseEvent.ROLL_OVER, sendToTop);
shopButton.addEventListener(MouseEvent.ROLL_OUT, shopOff);
shopButtonRoll.addEventListener(MouseEvent.ROLL_OVER, shopOver);
// Button Actions
// shopOver should bring rollOver to top and animate to 100%
function shopOver(event:MouseEvent):void
{
TweenLite.to(shopButtonRoll, 1, {alpha:1});
}
function shopOff(event:MouseEvent):void
{
// Code to animate back to 0 then change depth of rollOver to 0
}
function shopClick(event:MouseEvent):void
}
trace("You clicked Shop");
}
// sendToTop Function
// Sent to top - depth change
function sendToTop(e:Event):void
{
//this.setChildIndex(ShopButton(e.target), maxIndex);
this.setChildIndex(e.currentTarget as MovieClip, maxIndex);
}
我在翻转时遇到的错误:(
ArgumentError:错误 #2025:提供的 DisplayObject 必须是调用者的子对象。在 flash.display::DisplayObjectContainer/setChildIndex() 在 test_fla::MainTimeline/sendToTop()
我不明白提供的 DisplayObject 必须是调用者的孩子的错误意味着什么?