如何从NativeWindow对象访问NativeWindow的包装类(mx:Window)属性

时间:2012-05-24 14:43:03

标签: actionscript-3 flex air flex4.5 nativewindow

假设我有一个名为myCustomWindow的Window组件。然后我用:

创建新窗口
var newWindow:myCustomWindow = new myCustomWindow();
newWindow.open();

myCustomWindow具有名为myProperty的公共属性。

如何从NativeWindow访问myCustomWindow? 例如,如何在此循环中执行此操作:

for (var i:int = 0; i < NativeApplication.nativeApplication.openedWindows.length; i++) 
{
    if( NativeApplication.nativeApplication.openedWindows[i].myProperty == 25)
    {
          NativeApplication.nativeApplication.openedWindows[i].close();
    } 
    //error, cause NativeWindow doesn't have myProperty
    //how to access myCustomWindow.myProperty of this NativeWindow ?
}

1 个答案:

答案 0 :(得分:0)

这是一个解决方案:

创建数组并推送()所有窗口。

var myWindowsArray:Array = [];
...
myWindowsArray.push(myCustomWindow);

访问myProperty:

for each (var k:myCustomWindow in myWindowsArray) 
{
    if( k.myProperty == 25)  k.close();
}