在这段简单的 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 类似:SimpleButton 类型的全局变量因未知原因更改为 DisplayObject,不会让我访问 .upState.textColor!. 我发布这个是因为它更专注并且处理更广泛问题的一个方面。