summaryrefslogtreecommitdiffstats
path: root/examples/declarative/dynamic/qml/Sun.qml
blob: 362796402a925d16693185fb4fc6c1d1f390eee6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import Qt 4.7

Image {
    id: sun
    property bool created: false
    property string image: "../images/sun.png"
    onCreatedChanged: if(created){window.activeSuns++;}else{window.activeSuns--;}

    source: image; 
    z: 1

    //x and y get set when instantiated
    //head offscreen
    NumberAnimation on y {
        to: window.height / 2;
        running: created
        onRunningChanged: if (running) duration = (window.height - sun.y) * 10; else state = "OffScreen";
    }

    states: State {
        name: "OffScreen";
        StateChangeScript { script: { sun.created = false; sun.destroy() } }
    }
}