This BackgroundManager class started out as a feature of my MediaGallery but it only supported images and solid colors, with no way of changing them after they’d been set. This got me thinking about building a BackgroundManager, and here it is.
It allows you to setup a background structure via xml. It supports the following background types:
- Solid Colors
- Complex Gradients
- Tiles (repeating) Images
- Static (non-repeating) Images – stretched or not, proportionate or not, centered
It allows you to set the master alpha (regardless of alpha values in, say, a gradient) for each item, you can add blend modes and filters also.
It has a few methods to modify the backgrounds also. You can add a new background anywhere in the list, change a certain background with another of the same type, remove a specific background, and remove all backgrounds. Each of these methods allow you to animate the transition with an alpha fade, and you can specify the duration.
In my example, I’ve setup a button to add a new solid color to the top of the list with the blend mode set to “multiply”. I setup another to remove the gradient that’s there. That gradient has the blend mode “add” enabled. Another button to change the image from coins to crayons, and finally a button to reset everything.
I had a lot of fun experimenting with all the different layers and combinations.
The class was written in AS3 , and if anyone needs any help, I’m glad to assist. Thank you, and enjoy!