Displaying a video in a pop up window in Flex

The following example shows how you can use the PopUpManager class to display a VideoDisplay control in a TitleWindow container in Flex.

Full code after the jump.


<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/04/displaying-a-video-in-a-pop-up-window-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

            import mx.managers.PopUpManager;

            private function button_click(evt:MouseEvent):void {
                var popUpVideoDisplay:PopUpVideoDisplay;
                popUpVideoDisplay = new PopUpVideoDisplay();
                popUpVideoDisplay.source = "http://www.helpexamples.com/flash/video/water.flv";
                PopUpManager.addPopUp(popUpVideoDisplay, this, true);

    <mx:Button id="button"
            label="Launch video"
            click="button_click(event);" />



<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/04/displaying-a-video-in-a-pop-up-window-in-flex/ -->
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"

        .noPadding {
            paddingBottom: 0;
            paddingTop: 0;
            paddingLeft: 0;
            paddingRight: 0;

            import mx.managers.IFocusManagerComponent;
            import mx.controls.Alert;
            import mx.core.IFlexDisplayObject;
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;

            public var source:String;

            private function init():void {

            private function titleWindow_close(evt:CloseEvent):void {
                PopUpManager.removePopUp(evt.target as IFlexDisplayObject);

    <mx:VideoDisplay id="videoDisplay"
            resize="init();" />

    <mx:ControlBar horizontalAlign="right" width="100%">


View source is enabled in the following example.

20 thoughts on “Displaying a video in a pop up window in Flex

  1. There is lots of talk about using video – but finding a post about how to *embed* video in a Flex app was a lot harder than I expected. If you can convert an .FLV to a .SWF, you can easily embed a video file just like you might embed an image. See the code below for an example. I think this warrants a post of its own…

    <mx:SWFLoader id="myVideo" left="0" right="0" top="0" bottom="0" source="@Embed(source='misc/video.swf')" autoLoad="true" />
    <mx:Canvas id="canvas" height="100%" width="100%" verticalScrollPolicy="off" horizontalScrollPolicy="off"
        <mx:Button x="-21" y="244" label="Get Data ..." click="myVideo.load()" />
  2. HI well there is a bug here……the moment you keep pressing space bar…new window will load automtaiclly……can you resolve this

  3. rahul,

    In PopUpVideoDisplay.mxml file, change the init() method to the following:

    private function init():void {

    Now, when you press the space bar, the TitleWindow will close.


  4. HI well there is a bug here……the moment you keep pressing space bar…new window will load automtaiclly……can you resolve this

    hi i resolved this…use this.setFocus();inside your init function.

  5. I have a form designed using Flex. The form does not fit the screen area and hence I am having scroll bars in it. When we click on some of the controls in the form, we open popups. But when the popup is opened, if we scroll the form using the form scroll bar then the popup is not getting scrolled. I want the popup to be scrolled along with the form elements. Please let me know how this can be done.



  6. Hi Peter,

    Is it possible for the pop up window to move outside the boundaries of the parent application. As I would like them to be able to play a tutorial video on one screen and follow along in the second one.

Comments are closed.