Adobe AIR What is the proper method of using EventListener in a newly created window?

I am very new to AIR development and have just started seriously creating my first simple application. I would like to open a new window to ask the user for the necessary settings at the first start. When testing a new window and detecting its closed state, I performed the following (some jQuery codes are included):

The following code is used to open a new window when the main application starts (as it appears when it opens).

$(document).ready(function(){
    var options = new air.NativeWindowInitOptions();
    options.type = air.NativeWindowType.UTILITY;
    var windowBounds = new air.Rectangle(200,250,300,400);

    //create the new window
    newHTMLLoader = air.HTMLLoader.createRootWindow(true, options, true, windowBounds);
    newHTMLLoader.load(new air.URLRequest("setup.html"));
    newHTMLLoader.window.opener = window;
    newHTMLLoader.window.nativeWindow.addEventListener(air.Event.CLOSE, handleNewSettings);
}

, jQuery document.ready. - . - , , - , , , ( ).

function handleNewSettings(event){
    //remove the event handler from memory first...
    newHTMLLoader.removeEventListener(Event.CLOSE, arguments.callee);

    //this is my event handler code
    alert('yay');
    window.close();
}

AIR :

ActionScript: "TypeError: # 2007: .    flash.events::EventDispatcher/removeEventListener()"

, , JS. removeEventListener, , , ; , . , .

+3
1

- ( ?)

newHTMLLoader.removeEventListener(Event.CLOSE, arguments.callee);

... ...

newHTMLLoader.removeEventListener(air.Event.CLOSE, arguments.callee);

, .

+2

Source: https://habr.com/ru/post/1715023/


All Articles