/**
* EaselJS
* Visit http://easeljs.com/ for documentation, updates and examples.
*
* Copyright (c) 2011 Grant Skinner
* 
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
**/
(function(l){function b(){throw"UID cannot be instantiated";}b._nextID=0;b.get=function(){return b._nextID++};l.UID=b})(window);(function(l){function b(){throw"Ticker cannot be instantiated.";}b._listeners=[];b._pauseable=[];b._paused=false;b._inited=false;b._startTime=0;b._pausedTime=0;b._ticks=0;b._pausedTickers=0;b._interval=50;b._intervalID=null;b._lastTime=0;b._times=[];b.addListener=function(a,c){if(!b._inited){b._inited=true;b.setInterval(b._interval)}this.removeListener(a);b._pauseable[b._listeners.length]=c==null?true:c;b._listeners.push(a)};b.removeListener=function(a){if(b._listeners!=null){a=b._listeners.indexOf(a);
if(a!=-1){b._listeners.splice(a,1);b._pauseable.splice(a,1)}}};b.removeAllListeners=function(){b._listeners=[];b._pauseable=[]};b.setInterval=function(a){b._intervalID!=null&&clearInterval(b._intervalID);b._lastTime=b._getTime();b._interval=a;b._intervalID=setInterval(b._tick,a)};b.getInterval=function(){return b._interval};b.getFPS=function(){return 1E3/b._interval};b.setFPS=function(a){b.setInterval(1E3/a)};b.getMeasuredFPS=function(a){if(b._times.length<2)return-1;if(a==null)a=b.getFPS()>>1;a=
Math.min(b._times.length-1,a);return 1E3/((b._times[0]-b._times[a])/a)};b.setPaused=function(a){b._paused=a};b.getPaused=function(){return b._paused};b.getTime=function(a){return b._getTime()-b._startTime-(a?b._pausedTime:0)};b.getTicks=function(a){return b._ticks-(a?b._pausedTickers:0)};b._tick=function(){b._ticks++;var a=b.getTime(false),c=a-b._lastTime,d=b._paused;if(d){b._pausedTickers++;b._pausedTime+=c}b._lastTime=a;for(var e=b._pauseable,f=b._listeners,h=f?f.length:0,g=0;g<h;g++){var i=e[g],
j=f[g];j==null||d&&i||j.tick==null||j.tick(c)}b._times.unshift(a);b._times.length>100&&b._times.pop()};b._getTime=function(){return(new Date).getTime()};b._startTime=b._getTime();l.Ticker=b})(window);(function(l){function b(a,c,d){this.initialize(a,c,d)}b.prototype.stageX=0;b.prototype.stageY=0;b.prototype.type=null;b.prototype.onMouseMove=null;b.prototype.onMouseUp=null;b.prototype.initialize=function(a,c,d){this.type=a;this.stageX=c;this.stageY=d};b.prototype.clone=function(){return new b(this.type,this.stageX,this.stageY)};b.prototype.toString=function(){return"[MouseEvent (type="+this.type+" stageX="+this.stageX+" stageY="+this.stageY+")]"};l.MouseEvent=b})(window);(function(l){function b(a,c,d,e,f,h){this.initialize(a,c,d,e,f,h)}b.identity=null;b.DEG_TO_RAD=Math.PI/180;b.prototype.a=1;b.prototype.b=0;b.prototype.c=0;b.prototype.d=1;b.prototype.tx=0;b.prototype.ty=0;b.prototype.alpha=1;b.prototype.shadow=null;b.prototype.compositeOperation=null;b.prototype.initialize=function(a,c,d,e,f,h){if(a!=null)this.a=a;if(c!=null)this.b=c;if(d!=null)this.c=d;if(e!=null)this.d=e;if(f!=null)this.tx=f;if(h!=null)this.ty=h};b.prototype.prepend=function(a,c,d,e,f,h){var g=
this.tx;if(a!=1||c!=0||d!=0||e!=1){var i=this.a,j=this.c;this.a=i*a+this.b*d;this.b=i*c+this.b*e;this.c=j*a+this.d*d;this.d=j*c+this.d*e}this.tx=g*a+this.ty*d+f;this.ty=g*c+this.ty*e+h};b.prototype.append=function(a,c,d,e,f,h){var g=this.a,i=this.b,j=this.c,k=this.d;this.a=a*g+c*j;this.b=a*i+c*k;this.c=d*g+e*j;this.d=d*i+e*k;this.tx=f*g+h*j+this.tx;this.ty=f*i+h*k+this.ty};b.prototype.prependMatrix=function(a){this.prepend(a.a,a.b,a.c,a.d,a.tx,a.ty);this.prependProperties(a.alpha,a.shadow,a.compositeOperation)};
b.prototype.appendMatrix=function(a){this.append(a.a,a.b,a.c,a.d,a.tx,a.ty);this.appendProperties(a.alpha,a.shadow,a.compositeOperation)};b.prototype.prependTransform=function(a,c,d,e,f,h,g,i,j){if(f%360){var k=f*b.DEG_TO_RAD;f=Math.cos(k);k=Math.sin(k)}else{f=1;k=0}if(i||j){this.tx-=i;this.ty-=j}if(h||g){h*=b.DEG_TO_RAD;g*=b.DEG_TO_RAD;this.prepend(f*d,k*d,-k*e,f*e,0,0);this.prepend(Math.cos(g),Math.sin(g),-Math.sin(h),Math.cos(h),a,c)}else this.prepend(f*d,k*d,-k*e,f*e,a,c)};b.prototype.appendTransform=
function(a,c,d,e,f,h,g,i,j){if(f%360){var k=f*b.DEG_TO_RAD;f=Math.cos(k);k=Math.sin(k)}else{f=1;k=0}if(h||g){h*=b.DEG_TO_RAD;g*=b.DEG_TO_RAD;this.append(Math.cos(g),Math.sin(g),-Math.sin(h),Math.cos(h),a,c);this.append(f*d,k*d,-k*e,f*e,0,0)}else this.append(f*d,k*d,-k*e,f*e,a,c);if(i||j){this.tx-=i*this.a+j*this.c;this.ty-=i*this.b+j*this.d}};b.prototype.rotate=function(a){var c=Math.cos(a);a=Math.sin(a);var d=this.a,e=this.c,f=this.tx;this.a=d*c-this.b*a;this.b=d*a+this.b*c;this.c=e*c-this.d*a;this.d=
e*a+this.d*c;this.tx=f*c-this.ty*a;this.ty=f*a+this.ty*c};b.prototype.skew=function(a,c){a*=b.DEG_TO_RAD;c*=b.DEG_TO_RAD;this.append(Math.cos(c),Math.sin(c),-Math.sin(a),Math.cos(a),0,0)};b.prototype.scale=function(a,c){this.a*=a;this.d*=c;this.tx*=a;this.ty*=c};b.prototype.translate=function(a,c){this.tx+=a;this.ty+=c};b.prototype.identity=function(){this.alpha=this.a=this.d=1;this.b=this.c=this.tx=this.ty=0;this.shadow=this.compositeOperation=null};b.prototype.invert=function(){var a=this.a,c=this.b,
d=this.c,e=this.d,f=this.tx,h=a*e-c*d;this.a=e/h;this.b=-c/h;this.c=-d/h;this.d=a/h;this.tx=(d*this.ty-e*f)/h;this.ty=-(a*this.ty-c*f)/h};b.prototype.decompose=function(a){if(a==null)a={};a.x=this.tx;a.y=this.ty;a.scaleX=Math.sqrt(this.a*this.a+this.b*this.b);a.scaleY=Math.sqrt(this.c*this.c+this.d*this.d);var c=Math.atan2(-this.c,this.d),d=Math.atan2(this.b,this.a);if(c==d){a.rotation=d/b.DEG_TO_RAD;if(this.a<0&&this.d>=0)a.rotation+=a.rotation<=0?180:-180;a.skewX=a.skewY=0}else{a.skewX=c/b.DEG_TO_RAD;
a.skewY=d/b.DEG_TO_RAD}return a};b.prototype.appendProperties=function(a,c,d){this.alpha*=a;this.shadow=c||this.shadow;this.compositeOperation=d||this.compositeOperation};b.prototype.prependProperties=function(a,c,d){this.alpha*=a;this.shadow=this.shadow||c;this.compositeOperation=this.compositeOperation||d};b.prototype.clone=function(){var a=new b(this.a,this.b,this.c,this.d,this.tx,this.ty);a.shadow=this.shadow;a.alpha=this.alpha;a.compositeOperation=this.compositeOperation;return a};b.prototype.toString=
function(){return"[Matrix2D (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")]"};b.identity=new b(1,0,0,1,0,0);l.Matrix2D=b})(window);(function(l){function b(a,c){this.initialize(a,c)}b.prototype.x=0;b.prototype.y=0;b.prototype.initialize=function(a,c){this.x=a==null?0:a;this.y=c==null?0:c};b.prototype.clone=function(){return new b(this.x,this.y)};b.prototype.toString=function(){return"[Point (x="+this.x+" y="+this.y+")]"};l.Point=b})(window);(function(l){function b(a,c,d,e){this.initialize(a,c,d,e)}b.prototype.x=0;b.prototype.y=0;b.prototype.width=0;b.prototype.height=0;b.prototype.initialize=function(a,c,d,e){this.x=a==null?0:a;this.y=c==null?0:c;this.width=d==null?0:d;this.height=e==null?0:e};b.prototype.clone=function(){return new b(this.x,this.y,this.width,this.height)};b.prototype.toString=function(){return"[Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")]"};l.Rectangle=b})(window);(function(l){function b(a,c,d,e){this.initialize(a,c,d,e)}b.identity=null;b.prototype.color=null;b.prototype.offsetX=0;b.prototype.offsetY=0;b.prototype.blur=0;b.prototype.initialize=function(a,c,d,e){this.color=a;this.offsetX=c;this.offsetY=d;this.blur=e};b.prototype.toString=function(){return"[Shadow]"};b.prototype.clone=function(){return new b(this.color,this.offsetX,this.offsetY,this.blur)};b.identity=new b(null,0,0,0);l.Shadow=b})(window);(function(l){function b(a,c,d,e){this.initialize(a,c,d,e)}b.prototype.image=null;b.prototype.frameWidth=0;b.prototype.frameHeight=0;b.prototype.frameData=null;b.prototype.loop=true;b.prototype.totalFrames=0;b.prototype.initialize=function(a,c,d,e){this.image=a;this.frameWidth=c;this.frameHeight=d;this.frameData=e};b.prototype.toString=function(){return"[SpriteSheet]"};b.prototype.clone=function(){var a=new b(this.image,this.frameWidth,this.frameHeight,this.frameData);a.loop=this.loop;a.totalFrames=
this.totalFrames;return a};l.SpriteSheet=b})(window);(function(l){function b(c,d){this.f=c;this.params=d}function a(c){this.initialize(c)}b.prototype.exec=function(c){this.f.apply(c,this.params)};a.getRGB=function(c,d,e,f){if(c!=null&&e==null){f=d;e=c&255;d=c>>8&255;c=c>>16&255}return f==null?"rgb("+c+","+d+","+e+")":"rgba("+c+","+d+","+e+","+f+")"};a.getHSL=function(c,d,e,f){return f==null?"hsl("+c%360+","+d+"%,"+e+"%)":"hsla("+c%360+","+d+"%,"+e+"%,"+f+")"};a.STROKE_CAPS_MAP=["butt","round","square"];a.STROKE_JOINTS_MAP=["miter","round","bevel"];
a._canvas=document.createElement("canvas");a._ctx=a._canvas.getContext("2d");a.beginCmd=new b(a._ctx.beginPath,[]);a.fillCmd=new b(a._ctx.fill,[]);a.strokeCmd=new b(a._ctx.stroke,[]);a.prototype._strokeInstructions=null;a.prototype._strokeStyleInstructions=null;a.prototype._fillInstructions=null;a.prototype._instructions=null;a.prototype._oldInstructions=null;a.prototype._activeInstructions=null;a.prototype._active=false;a.prototype._dirty=false;a.prototype.initialize=function(c){this.clear();this._ctx=
a._ctx;with(this)eval(c)};a.prototype.draw=function(c){this._dirty&&this._updateInstructions();for(var d=this._instructions,e=0,f=d.length;e<f;e++)d[e].exec(c)};a.prototype.moveTo=function(c,d){this._activeInstructions.push(new b(this._ctx.moveTo,[c,d]));return this};a.prototype.lineTo=function(c,d){this._dirty=this._active=true;this._activeInstructions.push(new b(this._ctx.lineTo,[c,d]));return this};a.prototype.arcTo=function(c,d,e,f,h){this._dirty=this._active=true;this._activeInstructions.push(new b(this._ctx.arcTo,
[c,d,e,f,h]));return this};a.prototype.arc=function(c,d,e,f,h,g){this._dirty=this._active=true;if(g==null)g=false;this._activeInstructions.push(new b(this._ctx.arc,[c,d,e,f,h,g]));return this};a.prototype.quadraticCurveTo=function(c,d,e,f){this._dirty=this._active=true;this._activeInstructions.push(new b(this._ctx.quadraticCurveTo,[c,d,e,f]));return this};a.prototype.bezierCurveTo=function(c,d,e,f,h,g){this._dirty=this._active=true;this._activeInstructions.push(new b(this._ctx.bezierCurveTo,[c,d,
e,f,h,g]));return this};a.prototype.rect=function(c,d,e,f){this._dirty=this._active=true;this._activeInstructions.push(new b(this._ctx.rect,[c,d,e-1,f]));return this};a.prototype.closePath=function(){if(this._active){this._dirty=true;this._activeInstructions.push(new b(this._ctx.closePath,[]))}return this};a.prototype.clear=function(){this._instructions=[];this._oldInstructions=[];this._activeInstructions=[];this._strokeInstructions=this._fillInstructions=this._strokeStyleInstructions=null;this._active=
this._dirty=false;return this};a.prototype.beginFill=function(c){this._active&&this._newPath();this._fillInstructions=c?[new b(this._setProp,["fillStyle",c])]:null;return this};a.prototype.beginLinearGradientFill=function(c,d,e,f,h,g){this._active&&this._newPath();e=this._ctx.createLinearGradient(e,f,h,g);f=0;for(h=c.length;f<h;f++)e.addColorStop(d[f],c[f]);this._fillInstructions=[new b(this._setProp,["fillStyle",e])];return this};a.prototype.beginRadialGradientFill=function(c,d,e,f,h,g,i,j){this._active&&
this._newPath();e=this._ctx.createRadialGradient(e,f,h,g,i,j);f=0;for(h=c.length;f<h;f++)e.addColorStop(d[f],c[f]);this._fillInstructions=[new b(this._setProp,["fillStyle",e])];return this};a.prototype.beginBitmapFill=function(c,d){this._active&&this._newPath();var e=this._ctx.createPattern(c,d||"");this._fillInstructions=[new b(this._setProp,["fillStyle",e])];return this};a.prototype.endFill=function(){this.beginFill(null);return this};a.prototype.setStrokeStyle=function(c,d,e,f){this._active&&this._newPath();
this._strokeStyleInstructions=[new b(this._setProp,["lineWidth",c==null?"1":c]),new b(this._setProp,["lineCap",d==null?"butt":isNaN(d)?d:a.STROKE_CAPS_MAP[d]]),new b(this._setProp,["lineJoin",e==null?"miter":isNaN(e)?e:a.STROKE_JOINTS_MAP[e]]),new b(this._setProp,["miterLimit",f==null?"10":f])];return this};a.prototype.beginStroke=function(c){this._active&&this._newPath();this._strokeInstructions=c?[new b(this._setProp,["strokeStyle",c])]:null;return this};a.prototype.beginLinearGradientStroke=function(c,
d,e,f,h,g){this._active&&this._newPath();e=this._ctx.createLinearGradient(e,f,h,g);f=0;for(h=c.length;f<h;f++)e.addColorStop(d[f],c[f]);this._strokeInstructions=[new b(this._setProp,["strokeStyle",e])];return this};a.prototype.beginRadialGradientStroke=function(c,d,e,f,h,g,i,j){this._active&&this._newPath();e=this._ctx.createRadialGradient(e,f,h,g,i,j);f=0;for(h=c.length;f<h;f++)e.addColorStop(d[f],c[f]);this._strokeInstructions=[new b(this._setProp,["strokeStyle",e])];return this};a.prototype.beginBitmapStroke=
function(c,d){this._active&&this._newPath();var e=this._ctx.createPattern(c,d||"");this._strokeInstructions=[new b(this._setProp,["strokeStyle",e])];return this};a.prototype.endStroke=function(){this.beginStroke(null);return this};a.prototype.curveTo=a.prototype.quadraticCurveTo;a.prototype.drawRect=a.prototype.rect;a.prototype.drawRoundRect=function(c,d,e,f,h){this.drawRoundRectComplex(c,d,e,f,h,h,h,h);return this};a.prototype.drawRoundRectComplex=function(c,d,e,f,h,g,i,j){this._dirty=this._active=
true;this._activeInstructions.push(new b(this._ctx.moveTo,[c+h,d]),new b(this._ctx.lineTo,[c+e-g,d]),new b(this._ctx.arc,[c+e-g,d+g,g,-Math.PI/2,0,false]),new b(this._ctx.lineTo,[c+e,d+f-i]),new b(this._ctx.arc,[c+e-i,d+f-i,i,0,Math.PI/2,false]),new b(this._ctx.lineTo,[c+j,d+f]),new b(this._ctx.arc,[c+j,d+f-j,j,Math.PI/2,Math.PI,false]),new b(this._ctx.lineTo,[c,d+h]),new b(this._ctx.arc,[c+h,d+h,h,Math.PI,Math.PI*3/2,false]));return this};a.prototype.drawCircle=function(c,d,e){this.arc(c,d,e,0,Math.PI*
2);return this};a.prototype.drawEllipse=function(c,d,e,f){this._dirty=this._active=true;var h=e/2*0.5522848,g=f/2*0.5522848,i=c+e,j=d+f;e=c+e/2;f=d+f/2;this._activeInstructions.push(new b(this._ctx.moveTo,[c,f]),new b(this._ctx.bezierCurveTo,[c,f-g,e-h,d,e,d]),new b(this._ctx.bezierCurveTo,[e+h,d,i,f-g,i,f]),new b(this._ctx.bezierCurveTo,[i,f+g,e+h,j,e,j]),new b(this._ctx.bezierCurveTo,[e-h,j,c,f+g,c,f]));return this};a.prototype.drawPolyStar=function(c,d,e,f,h,g){this._dirty=this._active=true;if(h==
null)h=0;h=1-h;if(g==null)g=0;else g/=180/Math.PI;var i=Math.PI/f;this._activeInstructions.push(new b(this._ctx.moveTo,[c+Math.cos(g)*e,d+Math.sin(g)*e]));for(var j=0;j<f;j++){g+=i;h!=1&&this._activeInstructions.push(new b(this._ctx.lineTo,[c+Math.cos(g)*e*h,d+Math.sin(g)*e*h]));g+=i;this._activeInstructions.push(new b(this._ctx.lineTo,[c+Math.cos(g)*e,d+Math.sin(g)*e]))}return this};a.prototype.clone=function(){var c=new a;c._instructions=this._instructions.slice();c._activeIntructions=this._activeInstructions.slice();
c._oldInstructions=this._oldInstructions.slice();c._fillInstructions=this._fillInstructions.slice();c._strokeInstructions=this._strokeInstructions.slice();c._strokeStyleInstructions=this._strokeStyleInstructions.slice();c._active=this._active;c._dirty=this._dirty;c._assets=this._assets;return c};a.prototype.toString=function(){return"[Graphics]"};a.prototype.mt=a.prototype.moveTo;a.prototype.lt=a.prototype.lineTo;a.prototype.at=a.prototype.arcTo;a.prototype.bt=a.prototype.bezierCurveTo;a.prototype.qt=
a.prototype.quadraticCurveTo;a.prototype.a=a.prototype.arc;a.prototype.r=a.prototype.rect;a.prototype.cp=a.prototype.closePath;a.prototype.c=a.prototype.clear;a.prototype.f=a.prototype.beginFill;a.prototype.lf=a.prototype.beginLinearGradientFill;a.prototype.rf=a.prototype.beginRadialGradientFill;a.prototype.bf=a.prototype.beginBitmapFill;a.prototype.ef=a.prototype.endFill;a.prototype.ss=a.prototype.setStrokeStyle;a.prototype.s=a.prototype.beginStroke;a.prototype.ls=a.prototype.beginLinearGradientStroke;
a.prototype.rs=a.prototype.beginRadialGradientStroke;a.prototype.bs=a.prototype.beginBitmapStroke;a.prototype.es=a.prototype.endStroke;a.prototype.dr=a.prototype.drawRect;a.prototype.rr=a.prototype.drawRoundRect;a.prototype.rc=a.prototype.drawRoundRectComplex;a.prototype.dc=a.prototype.drawCircle;a.prototype.de=a.prototype.drawEllipse;a.prototype.dp=a.prototype.drawPolyStar;a.prototype._updateInstructions=function(){this._instructions=this._oldInstructions.slice();this._instructions.push(a.beginCmd);
this._fillInstructions&&this._instructions.push.apply(this._instructions,this._fillInstructions);if(this._strokeInstructions){this._instructions.push.apply(this._instructions,this._strokeInstructions);this._strokeStyleInstructions&&this._instructions.push.apply(this._instructions,this._strokeStyleInstructions)}this._instructions.push.apply(this._instructions,this._activeInstructions);this._fillInstructions&&this._instructions.push(a.fillCmd);this._strokeInstructions&&this._instructions.push(a.strokeCmd)};
a.prototype._newPath=function(){this._dirty&&this._updateInstructions();this._oldInstructions=this._instructions;this._activeInstructions=[];this._active=this._dirty=false};a.prototype._setProp=function(c,d){this[c]=d};l.Graphics=a})(window);(function(l){function b(){this.initialize()}b.suppressCrossDomainErrors=false;b._hitTestCanvas=document.createElement("canvas");b._hitTestCanvas.width=b._hitTestCanvas.height=1;b._hitTestContext=b._hitTestCanvas.getContext("2d");b._workingMatrix=new Matrix2D;b.prototype.alpha=1;b.prototype.cacheCanvas=null;b.prototype.id=-1;b.prototype.mouseEnabled=true;b.prototype.name=null;b.prototype.parent=null;b.prototype.regX=0;b.prototype.regY=0;b.prototype.rotation=0;b.prototype.scaleX=1;b.prototype.scaleY=
1;b.prototype.skewX=0;b.prototype.skewY=0;b.prototype.shadow=null;b.prototype.visible=true;b.prototype.x=0;b.prototype.y=0;b.prototype.compositeOperation=null;b.prototype.snapToPixel=false;b.prototype.onPress=null;b.prototype.onClick=null;b.prototype._cacheOffsetX=0;b.prototype._cacheOffsetY=0;b.prototype._cacheDraw=false;b.prototype._activeContext=null;b.prototype._restoreContext=false;b.prototype._revertShadow=false;b.prototype._revertX=0;b.prototype._revertY=0;b.prototype._revertAlpha=1;b.prototype.initialize=
function(){this.id=UID.get();this.children=[]};b.prototype.isVisible=function(){return this.visible&&this.alpha>0&&this.scaleX!=0&&this.scaleY!=0};b.prototype.draw=function(a,c){if(c||!this.cacheCanvas)return false;a.translate(this._cacheOffsetX,this._cacheOffsetY);a.drawImage(this.cacheCanvas,0,0);a.translate(-this._cacheOffsetX,-this._cacheOffsetY);return true};b.prototype.cache=function(a,c,d,e){var f;if(this.cacheCanvas==null)this.cacheCanvas=document.createElement("canvas");f=this.cacheCanvas.getContext("2d");
this.cacheCanvas.width=d;this.cacheCanvas.height=e;f.setTransform(1,0,0,1,-a,-c);f.clearRect(0,0,d+1,e+1);this.draw(f,true);this._cacheOffsetX=a;this._cacheOffsetY=c};b.prototype.updateCache=function(a){if(this.cacheCanvas==null)throw"cache() must be called before updateCache()";var c=this.cacheCanvas.getContext("2d");c.setTransform(1,0,0,1,-this._cacheOffsetX,-this._cacheOffsetY);if(a)c.globalCompositeOperation=a;else c.clearRect(0,0,this.cacheCanvas.width+1,this.cacheCanvas.height+1);this.draw(c,
true);if(a)c.globalCompositeOperation="source-over"};b.prototype.uncache=function(){this.cacheCanvas=null;this.cacheOffsetX=this.cacheOffsetY=0};b.prototype.getStage=function(){for(var a=this;a.parent;)a=a.parent;if(a instanceof Stage)return a;return null};b.prototype.localToGlobal=function(a,c){var d=this.getConcatenatedMatrix();if(d==null)return null;d.append(1,0,0,1,a,c);return new Point(d.tx,d.ty)};b.prototype.globalToLocal=function(a,c){var d=this.getConcatenatedMatrix();if(d==null)return null;
d.invert();d.append(1,0,0,1,a,c);return new Point(d.tx,d.ty)};b.prototype.localToLocal=function(a,c,d){a=this.localToGlobal(a,c);return d.globalToLocal(a.x,a.y)};b.prototype.getConcatenatedMatrix=function(a){if(a)a.identity();else a=new Matrix2D;for(var c=this;;){a.prependTransform(c.x,c.y,c.scaleX,c.scaleY,c.rotation,c.skewX,c.skewY,c.regX,c.regY);a.prependProperties(c.alpha,c.shadow,c.compositeOperation);if((p=c.parent)==null)break;c=p}return a};b.prototype.hitTest=function(a,c){var d=b._hitTestContext,
e=b._hitTestCanvas;d.setTransform(1,0,0,1,-a,-c);this.draw(d);d=this._testHit(d);e.width=0;e.width=1;return d};b.prototype.clone=function(){var a=new b;this.cloneProps(a);return a};b.prototype.toString=function(){return"[DisplayObject (name="+this.name+")]"};b.prototype.cloneProps=function(a){a.alpha=this.alpha;a.name=this.name;a.regX=this.regX;a.regY=this.regY;a.rotation=this.rotation;a.scaleX=this.scaleX;a.scaleY=this.scaleY;a.shadow=this.shadow;a.skewX=this.skewX;a.skewY=this.skewY;a.visible=this.visible;
a.x=this.x;a.y=this.y;a.mouseEnabled=this.mouseEnabled;a.compositeOperation=this.compositeOperation};b.prototype.applyShadow=function(a,c){a.shadowColor=c.color;a.shadowOffsetX=c.offsetX;a.shadowOffsetY=c.offsetY;a.shadowBlur=c.blur};b.prototype._testHit=function(a){try{var c=a.getImageData(0,0,1,1).data[3]>1}catch(d){if(!b.suppressCrossDomainErrors)throw"An error has occured. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images.";}return c};
l.DisplayObject=b})(window);(function(l){function b(){this.initialize()}b.prototype=new DisplayObject;b.prototype.children=null;b.prototype.DisplayObject_initialize=b.prototype.initialize;b.prototype.initialize=function(){this.DisplayObject_initialize();this.children=[]};b.prototype.isVisible=function(){return this.visible&&this.alpha>0&&this.children.length&&this.scaleX!=0&&this.scaleY!=0};b.prototype.DisplayObject_draw=b.prototype.draw;b.prototype.draw=function(a,c,d){var e=Stage._snapToPixelEnabled;if(!d){d=new Matrix2D;
d.appendProperties(this.alpha,this.shadow,this.compositeOperation)}if(this.DisplayObject_draw(a,c))return true;c=this.children.length;for(var f=this.children.slice(0),h=0;h<c;h++){var g=f[h];g.tick&&g.tick();if(g.isVisible()){var i=d.clone();i.appendTransform(g.x,g.y,g.scaleX,g.scaleY,g.rotation,g.skewX,g.skewY,g.regX,g.regY);i.appendProperties(g.alpha,g.shadow,g.compositeOperation);if(!(g instanceof b)){e&&g.snapToPixel&&i.a==1&&i.b==0&&i.c==0&&i.d==1?a.setTransform(i.a,i.b,i.c,i.d,i.tx+0.5|0,i.ty+
0.5|0):a.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty);a.globalAlpha=i.alpha;a.globalCompositeOperation=i.compositeOperation||"source-over";i.shadow&&this.applyShadow(a,i.shadow)}g.draw(a,false,i)}}return true};b.prototype.addChild=function(a){var c=arguments.length;if(c>1){for(var d=0;d<c;d++)this.addChild(arguments[d]);return arguments[c-1]}a.parent&&a.parent.removeChild(a);a.parent=this;this.children.push(a);return a};b.prototype.addChildAt=function(a,c){var d=arguments.length;if(d>2){c=arguments[e-
1];for(var e=0;e<d-1;e++)this.addChildAt(arguments[e],c+e);return arguments[d-2]}a.parent&&a.parent.removeChild(a);a.parent=this;this.children.splice(c,0,a);return a};b.prototype.removeChild=function(a){var c=arguments.length;if(c>1){for(var d=true,e=0;e<c;e++)d=d&&this.removeChild(arguments[e]);return d}return this.removeChildAt(this.children.indexOf(a))};b.prototype.removeChildAt=function(a){var c=arguments.length;if(c>1){for(var d=[],e=0;e<c;e++)d[e]=arguments[e];d.sort(function(h,g){return g-
h});var f=true;for(e=0;e<c;e++)f=f&&this.removeChildAt(d[e]);return f}if(a<0||a>this.children.length-1)return false;c=this.children[a];if(c!=null)c.parent=null;this.children.splice(a,1);return true};b.prototype.removeAllChildren=function(){for(;this.children.length;)this.removeChildAt(0)};b.prototype.getChildAt=function(a){return this.children[a]};b.prototype.sortChildren=function(a){this.children.sort(a)};b.prototype.getChildIndex=function(a){return this.children.indexOf(a)};b.prototype.getNumChildren=
function(){return this.children.length};b.prototype.contains=function(a){for(;a;){if(a==this)return true;a=a.parent}return false};b.prototype.hitTest=function(a,c){return this.getObjectUnderPoint(a,c)!=null};b.prototype.getObjectsUnderPoint=function(a,c){var d=[],e=this.localToGlobal(a,c);this._getObjectsUnderPoint(e.x,e.y,d);return d};b.prototype.getObjectUnderPoint=function(a,c){var d=this.localToGlobal(a,c);return this._getObjectsUnderPoint(d.x,d.y)};b.prototype.clone=function(a){var c=new b;this.cloneProps(c);
if(a)for(var d=c.children=[],e=0,f=this.children.length;e<f;e++)d.push(this.children[e].clone(a));return c};b.prototype.toString=function(){return"[Container (name="+this.name+")]"};b.prototype._getObjectsUnderPoint=function(a,c,d,e){var f=DisplayObject._hitTestContext,h=DisplayObject._hitTestCanvas,g=DisplayObject._workingMatrix,i=e&&(this.onPress||this.onClick);if(this.cacheCanvas){this.getConcatenatedMatrix(g);f.setTransform(g.a,g.b,g.c,g.d,g.tx-a,g.ty-c);f.globalAlpha=g.alpha;this.draw(f);if(this._testHit(f)){h.width=
0;h.width=1;if(i)return this}else return null}for(var j=this.children.length-1;j>=0;j--){var k=this.children[j];if(k.isVisible()&&k.mouseEnabled)if(k instanceof b)if(i){if(k=k._getObjectsUnderPoint(a,c))return this}else{k=k._getObjectsUnderPoint(a,c,d,e);if(!d&&k)return k}else if(!e||e&&(k.onPress||k.onClick||i)){k.getConcatenatedMatrix(g);f.setTransform(g.a,g.b,g.c,g.d,g.tx-a,g.ty-c);f.globalAlpha=g.alpha;k.draw(f);if(this._testHit(f)){h.width=0;h.width=1;if(i)return this;else if(d)d.push(k);else return k}}}return null};
l.Container=b})(window);(function(l){function b(a){this.initialize(a)}b.prototype=new Container;b._snapToPixelEnabled=false;b.prototype.autoClear=true;b.prototype.canvas=null;b.prototype.mouseX=null;b.prototype.mouseY=null;b.prototype.onMouseMove=null;b.prototype.onMouseUp=null;b.prototype.onMouseDown=null;b.prototype.snapToPixelEnabled=false;b.prototype._tmpCanvas=null;b.prototype._activeMouseEvent=null;b.prototype._activeMouseTarget=null;b.prototype.Container_initialize=b.prototype.initialize;b.prototype.initialize=function(a){this.Container_initialize();
this.canvas=a;this.mouseChildren=true;var c=this;if(l.addEventListener)l.addEventListener("mouseup",function(d){c._handleMouseUp(d)},false);else document.addEventListener&&document.addEventListener("mouseup",function(d){c._handleMouseUp(d)},false);a.addEventListener("mousemove",function(d){c._handleMouseMove(d)},false);a.addEventListener("mousedown",function(d){c._handleMouseDown(d)},false)};b.prototype.update=function(){if(this.canvas){this.autoClear&&this.clear();b._snapToPixelEnabled=this.snapToPixelEnabled;
this.draw(this.canvas.getContext("2d"),false,this.getConcatenatedMatrix(DisplayObject._workingMatrix))}};b.prototype.tick=b.prototype.update;b.prototype.clear=function(){if(this.canvas){var a=this.canvas.getContext("2d");a.setTransform(1,0,0,1,0,0);a.clearRect(0,0,this.canvas.width,this.canvas.height)}};b.prototype.toDataURL=function(a,c){c||(c="image/png");var d=this.canvas.getContext("2d"),e=this.canvas.width,f=this.canvas.height,h;if(a){h=d.getImageData(0,0,e,f);var g=d.globalCompositeOperation;
d.globalCompositeOperation="destination-over";d.fillStyle=a;d.fillRect(0,0,e,f)}var i=this.canvas.toDataURL(c);if(a){d.clearRect(0,0,e,f);d.putImageData(h,0,0);d.globalCompositeOperation=g}return i};b.prototype.clone=function(){var a=new b(null);this.cloneProps(a);return a};b.prototype.toString=function(){return"[Stage (name="+this.name+")]"};b.prototype._handleMouseMove=function(a){if(this.canvas){if(!a)a=l.event;this.mouseX=a.pageX-this.canvas.offsetLeft;this.mouseY=a.pageY-this.canvas.offsetTop;
a=new MouseEvent("onMouseMove",this.mouseX,this.mouseY);if(this.onMouseMove)this.onMouseMove(a);if(this._activeMouseEvent&&this._activeMouseEvent.onMouseMove)this._activeMouseEvent.onMouseMove(a)}else this.mouseX=this.mouseY=null};b.prototype._handleMouseUp=function(){var a=new MouseEvent("onMouseUp",this.mouseX,this.mouseY);if(this.onMouseUp)this.onMouseUp(a);if(this._activeMouseEvent&&this._activeMouseEvent.onMouseUp instanceof Function)this._activeMouseEvent.onMouseUp(a);if(this._activeMouseTarget&&
this._activeMouseTarget.onClick&&this._getObjectsUnderPoint(this.mouseX,this.mouseY,null,true)==this._activeMouseTarget)this._activeMouseTarget.onClick(new MouseEvent("onClick",this.mouseX,this.mouseY));this._activeMouseEvent=this.activeMouseTarget=null};b.prototype._handleMouseDown=function(){if(this.onMouseDown)this.onMouseDown(new MouseEvent("onMouseDown",this.mouseX,this.mouseY));var a=this._getObjectsUnderPoint(this.mouseX,this.mouseY,null,true);if(a){if(a.onPress instanceof Function){var c=
new MouseEvent("onPress",this.mouseX,this.mouseY);a.onPress(c);if(c.onMouseMove||c.onMouseUp)this._activeMouseEvent=c}this._activeMouseTarget=a}};l.Stage=b})(window);(function(l){function b(a){this.initialize(a)}b.prototype=new DisplayObject;b.prototype.image=null;b.prototype.snapToPixel=true;b.prototype.DisplayObject_initialize=b.prototype.initialize;b.prototype.initialize=function(a){this.DisplayObject_initialize();this.image=a};b.prototype.isVisible=function(){return this.visible&&this.alpha>0&&this.scaleX!=0&&this.scaleY!=0&&this.image&&(this.image.complete||this.image.getContext)};b.prototype.DisplayObject_draw=b.prototype.draw;b.prototype.draw=function(a,
c){if(this.DisplayObject_draw(a,c))return true;a.drawImage(this.image,0,0);return true};b.prototype.cache=function(){};b.prototype.updateCache=function(){};b.prototype.uncache=function(){};b.prototype.clone=function(){var a=new b(this.image);this.cloneProps(a);return a};b.prototype.toString=function(){return"[Bitmap (name="+this.name+")]"};l.Bitmap=b})(window);(function(l){function b(a){this.initialize(a)}b.prototype=new DisplayObject;b.prototype.callback=null;b.prototype.currentFrame=-1;b.prototype.currentSequence=null;b.prototype.currentEndFrame=null;b.prototype.currentStartFrame=null;b.prototype.nextSequence=null;b.prototype.paused=false;b.prototype.spriteSheet=null;b.prototype.snapToPixel=true;b.prototype.DisplayObject_initialize=b.prototype.initialize;b.prototype.initialize=function(a){this.DisplayObject_initialize();this.spriteSheet=a};b.prototype.isVisible=
function(){var a=this.spriteSheet?this.spriteSheet.image:null;return this.visible&&this.alpha>0&&this.scaleX!=0&&this.scaleY!=0&&a&&this.currentFrame>=0&&(a.complete||a.getContext)};b.prototype.DisplayObject_draw=b.prototype.draw;b.prototype.draw=function(a,c){if(this.DisplayObject_draw(a,c))return true;var d=this.spriteSheet.image,e=this.spriteSheet.frameWidth,f=this.spriteSheet.frameHeight,h=d.width/e|0,g=d.height/f|0;if(this.currentEndFrame!=null){if(this.currentFrame>this.currentEndFrame){if(this.nextSequence)this._goto(this.nextSequence);
else{this.paused=true;this.currentFrame=this.currentEndFrame}this.callback&&this.callback(this)}}else if(this.spriteSheet.frameData)this.paused=true;else{g=this.spriteSheet.totalFrames||h*g;if(this.currentFrame>=g){if(this.spriteSheet.loop)this.currentFrame=0;else{this.currentFrame=g-1;this.paused=true}this.callback&&this.callback(this)}}this.currentFrame>=0&&a.drawImage(d,e*(this.currentFrame%h),f*(this.currentFrame/h|0),e,f,0,0,e,f);return true};b.prototype.tick=function(){this.paused||this.currentFrame++};
b.prototype.cache=function(){};b.prototype.updateCache=function(){};b.prototype.uncache=function(){};b.prototype.gotoAndPlay=function(a){this.paused=false;this._goto(a)};b.prototype.gotoAndStop=function(a){this.paused=true;this._goto(a)};b.prototype.clone=function(){var a=new b(this.spriteSheet);this.cloneProps(a);return a};b.prototype.toString=function(){return"[BitmapSequence (name="+this.name+")]"};b.prototype.DisplayObject_cloneProps=b.prototype.cloneProps;b.prototype.cloneProps=function(a){this.DisplayObject_cloneProps(a);
a.callback=this.callback;a.currentFrame=this.currentFrame;a.currentStartFrame=this.currentStartFrame;a.currentEndFrame=this.currentEndFrame;a.currentSequence=this.currentSequence;a.nextSequence=this.nextSequence;a.paused=this.paused;a.frameData=this.frameData};b.prototype._goto=function(a){if(isNaN(a))if(a==this.currentSequence)this.currentFrame=this.currentStartFrame;else{var c=this.spriteSheet.frameData[a];if(c instanceof Array){this.currentFrame=this.currentStartFrame=c[0];this.currentSequence=
a;this.currentEndFrame=c[1];if(this.currentEndFrame==null)this.currentEndFrame=this.currentStartFrame;if(this.currentEndFrame==null)this.currentEndFrame=this.currentFrame;this.nextSequence=c[2];if(this.nextSequence==null)this.nextSequence=this.currentSequence;else if(this.nextSequence==false)this.nextSequence=null}else{this.currentSequence=this.nextSequence=null;this.currentEndFrame=this.currentFrame=this.currentStartFrame=c}}else{this.currentSequence=this.nextSequence=this.currentEndFrame=null;this.currentStartFrame=
0;this.currentFrame=a}};l.BitmapSequence=b})(window);(function(l){function b(a){this.initialize(a)}b.prototype=new DisplayObject;b.prototype.graphics=null;b.prototype.DisplayObject_initialize=b.prototype.initialize;b.prototype.initialize=function(a){this.DisplayObject_initialize();this.graphics=a?a:new Graphics};b.prototype.isVisible=function(){return this.visible&&this.alpha>0&&this.scaleX!=0&&this.scaleY!=0&&this.graphics};b.prototype.DisplayObject_draw=b.prototype.draw;b.prototype.draw=function(a,c){if(this.DisplayObject_draw(a,c))return true;this.graphics.draw(a);
return true};b.prototype.clone=function(a){a=new b(a&&this.graphics?this.graphics.clone():this.graphics);this.cloneProps(a);return a};b.prototype.toString=function(){return"[Shape (name="+this.name+")]"};l.Shape=b})(window);(function(l){function b(c,d,e){this.initialize(c,d,e)}b.prototype=new DisplayObject;var a=document.createElement("canvas");b._workingContext=a.getContext("2d");b.prototype.text="";b.prototype.font=null;b.prototype.color=null;b.prototype.textAlign=null;b.prototype.textBaseline=null;b.prototype.maxWidth=null;b.prototype.outline=false;b.prototype.lineHeight=null;b.prototype.lineWidth=null;b.prototype.DisplayObject_initialize=b.prototype.initialize;b.prototype.initialize=function(c,d,e){this.DisplayObject_initialize();
this.text=c;this.font=d;this.color=e?e:"#000"};b.prototype.isVisible=function(){return Boolean(this.visible&&this.alpha>0&&this.scaleX!=0&&this.scaleY!=0&&this.text!=null&&this.text!="")};b.prototype.DisplayObject_draw=b.prototype.draw;b.prototype.draw=function(c,d){if(this.DisplayObject_draw(c,d))return true;if(this.outline)c.strokeStyle=this.color;else c.fillStyle=this.color;c.font=this.font;c.textAlign=this.textAlign?this.textAlign:"start";c.textBaseline=this.textBaseline?this.textBaseline:"alphabetic";
for(var e=String(this.text).split(/(?:\r\n|\r|\n)/),f=this.lineHeight==null?this.getMeasuredLineHeight():this.lineHeight,h=0,g=0,i=e.length;g<i;g++){var j=c.measureText(e[g]).width;if(this.lineWidth==null||j<this.lineWidth)this._drawTextLine(c,e[g],h);else{j=e[g].split(/(\s)/);for(var k=j[0],m=1,n=j.length;m<n;m+=2)if(c.measureText(k+j[m]+j[m+1]).width>this.lineWidth){this._drawTextLine(c,k,h);h+=f;k=j[m+1]}else k+=j[m]+j[m+1];this._drawTextLine(c,k,h)}h+=f}return true};b.prototype.getMeasuredWidth=
function(){return this._getWorkingContext().measureText(this.text).width};b.prototype.getMeasuredLineHeight=function(){return this._getWorkingContext().measureText("M").width*1.2};b.prototype.clone=function(){var c=new b(this.text,this.font,this.color);this.cloneProps(c);return c};b.prototype.toString=function(){return"[Text (text="+(this.text.length>20?this.text.substr(0,17)+"...":this.text)+")]"};b.prototype.DisplayObject_cloneProps=b.prototype.cloneProps;b.prototype.cloneProps=function(c){this.DisplayObject_cloneProps(c);
c.textAlign=this.textAlign;c.textBaseline=this.textBaseline;c.maxWidth=this.maxWidth;c.outline=this.outline;c.lineHeight=this.lineHeight;c.lineWidth=this.lineWidth};b.prototype._getWorkingContext=function(){var c=b._workingContext;c.font=this.font;c.textAlign=this.textAlign?this.textAlign:"start";c.textBaseline=this.textBaseline?this.textBaseline:"alphabetic";return c};b.prototype._drawTextLine=function(c,d,e){this.outline?c.strokeText(d,0,e,this.maxWidth):c.fillText(d,0,e,this.maxWidth)};l.Text=
b})(window);(function(l){function b(){throw"SpriteSheetUtils cannot be instantiated";}b._workingCanvas=document.createElement("canvas");b._workingContext=b._workingCanvas.getContext("2d");b.flip=function(a,c){var d=a.image,e=a.frameData,f=a.frameWidth,h=a.frameHeight,g=d.width/f|0,i=d.height/h|0,j=g*i,k={},m,n;for(n in e){m=e[n];if(m instanceof Array)m=m.slice(0);k[n]=m}var s=[],q=0,o=0;for(n in c){m=c[n];m=e[m[0]];if(m!=null){if(m instanceof Array){var t=m[0],r=m[1];if(r==null)r=t}else t=r=m;s[o]=n;s[o+1]=t;
s[o+2]=r;q+=r-t+1;o+=4}}e=b._workingCanvas;e.width=d.width;e.height=Math.ceil(i+q/g)*h;q=b._workingContext;q.drawImage(d,0,0,g*f,i*h,0,0,g*f,i*h);i=j-1;for(o=0;o<s.length;o+=4){n=s[o];t=s[o+1];r=s[o+2];m=c[n];j=m[1]?-1:1;for(var v=m[2]?-1:1,w=j==-1?f:0,x=v==-1?h:0,u=t;u<=r;u++){i++;q.save();q.translate(i%g*f+w,(i/g|0)*h+x);q.scale(j,v);q.drawImage(d,u%g*f,(u/g|0)*h,f,h,0,0,f,h);q.restore()}k[n]=[i-(r-t),i,m[3]]}d=new Image;d.src=e.toDataURL("image/png");return new SpriteSheet(d.width>0?d:e,f,h,k)};
b.frameDataToString=function(a){var c="",d=0,e=0,f=0,h,g;for(g in a){f++;h=a[g];if(h instanceof Array){var i=h[0],j=h[1];if(j==null)j=i;h=h[2];if(h==null)h=g}else{i=j=h;h=g}c+="\n\t"+g+", start="+i+", end="+j+", next="+h;if(h==false)c+=" (stop)";else if(h==g)c+=" (loop)";if(j>d)d=j;if(i<e)e=i}return f+" sequences, min="+e+", max="+d+c};b.extractFrame=function(a,c){var d=a.image,e=a.frameWidth,f=a.frameHeight,h=d.width/e|0;if(isNaN(c)){var g=a.frameData[c];c=g instanceof Array?g[0]:g}g=b._workingCanvas;
g.width=e;g.height=f;b._workingContext.drawImage(d,c%h*e,(c/h|0)*f,e,f,0,0,e,f);d=new Image;d.src=g.toDataURL("image/png");return d};l.SpriteSheetUtils=b})(window);

