views:

163

answers:

1

Ok, this one is driving me batty. I've made a custom video player in CS4. Basically, I just used The Gimp to draw a video player and saved it as a PNG, which I dragged to the stage.

I didn't want to use FLVPlayback, so I used Actionscript to add a Video to the stage.

var video:Video = new Video(480,360);
addChild(video);

I'll spare you the details of how I hooked it up, but it works perfectly. The problem starts when I try to drag a ComboBox to the stage. Before I add any handlers or anything, if I select an item from the ComboBox, it terminates playback on my Video (and NetStream). Wierd! Why? And how do I keep it from doing so?

A: 

Ok, I'm feeling pretty damn smart right now that I figured this out. Of course, I'd have been smarter to not have caused the error in the first place. This was a problem of garbage collection and really had nothing to do with the ComboBox at all. Clicking on the ComboBox, it turns out, caused just enough object garbage to trigger the garbage collector.

My NetStream was dying without triggering the event handler because it was being garbage collected. I wasn't holding a reference to it in my code. I didn't think that I had to because I had called video.attachStream(ns) and was holding a reference to video. However, the Video class obviously doesn't hold a reference to the NetStream either.

Jonathan Hawkes