This is a repost of an earlier post. I wanted to be more clear about the steps involved with publishing a Flash HTML 5 canvas document and uploading to a BC blog. I have been unsuccessful so far in getting element to work on my blog:
I recently published an HTML 5 canvas document in Flash but I’m not sure where to place the different parts in my BC blog. My goal is the have the HTML 5 file display on the right side of my blog, similar to an advertisement. I tried several approaches but nothing has worked. I'm not concerned about the code itself because it works when I test it. However, the problem arises when I distribute the different parts.
There are 5 steps I took that involved: the javascript file, the images, the javascript code links, javascript code related to the file, and the canvas element.
Here are the parts and steps I took:
1) Myfile.js
*I put this file in the root folder
2) Images
*I put the images related to the file in this folder.
3) Javascript code links
*I put this code in the <head> tag of the blog template.
<script src="http://code.createjs.com/easeljs-0.7.1.min.js"></script>
<script src="http://code.createjs.com/tweenjs-0.5.1.min.js"></script>
<script src="http://code.createjs.com/movieclip-0.7.1.min.js"></script>
<script src="http://code.createjs.com/preloadjs-0.4.1.min.js"></script>
<script src="sideTop.js"></script>
4) Javascript
*I put this in the head of the blog template file.
<script>
var canvas, stage, exportRoot;
function init() {
canvas = document.getElementById("canvas");
images = images||{};
var loader = new createjs.LoadQueue(false);
loader.addEventListener("fileload", handleFileLoad);
loader.addEventListener("complete", handleComplete);
loader.loadManifest(lib.properties.manifest);
}
function handleFileLoad(evt) {
if (evt.item.type == "image") { images[evt.item.id] = evt.result; }
}
function handleComplete() {
exportRoot = new lib.sideTop();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
stage.update();
createjs.Ticker.setFPS(lib.properties.fps);
createjs.Ticker.addEventListener("tick", stage);
}
</script>
5) Canvas Element
* I change the <body> tag to a <div> tag and put it on the Overall Blog Elements template.
<div onload="init();" style="background-color:#D4D4D4">
<canvas id="canvas" width="231" height="231" style="background-color:#FFFFFF"></canvas>
</div>