This capx is a simple program that demonstrates fading between 5 different colored background layers each click. Demo
A good practice when naming objects or layers of a similar type is to use an indexed naming convention. This is accomplished by naming the Layers to be used as such:
We can then use a numerical variable (in this capx case 'bkgLayer') to reference the layers.
For example, if we want to reference layer "Background2", we set our variable 'bkgLayer' =2, and then can reference the layer:
layer = "Background" & bkgLayer
Once we have the variables to reference our layers, we can trigger a simultaneous fade in/out by gradually adjusting the opacity of the layers. In this capx, new layers displayed are chosen at random, and will also be different each click (the same layer will not be chosen twice in a row).
The capx should be self explanatory. Some of the functionality could be useful for testing different backgrounds in your game, and could easily be applied to other objects (such as sprites or layered menu items). Also, instead of 'random' picking, you could cycle through, or set the fade events to be triggered by specific events.
This is my first tutorial. I just wanted to consolidate a few tips I learned from the wonderful forum community here. I hope you find this useful.