summaryrefslogtreecommitdiffstats
path: root/examples/declarative/dynamic/qml/Sun.qml
blob: 81b6e9b9e17931f0be311af115c25f9b2f5224f7 (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.6

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() } }
    }
}