Über Key setzt du Werte in Keys auf einen Zeitstrahl von 0.0 (Start) bis 1.0 (Ende). Duration gibt die gesamte Länge der Animation an. Hier ein Beispiel. Ich habe das mal in FormCreate gepackt und das TRectangle dynamisch erstellt, so dass es einfach so gehen sollte:
Delphi-Quellcode:
uses
FMX.Ani, FMX.Objects;
procedure TForm286.FormCreate(Sender: TObject);
var
Rectangle: TRectangle;
ColorKeyAnimation1: TColorKeyAnimation;
ColorKey1, ColorKey2, ColorKey3, ColorKey4: TColorKey;
begin
Rectangle := TRectangle.Create(Self);
Rectangle.Parent := Self;
Rectangle.Width := 200;
Rectangle.Height := 100;
Rectangle.Position.X := 100;
Rectangle.Position.Y := 100;
Rectangle.Fill.Color := TAlphaColorRec.Red;
ColorKeyAnimation1 := TColorKeyAnimation.Create(Self);
ColorKeyAnimation1.Parent := Rectangle;
ColorKeyAnimation1.PropertyName := 'Fill.Color';
ColorKeyAnimation1.Duration := 3.0;
ColorKeyAnimation1.Loop := True;
ColorKey1 := ColorKeyAnimation1.Keys.Add as TColorKey;
ColorKey1.Key := 0.0;
ColorKey1.Value := TAlphaColorRec.Red;
ColorKey2 := ColorKeyAnimation1.Keys.Add as TColorKey;
ColorKey2.Key := 0.33;
ColorKey2.Value := TAlphaColorRec.Green;
ColorKey3 := ColorKeyAnimation1.Keys.Add as TColorKey;
ColorKey3.Key := 0.67;
ColorKey3.Value := TAlphaColorRec.Blue;
ColorKey4 := ColorKeyAnimation1.Keys.Add as TColorKey;
ColorKey4.Key := 1.0;
ColorKey4.Value := TAlphaColorRec.Red;
ColorKeyAnimation1.Start;
end;