Labs: Camera Fun ReDux
Dec 21, 2006 Articles, Experiments
Okay, so not really Camera.
I know not everyone has a Webcam to use, so I decided: why don’t I make one that uses a .flv? So I sat down again, and tweaked my code a little to use a .flv instead of a camera. And boy did that stump me for awhile. Talk about hitting your head against a brick wall.
Of course, for me to work with video, I had to understand the mechanics of it in AVM2.
Working with flv comes in 3 lovely parts:
- flash.media.Video();
- flash.net.NetConnection();
- flash.net.NetStream();
Now, simply put, your NetConnection is basically the URLRequest of your URLLoader class. You need to establish a connection to the internet first, before telling NetStream to connect through that connection (seems silly to me).
1 | myNetStream = new NetStream(myConnection); |
So once you’ve done that, you then have to call NetStream.play(path) to load the .flv. Strangely enough, you do not need to use URLRequest for this. I find this slightly offputting. But hey, I figured it out soon enough.
Of course now we get more confusing parts. NetStream has a little property called Client. This allows you to pass through an object which holds several Event Handlers (onMetaEvent for example), and uses it as a callBack. Is this only me that finds it inconsistent? This must be the most inconsistent class I’ve come across so far. Not to mention that some events that NetStream dispatches (NetStatusEvents) comes from the NetStream itself, and doesn’t need a object callback!
But of course, setting the client to the “this” was simple enough. So I got through eventually. Putting aside my little attempt to load a Youtube video (sorry GoogleTube! I won’t do it again. Please don’t sue me with your 1.65b capital) and fiddling around with policyFiles I ended up uploading a .flv myself which you can find at my labs.
On a side-note, I’m really getting into the graphics API. Except for any major tweening, I now do everything in AS. Go Me!
Experiment Focus:
- flash.net.NetConnection();
- flash.net.NetStream();






Leave a Reply