A while ago I wrote a post about how Flexbuilder (FB) can be used to write AS3 code for Flash apps. It took a little effort to set it all up but once that first hurdle was taken things were running smoothly. And to be honest who'd want to use Flash's code editor after having used FB for a while?

Not long ago Adobe released the Flex Component Kit for Flash CS3 on Labs. The kit allows you to use Flash content as components in Flex. I've seen that the kit is now part of Flex 3 but for this example I was using Flex 2.01 with this patch applied (although I am not sure if the patch is needed).


One thing that is clearly lacking in Flex right now is a good set of video components. There's the VideoDisplay component but to be honest I never use it because it's quite restrictive. However I do like Flash's FLVPlayback component so I wnet ahead and created a Flash file which contains the AS3 based FLVPlayback component. I had a go at this exact same excercise a while ago but had no joy then. I'm glad to say that this time it worked, but I had some funky problems. However I think those problems were self inflicted so I won't detail them here.
Anyway, I created a SWC as detailed in the component kit's docs and added it to my Flash project library. I was then able to access the FLVPlayback component and all its methods, events and properties in Flex. Neat.
Long story short, I am posting all my files here in case someone will find them useful.
There are a few things to note however:
- you need to use the boundingBox MC in Flash (like I did) or the FLVPlayback component will break its boundaries in Flex due to the hidden seekbar being veeeery long (but invisible)
- if I resize the FLVPlayback component in Flex it scales the skin as well as the video. Someone got a workaround for that? - you need to 'dig' one level down to get at the FLVPlayback component itself from Flex. So instead of using player.source for example you need to use player.pb.source (pb being the name I gave the component in Flash, you may call it whatever name you see fit)
- I am not sure if FLVpb.as (the class used with Flash) is needed. I think it's left over from another exercise, you may be able to ignore it (plus the SWC is there for you anyway now)

Hopefully this makes sense. The video player can be seen here and sources are available here or via right click on the Flex app. Hopefully the files are not too jumbled up, it was not a normal Flex project as the Flash files were mixed into it in a FLA folder. Any questions just ask.