---
title: "AnimationBox (Generic)"
canonical: "https://docs.cuesystem.com/space/CVCGC/417234956/AnimationBox%20(Generic)"
format: markdown
---
> Macro (toc)

---

# Description

This object allows to play animation stored in project resources. Animation is set of pictures (frames) which can played with defined FrameRate (number of pictures displayed per second). First displayed frame is defined by property FrameNumber. Function Play(True) starts playing, Play(False) stops playing. Repeat mode on/off can be set by property Repeat.

![image](media://4bb3766b-7d90-4303-9896-4d9810c684e5)

# Properties

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| Property Name | Data Type | Allowed Values | Default Value | Description |
| Behavior |
| Events | Boolean | True False | False | If True event OnTouch is enabled. If False event OnTouch is disabled. |
| FrameNumber | Long | >= 1<br><= Animation frame count | 1 | It is start frame (index of frame in animation). |
| FrameRate | Double | Any | -1 | Number of frames that are displayed per second. If FrameRate < 0 then “Frame per second” defined in resources is used. |
| Play | Boolean | True False | True | If True animation plays. If False animation stops playing. |
| Repeat | Boolean | True False | True | If True animation plays in repeat mode while Play = True. |
| Appearance |
| Animation | AddressOf _Animation | Any | Nothing | Animation placed to object |
| Fitting | Long | 0 = None  
1 = Fit Object to Content   
2 = Fit Content to Object   
3 = Center Content  
4 = Fit Content Proportionally  
5 = Fill Object Proportionally | 0 | Method of picture fitting |

# Functions

## SetAnimation

This function sets Animation to newanimation. Function returns True.

#### Syntax

```visualbasic
Function SetAnimation(newanimation As AddressOf _Animation) As Boolean
```

## GetAnimation

This function returns address of current Animation.

#### Syntax

```visualbasic
Function GetAnimation() As AddressOf _Animation
```

## GetDefaultFrameRate

This function returns DefaultFrameRate.

#### Syntax

```visualbasic
Function GetDefaultFrameRate() As Double
```

## SetEvents

This function enables (newevents = True) or disables (newevents = False) event OnTouch. Function returns True.

#### Syntax

```visualbasic
Function SetEvents(newevents As Boolean) As Boolean
```

## GetEvents

This function returns True (event OnTouch enabled) or False (event OnTouch disabled).

#### Syntax

```visualbasic
Function GetEvents() As Boolean
```

## SetFitting

This function sets Fitting of Animation to newfitting. You can use the following predefined constants for fitting

- FITTING_NONE
- FITTING_FIT_OBJECT_TO_CONTENT
- FITTING_FIT_CONTENT_TO_OBJECT
- FITTING_CENTER_CONTENT
- FITTING_FIT_CONTENT_PROPORTIONALLY
- FITTING_FILL_OBJECT_PROPORTIONALLY

For example, if instance of AnimationBox is named AnimationBox1, you can use as parameter AnimationBox1.FITTING_FIT_CONTENT_PROPORTIONALLY to fit content proportionally.

Function returns True on success or False if an error occurs (parameter has wrong value).

#### Syntax

```visualbasic
Function SetFitting(newfitting As Long) As Boolean
```

## GetFitting

This function returns current Fitting of Animation.

#### Syntax

```visualbasic
Function GetFitting() As Long
```

## SetFrameNumber

This function sets FrameNumber to newframenumber. Function returns True if newframenumber >= 1 and newframenumber <= FrameCount (number of frames in animation), otherwise it returns False.

#### Syntax

```visualbasic
Function SetFrameNumber(newframenumber As Long) As Boolean
```

## GetFrameNumber

This function returns current FrameNumber.

#### Syntax

```visualbasic
Function GetFrameNumber() As Long
```

## SetFrameRate

This function sets FrameRate to newframerate. Function returns True.

#### Syntax

```visualbasic
Function SetFrameRate(newframerate As Double) As Boolean
```

## GetFrameRate

This function returns current FrameRate.

#### Syntax

```visualbasic
Function GetFrameRate() As Double
```

## SetPlay

This function starts (newplay = True) or stops (newplay = False) animation playing. Function returns True.

#### Syntax

```visualbasic
Function SetPlay(newplay As Boolean) As Boolean
```

## GetPlay

Function returns True if animation is playing, otherwise it returns False.

#### Syntax

```visualbasic
Function GetPlay() As Boolean
```

## SetRepeat

This function sets playing repeat mode on (newrepeat = True) or off (newrepeat = False). Function returns True.

#### Syntax

```visualbasic
Function SetRepeat(newrepeat As Boolean) As Boolean
```

## GetRepeat

Function returns True if repeat mode is on, otherwise it returns False.

#### Syntax

```visualbasic
Function GetRepeat() As Boolean
```

## BringToFrontZOrder

This function temporarily brings the object to the very top position.

#### Syntax

```visualbasic
Function BringToFrontZOrder()
```

## RestoreZOrder

This function restores object’s z-order to value defined in design mode.

#### Syntax

```visualbasic
Function RestoreZOrder()
```

# Events

## OnTouch

This event is generated when the object is touched and property Events is set to True.

#### Syntax

```visualbasic
Event OnTouch As Process()
```