Archive for the ‘Flex’ Category

Flex custom preloader not working

Lately,

I encountered a problem involving flex custom preloaders.

The context I was using was as follows:
- I created a preloader.swf in flash with a 100 frames to show a progressbar evolution.
- I embedded that preloader.swf in my flex app. Read more about this here

This all worked fine when I ran my application locally.
However, the problem showed itself when deploying my app to my webserver (thus no longer running it locally).
The unintended behavior was that the preloader would not show up until my app was nearly fully loaded, and it then popped up for about a second @ 100% full.

I tried all sorts of different approaches.
- Extending mx.preloaders.DownloadProgressBar
- Creating a new MovieClip that implemented IPreloaderDisplay. More about this here
- Creating a loader .swf that contained the preloader, and loading in my app from there
- Using Charles to monitor request and responses

However none of these solutions seemed to work.

After searching a long time for what the fudge could be causing this problem, I stumbled upon the following blog posts:
http://patrickmcd.com/2009/04/20/flash-preloading-errors-turn-off-gzip/
http://www.flash-db.com/Board/index.php?topic=19252.0

As it turns out, the problem isn’t caused by Flash Player or by Flex. It is caused by your server setup.
If you have gzip compression enabled on your server (for speeding up requests and responses), the problem occurs.
What the gzip compression does is compress your already compressed binary .swf file, thus screwing up the loading procedure from an actionscript point of view.
Actually gzip compression doesn’t enhance performance in any way because a .swf is as compressed as it can be.
This also counts for numerous other already compressed files that can’t be compressed any further (.jpg,.gif,.flv,.png,..)

So the solution is rather simple. You can just add a .htaccess file to the root of your public directory to ensure that .swf files (and any other already compressed files) will no longer be compressed.
All that has to be in this file is the following:

1
2
3
# Don't compress images/flash
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|swf|flv)$ no-gzip dont-vary

Et voila, you have disabled the gzip compression and fixed your preloader bug because it’s working now.

This really was a pain in the *ss for me, as I spent 2 days looking for a solution.
I hope this post can save you the trouble I went through :)

Tags: , , , ,

3 Comments


Flex cumulative Arraycollection.filterfunction

Earlier today I was working on some app @ boulevart

I had a datagrid containing a set of data, which i needed to be able to filter given various parameters.
I quickly found out that i could use the standard Arraycollection.filterfunction on the dataprovider to do so easily…
At least I thought :)

When applying only one filter on the dataprovider, this worked like a charm
It soon became clear that when you want to apply multiple filters at the same time, the whole dataprovider was passed to the second filter function instead of the already filtered dataprovider. With this, undoing the first filter and showing only the filter results of the last used filter.

I made my own “workaround” which involved some redundant and crappy coding :)
So the next step was some basic googling. It didn’t take long to find a solution by Cristian Rotundu. It can be found here

I like this solution because it enables flexibility by simply extending the standard flex Arraycollection and adding the functionality we need.
So it’s rather brilliant in its simplicity.

Two thumbs up for Cristian!

Tags: , , ,

1 Comment



SetPageWidth