Chris-NTA
Chris-NTA

Reputation: 114

JavaFX onclick Transition

I'm trying to invoke a transition by clicking on one of the two buttons. It is actually working however, i can only call the transition once for some reasons. There is a rectangle I would like to move from A to B, B to A and again from A to B.

function button2Action(): Void {
    oo.play();
}

function testani1(): Void {
    ooo.play();
}     

var oo = TranslateTransition {
     duration: 1s
     node: rectangle3
     fromY: 0
     toY: 70
}

var ooo = TranslateTransition {
    duration: 1s
    node: rectangle3
    fromY: 70
    toY: 0
}

Upvotes: 1

Views: 487

Answers (2)

Honza
Honza

Reputation: 4409

you should use ooo.playFromStart(); after the first playback the transition "play-head" is at the end and you have to "rewind" it for subsequent playbacks.

Upvotes: 1

Chris-NTA
Chris-NTA

Reputation: 114

I have found the problem and answer my question. I have put the transitions inside the function and it's working now.

Upvotes: 0

Related Questions