FLash:尝试使用setChildIndex和TweenLite创建按钮翻转效果时出错

FLash:尝试使用setChildIndex和TweenLite创建按钮翻转效果时出错,flash,actionscript-3,button,tween,Flash,Actionscript 3,Button,Tween,(来源:) 大家好:)所以今天我尝试在按钮翻转上创建一个简单的发光效果。我可能把事情复杂化了,但我要做的是有两个movieClips(默认状态和过度状态) 首先,我将默认状态添加到stage,然后,我将滚动状态添加到stage,但深度为0,alpha也设置为0。现在,我希望滚动状态与默认状态交换深度,并使用TweetLite类设置完整alpha的动画,以便获得良好的平滑过渡 我现在收到一个错误,但下面是我的代码: import gs.TweenLite; import fl.motion.eas


(来源:)

大家好:)所以今天我尝试在按钮翻转上创建一个简单的发光效果。我可能把事情复杂化了,但我要做的是有两个movieClips(默认状态和过度状态)

首先,我将默认状态添加到stage,然后,我将滚动状态添加到stage,但深度为0,alpha也设置为0。现在,我希望滚动状态与默认状态交换深度,并使用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:Error#2025:提供的DisplayObject必须是调用者的子对象。 在flash.display::DisplayObjectContainer/setChildIndex()处 测试时佛罗里达州::主时间线/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");
}

根据您尝试完成的内容,您不必管理深度。基本上,您只需在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");
}

谢谢!我不再犯那个错误了,但仍然看不到我的Tween动画…嗯,谢谢!我不再犯那个错误了,但是仍然看不到我的Tween动画…嗯,谢谢