<< Chapter < Page | Chapter >> Page > |
Two GradientEntry elements
Referring back to Listing 4, we see that the two inner-most elements are two elements named GradientEntry .
We can now update the list of things that we have accomplished to read as follows:
The rotation attribute of the LinearGradient object
Before getting into the attributes of the GradientEntry objects, let's go back and take a look at the rotation attribute of the LinearGradient object.
According to the documentation :
The LinearGradient class lets you specify the fill of a graphical element, where a gradient specifies a gradual color transition in the fillcolor. You add a series of GradientEntry objects to the LinearGradient object's entries Array to define the colors that make up the gradient fill.
By default, the color transition is from left to right. However, by specifying a rotation value in degrees for the rotation property, you can cause the color transition to take place along an invisibleline that is rotated by that amount relative to the horizontal.
Setting the rotation attribute to 90 degrees in Listing 4 causes the invisible line to be vertical and causes the color transition to take place from the top to thebottom of the Flash window as shown in Figure 3.
The color attributes of the GradientEntry elements
According to the documentation , GradientEntry is a class in the mx.graphics package. (Note that the name begins with an upper-case character.) A GradientEntry element can define several attributes, including color , ratio , and alpha . Let's begin by taking a look at the color attribute.
The color attributes of the GradientEntry elements
The array of GradientEntry objects assigned to the entries property of the LinearGradient object can contain a large number of objects. Each object has a color property, which is black by default.
The color transition produced by the LinearGradient object will begin with the color property of the first object in the array, transitionthrough the colors specified by each successive object, and end up at the color specified by the last object in the array.
Only two colors for this case
The code in Listing 4 places only two GradientEntry objects in the array. The color property for the first one is pure green and the color property for the secondone is pure blue. That means that the color will transition from pure green at the top of the Flash window to pure blue at the bottom of the Flash window asshown by the bottom right image in Figure 3.
The alpha attributes of the GradientEntry elements
The alpha attributes shouldn't require much of an explanation. They mean essentially the same thing that the backgroundAlpha attribute means in Listing 2. The difference is that in Listing 2, the same alpha value is applied to both colors involved inthe color transition while in Listing 4, each color involved in the transition has its own alpha value.
Notification Switch
Would you like to follow the 'Introduction to xml' conversation and receive update notifications?