【发布时间】:2011-05-06 01:58:35
【问题描述】:
我有一个动作脚本项目,它使用来自 SWC 的视觉符号。
我有一个CheckoutButton,它具有以下关联的类(编译到 Flash CS3 中的 SWC)。
public class CheckoutButton extends SimpleButton {
public function CheckoutButton () {
this.addEventListener(MouseEvent.CLICK, checkoutClicked);
}
// click on the button and the alpha will go to 50%
public function checkoutClicked(e:MouseEvent):void {
this.alpha = .5; // take user to checkout
}
public function dispose ():void {
}
}
重要提示:CheckoutButton.as 文件位于使用 SWC 的 actionscript 项目的类路径中。
我在一个 actionscript 项目中使用编译后的 SWC,我已经运行了以下场景:
1) 我从我的 actionscript 项目的类路径中删除 CheckoutButton.as:
var x:CheckoutButton = new CheckoutButton();
addChild(x);
我从我的 Flash CS3 文件中获得了一个视觉符号的实例。当我点击它时,它的 alpha 变为 50%。这又完全符合我的预期。
2) 我在我的 actionscript 项目的类路径中使用 CheckoutButton.as 运行此代码:
var x:CheckoutButton = new CheckoutButton();
addChild(x);
什么都没有发生。这正是我所期望的——因为我基本上用没有任何视觉功能的SimpleButton 覆盖了 SWC 中的类定义。
现在我的 Flash 文件中还有一个时间轴动画 CheckoutAnimation,它恰好包含 CheckoutButton 符号的一个实例。
3) 我在从类路径中删除 CheckoutButton.as 之后运行 actionscript 项目:
var x:CheckoutAnimation = new CheckoutAnimation();
addChild(x);
动画中的符号获取类定义(最初编译到 SWC 中),当我单击它时,符号的 alpha 变为 50%。这完全符合预期。
4) 我在类路径中运行带有 CheckoutButton.as 的 actionscript 项目:
var x:CheckoutAnimation = new CheckoutAnimation();
addChild(x);
结帐符号出现在动画中,但点击它没有任何反应!!
这是为什么!我不明白!我不明白为什么我没有得到与上面(2)相同的结果,我绝对不明白为什么没有代码正在执行。这里有什么冲突?
【问题讨论】:
标签: actionscript-3 actionscript swc