Clearing the video on a Spark VideoElement control in Flex 4

In a previous example, “Clearing the video on a Flex VideoDisplay control”, we saw how you could clear a VideoDisplay control’s content using the videoPlayer property in the mx_internal namespace.

The following example shows how you can clear a Spark VideoElement control’s video stream in a Flex 4 application by calling the clear() method on the VideoElement instance’s videoObject property.

Full code after the jump.

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see To download the latest nightly build of the Flex 4 SDK, see

For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:Application name="Spark_VideoElement_clear_test"
        <s:Button id="btn"
                label="clear video"
                click="btn_clickHandler(event)" />
            protected function btn_clickHandler(evt:MouseEvent):void{
                if (vdElmnt.playing) {
    <s:VideoElement id="vdElmnt"
            horizontalCenter="0" verticalCenter="0" />

This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.