[Sie-announce] SIEコード [1445] set要素の同期をとる処理を施した

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2009年 12月 4日 (金) 23:25:27 JST


Revision: 1445
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1445
Author:   dhrname
Date:     2009-12-04 23:25:27 +0900 (Fri, 04 Dec 2009)

Log Message:
-----------
set要素の同期をとる処理を施した

Modified Paths:
--------------
    branches/05x/055/sie.js

Modified: branches/05x/055/sie.js
===================================================================
--- branches/05x/055/sie.js	2009-12-02 14:36:14 UTC (rev 1444)
+++ branches/05x/055/sie.js	2009-12-04 14:25:27 UTC (rev 1445)
@@ -100,6 +100,9 @@
 }
 //他のページに移動する際に起動
 function unsvgtovml() {
+  if (NAIBU.Clip.length > 0) {
+    clearInterval(NAIBU.stop);
+  }
   NAIBU = stlog = STLog = SIE = null;
 }
 
@@ -332,8 +335,8 @@
   } else { //全要素の読み込みが終われば
     _ie_svgfont();
     if (NAIBU.Clip.length > 0) {
-      setInterval( (function(){
-          var ntc = NAIBU.Time.currentTime++;
+      NAIBU.stop = setInterval( (function(){
+          var ntc = NAIBU.Time.currentFrame++;
           var nc = NAIBU.Clip;
           for (var i=0,ncli=nc.length;i<ncli;++i) {
             nc[i]._frame(ntc);
@@ -2176,7 +2179,7 @@
 };
 
 NAIBU.Time = {
-  curentFrame : 0
+  currentFrame : 0
 };
 NAIBU.Clip = [];
 function STSetElement(/*Element*/ ele, /*Matrix*/ matrix, /*float*/w, h) {
@@ -2225,14 +2228,14 @@
   this.fill = ele.getAttribute("fill");
   this.w = w;
   this.h = h;
-  this._begin = this._end = null;
+  this._begin = this._end =  this.simpleDuration = null;
   dummy = null;
   NAIBU.Clip[NAIBU.Clip.length] = this;
   return this;
 };
 STSetElement.prototype.set = function (w,h){
   this.to = this.tar.getAttribute("to");
-  var offset;
+  var offset, beginOffset = 0;
   try {
     var n = parseFloat(this.begin.match(/[\-\d\.]+(h|min|s|ms)/));
     offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0;
@@ -2244,11 +2247,16 @@
         tar = this.tarrget.tar;
       }
       var tea = this.beginElementAt;
-      tar.addEvent( "on" + this.begin.match(/(mouse|activ)[a-z]+/i), (function(){tea(offset)}) );
+      tar.attachEvent( "on" + this.begin.match(/(mouse|activ)[a-z]+/i), (function(){tea(offset)}) );
     } else {
       this.beginElementAt(offset);
+      beginOffset = offset;
     }
-    if (!this.dur) {
+    if (this.dur) {
+      var n = parseFloat(this.dur.match(/[\-\d\.]+(h|min|s|ms)/));
+      this.simpleDuration = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0;    
+    }
+    if (this.end) {
       var n = parseFloat(this.end.match(/[\-\d\.]+(h|min|s|ms)/));
       offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0;
       if ( /(mouse|activ)/.test(this.end) ) { //イベントがある場合
@@ -2259,7 +2267,7 @@
           tar = this.tarrget.tar;
         }
         var tea = this.endElementAt;
-        tar.addEvent( "on" + this.end.match(/(mouse|activ)[a-z]+/i), (function(){tea(offset)}) );
+        tar.attachEvent( "on" + this.end.match(/(mouse|activ)[a-z]+/i), (function(){tea(offset)}) );
       } else {
         this.endElementAt(offset);
       }
@@ -2274,17 +2282,19 @@
 };
 //sは現在のフレーム数であることに気をつけること
 STSetElement.prototype._frame = function (/*int*/ s){
-  if (this._begin && this._end) {
+  if (this._begin) {
     if (this._begin <= s) {
       if (this.currentFrame === 0) {
         this.beginElement();
       }
       this.currentFrame++;
     }
-    if (this._end <= s && this.currentFrame !== 0) {
-      this.endElement();
-      this.currentFrame = 0;
-      this._begin = null;
+    if (this._end) {
+      if (this._end <= s && this.currentFrame !== 0) {
+        this.endElement();
+        this.currentFrame = 0;
+        this._begin = null;
+      }
     }
   }
 };
@@ -2306,7 +2316,7 @@
       target[this.attributeName] = this.to;
     } else if (base instanceof STLength) {
       var s = base.value;
-      base.newValueSpecified(base.unitType, parseFloat(this.to));
+      base.newValueSpecifiedUnits(base.unitType, parseFloat(this.to));
       base = s;
     }
   } else if (target.paint.defaults[this.attributeName] !== void 0) {
@@ -2318,6 +2328,14 @@
   }
   target.set(this.w, this.h);
   this.base = base;
+  if (this.simpleDuration) {
+    if (this._end) {
+      var offset = (this.simpleDuration > this._end - this._begin) ? this._end - this._begin : this.simpleDuration;
+      this.endElementAt(offset);
+    } else {
+      this.endElementAt(this.simpleDuration);
+    }
+  }
   return;
 };
 STSetElement.prototype.endElement = function (){
@@ -2331,10 +2349,10 @@
   return;
 };
 STSetElement.prototype.beginElementAt = function (offset){
-  this._begin = offset * 0.8 * 0.024 + NAIBU.Time.cuurentFrame;  //フレーム数に変換(軽量化のために、1s = 800msで計算)
+  this._begin = Math.ceil(offset * 0.8 / 24 + NAIBU.Time.currentFrame);  //フレーム数に変換(軽量化のために、1s = 800msで計算)
 };
 STSetElement.prototype.endElementAt = function (offset){
-  this._end = offset * 0.8 * 0.024 + NAIBU.Time.cuurentFrame;
+  this._end = Math.ceil(offset * 0.8 / 24 + NAIBU.Time.currentFrame);
 };
 
 function utf16( /*string*/ s)  {




Sie-announce メーリングリストの案内
アーカイブの一覧に戻る