Hybrid Hacking

Subscribe

 

Hybrid Hacking provides tutorials on how to integrate with some of today's hottest web services.

 

 

Hybrid Hacking

 

Links

RIApedia
Ryan Stewart
AllFacebook
TechCrunch

 BlogTutorialsAbout 

Loading ActionScript 2 Content in Flex

Flex 2 has difficulties loading SWFs that aren't published as ActionScript 3. 

If you want to load Flash movies that are published as ActionScript 2 into your Flex project you can use an SWFLoader. However, if you want to call ActionScript commands on that loaded file you need to communicate using a LocalConnection.

Peter Ent has a thorough explanation of this process here.

I had a hard time setting up this LocalConnection while I was building an application to load my old Flash content. So in order to make it easier for others I have created a custom Flex Component called "ProxySWFLoader" that abstracts this LocalConnection code and can easily be dropped into your Flex application instead of using an SWFLoader.

This component will have no problems loading ActionScript 2 files, as well as ActionScript 3, JPG, GIF, and PNG files. It acts just like an SWFLoader, except it now allows you to call functions on the target file.

Example Instructions:

  1. Download the example files (.zip - 720KB)
  2. Run the Main.mxml file
  3. See that SWF is showing frame 2

Once you have an idea of how it works based on this example, you can drop the ProxySWFLoader component into your own Flex projects as long as the proxySWF.swf file is also in the same directory.

Note that this code currently only supports having one instance of the ProxySWFLoader component in your project.

Hopefully this will make your life a little easier. If you experience any problems with this example please leave a comment below.

Comments

Dear Shongrunden,

I tried your code in Flex builder 3.
But the 'slide1.swf' cannot be loaded successfully.
Do you know why?
Thanks a lot!

Hi Luda,

I just tried it in Flex Builder 3 and it's not working for me as well. It looks like Flex Builder 3 changes the default security settings. I haven't been able to fix this yet, but will post an update if I can get it going.

Steve

Hello. I'm from Italy, so sorry for my english;
I read your article and i've downloaded your project; but I've the opposite problem; I'm creation a simple Flash animation and at the last frame i've put a stop(); after that I put this SWF inside my Flex project; Inside Flex I've to write some questions but these questions has to appear only after the Flash animation. So I need to make a communication between Flash and Flex. How can I do this; is it possible? Thank You so much.

Patrick

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
8 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
 

Copyright © 2007 Steven Shongrunden