Dual Monitor Support in Flex Application [closed]

China☆狼群 提交于 2019-12-11 19:29:16

问题


I am building an application for windows using adobe flex and Air.

It will support two displays, one will be used to select the video to play, and the other will be used to play the qued/selected videos.

I read on the adobe website, that Air supports multiple displays however, it did not go into great depth.

This is my first time doing this, so could someone please: a) let me know if it is possible b) give me an overview of how I could achieve it

Thanks


回答1:


I'll try to describe a simple example.

Let's assume your list of videos is the main application window (this is the window you always want to see) and the player window is optional, depending on whether the user selected a video or not.

First create the player window:

<!-- PlayerWindow.mxml -->
<s:Window xmlns:fx="http://ns.adobe.com/mxml/2009" 
          xmlns:s="library://ns.adobe.com/flex/spark" 
          width="400" height="300">

    <fx:Declarations>
        <fx:String id="video" />
    </fx:Declarations>

    <s:Label text="Now playing: {video}" />

</s:Window>

As you can see there's no video player in there: I just wan the example to be as simple as possible.
Now from the main application we are going to open that window and set that video property when the user selects a video from a list:

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark">

    <fx:Script>
        <![CDATA[               
            private var playerWindow:PlayerWindow;

            private function openPlayerWindow():void {
                //only open a new window if it isn't already there,
                //otherwise just set the 'video' property
                if (!playerWindow) {
                    playerWindow = new PlayerWindow();
                    playerWindow.addEventListener(Event.CLOSE, onClose);
                    playerWindow.open();
                }
                playerWindow.video = movieList.selectedItem;
            }

            private function onClose(event:Event):void {
                //remove the reference to the window when the user closes it,
                //so we can reopen it later
                playerWindow.removeEventListener(Event.CLOSE, onClose);
                playerWindow = null;
            }
        ]]>
    </fx:Script>

    <s:List id="movieList" change="openPlayerWindow()">
        <s:dataProvider>
            <s:ArrayList>
                <fx:String>Batman</fx:String>
                <fx:String>Superman</fx:String>
                <fx:String>Spiderman</fx:String>
            </s:ArrayList>
        </s:dataProvider>
    </s:List>

The video property is just a simple string here. It can be replaced with a complex model object. If you then change properties of that model object from the main window, those changes can simply be reflected in the player window through data binding.



来源:https://stackoverflow.com/questions/11880104/dual-monitor-support-in-flex-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!