问题
I am building an Adobe AIR (HTML/JavaScript) app for a client who wants to display a game interface on two screens. One screen is where the user will interact with the game itself, the other screen (shown on a projector) will show the game to an audience. The contents of screen 2 is NOT the same as screen 1, so it's NOT a case of mirroring.
An example of this, is a bingo game where the user will click buttons on screen 1 to pull out numbers, etc. And screen 2 will just show the number grid and next number pulled out to the audience who are playing the game. So you can imagine this in a hall of people, with screen 1 being displayed to the guy on stage, and screen 2 being projected to everyone else in the hall. So screen 2 has no interaction and ONLY displays data.
How would I handle this? As I need to be able to send commands to the other window to make it show numbers, update the number grid, etc.
I've looked at doing something like:
projectorWindow.setWindowReference(air.NativeApplication.nativeApplication.openedWindows[1].stage.getChildAt(0).window);
projectorWindow.sendNumber( 88 );
But does anyone have a better idea? Existing examples of doing this?
Second question:
Also in order to make the windows know what each is talking about, I presume I will have to load the EXACT same code into each one so basically load a HTML file like: Bingo.html
and then pass a query string to tell it what mode to run in... e.g. Bingo.html?mode=user
and Bingo.html?mode=audience
does that sound right? Or would there be a better way to do this?
So for example:
function loadGame(game) {
mainWindow.load(new air.URLRequest(game + '.html?mode=user'));
projectorWindow.load(new air.URLRequest(game + '.html?mode=audience'));
}
Not quite sure how I'll trigger the different UI elements based on the query string yet... but is this the best way to build a split screen game using AIR? Or could I do it better?
来源:https://stackoverflow.com/questions/24240491/communicate-between-two-adobe-air-windows