svnno****@sourc*****
svnno****@sourc*****
2009年 12月 22日 (火) 22:50:11 JST
Revision: 1490 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1490 Author: dhrname Date: 2009-12-22 22:50:11 +0900 (Tue, 22 Dec 2009) Log Message: ----------- フレームごとに実行する関数に関して、beginが呼び出されたときのみ実行されるように改良した Modified Paths: -------------- branches/05x/056/sie.js Modified: branches/05x/056/sie.js =================================================================== --- branches/05x/056/sie.js 2009-12-21 13:06:00 UTC (rev 1489) +++ branches/05x/056/sie.js 2009-12-22 13:50:11 UTC (rev 1490) @@ -2186,7 +2186,9 @@ var ntc = NAIBU.Time.currentFrame++; var nc = NAIBU.Clip; for (var i=0,ncli=nc.length;i<ncli;++i) { - nc[i]._frame(ntc); + if (nc[i]._begin) { + nc[i]._frame(ntc); + } } if (ntc > 7000) { clearInterval(NAIBU.stop); @@ -2256,13 +2258,15 @@ } return this; }; +STSetElement.prototype._eventRegExp = /(mouse|activ|clic)[a-z]+/; +STSetElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)/; STSetElement.prototype.set = function(w,h) { this.to = this.tar.getAttribute("to"); var offset = 0; try { this.eventSync(this.begin, (function(te, offse, ta) { - ta.attachEvent( "on" + te.begin.match(/(mouse|activ|clic)[a-z]+/)[0], + ta.attachEvent( "on" + te.begin.match(te._eventRegExp)[0], function(){te.beginElementAt(offse);}, false ); }), "beginElementAt"); if (this.dur) { @@ -2271,7 +2275,7 @@ if (this.end) { this.eventSync(this.end, (function(te, offse, ta) { - ta.attachEvent( "on" + te.end.match(/(mouse|activ|clic)[a-z]+/)[0], + ta.attachEvent( "on" + te.end.match(te._eventRegExp)[0], function(){te.endElementAt(offse);}, false ); }), "endElementAt"); } @@ -2285,7 +2289,7 @@ }; //どれだけズレの時間があるかを計測するメソッド STSetElement.prototype.getOffset = function(/*string*/ t) { - var n = parseFloat(t.match(/[\-\d\.]+(h|min|s|ms)/)); + var n = parseFloat(t.match(this._timeRegExp)); var offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; n = t = null; return offset; @@ -2305,19 +2309,17 @@ }}; //sは現在のフレーム数であることに気をつけること STSetElement.prototype._frame = function(/*int*/ s) { - if (this._begin) { - if (this._begin <= s) { - if (this.currentFrame === 0) { - this.beginElement(); - } - this.currentFrame++; + if (this._begin <= s) { + if (this.currentFrame === 0) { + this.beginElement(); } - if (this._end) { - if (this._end <= s && this.currentFrame !== 0) { - this.endElement(); - this.currentFrame = 0; - this._begin = this._end = null; - } + this.currentFrame++; + } + if (this._end) { + if (this._end <= s && this.currentFrame !== 0) { + this.endElement(); + this.currentFrame = 0; + this._begin = this._end = null; } } }; @@ -2415,7 +2417,7 @@ this.eventSync(this.begin, //クロージャを参照 (function(te, offse, ta) { - ta.addEventListener( te.begin.match(/(mouse|activ|clic)[a-z]+/)[0], + ta.addEventListener( te.begin.match(te._eventRegExp)[0], function(){te.beginElementAt(offse);}, false ); }), "beginElementAt"); if (this.dur) { @@ -2425,7 +2427,7 @@ this.eventSync(this.end, //クロージャを参照 (function(te, offse, ta) { - ta.addEventListener( te.end.match(/(mouse|activ|clic)[a-z]+/)[0], + ta.addEventListener( te.end.match(te._eventRegExp)[0], function(){te.endElementAt(offse);}, false ); }), "endElementAt"); }