1

早些时候我使用了以下结构:

Canvas -> Screen1
Canvas -> Screen2

当我觉得在我的应用程序中需要通用逻辑时,我会执行以下操作:

Canvas -> Screen
Screen -> Screen1
Screen -> Screen2

所以当我尝试在我的代码中应用它时

if(child is Screen){
    return child.localToGlobal(new Point()).x;
}

这是行不通的!当我在调试器中看到时,孩子的类型为“Screen2”,但“孩子是屏幕”返回 false 给我(和“孩子 instanceof 屏幕”也是)。当我应用编译器密钥:“-keep-generated-actionscript”时,我可以看到 Screen2-generated.as 它包含

public class Screen3 extends screens.Screen

在此先感谢对不起我丑陋的英语=)

4

1 回答 1

2

I think the issue is with this specific name - there already is a class called Screen (in flash.display - http://livedocs.adobe.com/flex/3/langref/flash/display/Screen.html), and Flex checks if it's an instance of the original screen.

You can try two things:

1) Rename your Screen class to CustomScreen and try it again.

2) Check if the child is an instance of your class by referencing it full path eg. if (child is screens.Screen)

于 2010-07-05T12:09:54.060 回答