Skip to content

2. Getting started

Gary Criblez edited this page Jun 26, 2020 · 4 revisions

How to start

Installation

AJUI_Animate must be installed in the Components folder of your 4D project with a second component AJ_Math providing additional Mathematical functions.

How to create an animation

The purpose of this animation example is to make a 4D form object (rectangle) Bounce from is current position.

Let's start by creating a form in which we are going to add a 4D rectangle interface object and a simple button.

You will then define the animation effect.

In the object method of the Form Button we will write the following code:

C_OBJECT($animation)
$animation:=New Animation
$animation.target:="Rectangle"
$animation.bounce()

The New Animation method will return a 4D object variable containing all the available member functions :

C_OBJECT($animation)
$animation:= New Animation

In this object, you will be able to edit several properties that will depend on the type of effect used.

Now it is time to define the form object that will be the object to animate. In this case it will be the "Rectangle" object:

$animation.target:="Rectangle"

And finally we will use the member function "bounce" which will define the animation to be performed:

$animation.bounce()

Now we launch the execution of our Form :

Miracle, this is your first animation!

We are now going to launch two animations simultaneously. To do this I will add a second rectangle : "Rectangle1".

In the object method of the Button of the form we add the following code:

C_OBJECT($animation)
$animation:=New Animation
$animation.target:="Rectangle"

C_OBJECT($animation2)
$animation2:=New Animation
$animation2.target:="Rectangle1"

$animation.bounceIn()
$animation2.bounceIn()

Now we're going to launch the execution of our Form.

By clicking on the button, you will be able to see the two rectangles simultaneously animate!

AJUI_Animate class

Since V18R3, you can replace the returned instance by New Animation with the call of the Animation class. The functions of the Animation class use the same names and parameters as for the formulas obtainable by New Animation. The default values are also the same.

The only difference in terms of code is when the instance is created:

  //with formulas
    $myAnim:=new Animation ()

  //with class
    $myAnim:= AJUI_Animate.new ()