Home Email Message Boards Help
  What are particles? Buy ElementalFX ElementalFX Settings ElementalFX Tutorials Other Stuff
What are gradient selectors?
Gradient selectors are a pair of components I came up with because I needed an easy way for users to assign an array of color or alpha values to a particle for changing settings over the life of a particle. Now, I can't claim the idea, Discreet Combustion has been doing it this way for years, as has several other excellent particle systems. Someone figured out that the best way to set up smooth changes in alpha or color settings for a particle would be to use a black-to-white gradient, where white is fully opaque and black is fully transparent, because you can visually see incremental changes in value. At any rate, I thought it was a great way to set both the opacity over life and the size over life for my particle system, but I needed a component to build a gradient for this purpose, so I wrote one. You can get both the component and the source code below. It's ugly and messy, but it works.
Sample Movie
These are Flash MX 2004 Components only
Gradient Selector
SWC File Only (13k)
Complete Source & SWC File (39k)
Luminosity Selector
SWC File Only (13k)
Complete Source & SWC File (53k)

I'm not sure why the source for the luminosity selector is so much bigger
I might have included some unnecessary files

How do they work?

These were written quickly so they are sloppy and only do what I needed them to do, but I intend to add a bunch of output formats and suff. The setup is the same as most components: drag it on the stage, give it a name, and assign a change handler function. That's it. The change handler hasn't been standardized to MM nomenclature yet, so assigning the change handler goes like this:

ComponentName.ChangeHandler = function(CallbackObject){
     trace(CallbackObject.Data);
}
The callback object currently only carries the one format, but as I figure out what formats would be useful I'll add them to the object. The current output format is as an array of strings. The strings consist of the following data, seperated by a semi-colon:
percent (0-100) of duration/width : color (hex)/alpha (0-100) value
This was a useful format for my purpose, but it's not exactly useful for much else. So, as people tell me what kind of formats they want, I'll start adding them to the components' output object. I'm thinking the format will be something like:
CallbackObject.Data - array with current format
CallbackObject.Colors - array of hex values (0-F, i.e. 00FF00)
CallbackObject.Ratios - array of integer values (0-255)
CallbackObject.Alphas - array of percent values (0-100)
etc...
With output like that you could use it to draw a gradient fill or something, and if there are other standard formats for describing a gradient, I could implement those as well.
Anyway, do whatever you want with this. If you find it useful, give me feedback and let me know how you want me to improve it. Email me at the support link below.
©2003 HorseFish Productions