Howto import SWF files in Flex and avoid lag problems

Howto import SWF files in Flex and avoid lag problems

Howto import SWF files in Flex and avoid lag problems

Lately I was working on a flex application where integration of a remote SWF file was required. I noticed that the imported SWF file inside Flex had some lagging problems … So I tried different methods to load the SWF, and came to the conclusion that only one way fits my needs. By using the SWFLoader which is introduced  in the latest release
of flash builder you avoid anoying problems. Such as lag between both SWF movies (Parent FLEX and child Flash in my case).
The lag problems occured when trying to use TweenLite effects as animation between states etc.
Below I will show you guys how to avoid these problems whithout getting headache and shivers.

First you need to initliaze the SWFLoader component:

<mx:SWFLoader source="movie.swf"  width="100%" height="100%"
id="gamec" loadForCompatibility="true"  complete="gamec_completeHandler(event)" scaleContent="true" autoLoad="true"/>

As you can see the required paramters are only source. Beside this you can also set alot of options, whether or not the movie should
load automatically etc. But if you look closer you also see this parameter loadForCompatibility which is set to true.
THIS is the key to solve the lag issue! When you set this parameter to true you will have less lag between both flex and flash movies.

I hope I saved you some headaches with this little article.

If you have any questions, do not hesitate to post a comment.


About the Author

Lode is a Creative-Geek with passion for webdesign, SEO and everything related to online marketing. In January 2014, he has started his own company Magnefk, which specialises in online marketing and website optimization.