I have 2 AIR applications (A and B) that are able to communicate via a LocalConnection object. I’ve verified that messages are definitely being sent/received appropriately.
I want to be able to have A tell B to come to the front. Both applications are full screen:
stage.fullScreenSourceRect = new Rectangle(0, 0, 1080, 1920);
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
I’ve tried several permutations, but as of yet nothing seems to work.
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), then toggling alwaysInFront actually works. Calling activate() or orderToFront() still do nothing. If I try to toggle alwaysInFront and then set the application to fullscreen, the application ends up fullscreen behind my windowed app. Maybe there is an event I should wait for before setting the app to fullscreen?
I found a thread mentioning that orderToFront() only works relative to windows within the same application, which explains why it doesn’t seem to do anything.
Does anyone have any insights into pulling this off? Maybe there is a way for me to embed B into application A so they are actually the same application? I am not sure how to do this with an AIR application as simply as just loading the SWF due to requiring external resources.
As no one else has offered a solution, I’ll just mention quickly the hack that I’m using. Basically I have 2
LocalConnectionchannels, one fromAtoB, and one fromBtoA.The visible program (e.g.
A) will then fade to white, setvisibletofalse, and send a message toBgiving up control.Bhas initialized itself withstage.nativeWindow.visible = false, and when it receives the message fromAit goes visible as a full white screen and fades in the GUI. There is a slight offset beforeAsetsvisibletofalseto giveBtime to display, otherwise there is a pop in the brief moment when both windows are minimized.Anyway, there you go, it’s ugly but it actually works fairly well.