这个简单的AS3代码发生了什么?为什么我的对象从TextField更改为更通用的DisplayObject?AS3:为什么数据类型自动从TextField自动更改为DisplayObject?
public class Menu extends MovieClip
{
private var active_button:SimpleButton;
public function Menu()
{
active_button = SimpleButton(menu_list.getChildAt(0)); // ignore menu_list. it's just a collection of SimpleButtons
trace(active_button.upState); // [object TextField]
// ** What's occuring here that makes active_button.upState no longer a TextField? **
active_button.upState.textColor = 0x000000; // "1119: Access of possibly undefined property textColor through a reference with static type flash.display:DisplayObject."
这个问题是类似于AS3: global var of type SimpleButton changes to DisplayObject for unknown reason, won't let me access .upState.textColor!。我发布这篇文章是因为它更专注于处理更广泛问题的单一方面。
对我来说,这两个问题看起来像重复。我不确定有什么不同。 – 2010-01-29 21:14:09