So, I’m trying to write a generic video player in AS3. I actually had it working perfectly when writing it on the stage in a frame. (so much easier!) Then I decided to convert it to a document class, that being a better coding practice and all.
My main issue now is this part in the constructor:
// Create net connection and stream.
var conn:NetConnection = new NetConnection();
conn.connect(null);
var stream:NetStream = new NetStream(conn);
stream.play(mfile);
var metaListener:Object = new Object();
metaListener.onMetaData = theMeta;
stream.client = metaListener;
// Sound
var st:SoundTransform = new SoundTransform();
stream.soundTransform = st;
// Video
var video:Video = new Video();
video.attachNetStream(stream);
This is followed by a bunch of eventListeners. Several functions called by the eventListeners reference conn, stream and str, so the result is a whole bunch of 1120: Access of undefined property conn. errors. This is where I need the variables to go global.
I did attempt to move the variables above out of the function, but that gave me the following output, which leaves me even more lost.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at src.videoPlayer::videoPlayer()
Any help is deeply appreciated!