In my application I have a video playing from a NetStream. Every second on timer I update a text label with statistics like stream.info.currentBytesPerSecond. The problem occurs when the NetConnection associated with this NetStream closes: the getter for stream.info throws
Error: Error #2154:The NetStream Object is invalid.
The only solution for this seems to be to listen to NetStatus event and stop the timer when "NetConnection.Connect.Closed" gets caught.
Isn’t there a better way to do this?
You could wrap your test for stream.info in a try..catch, I suppose. Or you could test to see if the object exists first:
Really, though, the cleanest way would be to remove the applicable listener and perform cleanup when your connection closes.