tags:

views:

146

answers:

1

ok I have a subclass of TitleWindow with this method:

public function launchInNewWindow(e:Event):void
{
    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;
    ownWindow.addChild(this);
    ownWindow.width += 5; //add to show dropshadow
    ownWindow.height += 10; //add to show dropshadow
    ownWindow.open();
    _inOwnWindow = true;
    ownWindow.nativeWindow.x = Application.application.nativeWindow.x + this.x + 5; //keep in same spot add 5 for systemChrom border
    ownWindow.nativeWindow.y = Application.application.nativeWindow.y + this.y + 30;//keep in same spot add 30 for systemChrom title
}

What this does is make the title window its own Window (NativeWindow) by creating a new Window object and adding itself to the new Window's displayList.

It works really well, however if I have a removedEffect set on the instance of this class it produces an error when trying to add itself to the Window's displayList.

I tried adding:

this.setStyle('removedEffect',null);

and

this.setStyle('removedEffect',new TitleWindow().getStyle('removedEffect'));

to the method as an attempt to remove any removedEffect set on itself before hand, but with no luck.

but it works fine if there is no removedEffect on the component. There has got to be a way to fix this.

Any ideas?

Thanks!!

A: 

For the removedEffect to work the window needs to be on the original parent, but you're immediately trying to add it to the new parent and it can't belong to two parents at once. There are a few options I can think of.

  1. Get a bitmap of the window to be removed, show that in the same place, run the effect you want on this bitmap copy, and then you can run re-parent the original without interference from the effect.

  2. Separate the code that removes and re-parents into two steps. Remove the window first. Then when the removedEffect is done, add it to the new window's display list.

Sam
well, I listened for Effect_END and TWEEN_END neither work alone, but if I listen for them then set a timer to addChild 100ms after it does work. I am hoping there is just 1 event I can listen for, not listen for one event then set a timer, as that just seems very poor.
John Isaacks