forked from Arcticjs/Arctic.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arctic.min.js
72 lines (72 loc) · 35.8 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
(function(B){function r(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 window.orientation==90||window.orientation==-90?screen.height:screen.width}var C={trace:function(){try{if(arguments.length==1)console.log(arguments[0]);
else{for(var a="",b=0;b<arguments.length;b++)b!=0&&(a+=","),a+=arguments[b];console.log(a)}}catch(c){}},bind:r,copyArray:y},o={};o.isiPhone=/iPhone/i.test(navigator.userAgent);o.isiPhone4=o.isiPhone&&window.devicePixelRatio==2;o.isiPad=/iPad/i.test(navigator.userAgent);o.isiOS=o.isiPhone||o.isiPad;o.isiOS3=(o.isiPhone||o.isiPad)&&/OS\s3/.test(navigator.userAgent);o.isAndroid=/android/i.test(navigator.userAgent);o.isAndroid2_1=/android\s2\.1/i.test(navigator.userAgent);o.isMobile=o.isiOS||o.isAndroid;
var i=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 a.length==1&&!a[0]?[]:a}function d(a,b){var c=function(){var c=this,$super=b!==void 0?function(){return b.apply(c,arguments)}:void 0,d=y(arguments);d.unshift($super);return a.apply(c,d)};c.valueOf=r(a.valueOf,a);c.toString=r(a.toString,
a);return c}var e=typeof arguments[0]=="function"?arguments[0].prototype:{};if(!arguments[0])throw Error("define class");if(typeof arguments[0]=="function")a.prototype=e,b.prototype=new a,Array.prototype.shift.apply(arguments);var g=arguments[0],j;for(j in g){var f=g[j];if(typeof f=="function")if(c(f)[0]=="$super")f=d(f,e[j]);else if(j=="initialize"&&e.initialize)var l=f,f=function(){e.initialize.apply(this,arguments);l.apply(this,arguments)};b.prototype[j]=f}return b.prototype.constructor=b}}}(),
h=i.create({type:null,target:null,initialize:function(a,b){this.type=a;for(var c in b)if(b.hasOwnProperty(c)&&!(c=="type"||c=="target"))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 q=i.create({addEventListener:function(a,b){q.listenHash[a]||(q.listenHash[a]=[]);q.listenHash[a].push({target:this,callback:b})},
removeEventListener:function(a,b){var c=q.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)}c.length==0&&delete q.listenHash[a]}},dispatchEvent:function(a,b){if(q.listenHash[a]){for(var c=[],d=q.listenHash[a],e=0;e<d.length;e++)c[e]=d[e];d=c.length;for(e=0;e<d;e++){var g=c[e];if(g.target==this){var j=new h(a,b);j.target=this;g.callback.call(this,j)}}}}});q.listenHash={};var n=i.create({_startTime:0,_isCounting:!1,initialize:function(){},
start:function(){this._isCounting=!0;this._startTime=n.time},stop:function(){this._isCounting=!1},reset:function(){this._isCounting=!0;this._startTime=n.time},getElapsed:function(){return!this._isCounting&&!this._startTime?0:n.time-this._startTime}});n.time=0;n.tick=function(){n.time=Date.now()};var w=i.create(q,{_timer:null,_currentCount:0,_repeatCount:0,_delay:0,_isRunning:!1,_updateFunc:null,initialize:function(a,b){this._timer=new n;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=r(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=i.create(q,{_method:"GET",_params:null,_url:null,_request:null,_jsonResponse:null,_loadedCallBack:null,initialize:function(){this._request=new XMLHttpRequest;this._loadedCallBack=r(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(this._request.readyState==4)if(this._request.status==200)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}}),f={};f.Image=i.create(q,{_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&&b.length==4?(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 f.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,g=this._width,j=this._height;c.width=a;c.height=b;if(this._hasLocalPos)d=this._lx,e=this._ly,g=this._lwidth,j=this._lheight,
this._hasLocalPos=!1;if(arc.ua.isAndroid2_1&&v()!=320)var f=320/v(),d=~~(d*f),e=~~(e*f),g=~~(g*f),j=~~(j*f),a=~~(a*f),b=~~(b*f);c.getContext("2d").drawImage(this._data,d,e,g,j,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 g=e.getContext("2d");g.drawImage(this._data,0,0);for(var j=g.getImageData(0,0,c,d),f=g.createImageData(c,
d),l=a>>16,h=a>>8&255,p=a&255,u=0;u<d;u++)for(var m=0;m<c;m++){var k=m*4+u*4*c;f.data[k]=(l-j.data[k])*b+j.data[k];f.data[k+1]=(p-j.data[k+1])*b+j.data[k+1];f.data[k+2]=(h-j.data[k+2])*b+j.data[k+2];f.data[k+3]=j.data[k+3]}g.putImageData(f,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&&v()!=320){var d=320/v();a*=d;b*=d}a=~~a;b=~~b;d=f.Image.context;d.save();
d.translate(a,b);c%360!=0&&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 g=c/this._width,j=d/this._height,h=f.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),e%360!=0&&h.rotate(e*Math.PI/180),(g!=1||j!=1)&&h.scale(g,j),h.drawImage(this._data,0,0,this._width,this._height),
h.restore())}},drawCrop:function(a,b,c,d,e,g,j,h,l){this._hasLocalPos&&this._frameWidth&&(a+=this._lx,b+=this._ly);var s=this._frameWidth?this._frameWidth:this._width,p=j/s,u=h/this._height,m=f.Image.context;arc.ua.isAndroid2_1?(l=320/v(),this._data.constructor!=HTMLCanvasElement&&(a=~~(a*l),b=~~(b*l),c=~~(c*l),d=~~(d*l)),m.drawImage(this._data,a,b,c,d,~~(e*l),~~(g*l),~~(j*l),~~(h*l))):(a=~~a,b=~~b,c=~~c,d=~~d,e=~~e,g=~~g,m.save(),m.translate(e,g),l%360!=0&&m.rotate(l*Math.PI/180),(p!=1||u!=1)&&m.scale(p,
u),m.drawImage(this._data,a,b,c,d,0,0,s,this._height),m.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}});f.Image.context=null;f.DisplayObject=i.create(q,{_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,g=0,f=0;c;)d=x(d,e,c.getRotation()),g+=d[0],f+=d[1],d=c.getX(),e=c.getY(),c=c.getParent();return[g,f]},globalToLocal:function(a,b){for(var c=[],d=this,e=a,g=b;d;)c.unshift(d),d=d.getParent();for(d=0;d<c.length;d++){var f=c[d];e-=f.getX();g-=f.getY();e=x(e,g,-1*f.getRotation());g=e[1];e=e[0]}return[e,g]},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}});
f.DisplayObjectContainer=i.create(f.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,g){if(this.getVisible()){a|=0;b|=0;c=!isNaN(c)?c:1;d=!isNaN(d)?d:1;e=!isNaN(e)?
e:1;c*=this._scaleX;d*=this._scaleY;e*=this._alpha;for(var g=(g?g:0)+this._rotation,j=f.Image.context,h=y(this._displayArr),l=h.length,s=0;s<l;s++){var p=h[s],u=p.getX()*c,m=p.getY()*d;if(g%360!=0)var k=x(u,m,g),u=k[0],m=k[1];var k=p.getAlignX()*c*p.getScaleX(),i=p.getAlignY()*d*p.getScaleY(),k=x(k,i,p.getRotation()+g);u+=k[0]+a;m+=k[1]+b;p.getVisible()&&(this._maskObj&&(j.save(),j.beginPath(),j.rect(this._maskObj.x*c+a,this._maskObj.y*d+b,this._maskObj.width*c,this._maskObj.height*d),j.closePath(),
j.clip()),p.draw(u,m,c,d,e,g),this._maskObj&&j.restore())}this._updateSize()}},_updateSize:function(){for(var a=0,b=0,c=0,d=0,e=this._displayArr.length,g=0;g<e;g++){var f=this._displayArr[g];g==0&&(a=f.getX(),b=f.getY(),c=f.getX()+f.getWidth(),d=f.getY()+f.getHeight());f.getX()<a&&(a=f.getX());f.getX()+f.getWidth()>c&&(c=f.getX()+f.getWidth());f.getY()<b&&(b=f.getY());f.getY()+f.getHeight()>d&&(d=f.getY()+f.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}});f.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"};f.Shape=i.create(f.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,g,h,i){c._willBeFilled=!0;d=f.Image.context;d.fillStyle=z(a);d.globalAlpha=b*i})},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,g,h,i,l){d._willBeStroked=!0;e=f.Image.context;e.lineWidth=a;e.strokeStyle=z(b);e.globalAlpha=c*l})},endStroke:function(){var a=this;this._funcStuck.push(function(){a._willBeStroked=!1})},moveTo:function(a,b){this._funcStuck.push(function(c,d,e,g){f.Image.context.moveTo((a+c)/e,(b+d)/g)})},lineTo:function(a,b){var c=this;this._funcStuck.push(function(d,e,g,h){var i=
f.Image.context;i.lineTo((a+d)/g,(b+e)/h);c._willBeStroked&&i.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(g,h,i,l){var s=f.Image.context;s.beginPath();s.rect((a+g)/i,(b+h)/l,c,d);e._willBeFilled&&
s.fill();e._willBeStroked&&s.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,g,h,i){var l=f.Image.context;l.beginPath();l.arc((a+e)/h,(b+g)/i,c,0,
360,!1);d._willBeFilled&&l.fill();d._willBeStroked&&l.stroke()})},draw:function(a,b,c,d,e,g){a|=0;b|=0;c=!isNaN(c)?c:1;d=!isNaN(d)?d:1;e=!isNaN(e)?e:1;a+=this._x*c;b+=this._y*d;c*=this._scaleX;d*=this._scaleY;e*=this._alpha;var g=(g?g:0)+this._rotation,h=this._funcStuck.length,i=f.Image.context;i.save();i.scale(c,d);for(var l=0;l<h;l++)this._funcStuck[l].call(this,a,b,c,d,e,g);i.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}});f.ImageContainer=i.create(f.DisplayObject,{_align:f.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 f.Align.TOP:this._alignX=-1*b/2;this._alignY=0;break;case f.Align.TOP_LEFT:this._alignY=this._alignX=0;break;case f.Align.TOP_RIGHT:this._alignX=
-1*b;this._alignY=0;break;case f.Align.CENTER:this._alignX=-1*b/2;this._alignY=-1*this._data.getHeight()/2;break;case f.Align.LEFT:this._alignX=0;this._alignY=-1*this._data.getHeight()/2;break;case f.Align.RIGHT:this._alignX=-1*b;this._alignY=-1*this._data.getHeight()/2;break;case f.Align.BOTTOM:this._alignX=-1*b/2;this._alignY=-1*this._data.getHeight();break;case f.Align.BOTTOM_LEFT:this._alignX=0;this._alignY=-1*this._data.getHeight();break;case f.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}});f.Sprite=i.create(f.ImageContainer,{initialize:function(){},draw:function(a,b,c,d,e,g){a|=0;b|=0;var c=!isNaN(c)?c:1,d=!isNaN(d)?d:1,e=!isNaN(e)?e:1,g=this._rotation+(g?g:0),h=f.Image.context;h.globalAlpha=this._alpha*e;this._data.drawSize(a,b,this._width*c,this._height*d,g);h.globalAlpha=1}});f.MovieClip=i.create(f.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 n;this._currentFrame=1;this._timelineArr=[];this._totalFrame=0;this._shouldAutoPlay=c==void 0?!0:c},draw:function($super,b,c,d,e,f,h){if(!this._isShowed&&this._shouldAutoPlay)this._isShowed=!0,this.play();this._isPlaying&&this._update();$super(b,c,d,e,f,h)},_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 t.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(a<1||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.play()},gotoAndStop:function(a){if(a<1||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.stop()}});f.SheetMovieClip=i.create(f.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 n;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(a!=void 0)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(a<1||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.play()},gotoAndStop:function(a){if(a<1||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.stop()},draw:function(a,b,c,d,e,g){a|=0;b|=0;c=!isNaN(c)?c:1;d=!isNaN(d)?d:1;isNaN(e);g=g?g: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+g;g=f.Image.context;g.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);g.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}});f.SequenceMovieClip=i.create(f.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,g=a.length;this._spriteArr=[];this._frameTime=b;this._shouldLoop=c;this._shouldHide=d;this._totalFrame=a.length;this._timer=new n;for(e=0;e<g;e++)b=new f.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,j){$super(b,c,d,e,f,j);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(a<1||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.play()},gotoAndStop:function(a){if(a<1||a>this._totalFrame)throw Error("Invalid frame index");this._currentFrame=a;this.stop()}});f.TextField=i.create(f.DisplayObject,{_font:null,_family:"sans-serif",_textArr:null,_color:0,_align:"left",_baseline:"top",_size:10,initialize:function(){if(o.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=f.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 f.Align.TOP:this._align="center";this._baseline=
"top";break;case f.Align.TOP_LEFT:this._align="left";this._baseline="top";break;case f.Align.TOP_RIGHT:this._align="right";this._baseline="top";break;case f.Align.CENTER:this._align="center";this._baseline="middle";break;case f.Align.LEFT:this._align="left";this._baseline="middle";break;case f.Align.RIGHT:this._align="right";this._baseline="middle";break;case f.Align.BOTTOM:this._align="center";this._baseline="bottom";break;case f.Align.BOTTOM_LEFT:this._align="left";this._baseline="bottom";break;
case f.Align.BOTTOM_RIGHT:this._align="right";this._baseline="bottom";break;default:throw Error("Specify align");}},setText:function(a){a instanceof String||(a=String(a));this._textArr=a.split("\n");this._width&&this._adjustWidth()},_adjustWidth:function(){var a=f.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,g=c.length;e<g;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 t={};t.Animation=i.create(q,{_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(arguments.length<2)throw Error("Specify Animaiton Objects");this._target=a;this._timer=new n;this._animObjArr=[];for(var b=1;b<arguments.length;b++)this._animObjArr.push(arguments[b])},play:function(a){if(!this._isPlaying){var b=t.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=
r(this._update,this),b.addEventListener(h.ENTER_FRAME,this._updateFunc)}},stop:function(){if(this._isPlaying){var a=t.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)b=="time"||b=="transition"||(this._currentAnim[b]=a[b],this._firstParams[b]=this._getProperty(this._target,b));this._currentDuration=a.time==void 0?1E3:a.time;this._currentTransFunc=t.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],c=="visible"&&(a=this._firstParams[c]),this._setProperty(this._target,c,a)},isPlaying:function(){return this._isPlaying}});t.Animation.system=
null;(function(a){function b(a){return a}function c(a){return 1-Math.cos(a*o)}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 h(a){return a<0.5?e(a*2)*0.5:1-e(2-a*2)*0.5}function i(a){return a*a*a}function l(a){return 1-i(1-a)}function s(a){return a<0.5?i(a*2)*0.5:1-i(2-a*2)*0.5}function p(a){return 1-u(1-a)}function u(a){var b=1-a;return 1-Math.pow(b,8)+Math.sin(a*a*6*Math.PI)*b*b}function m(a){return a<0.5?p(a*2)*0.5:1-p(2-a*2)*0.5}var k=
{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 k.LINEAR:return b;case k.SINE_IN:return c;case k.SINE_OUT:return d;case k.SINE_INOUT:return getSinInOut;case k.CIRC_IN:return e;case k.CIRC_OUT:return f;case k.CIRC_INOUT:return h;
case k.CUBIC_IN:return i;case k.CUBIC_OUT:return l;case k.CUBIC_INOUT:return s;case k.ELASTIC_IN:return p;case k.ELASTIC_OUT:return u;case k.ELASTIC_INOUT:return m;default:return b}}},o=Math.PI/2;a.Transition=k})(t);t.Timeline=i.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(this._firstFrame==0||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){b+=(a-this._baseFrame.index)*1E3/this._fps;var c=(this._baseFrame.nextFrame.index-this._baseFrame.index)*1E3/this._fps,c=t.Transition.getTransFunc(this._baseFrame.transition)(b/c),d;for(d in this._baseFrame)if(!(d=="transition"||d=="action"||d=="index"||d=="nextFrame"||this._baseFrame.nextFrame[d]==void 0)){var e=(this._baseFrame.nextFrame[d]-
this._baseFrame[d])*c+this._baseFrame[d];d=="visible"&&(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)c=="transition"||c=="action"||c=="index"||c=="nextFrame"||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)}});t.KeyFrameAnimation=i.create(q,{_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 n;for(a=0;a<c.length;a++){var d=c[a];if(d.constructor!=t.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=
t.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=r(this._update,this);this._currentFrame=a;this._executeKeyFrame(this._currentFrame);this._timer.start();t.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=i.create(q,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(d===0)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=r(a,this),e.onerror=r(b,this));else if(e.constructor==String)f=document.createElement("img"),f.src=e,f.onload=r(a,this),f.onerror=r(b,this),this._imageHash[e]=
f;this._loadingImgArr.push(f)}this._srcArr=[]}},getImage:function(a,b){return!this._imageHash[a]?null:b&&b.length==4?new f.Image(this._imageHash[a],b):new f.Image(this._imageHash[a])},getTotal:function(){return this._loadImgNum},getLoaded:function(){return this._loadedImgNum}}}()),E=i.create(q,{_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 f.DisplayObjectContainer;this._timer=new n;this._disableClearRect=d?!0:!1;this._canvas.width=this._width;this._canvas.height=this._height;t.Animation.system=this;w.system=this;f.Image.context=this._context;this._fpsElem=document.getElementById("fps");
this._setEvent()},setFullScreen:function(){this._setViewport();o.isiOS?window.addEventListener("orientationchange",r(this._setViewport,this),!0):window.addEventListener("resize",r(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-i._canvas.offsetLeft,y:a.pageY-
i._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;h>=0;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 s(d,e){var f=a(d),g=c(i._stage,f.x,f.y);(n[e]=g)&&b(g,h.TOUCH_START,{x:f.x,y:f.y})}d.preventDefault();if(d.type=="mousedown")window.addEventListener("mousemove",e,!0),window.addEventListener("mouseup",
f,!0),s(d,0);else for(var p=0,o=d.changedTouches.length;p<o;p++){var m=d.changedTouches[p];s(m,m.identifier)}}function e(c){function d(c,e){var f=n[e],g=a(c);f&&b(f,h.TOUCH_MOVE,{x:g.x,y:g.y})}c.preventDefault();if(c.type=="mousemove")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=n[e],g=a(c);delete n[e];f&&b(f,h.TOUCH_END,{x:g.x,y:g.y})}c.preventDefault();if(c.type=="mouseup")window.removeEventListener("mousemove",
e,!0),window.removeEventListener("mouseup",f,!0),d(c,0);else for(var i=0,j=c.changedTouches.length;i<j;i++){var m=c.changedTouches[i];d(m,m.identifier)}}var i=this,n={};o.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,r(this._loading,
this));this._imageManager.addEventListener(h.COMPLETE,r(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);n.tick();this._prevTime=n.time;this._timer.start();this._intervalId=setInterval(r(this.run,this),1E3/this._fps)},stop:function(){clearInterval(this._intervalId)},run:function(){n.tick();this._runTime+=n.time-this._prevTime;this._runCount++;if(this._runTime>=1E3){this._realFps=this._runCount*1E3/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=
n.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=i.create(f.DisplayObjectContainer,{_system:null,initialize:function(a,
b){this._system=b},update:function(){}});window.addEventListener("load",function(){window.pageYOffset<=1&&setTimeout(function(){scrollTo(0,1)},10)},!1);B.arc={ua:o,display:f,anim:t,util:C,Class:i,Event:h,EventDispatcher:q,Timer:n,CountTimer:w,Ajax:D,ImageManager:A,System:E,Game:F}})(window);