I am trying to preload a set of SVG objects and display them using CreateJS/PreloadJS. So far I was able to display a SVG object without preloading, but as soon as I use the LoadQueue from PreloadJS, I can't get my sample to work.
Does somebody know what I am doing wrong here? Thanks!
http://jsfiddle.net/trudeo/05eqqp49/
Javascript
var imageManifest = [
{ id: "MySvgImage", src: "http://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg" }
];
var stage = new createjs.Stage(document.getElementById('gameCanvas'));
var assetQueue = new createjs.LoadQueue(true);
assetQueue.loadManifest(imageManifest);
assetQueue.on('complete', complete);
function complete(e) {
// DOESN'T WORK
var svgImage = new createjs.Bitmap(assetQueue.getResult('MySvgImage'));
stage.addChild(svgImage);
// WORKS
var svgImage2 = new createjs.Bitmap("http://dev.w3.org/SVG/tools/svgweb/samples/svg-files/circles1.svg");
stage.addChild(svgImage2);
stage.update();
createjs.Ticker.setFPS(40);
createjs.Ticker.addListener(tick);
}
function tick() {
stage.update();
}
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<script src="http://code.createjs.com/createjs-2013.12.12.min.js"></script>
<script src="http://code.createjs.com/preloadjs-0.4.1.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<canvas id="gameCanvas" width="800" height="800"></canvas>
</body>
</html>