Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTML
- -------------------------------------------------------------------------------------------------------
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>speedtest</title>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" ></script>
- <script src="https://code.createjs.com/createjs-2015.05.21.min.js"></script>
- <script src="https://code.createjs.com/movieclip-0.8.1.min.js"></script>
- <script src="speedtest.js"></script>
- <script>
- var canvas, stage, exportRoot;
- function init() {
- canvas = document.getElementById("canvas");
- images = images||{};
- ss = ss||{};
- var loader = new createjs.LoadQueue(false);
- loader.addEventListener("fileload", handleFileLoad);
- loader.addEventListener("complete", handleComplete);
- loader.loadFile({src:"images/speedtest_atlas_.json", type:"spritesheet", id:"speedtest_atlas_"}, true);
- loader.loadManifest(lib.properties.manifest);
- }
- function handleFileLoad(evt) {
- if (evt.item.type == "image") { images[evt.item.id] = evt.result; }
- }
- function handleComplete(evt) {
- var queue = evt.target;
- ss["speedtest_atlas_"] = queue.getResult("speedtest_atlas_");
- exportRoot = new lib.speedtest();
- stage = new createjs.Stage(canvas);
- stage.addChild(exportRoot);
- stage.update();
- createjs.Ticker.setFPS(lib.properties.fps);
- createjs.Ticker.addEventListener("tick", stage);
- }
- </script>
- </head>
- <body onload="init();" style="background-color:#D4D4D4">
- <canvas id="canvas" width="900" height="600" style="background-color:#FFFFFF"></canvas>
- </body>
- </html>
- speedtest.js
- -------------------------------------------------------------------------------------------------------
- (function (lib, img, cjs, ss) {
- var p; // shortcut to reference prototypes
- // library properties:
- lib.properties = {
- width: 550,
- height: 400,
- fps: 24,
- color: "#FFFFFF",
- manifest: []
- };
- // symbols:
- // stage content:
- (lib.speedtest = function(mode,startPosition,loop) {
- this.initialize(mode,startPosition,loop,{});
- // timeline functions:
- this.frame_0 = function() {
- mytext = new createjs.Text("Lorem ipsum dolor sit amet 2","19px Calibri","#073949");
- mytext.x = 450
- mytext.y = 300;
- stage.addChild(mytext);
- resize = function() {
- var canvas = document.getElementById('canvas');
- var canvasRatio = canvas.height / canvas.width;
- var windowRatio = window.innerHeight / window.innerWidth;
- var width;
- var height;
- if (windowRatio < canvasRatio) {
- height = window.innerHeight - 35;
- width = height / canvasRatio;
- } else {
- width = window.innerWidth;
- height = width * canvasRatio;
- }
- canvas.style.width = width + 'px';
- canvas.style.height = height + 'px';
- }()
- }
- // actions tween:
- this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1));
- }).prototype = p = new cjs.MovieClip();
- p.nominalBounds = null;
- })(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{});
- var lib, images, createjs, ss;
Advertisement
Add Comment
Please, Sign In to add comment