FlashComGuru Home InfluxisCDNImediaseeUvault
                                                                                       Forum Index | Active Topics | Register
                                                                                                          List Overview | List Archives
                                                                                                                           About this site | Advertise
 

home

Adobe AIR (11)
Applications (40)
Books & Training (11)
Collaboration (18)
Components (10)
Events (80)
Flash Player (35)
Flex (39)
FMS (110)
General (123)
Hosting (6)
Jobs (17)
Off topic (36)
OSMF (3)
Press Releases (23)
Site Check (11)
Tools (53)
Videos & Players (74)

Follow me on Twitter

 
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 = new Icon();<br>
preview_mc.icon_mc.name = "icon_mc";<br>
preview_mc.addChild(preview_mc.icon_mc);
This is the live preview for the component within Flash and Flex Builder couldn't deal with that.
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.

Related Articles

Comments
[Add Comment]
I agree on there needs to be a way for Flash CS3Pro and Flex to share classes without hassles

I've been looking for information on how to do this and your page is the ONLY decent one yet.
# Posted By Geordie Martinez | 4/23/07 6:57 PM
It should get easier. Keep your eyes on http://labs.adobe.com - I think they will be releasing a Flex/Flash integration kit today. At least it was announced for today...
# Posted By Stefan | 4/23/07 7:19 PM
I tried the same thing but only get audio. Below is the code :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*" xmlns:video="fl.video.*" creationComplete="init()">
   <mx:Script>
      <![CDATA[
         import mx.flash.UIMovieClip;
         import flash.events.Event;
         import mx.controls.Alert;
         import fl.livepreview.*;
         import fl.video.*;
         
         public function init() : void
         {
            pl.width = 320;
            pl.height = 240;
            pl.x = 0;
            pl.y = 0;
            pl.visible = true;
            pl.source = "rtmp://click.dyndns.tv/CTSstreaming/movies/400x300_On2_Italy_France_match.flv";
            pl.skin = "SkinOverAll.swf";
            pl.autoPlay = false;
            pl.playWhenEnoughDownloaded();
         }
         
      ]]>
   </mx:Script>
<video:FLVPlayback id="pl" />
</mx:Application>
# Posted By JY | 4/25/07 12:50 AM
hi JY,
that's a different approach to mine - I was only writing As code in FB, not compiling a Flex app... Are you using the the Flex/Flash integration kit?
# Posted By Stefan | 4/25/07 9:58 AM
Yeah, I've been playing around with the integration kit for the last few days. FB throws and error when I name the FLVPlayback instance. I e-mailed Adobe and they said that naming an instance would give me the properties and methods for that instance. So, I'm still digging around. Off to the flexcoders mailing list.

I don't want to use the videoDisplay component in FB2 because from what I can tell, it doesn't support captioning out of the box.
# Posted By JY | 4/25/07 4:06 PM
I had a play with FLVPlayback in Flex using the integration kit too. I didn;t get too far - the code hints did not seem to work and I could not set the source on the component. However assigning a source in Flash, producing the swc and then embedding it into a Flex app played the video fine...

I'll try some more next week and blog my findings.
# Posted By Stefan | 4/25/07 4:21 PM
Stefan, I had the same experience with the lack of code hinting. However, I was able to finally set the source of the flvplayback component (swc) from Flex. Also listening for swc events from Flex works. There is a strange UI issue though with the horizontal scrollbar when certain skins are used.
# Posted By JY | 4/25/07 8:48 PM
hey, why don't you tell me how you solved the code hinting (or how you managed to set the source) and I'll tell you how to fix the scrollbar issue ;-)
Email me: stefan AT flashcomguru DOT com and we can swap files, then I'll blog it.
# Posted By Stefan | 4/25/07 8:55 PM
JY, how did you get your above pasted code to work in Flex?
# Posted By Daganev | 5/10/07 6:01 PM
I tried placing the SWC file in the library but get the following error:

Severity and Description   Path   Resource   Location   Creation Time   Id
unable to load SWC FLVPlaybackAS3.swc   

Any other settings that need to happen as wel?
# Posted By KGF | 7/13/07 11:53 PM
@KGF:
place in the library? Do you mean you've linked the SWC in your project properties?
# Posted By Stefan | 7/14/07 11:08 AM
Project->Properties->Flex Build Path-> Library Path. I am assuming this is incorrect.
# Posted By KGF | 7/14/07 1:32 PM
hmm no that's what I did too... not sure why you're getting an error.
# Posted By Stefan | 7/14/07 7:46 PM
are you using Flexbuilder 2.01?
# Posted By Stefan | 7/14/07 7:47 PM
Hi,

I've this error too, and I have version 2.01 !
So I don't understand why FLVPlaybackAS3.swc isn't loadable ?
# Posted By Mike | 7/17/07 6:15 PM
very strange, I haven;t tried this in a while but as soon as I get a chance I'll post my findings of another attempt at this...
# Posted By Stefan | 7/17/07 9:12 PM
You have to update Flex.
See this technote: http://www.adobe.com/go/kb401493

The problem is that Flex Builder (with the update) reads Flash-CS3-created SWC files differently than Flex-created SWC files.

Fun stuff.
# Posted By Sam Ahn | 7/18/07 3:28 AM
[edit previous post]
I meant, "The problem is that Flex Builder (withOUT the update)..."

And I should have read the actual article. So the technote Stefan referenced (and I again) does the trick. You may have to close and reopen the project one more time if it doesn't work right away.
# Posted By Sam Ahn | 7/18/07 3:35 AM
ah yes, I forgot all about the patch!
# Posted By Stefan | 7/18/07 9:55 AM
Worked like a charm. Thanks!
# Posted By KGF | 7/18/07 9:01 PM
I am continually getting the error Error 1172: Definition fl.video.FLVPlayback not found. I added the FLVPlaybackAS3.swc to my Flex project library path, but still getting the same result.

Any suggestions?
# Posted By Shawn | 10/16/07 3:51 PM
Worked flawlessly. Thanks a lot.
# Posted By burun | 1/30/08 9:16 AM
Thanks for your help in explaining the classpath issue!
# Posted By Johan Nyberg | 3/7/08 12:52 PM
Hi,
I had created one component in Flex and that component is working in Flex 3.0 IDE,
Now I need to access the same component in Flash CS3, in Flash CS3 there is a tool for converting the Flash component to Flex , but let me know how to access the Flex component to Flash component,

1. Where to call the class file?
2. Whether I need set any properties for accessing the component?

Please let me know how to call the component in Flash CS3

Waiting for the reply
Regards
Balaji
# Posted By Balaji | 7/15/08 9:18 AM
I don't think that's possible. A Flex component requires the Flex framework, and Flash does not have access to this.
# Posted By Stefan Richter | 7/15/08 9:40 AM
Where did you get trailers feed? Youve done something I want to do for the redesign of my site, but I cant seem to find a feed to read from.
# Posted By Estetik | 11/24/08 7:00 PM
found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later ..
# Posted By Estetik | 11/26/08 1:41 PM
thanks for contribution. very nice and useful article..
# Posted By assos | 5/18/09 9:24 PM
I need to access the same component in Flash CS3
# Posted By lazer epilasyon | 9/2/09 1:59 PM
thanks for contribution. very nice and useful article..
# Posted By estetik | 12/9/09 9:29 AM
Document very successful. But a little more detailed information should be.
# Posted By çene tedavisi | 2/11/10 10:44 AM
this information most important for me.
thanks...
# Posted By sepetli platform | 2/11/10 9:58 PM