FLash:尝试使用setChildIndex和TweenLite创建按钮rollOver效果时出错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FLash:尝试使用setChildIndex和TweenLite创建按钮rollOver效果时出错相关的知识,希望对你有一定的参考价值。
(来源:flickr.com)
嗨再次大家:)所以今天我试图基本上在按钮rollOver上创建一个简单的发光效果。我可能会使事情变得复杂,但我正在做的事情是通过拥有2个movieClip(默认状态和over状态)。
首先我将默认状态添加到舞台,接下来我将rollOver状态添加到舞台,但深度为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);
}
我在rollOver上得到的错误:(
ArgumentError:错误#2025:提供的DisplayObject必须是调用者的子级。在flash.display :: DisplayObjectContainer / setChildIndex()at test_fla :: MainTimeline / sendToTop()
我不明白提供的DisplayObject的错误意味着什么必须是调用者的孩子?
根据您尝试完成的任务,您无需管理深度。基本上你可以在shopButton中添加翻转效果,然后翻过shopButton,为发光设置动画。我用以下代码编写了你的代码:
import gs.TweenLite;
import fl.motion.easing.*;
import flash.display.MovieClip;
var shopButton:MovieClip;
var shopButtonRoll:MovieClip;
// 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.alpha = 0;
shopButton.addChild(shopButtonRoll);
// Listeners
shopButton.buttonMode = true;
shopButton.addEventListener(MouseEvent.MOUSE_UP, shopClick);
shopButton.addEventListener(MouseEvent.ROLL_OVER, shopOver);
shopButton.addEventListener(MouseEvent.ROLL_OUT, shopOff);
// 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
{
TweenLite.to(shopButtonRoll, 1, {alpha:0});
// Code to animate back to 0 then change depth of rollOver to 0
}
function shopClick(event:MouseEvent):void
}
trace("You clicked Shop");
}
以上是关于FLash:尝试使用setChildIndex和TweenLite创建按钮rollOver效果时出错的主要内容,如果未能解决你的问题,请参考以下文章
espcomm_send_command: didn't receive command response | espcomm_send_command(FLASH_DOWNLOAD_BEGI
mini2440开发板用MDK和JLINK烧写程序时候出现error:flash download failed -ARM920t