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.qml24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml
new file mode 100644
index 0000000..796a370
--- /dev/null
+++ b/examples/declarative/dynamic/qml/Sun.qml
@@ -0,0 +1,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
+ y: NumberAnimation {
+ to: parent.height;
+ duration: 10000;
+ running: created
+ }
+
+ states: State {
+ name: "OffScreen"; when: created && y > window.height / 2;//Below the ground
+ StateChangeScript { script: { sun.created = false; sun.destroy() } }
+ }
+}