Working on a project where I have a highly interactive Flash SWF that needed to be embedded in a Flex project. The thing would not work. Here’s what I did to get it to successfully embed.

  1. Use SWFLoader. If your Flash SWF is self contained and doesn’t access any outside resources, you’re pretty much set.
  2. For SWFLoader, be sure to specify the minWidth and minHeight properties.
  3. Remove/change the loaderInfo statement. stage.loaderInfo.parameters["someValue"]
    I was trying to get flashvars from the getgo and it was failing right here. Commenting out that line made it work.
  4. Here’s the kicker though – don’t embed your SWF. Load it dynamically. So this statement:
    <mx:SWFLoader width="100%" height="100%" source="@Embed(source='FlashAS3.swf')"
    scaleContent="false" autoLoad="true" minWidth="500" minHeight="400" />

    should look like this:

     <mx:SWFLoader width="100%" height="100%" source="FlashAS3.swf"
    scaleContent="false" autoLoad="true" minWidth="500" minHeight="400" /> 

    For some reason, when you embed the SWF, it doesn’t work.

  5. Finally, be sure to update all your paths if your SWF accesses resources such as XML and images dynamically.

Popularity: 21% [?]

Related posts:

  1. SXSW 2008: Takeaway from AJAX & Flash Mistakes at Slideshare
  2. Flash ActionScript stage.stageWidth vs stage.width
  3. Flex AS3 Swf to Swf Communication via LocalConnection
  4. Flex E4X XML Filtering