How to manage windows in external applications

I have 2 AIR applications ( A and B ) that can communicate through a LocalConnection object. I checked that messages are certainly sent / received appropriately.

I want to have A tell B to go to the fore. Both applications have a full screen:

 stage.fullScreenSourceRect = new Rectangle(0, 0, 1080, 1920); stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE; 

I tried several permutations, but so far nothing is working.

 private function initSlave(channel: String): void { conn = new LocalConnection(); conn.client = { 'activateSlave': activateSlave }; conn.allowDomain("*"); conn.connect("_" + channel); } private function activateSlave(): void { stage.nativeWindow.orderToFront(); // or stage.nativeWindow.activate(); // or stage.nativeWindow.alwaysInFront = true; stage.nativeWindow.alwaysInFront = false; } 

If I leave both applications in windowed mode ( stage.displayState = StageDisplayState.NORMAL ), the alwaysInFront switch actually works. A call to activate() or orderToFront() still does nothing. If I try to switch alwaysInFront and then install the application in full screen mode, the application ends in full screen mode beyond my application window. Perhaps there is an event that I should wait before installing the application in full screen mode?

I found a thread that mentions that orderToFront() only works on windows in one application, which explains why it doesn't do anything.

Does anyone have any ideas for removing this? Maybe there is a way to add B to application A so that they are actually the same application? I'm not sure how to do this with an AIR application as simple as loading SWF due to the need for external resources.

+4
source share
1 answer

Since no one else has suggested a solution, I will just quickly talk about what I use. Basically, I have 2 LocalConnection channels, one from A to B , and one from B to A A visible program (for example, A ) will then turn white, set visible to false and send a message to B to give up control. B initialized itself to stage.nativeWindow.visible = false , and when it receives a message from A , it becomes visible as a full white screen and disappears in the GUI. There is a slight offset before A sets visible to false to display the time B , otherwise there will be a brief moment when both windows are minimized.

Anyway, you go, it's ugly, but actually it works pretty well.

+2
source

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


All Articles