summaryrefslogtreecommitdiffstats
path: root/examples/declarative/dynamic/qml/Sun.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/dynamic/qml/Sun.qml')
-rw-r--r--examples/declarative/dynamic/qml/Sun.qml32
1 files changed, 23 insertions, 9 deletions
diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml
index 3627964..43dcb9a 100644
--- a/examples/declarative/dynamic/qml/Sun.qml
+++ b/examples/declarative/dynamic/qml/Sun.qml
@@ -2,23 +2,37 @@ 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
+ source: image
- //x and y get set when instantiated
- //head offscreen
+ // once item is created, start moving offscreen
NumberAnimation on y {
- to: window.height / 2;
+ to: window.height / 2
running: created
- onRunningChanged: if (running) duration = (window.height - sun.y) * 10; else state = "OffScreen";
+ onRunningChanged: {
+ if (running)
+ duration = (window.height - sun.y) * 10;
+ else
+ state = "OffScreen"
+ }
}
states: State {
- name: "OffScreen";
- StateChangeScript { script: { sun.created = false; sun.destroy() } }
+ name: "OffScreen"
+ StateChangeScript {
+ script: { sun.created = false; sun.destroy() }
+ }
+ }
+
+ onCreatedChanged: {
+ if (created) {
+ sun.z = 1; // above the sky but below the ground layer
+ window.activeSuns++;
+ } else {
+ window.activeSuns--;
+ }
}
}