Index: sky/examples/raw/spinning_image.dart |
diff --git a/sky/examples/raw/spinning_image.dart b/sky/examples/raw/spinning_image.dart |
index 53fe140460f3b4dbc19e556d937e50c582b77596..cd5339fbf01ec43a35833825545b3c26a6aea665 100644 |
--- a/sky/examples/raw/spinning_image.dart |
+++ b/sky/examples/raw/spinning_image.dart |
@@ -6,7 +6,7 @@ import 'dart:sky'; |
double timeBase = null; |
-Image image; |
+Image image = null; |
void beginFrame(double timeStamp) { |
if (timeBase == null) timeBase = timeStamp; |
@@ -16,14 +16,21 @@ void beginFrame(double timeStamp) { |
canvas.rotateDegrees(delta / 10); |
canvas.scale(0.2, 0.2); |
Paint paint = new Paint()..setARGB(255, 0, 255, 0); |
- canvas.drawImage(image, -image.width / 2.0, -image.height / 2.0, paint); |
+ if (image != null) |
+ canvas.drawImage(image, -image.width / 2.0, -image.height / 2.0, paint); |
view.picture = canvas.endRecording(); |
view.scheduleFrame(); |
} |
void main() { |
- image = new Image(); |
- image.src = "https://www.dartlang.org/logos/dart-logo.png"; |
+ new ImageLoader("https://www.dartlang.org/logos/dart-logo.png", (result) { |
+ if (result != null) { |
+ print("${result.width}x${result.width} image loaded!"); |
+ image = result; |
+ view.scheduleFrame(); |
+ } else { |
+ print("Image failed to load"); |
+ } |
+ }).load(); |
view.setBeginFrameCallback(beginFrame); |
- view.scheduleFrame(); |
} |