# Closing vidoe stream. driving me crazy

**URL:** <https://forum.kirupa.com/t/closing-vidoe-stream-driving-me-crazy/306109>\
**Category:** Uncategorized\
**Created:** [March 9, 2010, 8:59pm UTC](https://forum.kirupa.com/t/closing-vidoe-stream-driving-me-crazy/306109 "2010-03-09T20:59:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phastings](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@phastings](https://forum.kirupa.com/u/phastings)\
**Post date:** [March 9, 2010, 8:59pm UTC](https://forum.kirupa.com/t/closing-vidoe-stream-driving-me-crazy/306109/1 "2010-03-09T20:59:11Z")

</div>

i have this working in another project but in this new one i’m getting errors. i put a video player on the stage:

function showVideo() {  
trace(“showVideo”);

```
var videoHolder:video_holder = new video_holder();
videoHolder.name="videoholder";
videoHolder.x=392;
videoHolder.y=300;
addChild(videoHolder);

```

}

i have functions to remove the video player and to also close the stream(or the video audio continues). i can remove the video fine but when trying to close the stream i get this error twice(once for each of the lines below noted with ( //ERROR HERE). Does anyone have any idea why this is or how i can close the video stream?

1119: Access of possibly undefined property stream through a reference with static type flash.display:DisplayObject.

function removeVideo() {

```
if (Boolean(getChildByName("videoholder"))) {
    trace("removeVideo");
    var doremove:DisplayObject=getChildByName("videoholder");
    //check if video stream exist. if so remove it
    if (doremove.stream) { //ERROR HERE
        doremove.stream.close(); //ERROR HERE
    }

    deleteVideo();
}

```

}  
function deleteVideo() {  
trace(“deleteVideo”);  
var doremove:DisplayObject=getChildByName(“videoholder”);  
var doIndex:int=getChildIndex(doremove);  
removeChildAt(doIndex);//  
}
