简体   繁体   English

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

[英]How to access NativeWindow's wrapper class (mx:Window) property from NativeWindow object

Lets say I have Window component named myCustomWindow. 可以说我有一个名为myCustomWindow的Window组件。 Then I create new windows with: 然后,我使用以下命令创建新窗口:

var newWindow:myCustomWindow = new myCustomWindow();
newWindow.open();

myCustomWindow has public property named myProperty. myCustomWindow具有名为myProperty的公共属性。

How to access myCustomWindow from NativeWindow? 如何从NativeWindow访问myCustomWindow? For example, how to do it in this loop: 例如,如何在此循环中执行此操作:

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 ?
}

This is one solution: 这是一种解决方案:

Create array and push() all windows in. 创建数组并推入所有窗口。

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

Accessing myProperty: 访问myProperty:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM