In a previous example, “Setting the background color on a VideoDisplay control in Flex”, we saw how you could modify the background color of a VideoDisplay control in Flex by setting the backgroundColor style.

The following example shows how you can set the background alpha on a Flex VideoDisplay control by setting the backgroundAlpha style.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/04/18/setting-the-background-alpha-on-a-videodisplay-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            private function loadButton_click(evt:MouseEvent):void {
                var url:String = "http://www.helpexamples.com/flash/video/clouds.flv";
                videoDisplay.source = url;
            }

            private function unloadButton_click(evt:MouseEvent):void {
                videoDisplay.close();
                videoDisplay.source = null;
                videoDisplay.mx_internal::videoPlayer.clear();
            }
        ]]>
    </mx:Script>

    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="backgroundAlpha:">
                <mx:HSlider id="slider"
                        minimum="0.0"
                        maximum="1.0"
                        value="1"
                        snapInterval="0.01"
                        liveDragging="true" />
            </mx:FormItem>
            <mx:FormItem label="backgroundColor:">
                <mx:ColorPicker id="colorPicker" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:VideoDisplay id="videoDisplay"
            backgroundAlpha="{slider.value}"
            backgroundColor="{colorPicker.selectedColor}"
            width="160"
            height="120" />

    <mx:ControlBar>
        <mx:Button id="loadButton"
                label="Load"
                click="loadButton_click(event);" />
        <mx:Button id="unloadButton"
                label="Unload"
                click="unloadButton_click(event);" />
    </mx:ControlBar>

</mx:Application>

View source is enabled in the following example.

 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

0 Responses to Setting the background alpha on a VideoDisplay control in Flex

  1. naresh says:

    this is very helpfull for fle developers.

    thanking u.and keep it up

    with regards
    naresh

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree