Java Reference
In-Depth Information
anim.play();
}
Listing 8-9 shows a Rectangle with its fill value bound to the function createRadialGradient ,
which takes a Sequence of Stops . The first stop is defined by the function createStop from Listing 8-6. In
turn, createStop is taking a Color defined by the function createColor , which is defined in Listing 8-7.
The interesting thing here is the function createRadialGradient shown in Listing 8-10.
Listing 8-10. createRadialGradient
public function createRadialGradient(centerX:Number, centerY:Number,
stops:Stop[]):RadialGradient{
return RadialGradient{
centerX: centerX
centerY: centerY
stops: sortStops(stops)
}
}
Listing 8-10 shows the function createRadialGradient , which takes the location of the center as the
two arguments centerX and centerY . The last argument is a sequence of Stops called stops that are
sorted before being used to create a new RadialGradient .
Multi-Colored Linear
Up to this point only the red portion of a single Color was being changed to create the animations. The
following example fleshes out how colors can be animated by using several different values animated by
a more complex Timeline . There is little reason to show a screenshot, as it would require many, many
shots to show all the different combinations this example creates. But you can run the source code in
Listing 8-11 to view this and the other animations.
Listing 8-11. mutlipleColorsLinear
function mutlipleColorsLinear():Void{
delete group.content;
var red1 = 0.0;
var green1 = 0.0;
var blue1 = 0.0;
var red2 = 0.0;
var green2 = 0.0;
var blue2 = 0.0;
var rect = Rectangle{
translateX: 640/2-350/2;
translateY: 480/2-50
width: 350
height: 50
Search WWH ::




Custom Search