Here's my first tip for working with Flex 2 and Flash CS3. I'm not sure if you have had the opportunity yet to test drive Flash CS3 but if you have and you've also used Flex Builder on a regular basis then F;ash's ActionScript Editor will suddenly appear like a second class citizen to you. Don't get me wrong, Flash is still entirely suited to write ActionScript and CS3 has some cool improvements in this area but I personally feel spoilt by Flex Builder and want to use it as an AS Editor for my Flash projects too.
I started working on a Flash (AS3) project last week which makes use of the new AS3 based FLVPlayback component.
My FLA makes use of Document class feature (which let's you assign a class to the root of your movie) and uses a bunch of other classes too.
The following may seem obvious to some of you who know Flash and Flex inside out but to me these issues posed some small hurdles I needed to take in order to stop Flex Builder from flagging up errors and problems in my As files which otherwise woudl compile fine in Flash. The reason being is that Flash uses some classes which Flex Builder does not 'know' about and they therefore need adding to the classpath in your Flex Builder project.
Problem 1: Flex Builder does not know about the FLVPlayback Component
Flex Builder did not know how to handle a reference to the FLVPlayback Component I had on stage. I knew I had to somehow add the necessary classes to my project and from looking at the Flash docs I knew that the component lives in fl.video.FLVPlayback and I managed to find the classes in C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Component Source\ActionScript 3.0\FLVPlayback.
However after adding them to Flex Builder's project source path I got this error:
1180: Call to a possibly undefined method Icon.
FLVPlayback.as FLVPlayback/fl/video line 4366
It referred to this code:
preview_mc.icon_mc.name = "icon_mc";<br>
preview_mc.icon_mc = new Icon();
Fortunately the solution was easy - after some poking around inside the Flash install directory I found the SWC file for FLVPlayback at C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Components\Video\FLVPlaybackAS3.swc
I added this to Flex Builder's Library path and that did the trick (I removed the previously added classpath again too).
I had to do the same for the new FLVPlaybackCaptioning component, a SWC for which can be found in the same location as the FLVPlaybackAS3.swc.
Problem 2: Flex Builder also does not know about some Flash class packages, such as Transitions and Easing
This one was easier to sort out. After Flex Builder complained about missing classes inside the fl.* package (I think the whole package is not on FB's classpath) I simply added C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes to my project class path in Flex Builder.
It now appears I can use Flex Builder to write AS3 code for my Flash projects without having to put up with Problems popping up in FB. Turns out it's just a matter of classpath issues but it surely is a little confusing to realize that Flex and Flash do not share the same classes by default, even though both produce AS3 based SWF files. It woudl be great to see more tutorials explaining how both programs can be used hand in hand. I also can't figure out if this Adobe technote addresses the issues I have witnessed or if it's covering something entirely different. Can somebody advise? Nico also blogged about this with a solution that offers a SWC download of all the CS3 classes.