Animation 停止非根动画节点中的动画

Animation 停止非根动画节点中的动画,animation,qml,Animation,Qml,我想停止这样的动画: x上的行为{ 数字化{ id:animationElement 持续时间:100 } } ... 如果(某物) { animationElement.stop() } 但这段代码给了我一个错误,stop()不能在非根动画节点上使用。 它可能会停止来自外部的动画?这对我来说很好: import QtQuick 1.0 Rectangle { color: "grey" width: 800 height: 800 NumberAnima

我想停止这样的动画:

x上的行为{ 数字化{ id:animationElement 持续时间:100 } } ... 如果(某物) { animationElement.stop() } 但这段代码给了我一个错误,stop()不能在非根动画节点上使用。
它可能会停止来自外部的动画?

这对我来说很好:

import QtQuick 1.0

Rectangle
{
    color: "grey"
    width:  800
    height: 800

    NumberAnimation on width { id: animationElementw ;  from: 800; to: 500; duration: 8500 }
    NumberAnimation on height { id: animationElementH ;  from: 800; to: 500; duration: 8500 }

    MouseArea
    {
      anchors.fill: parent
      onClicked:
      {
          animationElementw.stop()
          animationElementH.stop()
      }
    }

    Text
    {
        id: name
        anchors.centerIn: parent
        text: "Click me to stop shrinking animation!!!"
        color: "white"
        font.pixelSize: 25
    }
}