forked from Arcticjs/Arctic.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arctic.min.js
73 lines (73 loc) · 36.5 KB
/
arctic.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
(function(B){function s(a,b){return function(){return a.apply(b,arguments)}}function y(a){for(var b=a.length,c=[];b--;)c[b]=a[b];return c}function x(a,b,c){if(arc.ua.isAndroid2_1)return[a,b];var d=c*Math.PI/180,c=a*Math.cos(d)-b*Math.sin(d),a=a*Math.sin(d)+b*Math.cos(d);return[c,a]}function z(a){return"rgb("+(a>>16)+", "+(a>>8&255)+", "+(a&255)+")"}function v(){return 90==window.orientation||-90==window.orientation?screen.height:screen.width}var C={trace:function(){try{if(1==arguments.length)console.log(arguments[0]);
else{for(var a="",b=0;b<arguments.length;b++)0!=b&&(a+=","),a+=arguments[b];console.log(a)}}catch(c){}},bind:s,copyArray:y},p={};p.isiPhone=/iPhone/i.test(navigator.userAgent);p.isiPhone4=p.isiPhone&&2==window.devicePixelRatio;p.isiPad=/iPad/i.test(navigator.userAgent);p.isiOS=p.isiPhone||p.isiPad;p.isiOS3=(p.isiPhone||p.isiPad)&&/OS\s3/.test(navigator.userAgent);p.isAndroid=/android/i.test(navigator.userAgent);p.isAndroid2_1=/android\s2\.1/i.test(navigator.userAgent);p.isWindowsPhone=/Windows\ Phone/i.test(navigator.userAgent);
p.isMobile=p.isiOS||p.isAndroid||p.isWindowsPhone;var m=function(){var a=function(){};return{create:function(){function b(){this.initialize.apply(this,arguments)}function c(a){a=a.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g,"").replace(/\s+/g,"").split(",");return 1==a.length&&!a[0]?[]:a}function d(a,b){var c=function(){var c=this,$super=void 0!==b?function(){return b.apply(c,arguments)}:void 0,d=y(arguments);d.unshift($super);return a.apply(c,
d)};c.valueOf=s(a.valueOf,a);c.toString=s(a.toString,a);return c}var e="function"==typeof arguments[0]?arguments[0].prototype:{};if(!arguments[0])throw Error("define class");if("function"==typeof arguments[0])a.prototype=e,b.prototype=new a,Array.prototype.shift.apply(arguments);var f=arguments[0],i;for(i in f){var g=f[i];if("function"==typeof g)if("$super"==c(g)[0])g=d(g,e[i]);else if("initialize"==i&&e.initialize)var k=g,g=function(){e.initialize.apply(this,arguments);k.apply(this,arguments)};b.prototype[i]=
g}return b.prototype.constructor=b}}}(),h=m.create({type:null,target:null,initialize:function(a,b){this.type=a;for(var c in b)if(b.hasOwnProperty(c)&&!("type"==c||"target"==c))this[c]=b[c]}});h.PROGRESS="PROGRESS";h.COMPLETE="COMPLETE";h.ENTER_FRAME="ENTER_FRAME";h.ERROR="ERROR";h.TIMER="TIMER";h.TIMER_COMPLETE="TIMER_COMPLETE";h.TOUCH_START="TOUCH_START";h.TOUCH_MOVE="TOUCH_MOVE";h.TOUCH_END="TOUCH_END";var r=m.create({addEventListener:function(a,b){r.listenHash[a]||(r.listenHash[a]=[]);r.listenHash[a].push({target:this,
callback:b})},removeEventListener:function(a,b){var c=r.listenHash[a];if(c){for(var d=0;d<c.length;d++){var e=c[d];e.target==this&&(b&&e.callback==b||!b)&&c.splice(d,1)}0==c.length&&delete r.listenHash[a]}},dispatchEvent:function(a,b){if(r.listenHash[a]){for(var c=[],d=r.listenHash[a],e=0;e<d.length;e++)c[e]=d[e];d=c.length;for(e=0;e<d;e++){var f=c[e];if(f.target==this){var i=new h(a,b);i.target=this;f.callback.call(this,i)}}}}});r.listenHash={};var q=m.create({_startTime:0,_isCounting:!1,initialize:function(){},
start:function(){this._isCounting=!0;this._startTime=q.time},stop:function(){this._isCounting=!1},reset:function(){this._isCounting=!0;this._startTime=q.time},getElapsed:function(){return!this._isCounting&&!this._startTime?0:q.time-this._startTime}});q.time=0;q.tick=function(){q.time=Date.now()};var w=m.create(r,{_timer:null,_currentCount:0,_repeatCount:0,_delay:0,_isRunning:!1,_updateFunc:null,initialize:function(a,b){this._timer=new q;this._delay=a;this._repeatCount=b?b:0},reset:function(){this._currentCount=
0;this.stop()},start:function(){this._timer.start();this._updateFunc&&w.system.removeEventListener(h.ENTER_FRAME,this._updateFunc);this._updateFunc=s(this._update,this);w.system.addEventListener(h.ENTER_FRAME,this._updateFunc)},_update:function(){this._timer.getElapsed()>=this._delay&&(this._currentCount++,this._timer.reset(),this.dispatchEvent(h.TIMER),this._currentCount>=this._repeatCount&&(this.reset(),this.dispatchEvent(h.TIMER_COMPLETE)))},stop:function(){this._timer.stop();if(this._updateFunc)w.system.removeEventListener(h.ENTER_FRAME,
this._updateFunc),this._updateFunc=null},setDelay:function(a){this._delay=a},getDelay:function(){return this._delay},setRepeatCount:function(a){this._repeatCount=a},getRepeatCount:function(){return this._repeatCount}});w.system=null;var D=m.create(r,{_method:"GET",_params:null,_url:null,_request:null,_jsonResponse:null,_loadedCallBack:null,initialize:function(){this._request=new XMLHttpRequest;this._loadedCallBack=s(this._loaded,this)},load:function(a,b){this._url=a;this._params=b;this._request.open(this._method,
this._url,!0);this._request.addEventListener("readystatechange",this._loadedCallBack,!1);this._request.send(this._params)},_loaded:function(){if(4==this._request.readyState)if(200==this._request.status||0==this._request.status)this.dispatchEvent(h.COMPLETE);else throw this.dispatchEvent(h.ERROR),Error("Load Error : "+this._url);},unload:function(){this._request.abort();this._jsonResponse=null;this._request.removeEventListener("readystatechange",this._loadedCallBack,!1)},setMethod:function(a){this._method=
a},getResponseText:function(){return this._request.responseText},getResponseJSON:function(){if(!this._jsonResponse)this._jsonResponse=JSON.parse(this._request.responseText);return this._jsonResponse},getURL:function(){return this._url}}),g={};g.Image=m.create(r,{_data:null,_path:null,_width:null,_height:null,_frameWidth:null,_lx:null,_ly:null,_lwidth:null,_lheight:null,_hasLocalPos:!1,initialize:function(a,b){if(!a&&a.constructor!=HTMLImageElement)throw Error("set HTMLImageElement");this._data=a;
this._path=a.src;b&&4==b.length?(this._lx=b[0],this._ly=b[1],this._lwidth=b[2],this._lheight=b[3],this._hasLocalPos=!0,this._width=this._lwidth,this._height=this._lheight):(this._width=this._data.width,this._height=this._data.height)},duplicate:function(){var a=new g.Image;a._setData(this._data);return a},changeScale:function(a,b){return this.changeSize(this._width*a,this._height*b)},changeSize:function(a,b){var c=document.createElement("canvas"),d=0,e=0,f=this._width,i=this._height;c.width=a;c.height=
b;if(this._hasLocalPos)d=this._lx,e=this._ly,f=this._lwidth,i=this._lheight,this._hasLocalPos=!1;if(arc.ua.isAndroid2_1&&320!=v())var g=320/v(),d=~~(d*g),e=~~(e*g),f=~~(f*g),i=~~(i*g),a=~~(a*g),b=~~(b*g);c.getContext("2d").drawImage(this._data,d,e,f,i,0,0,a,b);this._data=c;this._width=this._data.width;this._height=this._data.height;return this},changeColor:function(a,b){var c=this._data.width,d=this._data.height,e=document.createElement("canvas");e.width=c;e.height=d;var f=e.getContext("2d");f.drawImage(this._data,
0,0);for(var i=f.getImageData(0,0,c,d),g=f.createImageData(c,d),k=a>>16,h=a>>8&255,l=a&255,o=0;o<d;o++)for(var n=0;n<c;n++){var j=4*n+4*o*c;g.data[j]=(k-i.data[j])*b+i.data[j];g.data[j+1]=(l-i.data[j+1])*b+i.data[j+1];g.data[j+2]=(h-i.data[j+2])*b+i.data[j+2];g.data[j+3]=i.data[j+3]}f.putImageData(g,0,0);this._data=e;return this},draw:function(a,b,c){if(this._hasLocalPos)this.drawCrop(this._lx,this._ly,this._lwidth,this._lheight,a,b,this._width,this._height,c);else{if(arc.ua.isAndroid2_1&&320!=v())var d=
320/v(),a=a*d,b=b*d;a=~~a;b=~~b;d=g.Image.context;d.save();d.translate(a,b);0!=c%360&&d.rotate(c);d.drawImage(this._data,0,0);d.restore()}},drawSize:function(a,b,c,d,e){if(this._hasLocalPos)this.drawCrop(this._lx,this._ly,this._lwidth,this._lheight,a,b,c,d,e);else{var f=c/this._width,i=d/this._height,h=g.Image.context;arc.ua.isAndroid2_1?(e=320/v(),h.drawImage(this._data,~~(a*e),~~(b*e),~~(c*e),~~(d*e))):(a=~~a,b=~~b,h.save(),h.translate(a,b),0!=e%360&&h.rotate(e*Math.PI/180),(1!=f||1!=i)&&h.scale(f,
i),h.drawImage(this._data,0,0,this._width,this._height),h.restore())}},drawCrop:function(a,b,c,d,e,f,i,h,k){this._hasLocalPos&&this._frameWidth&&(a+=this._lx,b+=this._ly);var t=this._frameWidth?this._frameWidth:this._width,l=i/t,o=h/this._height,n=g.Image.context;arc.ua.isAndroid2_1?(k=320/v(),this._data.constructor!=HTMLCanvasElement&&(a=~~(a*k),b=~~(b*k),c=~~(c*k),d=~~(d*k)),n.drawImage(this._data,a,b,c,d,~~(e*k),~~(f*k),~~(i*k),~~(h*k))):(a=~~a,b=~~b,c=~~c,d=~~d,e=~~e,f=~~f,n.save(),n.translate(e,
f),0!=k%360&&n.rotate(k*Math.PI/180),(1!=l||1!=o)&&n.scale(l,o),n.drawImage(this._data,a,b,c,d,0,0,t,this._height),n.restore())},setFrameWidth:function(a){this._frameWidth=a},getFrameWidth:function(){return this._frameWidth},getWidth:function(){return this._width},getHeight:function(){return this._height},getPath:function(){return this._path}});g.Image.context=null;g.DisplayObject=m.create(r,{_data:null,_parent:null,_x:0,_y:0,_width:null,_height:null,_visible:!0,_scaleX:1,_scaleY:1,_alpha:1,_rotation:0,
_alignX:0,_alignY:0,initialize:function(a){if(a)this._data=a,this._width=this._data.getWidth(),this._height=this._data.getHeight()},localToGlobal:function(a,b){for(var c=this,d=a,e=b,f=0,i=0;c;)d=x(d,e,c.getRotation()),f+=d[0],i+=d[1],d=c.getX(),e=c.getY(),c=c.getParent();return[f,i]},globalToLocal:function(a,b){for(var c=[],d=this,e=a,f=b;d;)c.unshift(d),d=d.getParent();for(d=0;d<c.length;d++)var i=c[d],e=e-i.getX(),f=f-i.getY(),e=x(e,f,-1*i.getRotation()),f=e[1],e=e[0];return[e,f]},hitTestObject:function(){},
draw:function(){},setX:function(a){this._x=a},getX:function(){return this._x},setY:function(a){this._y=a},getY:function(){return this._y},setWidth:function(a){a||(a=0);this._width=a;if(this._data)this._scaleX=this._width/this._data.getWidth()},getWidth:function(){return this._width},setHeight:function(a){a||(a=0);this._height=a;if(this._data)this._scaleY=this._height/this._data.getHeight()},getHeight:function(){return this._height},setScaleX:function(a){a||(a=0);this._scaleX=a;this._width=this._data.getWidth()*
this._scaleX},getScaleX:function(){return this._scaleX},setScaleY:function(a){a||(a=0);this._scaleY=a;this._height=this._data.getHeight()*this._scaleY},getScaleY:function(){return this._scaleY},setVisible:function(a){this._visible=a},getVisible:function(){return this._visible},getParent:function(){return this._parent},setAlpha:function(a){a||(a=0);this._alpha=a},getAlpha:function(){return this._alpha},setRotation:function(a){a||(a=0);this._rotation=a},getRotation:function(){return this._rotation},
getAlignX:function(){return this._alignX},getAlignY:function(){return this._alignY}});g.DisplayObjectContainer=m.create(g.DisplayObject,{_displayArr:null,_originWidth:0,_originHeight:0,_maskObj:null,initialize:function($super){$super(null);this._displayArr=[]},addChild:function(a){for(var b=this._displayArr.length,c=0;c<b;c++)if(this._displayArr[c]==a)return;this._displayArr.push(a);a._parent=this;this._updateSize()},addChildAt:function(a,b){this._displayArr.splice(b,0,a);a._parent=this;this._updateSize()},
removeChild:function(a){for(var b=this._displayArr.length,c=0;c<b;c++)if(this._displayArr[c]==a){this._displayArr.splice(c,1);a._parent=null;a._removeAllChild&&a._removeAllChild();break}this._updateSize()},_removeAllChild:function(){var a,b,c;for(a=0,b=this._displayArr.length;a<b;a++)c=this._displayArr[a],c._parent=null,c._removeAllChild&&c._removeAllChild();this._displayArr=[]},contains:function(a){for(var b=this._displayArr.length,c=0;c<b;c++)if(this._displayArr[c]==a)return!0;return!1},draw:function(a,
b,c,d,e,f){if(this.getVisible()){for(var a=a|0,b=b|0,c=!isNaN(c)?c:1,d=!isNaN(d)?d:1,e=!isNaN(e)?e:1,c=c*this._scaleX,d=d*this._scaleY,e=e*this._alpha,f=(f?f:0)+this._rotation,i=g.Image.context,h=y(this._displayArr),k=h.length,t=0;t<k;t++){var l=h[t],o=l.getX()*c,n=l.getY()*d;if(0!=f%360)var j=x(o,n,f),o=j[0],n=j[1];var j=l.getAlignX()*c*l.getScaleX(),m=l.getAlignY()*d*l.getScaleY(),j=x(j,m,l.getRotation()+f),o=o+(j[0]+a),n=n+(j[1]+b);l.getVisible()&&(this._maskObj&&(i.save(),i.beginPath(),i.rect(this._maskObj.x*
c+a,this._maskObj.y*d+b,this._maskObj.width*c,this._maskObj.height*d),i.closePath(),i.clip()),l.draw(o,n,c,d,e,f),this._maskObj&&i.restore())}this._updateSize()}},_updateSize:function(){for(var a=0,b=0,c=0,d=0,e=this._displayArr.length,f=0;f<e;f++){var i=this._displayArr[f];0==f&&(a=i.getX(),b=i.getY(),c=i.getX()+i.getWidth(),d=i.getY()+i.getHeight());i.getX()<a&&(a=i.getX());i.getX()+i.getWidth()>c&&(c=i.getX()+i.getWidth());i.getY()<b&&(b=i.getY());i.getY()+i.getHeight()>d&&(d=i.getY()+i.getHeight())}this._originWidth=
c-b;this._originHeight=d-b;this._width=this._originWidth*this._scaleX;this._height=this._originHeight*this._scaleY},setWidth:function(a){this._width=a;this._scaleX=this._width/this._originWidth},setHeight:function(a){this._height=a;this._scaleY=this._height/this._originHeight},setScaleX:function(a){this._scaleX=a;this._width=this._originWidth*this._scaleX},setScaleY:function(a){this._scaleY=a;this._height=this._originHeight*this._scaleY},setMask:function(a,b,c,d){this._maskObj={x:a,y:b,width:c,height:d}},
clearMask:function(){this._maskObj=null}});g.Align={TOP:"TOP",TOP_LEFT:"TOP_LEFT",TOP_RIGHT:"TOP_RIGHT",CENTER:"CENTER",LEFT:"LEFT",RIGHT:"RIGHT",BOTTOM:"BOTTOM",BOTTOM_LEFT:"BOTTOM_LEFT",BOTTOM_RIGHT:"BOTTOM_RIGHT"};g.Shape=m.create(g.DisplayObject,{_funcStuck:null,_minX:0,_maxX:0,_minY:0,_maxY:0,_firstFlg:!0,_willBeFilled:!1,_willBeStroked:!1,initialize:function(){this._funcStuck=[]},beginFill:function(a,b){var c=this;this._funcStuck.push(function(d,e,f,i,h){c._willBeFilled=!0;d=g.Image.context;
d.fillStyle=z(a);d.globalAlpha=b*h})},endFill:function(){var a=this;this._funcStuck.push(function(){a._willBeFilled=!1})},beginStroke:function(a,b,c){var d=this;c||(c=1);this._funcStuck.push(function(e,f,i,h,k){d._willBeStroked=!0;e=g.Image.context;e.lineWidth=a;e.strokeStyle=z(b);e.globalAlpha=c*k})},endStroke:function(){var a=this;this._funcStuck.push(function(){a._willBeStroked=!1})},moveTo:function(a,b){this._funcStuck.push(function(c,d,e,f){g.Image.context.moveTo((a+c)/e,(b+d)/f)})},lineTo:function(a,
b){var c=this;this._funcStuck.push(function(d,e,f,i){var h=g.Image.context;h.lineTo((a+d)/f,(b+e)/i);c._willBeStroked&&h.stroke()})},drawRect:function(a,b,c,d){if(this._firstFlg)this._firstFlg=!1,this._minX=a,this._maxX=a+c,this._minY=b,this._maxY=b+d;if(a<this._minX)this._minX=a;if(a+c>this._maxX)this._maxX=a+c;if(b<this._minY)this._minY=b;if(b+d>this._maxY)this._maxY=b+d;this._width=this._maxX-this._minX;this._height=this._maxY-this._minY;var e=this;this._funcStuck.push(function(f,i,h,k){var t=
g.Image.context;t.beginPath();t.rect((a+f)/h,(b+i)/k,c,d);e._willBeFilled&&t.fill();e._willBeStroked&&t.stroke()})},drawCircle:function(a,b,c){if(this._firstFlg)this._firstFlg=!1,this._minX=a-c/2,this._maxX=a+c/2,this._minY=b-c/2,this._maxY=b+c/2;if(a-c/2<this._minX)this._minX=a-c/2;if(a+c/2>this._maxX)this._maxX=a+c/2;if(b-c/2<this._minY)this._minY=b-c/2;if(b+c/2>this._maxY)this._maxY=b+c/2;this._width=this._maxX-this._minX;this._height=this._maxY-this._minY;var d=this;this._funcStuck.push(function(e,
f,i,h){var k=g.Image.context;k.beginPath();k.arc((a+e)/i,(b+f)/h,c,0,360,!1);d._willBeFilled&&k.fill();d._willBeStroked&&k.stroke()})},draw:function(a,b,c,d,e,f){var a=a|0,b=b|0,c=!isNaN(c)?c:1,d=!isNaN(d)?d:1,e=!isNaN(e)?e:1,a=a+this._x*c,b=b+this._y*d,c=c*this._scaleX,d=d*this._scaleY,e=e*this._alpha,f=(f?f:0)+this._rotation,i=this._funcStuck.length,h=g.Image.context;h.save();h.scale(c,d);for(var k=0;k<i;k++)this._funcStuck[k].call(this,a,b,c,d,e,f);h.restore()},setWidth:function(a){this._scaleX=
a/this._width},getWidth:function(){return this._width*this._scaleX},setHeight:function(a){this._scaleY=a/this._height},getHeight:function(){return this._height*this._scaleY},setScaleX:function(a){this._scaleX=a},setScaleY:function(a){this._scaleY=a}});g.ImageContainer=m.create(g.DisplayObject,{_align:g.Align.TOP_LEFT,_alignX:0,_alignY:0,initialize:function(){},setAlign:function(a){var b=this._data.getFrameWidth()?this._data.getFrameWidth():this._data.getWidth();switch(a){case g.Align.TOP:this._alignX=
-1*b/2;this._alignY=0;break;case g.Align.TOP_LEFT:this._alignY=this._alignX=0;break;case g.Align.TOP_RIGHT:this._alignX=-1*b;this._alignY=0;break;case g.Align.CENTER:this._alignX=-1*b/2;this._alignY=-1*this._data.getHeight()/2;break;case g.Align.LEFT:this._alignX=0;this._alignY=-1*this._data.getHeight()/2;break;case g.Align.RIGHT:this._alignX=-1*b;this._alignY=-1*this._data.getHeight()/2;break;case g.Align.BOTTOM:this._alignX=-1*b/2;this._alignY=-1*this._data.getHeight();break;case g.Align.BOTTOM_LEFT:this._alignX=
0;this._alignY=-1*this._data.getHeight();break;case g.Align.BOTTOM_RIGHT:this._alignX=-1*b;this._alignY=-1*this._data.getHeight();break;default:throw Error("Specify align");}this._align=a},getAlign:function(){return this._align}});g.Sprite=m.create(g.ImageContainer,{initialize:function(){},draw:function(a,b,c,d,e,f){var a=a|0,b=b|0,c=!isNaN(c)?c:1,d=!isNaN(d)?d:1,e=!isNaN(e)?e:1,f=this._rotation+(f?f:0),i=g.Image.context;i.globalAlpha=this._alpha*e;this._data.drawSize(a,b,this._width*c,this._height*
d,f);i.globalAlpha=1}});g.MovieClip=m.create(g.DisplayObjectContainer,{_shouldLoop:!1,_fps:0,_timer:null,_currentFrame:0,_isPlaying:!1,_isShowed:!1,_timelineArr:null,_totalFrame:0,_shouldAutoPlay:!1,initialize:function(a,b,c){this._fps=a;this._shouldLoop=b;this._timer=new q;this._currentFrame=1;this._timelineArr=[];this._totalFrame=0;this._shouldAutoPlay=void 0==c?!0:c},draw:function($super,b,c,d,e,f,i){if(!this._isShowed&&this._shouldAutoPlay)this._isShowed=!0,this.play();this._isPlaying&&this._update();
$super(b,c,d,e,f,i)},_update:function(){var a=this._timer.getElapsed();a>=1E3/this._fps&&(this._step(),a=this._timer.getElapsed());for(var b=0;b<this._timelineArr.length;b++)this._timelineArr[b].update(this._currentFrame,a)},_step:function(){this._timer.reset();this._currentFrame++;this._executeKeyFrame(this._currentFrame);if(this._currentFrame==this._totalFrame)this._shouldLoop?this._currentFrame=0:this.stop()},_executeKeyFrame:function(a){for(var b,c,d=0,e=this._timelineArr.length;d<e;d++)b=this._timelineArr[d],
c=b.getTarget(),a==b.getFirstFrame()&&c.gotoAndPlay&&c.gotoAndPlay(1),b.executeKeyFrame(a)},removeChild:function($super,b){$super(b);this._isPlaying=!1;this._timer.stop();for(var c=0,d=this._timelineArr.length;c<d;c++)if(this._timelineArr[c].getTarget()===b){this._timelineArr.splice(c,1);break}},_setTimeline:function(a,b){timeline=new u.Timeline(a,b,this._fps);this._timelineArr.push(timeline);totalFrame=timeline.getTotalFrames();if(this._totalFrame<totalFrame)this._totalFrame=totalFrame},addChild:function($super,
b,c){$super(b);c&&this._setTimeline(b,c)},addChildAt:function($super,b,c,d){$super(b,c);d&&this._setTimeline(b,d)},play:function(){this._isPlaying=!0;this._timer.start();this._executeKeyFrame(this._currentFrame)},stop:function(){this._isPlaying=!1;this._timer.stop()},gotoAndPlay:function(a){if(1>a||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.play()},gotoAndStop:function(a){if(1>a||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.stop()}});
g.JSONMovieClip=m.create(g.MovieClip,{initialize:function($super,b){function c(b,g){var h,l,o,n,j;for(h=0,o=f.length;h<o&&!(l=f[h],l.id==b);h++);if(!l)throw Error("invalid animation");if("data"==l.type)return l.pos?new d(arc._system.getImage(l.data,l.pos)):new d(arc._system.getImage(l.data));g||(g=new e(i,l.loop));for(h=0,o=l.timelines.length;h<o;h++)n=l.timelines[h],j=c(n.target),j.constructor===d&&n.align&&j.setAlign(n.align),g.addChildAt(j,0,n.keyframes);return g}var d=arc.display.Sprite,e=arc.display.MovieClip,
f=b.lib,i=b.fps;$super(i);c(b.main,this)}});g.SheetMovieClip=m.create(g.ImageContainer,{_currentFrame:1,_totalFrame:1,_frameWidth:0,_frameTime:0,_isPlaying:!1,_timer:null,_shouldLoop:!1,_shouldHide:!1,initialize:function(a,b,c,d,e){this._timer=new q;this._frameWidth=b;this._totalFrame=Math.floor(this._data.getWidth()/b);this._width=b;this._frameTime=1E3/c;this._shouldLoop=d;this._shouldHide=e;this._data.setFrameWidth(this._frameWidth);if(this._shouldHide)this._visible=!1;this.stop()},play:function(a){this._isPlaying=
!0;if(void 0!=a)this._shouldLoop=a;if(this._shouldHide&&!this._visible)this._visible=!0;this._timer.start()},stop:function(){this._isPlaying=!1;this._timer.stop();if(this._shouldHide)this._visible=!1},gotoAndPlay:function(a){if(1>a||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.play()},gotoAndStop:function(a){if(1>a||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.stop()},draw:function(a,b,c,d,e,f){a|=0;b|=0;c=!isNaN(c)?c:1;d=!isNaN(d)?
d:1;isNaN(e);f=f?f:0;if(this._visible){if(this._isPlaying&&this._timer.getElapsed()>=this._frameTime&&(this._currentFrame++,this._timer.reset(),this._currentFrame>this._totalFrame))this._shouldLoop?this._currentFrame%=this._totalFrame:(this._currentFrame=this._totalFrame,this.stop(),this.dispatchEvent(h.COMPLETE));e=this._rotation+f;f=g.Image.context;f.globalAlpha=this._alpha;this._data.drawCrop((this._currentFrame-1)*this._frameWidth,0,this._frameWidth,this._data.getHeight(),a,b,this._width*c,this._height*
d,e);f.globalAlpha=1}},setWidth:function(a){this._width=a;this._scaleX=this._width/this._frameWidth},setScaleX:function(a){this._scaleX=a;this._width=this._frameWidth*this._scaleX}});g.SequenceMovieClip=m.create(g.DisplayObjectContainer,{_spriteArr:null,_frameTime:0,_shouldLoop:!1,_shouldHide:!1,_isPlaying:!1,_totalFrame:0,_currentIndex:0,_timer:null,initialize:function(a,b,c,d){var e=0,f=a.length;this._spriteArr=[];this._frameTime=b;this._shouldLoop=c;this._shouldHide=d;this._totalFrame=a.length;
this._timer=new q;for(e=0;e<f;e++)b=new g.Sprite(a[e]),b.setVisible(!1),this._spriteArr.push(b),this.addChild(b);if(d)this._visible=!1},draw:function($super,b,c,d,e,f,g){$super(b,c,d,e,f,g);b=this._spriteArr.length;if(this._isPlaying){c=Math.floor(this._timer.getElapsed()/this._frameTime);if(c>this._totalFrame-1)this._shouldLoop?c%=this._totalFrame:(c=this._totalFrame,this.stop(),this.dispatchEvent(h.COMPLETE));this._currentFrame=c}for(c=0;c<b;c++)d=this._spriteArr[c],c==this._currentFrame?d.setVisible(!0):
d.setVisible(!1)},play:function(a){this._isPlaying=!0;if(a)this._shouldLoop=a;if(this._shouldHide&&!this._visible)this._visible=!0;this._timer.start()},stop:function(){this._isPlaying=!1;this._timer.stop();if(this._shouldHide)this._visible=!1},gotoAndPlay:function(a){if(1>a||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.play()},gotoAndStop:function(a){if(1>a||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.stop()}});g.TextField=m.create(g.DisplayObject,
{_font:null,_family:"sans-serif",_textArr:null,_color:0,_align:"left",_baseline:"top",_size:10,initialize:function(){if(p.isiOS3)throw Error("Your can't use TextField in iOS3");this._font=this._size+"px "+this._family;this._textArr=[]},draw:function(a,b,c,d,e){a|=0;b|=0;isNaN(c);isNaN(d);e=!isNaN(e)?e:1;c=g.Image.context;c.globalAlpha=this._alpha*e;c.save();c.fillStyle=z(this._color);c.textBaseline="top";c.font=this._font;c.textAlign=this._align;c.textBaseline=this._baseline;e=0;for(d=this._textArr.length;e<
d;e++)c.fillText(this._textArr[e],a,b),b+=this._size;c.restore();c.globalAlpha=1},setAlign:function(a){switch(a){case g.Align.TOP:this._align="center";this._baseline="top";break;case g.Align.TOP_LEFT:this._align="left";this._baseline="top";break;case g.Align.TOP_RIGHT:this._align="right";this._baseline="top";break;case g.Align.CENTER:this._align="center";this._baseline="middle";break;case g.Align.LEFT:this._align="left";this._baseline="middle";break;case g.Align.RIGHT:this._align="right";this._baseline=
"middle";break;case g.Align.BOTTOM:this._align="center";this._baseline="bottom";break;case g.Align.BOTTOM_LEFT:this._align="left";this._baseline="bottom";break;case g.Align.BOTTOM_RIGHT:this._align="right";this._baseline="bottom";break;default:throw Error("Specify align");}},setText:function(a){a instanceof String||(a=""+a);this._textArr=a.split("\n");this._width&&this._adjustWidth()},_adjustWidth:function(){var a=g.Image.context;a.font=this._font;for(var b=0;b<this._textArr.length;b++){var c=this._textArr[b],
d=a.measureText(c);if(!(d.width<=this._width))for(var e=0,f=c.length;e<f;e++)if(d=c.substr(0,e+1),d=a.measureText(d),d.width>this._width){this._textArr[b]=c.substr(0,e);this._textArr.splice(b+1,0,c.substr(e));break}}},setFont:function(a,b,c){this._family=a;this._size=b;this._font=b+"px "+a;if(c)this._font="bold "+this._font;this._textArr.length&&this._width&&this._adjustWidth()},setColor:function(a){this._color=a}});var u={};u.Animation=m.create(r,{_timer:null,_target:null,_system:null,_animObjArr:null,
_shouldReplay:!1,_isPlaying:!1,_currentIndex:0,_currentAnim:null,_currentTransFunc:null,_firstParams:null,_currentDuration:null,_updateFunc:null,_HALF_PI:Math.PI/2,initialize:function(a){if(!a)throw Error("Specify target");if(2>arguments.length)throw Error("Specify Animaiton Objects");this._target=a;this._timer=new q;this._animObjArr=[];for(var b=1;b<arguments.length;b++)this._animObjArr.push(arguments[b])},play:function(a){if(!this._isPlaying){var b=u.Animation.system;this._isPlaying=!0;this._shouldReplay=
a;this._timer.start();this._currentIndex=-1;if(this._changeAnim())this._updateFunc&&b.removeEventListener(h.ENTER_FRAME,this._updateFunc),this._updateFunc=s(this._update,this),b.addEventListener(h.ENTER_FRAME,this._updateFunc)}},stop:function(){if(this._isPlaying){var a=u.Animation.system;this._isPlaying=!1;if(this._updateFunc)a.removeEventListener(h.ENTER_FRAME,this._updateFunc),this._updateFunc=null;this.dispatchEvent(h.COMPLETE)}},_changeAnim:function(){this._currentIndex++;if(this._currentIndex>=
this._animObjArr.length)if(this._shouldReplay)this._currentIndex=0;else return this.stop(),!1;this._timer.reset();var a=this._animObjArr[this._currentIndex];this._currentAnim={};this._firstParams={};for(var b in a)"time"==b||"transition"==b||(this._currentAnim[b]=a[b],this._firstParams[b]=this._getProperty(this._target,b));this._currentDuration=void 0==a.time?1E3:a.time;this._currentTransFunc=u.Transition.getTransFunc(a.transition);return!0},_getProperty:function(a,b){b.match(/^([a-z])(.*)/);var c=
"get"+RegExp.$1.toUpperCase()+RegExp.$2;if(a[c])return a[c]()},_setProperty:function(a,b,c){b.match(/^([a-z])(.*)/);b="set"+RegExp.$1.toUpperCase()+RegExp.$2;if(a[b])a[b](c)},_update:function(){var a=this._timer.getElapsed(),b=this._currentTransFunc(a/this._currentDuration);if(a>=this._currentDuration){for(var c in this._currentAnim)this._setProperty(this._target,c,this._currentAnim[c]);this._changeAnim()&&this._update()}else for(c in this._currentAnim)a=(this._currentAnim[c]-this._firstParams[c])*
b+this._firstParams[c],"visible"==c&&(a=this._firstParams[c]),this._setProperty(this._target,c,a)},isPlaying:function(){return this._isPlaying}});u.Animation.system=null;(function(a){function b(a){return a}function c(a){return 1-Math.cos(a*m)}function d(a){return 1-c(1-a)}function e(a){return 1-Math.sqrt(1-a*a)}function f(a){return 1-e(1-a)}function g(a){return 0.5>a?0.5*e(2*a):1-0.5*e(2-2*a)}function h(a){return a*a*a}function k(a){return 1-h(1-a)}function t(a){return 0.5>a?0.5*h(2*a):1-0.5*h(2-
2*a)}function l(a){return 1-o(1-a)}function o(a){var b=1-a;return 1-Math.pow(b,8)+Math.sin(6*a*a*Math.PI)*b*b}function n(a){return 0.5>a?0.5*l(2*a):1-0.5*l(2-2*a)}var j={SINE_IN:"SINE_IN",SINE_OUT:"SINE_OUT",SINE_INOUT:"SINE_INOUT",LINEAR:"LINEAR",CIRC_IN:"CIRC_IN",CIRC_OUT:"CIRC_OUT",CIRC_INOUT:"CIRC_INOUT",CUBIC_IN:"CUBIC_IN",CUBIC_OUT:"CUBIC_OUT",CUBIC_INOUT:"CIRC_INOUT",ELASTIC_IN:"ELASTIC_IN",ELASTIC_OUT:"ELASTIC_OUT",ELASTIC_INOUT:"ELASTIC_INOUT",getTransFunc:function(a){switch(a){case j.LINEAR:return b;
case j.SINE_IN:return c;case j.SINE_OUT:return d;case j.SINE_INOUT:return getSinInOut;case j.CIRC_IN:return e;case j.CIRC_OUT:return f;case j.CIRC_INOUT:return g;case j.CUBIC_IN:return h;case j.CUBIC_OUT:return k;case j.CUBIC_INOUT:return t;case j.ELASTIC_IN:return l;case j.ELASTIC_OUT:return o;case j.ELASTIC_INOUT:return n;default:return b}}},m=Math.PI/2;a.Transition=j})(u);u.Timeline=m.create({_target:null,_keyFrameObj:null,_totalFrame:0,_fps:0,_baseFrame:null,_firstFrame:0,initialize:function(a,
b,c){this._target=a;this._keyFrameObj=b;if(c)this._fps=c;for(var d in this._keyFrameObj){a=b[d];c=parseInt(d,10);if(0==this._firstFrame||this._firstFrame>c)this._firstFrame=c;a.index=d;a=parseInt(d,10);if(this._totalFrame<a)this._totalFrame=a}},update:function(a,b){if(this._baseFrame&&this._baseFrame.transition&&this._baseFrame.nextFrame){var b=b+1E3*(a-this._baseFrame.index)/this._fps,c=1E3*(this._baseFrame.nextFrame.index-this._baseFrame.index)/this._fps,c=u.Transition.getTransFunc(this._baseFrame.transition)(b/
c),d;for(d in this._baseFrame)if(!("transition"==d||"action"==d||"index"==d||"nextFrame"==d||void 0==this._baseFrame.nextFrame[d])){var e=(this._baseFrame.nextFrame[d]-this._baseFrame[d])*c+this._baseFrame[d];"visible"==d&&(e=this._baseFrame[d]);this._setProperty(this._target,d,e)}}},executeKeyFrame:function(a){var b=this._keyFrameObj[a];if(b){this._baseFrame=b;for(var c in b)"transition"==c||"action"==c||"index"==c||"nextFrame"==c||this._setProperty(this._target,c,b[c]);b.action&&b.action instanceof
Function&&b.action.apply(this._target);if(b.transition&&!b.nextFrame)for(;a<=this._totalFrame;)if(a++,this._keyFrameObj[a]){a=this._keyFrameObj[a];for(c in a)b[c]||(b[c]=this._getProperty(this._target,c));b.nextFrame=a;break}}},setTotalFrames:function(a){this._totalFrame=a},getTotalFrames:function(){return this._totalFrame},setFps:function(a){this._fps=a},getTarget:function(){return this._target},getFirstFrame:function(){return this._firstFrame},_getProperty:function(a,b){b.match(/^([a-z])(.*)/);
var c="get"+RegExp.$1.toUpperCase()+RegExp.$2;if(a[c])return a[c]()},_setProperty:function(a,b,c){b.match(/^([a-z])(.*)/);b="set"+RegExp.$1.toUpperCase()+RegExp.$2;if(a[b])a[b](c)}});u.KeyFrameAnimation=m.create(r,{_fps:0,_totalFrame:0,_timelineArr:null,_timer:null,_updateFunc:null,_shouldLoop:!1,_currentFrame:1,initialize:function(a,b,c){this._fps=a;this._totalFrame=b;this._timer=new q;for(a=0;a<c.length;a++){var d=c[a];if(d.constructor!=u.Timeline)throw Error("set an instance of anim.Timeline");
d.setTotalFrames(b);d.setFps(this._fps)}this._timelineArr=c?c:[]},addTimeline:function(a){this._timelineArr.push(a)},play:function(a){this.gotoAndPlay(1,a)},stop:function(){var a=u.Animation.system;if(this._updateFunc)a.removeEventListener(h.ENTER_FRAME,this._updateFunc),this._updateFunc=null;this.dispatchEvent(h.COMPLETE)},gotoAndPlay:function(a,b){if(a>this._totalFrame)throw Error("invalid frame index");if(b)this._shouldLoop=b;this._updateFunc=s(this._update,this);this._currentFrame=a;this._executeKeyFrame(this._currentFrame);
this._timer.start();u.Animation.system.addEventListener(h.ENTER_FRAME,this._updateFunc)},_update:function(){var a=this._timer.getElapsed();a>=1E3/this._fps&&(this._step(),a=this._timer.getElapsed());for(var b=0;b<this._timelineArr.length;b++)this._timelineArr[b].update(this._currentFrame,a)},_step:function(){this._timer.reset();this._currentFrame++;this._executeKeyFrame(this._currentFrame);if(this._currentFrame==this._totalFrame)this._shouldLoop?this._currentFrame=0:this.stop()},_executeKeyFrame:function(a){for(var b=
0;b<this._timelineArr.length;b++)this._timelineArr[b].executeKeyFrame(a)},getCurrentFrame:function(){return this._currentFrame},getTotalFrame:function(){return this._totalFrame}});var A=m.create(r,function(){function a(a){a.target.onload=null;a.target.onerror=null;this._loadedImgNum++;this.dispatchEvent(h.PROGRESS);this._loadedImgNum==this._loadImgNum&&this.dispatchEvent(h.COMPLETE)}function b(a){var b,e,f;for(b=0,e=this._loadingImgArr.length;b<e;b++)f=this._loadingImgArr[b],f.onload=null,f.onerror=
null;this.dispatchEvent(h.ERROR);throw Error("Load Error : "+a.target.src);}return{initialize:function(){this._loadedImgNum=this._loadImgNum=0;this._imageHash={};this._loadingImgArr=[];this._srcArr=[]},load:function(c){this._srcArr=c;this._loadedImgNum=0;this._loadImgNum=c.length;this._loadingImgArr=[];if(0===d)this.dispatchEvent(h.COMPLETE);else{for(var c=0,d=this._srcArr.length;c<d;c++){var e=this._srcArr[c],f;if(e.constructor==HTMLImageElement)f=e,f.complete?a.call(this,{target:f}):(e.onload=s(a,
this),e.onerror=s(b,this));else if(e.constructor==String)f=document.createElement("img"),f.src=e,f.onload=s(a,this),f.onerror=s(b,this),this._imageHash[e]=f;this._loadingImgArr.push(f)}this._srcArr=[]}},getImage:function(a,b){return!this._imageHash[a]?null:b&&4==b.length?new g.Image(this._imageHash[a],b):new g.Image(this._imageHash[a])},getTotal:function(){return this._loadImgNum},getLoaded:function(){return this._loadedImgNum}}}()),E=m.create(r,{_fps:60,_originFps:0,_width:0,_height:0,_canvas:null,
_context:null,_disableClearRect:!1,_game:null,_gameClass:null,_gameParams:null,_intervalId:null,_stage:null,_imageManager:null,_realFps:0,_runTime:0,_runCount:0,_prevTime:0,_fpsElem:null,_maxFps:0,_adjustCount:1,_timer:null,_ADJUST_FPS_TIME:1E4,_ADJUST_FACTOR:2.5,initialize:function(a,b,c,d){this._width=a;this._height=b;this._canvas=document.getElementById(c);this._context=this._canvas.getContext("2d");this._stage=new g.DisplayObjectContainer;this._timer=new q;this._disableClearRect=d?!0:!1;this._canvas.width=
this._width;this._canvas.height=this._height;u.Animation.system=this;w.system=this;g.Image.context=this._context;arc._system=this;this._fpsElem=document.getElementById("fps");this._setEvent()},setFullScreen:function(){this._setViewport();p.isiOS?window.addEventListener("orientationchange",s(this._setViewport,this),!0):window.addEventListener("resize",s(this._setViewport,this),!0)},_setViewport:function(){var a,b;b=window.innerWidth;if(b<this._canvas.width)b=this._canvas.width;a=b/this._canvas.width;
this._canvas.style.width=b+"px";this._canvas.style.height=Math.floor(this._canvas.height*a)+"px"},_setEvent:function(){function a(a){return{x:a.pageX-g._canvas.offsetLeft,y:a.pageY-g._canvas.offsetTop}}function b(a,c,d){var e=a.getParent();a.dispatchEvent(c,d);e&&b(e,c,d)}function c(a,b,d){for(var a=a._displayArr,e,f,g,h=a.length-1;0<=h;h--)if(e=a[h],f=e.getX(),g=e.getY(),f<=b&&f+e.getWidth()>=b&&g<=d&&g+e.getHeight()>=d)return e._displayArr?c(e,b,d):e;return null}function d(d){function t(d,e){var f=
a(d),k=c(g._stage,f.x,f.y);(m[e]=k)&&b(k,h.TOUCH_START,{x:f.x,y:f.y})}d.preventDefault();if("mousedown"==d.type)window.addEventListener("mousemove",e,!0),window.addEventListener("mouseup",f,!0),t(d,0);else for(var l=0,o=d.changedTouches.length;l<o;l++){var n=d.changedTouches[l];t(n,n.identifier)}}function e(c){function d(c,e){var f=m[e],g=a(c);f&&b(f,h.TOUCH_MOVE,{x:g.x,y:g.y})}c.preventDefault();if("mousemove"==c.type)d(c,0);else for(var e=0,f=c.changedTouches.length;e<f;e++){var g=c.changedTouches[e];
d(g,g.identifier)}}function f(c){function d(c,e){var f=m[e],g=a(c);delete m[e];f&&b(f,h.TOUCH_END,{x:g.x,y:g.y})}c.preventDefault();if("mouseup"==c.type)window.removeEventListener("mousemove",e,!0),window.removeEventListener("mouseup",f,!0),d(c,0);else for(var g=0,i=c.changedTouches.length;g<i;g++){var n=c.changedTouches[g];d(n,n.identifier)}}var g=this,m={};p.isMobile?(this._canvas.addEventListener("touchstart",d,!0),this._canvas.addEventListener("touchmove",e,!0),this._canvas.addEventListener("touchend",
f,!0)):this._canvas.addEventListener("mousedown",d,!0)},load:function(a){if(!this._imageManager)this._imageManager=new A;this._imageManager.addEventListener(h.PROGRESS,s(this._loading,this));this._imageManager.addEventListener(h.COMPLETE,s(this._loaded,this));this._imageManager.load(a)},_loading:function(){this.dispatchEvent(h.PROGRESS,{total:this._imageManager.getTotal(),loaded:this._imageManager.getLoaded()})},_loaded:function(){this._imageManager.removeEventListener(h.PROGRESS);this._imageManager.removeEventListener(h.COMPLETE);
this.dispatchEvent(h.COMPLETE);this.start()},setGameClass:function(a,b){this._gameClass=a;this._gameParams=b},start:function(){this._game=new this._gameClass(this._gameParams,this);this._stage.addChild(this._game);q.tick();this._prevTime=q.time;this._timer.start();this._intervalId=setInterval(s(this.run,this),1E3/this._fps)},stop:function(){clearInterval(this._intervalId)},run:function(){q.tick();this._runTime+=q.time-this._prevTime;this._runCount++;if(1E3<=this._runTime){this._realFps=1E3*this._runCount/
this._runTime;this._runCount=this._runTime=0;if(this._fpsElem)this._fpsElem.innerHTML=this._realFps;if(this._realFps>this._maxFps)this._maxFps=this._realFps}this._prevTime=q.time;this._disableClearRect||this._context.clearRect(0,0,this._width,this._height);this._game.update();this._stage.draw();this.dispatchEvent(h.ENTER_FRAME)},getWidth:function(){return this._width},getHeight:function(){return this._height},getImage:function(a,b){return this._imageManager.getImage(a,b)},getCanvas:function(){return this._canvas},
getStage:function(){return this._stage},getFps:function(){return this._realFps}}),F=m.create(g.DisplayObjectContainer,{_system:null,initialize:function(a,b){this._system=b},update:function(){}});window.addEventListener("load",function(){1>=window.pageYOffset&&setTimeout(function(){scrollTo(0,1)},10)},!1);B.arc={ua:p,display:g,anim:u,util:C,Class:m,Event:h,EventDispatcher:r,Timer:q,CountTimer:w,Ajax:D,ImageManager:A,System:E,Game:F}})(window);