Skip to content

Commit

Permalink
Added support for passing a canvas id to the Stage constructor.
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Skinner <info@gskinner.com>
  • Loading branch information
gskinner committed Dec 16, 2011
1 parent 676bbff commit 2d17846
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions examples/icons.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,20 @@
<!-- End EaselJS Imports -->

<script>
var canvas;
var stage;

var iconSheet = new Image();

function init() {
//find canvas and load images, wait for last image to load
canvas = document.getElementById("testCanvas");
iconSheet.onload = handleImageLoad;
iconSheet.src = "img/icons.png";
}

function handleImageLoad() {
// create a new stage and point it at our canvas:
stage = new Stage(canvas);
// note that we can just pass the id of the canvas:
stage = new Stage("testCanvas");

/*** FIRST: the "simple" approach ***/
// create a simple SpriteSheet using iconSheet with a frame size of 80x80:
Expand Down
4 changes: 2 additions & 2 deletions src/easeljs/display/Stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ var p = Stage.prototype = new Container();
/**
* Initialization method.
* @method initialize
* param {HTMLCanvasElement} canvas
* param {HTMLCanvasElement} canvas A canvas object, or the string id of a canvas object in the current document.
* @protected
**/
p.initialize = function(canvas) {
this.Container_initialize();
this.canvas = canvas;
this.canvas = (canvas instanceof HTMLCanvasElement) ? canvas : document.getElementById(canvas);
this._enableMouseEvents(true);
}

Expand Down

0 comments on commit 2d17846

Please sign in to comment.