FMXTFmxObjectAnimateFloat (Object Pascal)
This example shows how to call the FMX.Types.TFmxObject method FMX.Types.AnimateFloat. Note that once called, you do not have access to the FMX.Ani.TFloatAnimation instance that FMX.Types.AnimateFloat creates.
The FMX.Ani.TFloatAnimation instance has the Rectangle1 as its parent, therefore it is cleaned up when Rectangle1 is deleted.
Note that that the APropertyName parameter has to be a string that is a numerical property of Rectangle1, the class instance.
To replicate this example, use the Object Inspector to change the name of the buttons to TurnTranslucent and TurnOpaque. Create the event handlers for the FMX.Types.OnClick event of the buttons and copy the code below.
The form should look like the following image:
After pressing the TurnTranslucent button, the color of the rectangle starts to fade like in the following image, until the rectangle becomes transparent. Pressing TurnOpaque turns the rectangle's color to the original state.
//Delphi procedure TForm3.TurnOpaqueClick(Sender: TObject); begin Rectangle1.AnimateFloat('Opacity', 1.0, 5, TAnimationType.InOut, TInterpolationType.Linear); end; procedure TForm3.TurnTranslucentClick(Sender: TObject); begin Rectangle1.AnimateFloat('Opacity', 0, 5, TAnimationType.InOut, TInterpolationType.Linear); end;