Skip to main content

Can't use arrays in Timelines?

2 replies [Last post]
Joined: 2006-10-16

I'm taking a look at the Timeline animation example in the FX Script documentation here:

But, I noticed that if I simply change the size variable in this example from:

var size = 1.0;


var size = [1.0];

And, then access the size value by using "size[0]" within the Timeline block... it won't compile. Why is it that simply using an array index within the Timeline gives a compile error that prints:

"Sorry, I was trying to understand a key value literal expression but I got confused when I saw '[' which is an operator. Perhaps you are missing a 'SUCHTHAT'.
size[0] => 1.0;"

Are array indexes not allowed in Timelines?

Full app below:

import javafx.ext.swing.*;
import javafx.animation.*;
import javafx.scene.*;
import javafx.input.*;
import javafx.scene.*;
import javafx.scene.effect.*;
import javafx.scene.text.*;
import javafx.scene.transform.*;
import javafx.scene.image.*;
import javafx.scene.geometry.*;
import javafx.scene.paint.*;
import javafx.application.*;
import javafx.lang.*;
import java.lang.*;

Frame {
title: "Animation Demo";
width: 500
height: 400
visible: true
stage: Stage {
content: Rectangle {

x: 150
y: 150
// Declare variables
var rotation = 0.0;
var size = [1.0];
var color = Color.GREEN;

// Initialize attributes
cursor: Cursor.HAND
height: 50
width: 50
fill: bind color
transform: bind [

// Transform.rotate(rotation,25,25)

// Create animation timeline
var myTimeline = Timeline {

toggle: true

// Key Frames
var begin = at (0s) {
size[0] => 1.0;
color => Color.GREEN;
rotation => 0.0;

var mid = at (0.5s) {
color => Color.PURPLE tween Interpolator.EASEBOTH;

var end = at (1s) {
size[0] => 3.0 tween Interpolator.LINEAR;
color => Color.RED tween Interpolator.EASEBOTH;
rotation => 360.0 tween Interpolator.EASEBOTH;

keyFrames: [begin,mid,end]

onMouseClicked: function(e) {

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-10-16
Joined: 2007-07-12

Please, create a JIRA issue on it:!default.jspa