AS2 to AS3
So I sit down today to look at the outcomes from the recent meetings with Theatre Studies and to assess whether FMS can do the communication and background tasks required. The plan was to take the Media Manager application code and add some new screens to test the requirements.
The first test was a simple drag and drop sequencer; no problem – read the assets, create a visual array and let the user drag assets into sequencer ‘slots’, updating the play order array on the way. I quickly ascertain that I can’t create Video objects dynamically – they can only be accessed if already created on the Stage – not much use if you don’t know how many to create in the first place. I could load the target media into an FLVPlayback component, but I prefer the simplicity (and smaller footprint) of the Video class for this task.
The best solution seemed to be to use Actionscript 3 – the AS3.0 classes for handling streams and video objects have some subtle but useful improvements over the old AS2.0 ones. In AS2.0, you’d do something like this in order to attach a NetStream to a Video object:
var myNC:NetConnection = new NetConnection(); myNC.connect(fmsAppLoc); var myNS:NetStream = new NetStream(myNC); myVideo.attachVideo(myNS); myNS.play(myVideoFileLocation);
The problem is, this would need an object already on the Stage called myVideo. And I might need anything from 1 to n of those.
In AS3.0 however, things are slightly different;
// dynamically create a Video object var myVideo:Video = new Video(); addChild(myVideo); var myNC:NetConnection = new NetConnection(); myNC.connect(fmsAppLoc); var myNS:NetStream = new NetStream(myNC); myVideo.attachNetStream(myNS); myNS.play(myVideoFileLocation);
Cool – so now I can create as many Video objects as I need, when I need to. I haven’t been able to find out why the Video class is handled differently within Flash – you can create (and destroy) pretty much everything else dynamically.
Whatever; fire up the Flash 9 Alpha Preview IDE, change the Publish settings to AS3 and… bang, everything breaks with lots of namespace and binding errors, before I’ve had a chance to add my shiny new code. I’d expected problems of course, but after much fiddling and trying to make sure everything was typed, declared, imported etc., it remains broken in such a way that I reckon only a proper rewrite in AS3.0 will fix. For now I’ll do the proof of concept stuff using FLVPlayback objects, but I’ll recode the application in AS3.0 from scratch (probably at home when I get time), and if I’m going to do that I may as well try doing it in SEPY or Flex2. I can feel the fingers of OO dev tightening its grip around my neck…

