Flash CS3 and Flex 2 communication using ActionScript 3.0

Flex and Flash CS3 communicationHere is an example that demonstrates how to control the timeline of an SWF that was published with Flash CS3 from AS3 code in a Flex project. The Flash CS3 based SWF is set to publish for Flash Player 9 and uses ActionScript 3.0. The SWF is loaded into Flex using a SWFLoader control. Once it is loaded functions on the timeline of the loaded SWF can be called from functions in the Flex project.

This is something I have wanted to look into for a while now. I just got the chance last night while working on the Odeo API example. Using this technique really starts to blur the lines between Flex and Flash CS3. I think this approach also opens the door to more opportunities for interesting UI development.

View example here.

Full source available.

14 Responses to “Flash CS3 and Flex 2 communication using ActionScript 3.0”

  1. That’s very cool man!

  2. [...] for animation and the search text field has a real time “web 2.0″ reflection. A little bit of Flash CS3 to Flex communication going on here [...]

  3. Is there any way you could maybe post the source code for both of these showing an example?? I have been trying to find the best way to communicate between flash and flex for awhile… I am currently using LocalConnection to send strings from a flash menu to a flex interface…. doing it this way would be a lot easier..

  4. nevermind… the source code is right there…

  5. I have a quick question for you, is there a way for the flex to detect a keypress in the flash and load something from it ie. I have a flash menu, the user clicks one of the buttons(there movieclips) and I want the flex to load the associated .swf

  6. Hi,

    Thanks for this article, it is very usefull information.

    The sample swf & mxml works fine, however I am having trouble recreating this functionality if I start from the fla.

    I tried to export to swf from the library panel and from file->export movie, but when flex loads the swf the content object was of type “MovieClip” and so did not have the setFlashText method or the animhorse_mc movie clip member. I am using CS3 and Flex builder 2.

    This is probably a Flash noob question, but I can’t find info anywhere so any tips would be appreciated. :)

  7. Hi!
    Nice example! All works!!

    to “Yotam on December 9th, 2007 at 11:30 am”
    this hapens becourse of garbage collector removes you function - unless you use it inside SWF

  8. Hi!

    Thanks for the example… is it possible to do this the other way ’round? I need to call a function in a flex application from a flash movie.

    Any suggestions?

  9. [...] http://seantheflashguy.com/blog/2007/09/27/flash-cs3-and-flex-2-communication-using-actionscript-30/ [...]

  10. How to control Flash CS3 and Flex 3 communication using ActionScript 3.0?

  11. is this possible with Flash 8 and Action Script 2?

  12. Gah. I can’t get this to work. When I debug it says passes me the “Error #1009: Cannot access … a null object reference.”

    But it’s buggy though. The functions never works in debug mode but it does sometimes running in normal mode. When I pull in a fresh version of the Flash swf it works (not debug mode) but if I modify anything it just sits there (apparently passing the error).

    Otherwise it seems like a great way to solve the problem.

  13. [...] the Flex Guy has an excellent and simple tutorial for doing half of what I needed. It loads in a Flash swf animation, and then Flex talks to it to [...]

  14. [...] the Flex Guy has an excellent and simple tutorial for doing half of what I needed. It loads in a Flash swf animation, and then Flex talks to it to [...]

Leave a Reply