AIR:切换窗口后组件行为错误

时间:2010-02-22 16:16:33

标签: flex air

好的,我有一个组件,它有一个功能,可以在当前popUp中将自己删除为Window,并将自己添加到新创建的Window

但是,如果组件有一个像ComboBox这样的子组件,下拉组件仍然会在以前的旧窗口中弹出,也就是滚动条,并且焦点似乎在新的情况下表现不正确窗口也是。

在我看来,Flex仍然认为该组件是原始窗口的子项,而不是新窗口。我不知道如何解决这个问题。

这是我的代码:

private var ownWindow:Window;
private var _inOwnWindow:Boolean;
private var _removedEffect:Move;
private var _openX:Number;
private var _openY:Number;

public function launchInNewWindow(e:Event):void
{
    _openX = Application.application.nativeWindow.x + this.x + 5; //keep in same spot add 5 for systemChrom border
    _openY = Application.application.nativeWindow.y + this.y + 30;//keep in same spot add 30 for systemChrom title

    this.parent.removeChild(this);
    ownWindow = new Window();
    ownWindow.systemChrome = 'none';
    ownWindow.type = NativeWindowType.LIGHTWEIGHT;
    ownWindow.transparent = true;
    ownWindow.setStyle('showFlexChrome', false);
    ownWindow.width = this.width > 750 ? 750 : this.width;
    ownWindow.height = this.height > 550 ? 550 : this.height;
    edit.enabled = false;

    _removedEffect = this.getStyle('removedEffect') as Move;
    if(_removedEffect == null)
    {
        openNewWindow();
    }
    else
    {
    // Wait for removed effect to play before adding to new window
_removedEffect.addEventListener(EffectEvent.EFFECT_END,delayOpenInNewWindow);
    }
}

private function delayOpenInNewWindow(e:Event = null):void
{
    var t:Timer = new Timer(100,1);
    t.addEventListener(TimerEvent.TIMER,openNewWindow);
    t.start();
}

private function openNewWindow(e:Event = null):void
{
    ownWindow.addChild(this);
    ownWindow.width += 5; //add to show dropshadow
    ownWindow.height += 10; //add to show dropshadow
    ownWindow.open();
    _inOwnWindow = true;
    ownWindow.nativeWindow.x = _openX;
    ownWindow.nativeWindow.y = _openY;
}

有什么想法吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

在我开始运行之前,您是否尝试过openNewWindow()行的callLater?

[lame fix attempt,我知道 - 但是假设在removeEffect不为null的情况下似乎没有你可以监听的事件,并且似乎计时器是你唯一的选择,我认为没关系给予蹩脚的修复尝试:-)]