我有一个 movieClip,其中有一个在显示类 Thumbnail.as 中创建的按钮,并且我有一个在 ui 类 ThumbnailController.as< 中与其进行交互的按钮函数.
我目前遇到的问题是;在我的 ui 类中,我无法定位在我的显示类中创建的 movieClip playGlow。
在我的显示类中创建 playGlow 按钮的代码 (Thumbnail.as)
public function playBtns():void {
playThumb = new PlayThumb;
playThumb.x = 642;
playThumb.y = 22;
playThumb.alpha = 1;
playGlow = new PlayGlow;
playGlow.x = 628;
playGlow.y = 8;
playGlow.alpha = 1;
}
public function buildRow ():void{
thumbNailRow.addChild(thumbLoader);
thumbNailRow.addChild(thumbTitle);
thumbNailRow.addChild(thumbText);
thumbNailRow.addChild(playGlow);
thumbNailRow.addChild(playThumb);
playThumb.addEventListener(MouseEvent.ROLL_OVER, rowRollOver);
addChild(thumbNailRow);
}
现在是我的 ui 类中的代码 (ThumbnailController.as)
public function rowRollOver(e:MouseEvent):void
{
dispatchEvent(new Event(Event.CHANGE, true ));
TweenPlugin.activate([TintPlugin]);
TweenLite.to(playGlow, .4, {alpha:.5, tint:0x99cc00});
}
这是问题行:TweenLite.to(playGlow, .4, {alpha:.5, Tint:0x99cc00});
只有这样才有效:TweenLite.to(this, .4, {alpha:.5, Tint:0x99cc00});
但是如果我使用这个,整个thumbNailRow movieClip都会着色,我只想为thumbNailRow内部的playGlow movieClip着色,但我不知道如何具体针对该目标。我得到 1120: Access of undefined property playGlow 否则。
如何将 playGlow 的实例传递到我的 ui 类中,以便我可以使用补间色调定位该 movieClip?
最佳答案
尝试使用事件目标进行翻转?
TweenLite.to(e.target, .4, {alpha:.5, tint:0x99cc00});
您可能需要转换 e.target:
TweenLite.to(Sprite(e.target), .4, {alpha:.5, tint:0x99cc00});
至少,您应该尝试跟踪 e.target 并让我们知道它是什么。
关于flash - 如何将一个类中制作的 movieClip 的引用传递给另一个类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1500824/