FMXTFmxObjectAnimateFloat (C++)
Contents
Description
This example shows how to call the FMX.Types.TFmxObject method AnimateFloat. Note that, once called, you do not have access to the FMX.Ani.TFloatAnimation instance that FMX.Types.AnimateFloat creates.
This example requires a Multi-Device Application with a FMX.Objects.TRectangle and two FMX.StdCtrls.TButton objects in the FMX.Forms.TForm. FMX.Ani.TFloatAnimation is created dynamically.
The FMX.Ani.TFloatAnimation instance has the Rectangle1 as its parent, therefore it is cleaned up when Rectangle1 is deleted.
Note 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 color of the rectangle to the original state.
Code
//C++
void __fastcall TForm2::TurnTranslucentClick(TObject *Sender) {
Rectangle1->AnimateFloat("Opacity", 0, 5, TAnimationType::InOut,
TInterpolationType::Linear);
}
// ---------------------------------------------------------------------------
void __fastcall TForm2::TurnOpaqueClick(TObject *Sender) {
Rectangle1->AnimateFloat("Opacity", 1.0, 5, TAnimationType::InOut,
TInterpolationType::Linear);
}
// ---------------------------------------------------------------------------
Uses
- FMX.Types.TFmxObject.AnimateFloat ( fr | de | ja )
- FMX.Ani.TFloatAnimation ( fr | de | ja )
- FMX.Controls.TControl.Opacity ( fr | de | ja )
- FMX.Types.TAnimationType ( fr | de | ja )
- FMX.Types.TInterpolationType ( fr | de | ja )
See Also
- FMXAttachTAnimation (Delphi)
- FMXTFmxObjectAnimateColor (Delphi)
- FireMonkey
- Delphi version of this example
Samples
- FireMonkey First App3D sample
- FireMonkey GUI3d sample
- FireMonkey Planets sample
- FireMonkey HD Animation sample
- FireMonkey 3D Animation sample
- FireMonkey Cameras Textures 3D sample