flex air open new nativewindow null objecthen

263 Views Asked by At

i add a new window in windowapplication,i did by nativeWindow,but when i debug this,the new window's content is always not loading completely. the following is the error TypeError: Error #1009: Cannot access a property or method of a null object reference.

i did add the creation_complete event,but it still not work. why?someone could help?

opts = new NativeWindowInitOptions();
opts.resizable=false;
opts.maximizable=false;
win = new NativeWindow(opts);
win.alwaysInFront=true;

var newWindow:TestWindow=new TestWindow();
newWindow.addEventListener(FlexEvent.CREATION_COMPLETE,performWindowComplete);
win.activate();

public function performWindowComplete(e:FlexEvent):void
{
     win.stage.addChild(e.currentTarget as TestWindow);
}

and in the TestWindow ,I just add one textArea,when i open this new window,i click the textarea,it throws null object.i confused.

1

There are 1 best solutions below

0
On

CREATION_COMPLETE event never fire because your component not added in display list/stage.First you need to add to display list.

opts = new NativeWindowInitOptions();
opts.resizable=false;
opts.maximizable=false;
win = new NativeWindow(opts);
win.alwaysInFront=true;

var newWindow:TestWindow=new TestWindow();
newWindow.addEventListener(FlexEvent.CREATION_COMPLETE,performWindowComplete);
win.addElement(newWindow); //Todo
win.activate(); //or Set visible = true