A (probably obvious) FLV playback gotcha

March 18th, 2007 § Comments Off on A (probably obvious) FLV playback gotcha § permalink

So I’ve been learning how to play back FLVs with ActionScript. It’s pretty simple, but my first tests weren’t working. I spent some time scratching my head, because my test was a simple modification of the sample code provided in Learning ActionScript 2.0 in Flash.

What was going wrong?

I had taken the sample code and placed it in a method of an ActionScript class. Thus, the variables used in the sample code (e.g. my_nc:NetConnection, my_ns:NetStream) were no longer properties of the movie, but were purely local to the method. When the method completed executing, the variables vanished, which apparently destroyed the connection and stream.

To remedy this, I made the NetConnection and the NetStream properties of the class, so that they would stick around after the method exited.

I had originally thought that keeping around references to the NetConnection and the NetStream would be optional, only necessary if you wanted to refer to them later (like it might be in Java), but I guess not!

Where Am I?

You are currently browsing the Flash video category at bunnyhero dev.