チェンジセット 1616

差分発生行の前後
無視リスト:
コミット日時:
2008/10/14 17:23:20 (3 年前)
コミッタ:
gyuque
ログメッセージ:

4.0.11: supported exported symbols, button records and fixed bugs

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • ruby/jsplash/trunk/client2/index.xml

    r1579 r1616  
    5454                <div id="progbar"><div>  </div></div> 
    5555                <p id="statusout"> </p> 
    56                 <p id="sout"><em>JSplash Player</em> 0.4.10<br />-------------------------------------<br /></p> 
     56                <p id="sout"><em>JSplash Player</em> 0.4.11<br />-------------------------------------<br /></p> 
    5757                <svg id="svgrt" xmlns="http://www.w3.org/2000/svg" style="width: 100px; height: 100px;"> 
    5858                </svg> 
  • ruby/jsplash/trunk/client2/jsplash/executor.js

    r1525 r1616  
    7474        }, 
    7575         
     76        processAdditionalSprites: function() { 
     77                for(;this.additionals.length>0;) { 
     78                        this.advanceFrame( this.additionals.shift(), 0 ); 
     79                } 
     80        }, 
     81         
    7682        tick: function() { 
    7783                this.executed_stat = 0; 
     
    8692                } 
    8793                 
    88                 for(;this.additionals.length>0;) { 
    89 //      console.log("ADD           "+this.additionals[this.additionals.length-1]); 
    90                         this.advanceFrame( this.additionals.pop(), 0 ); 
    91                 } 
    92 //console.log("--------------------------------------------------------------------"); 
     94                this.processAdditionalSprites(); 
    9395                this.doReservedActions(); 
     96 
    9497                 
    9598                this.additionals = []; 
     
    102105                } 
    103106                 
    104                 for(;this.additionals.length>0;) { 
    105 //      console.log("ADD           "+this.additionals[this.additionals.length-1]); 
    106                         this.advanceFrame( this.additionals.pop(), 0 ); 
    107                 } 
    108                  
     107                this.processAdditionalSprites(); 
    109108                this.doReservedActions(); 
    110109//console.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); 
  • ruby/jsplash/trunk/client2/jsplash/objects.js

    r1579 r1616  
    4646                this.shape_disposed = false; 
    4747                this.overridden = false; 
     48                this.dynamic = false; 
    4849 
    4950                this.mousePos = {x:0, y:0}; 
     
    5455                this.nameMap     = {}; 
    5556                this.frameActionFuncs = {}; 
     57                this.handlerActionFuncs = {}; 
    5658                this.topDepths = [0]; 
    5759                 
    5860                this.instance_uid = JSplash.ObjectInstance.next_id++; 
     61                this.listeningMouse = false; 
    5962         
    6063                if (g) 
     
    200203                                this.removeObject(depth); 
    201204                        } 
     205                         
     206                        if (!po.sleeping){ 
     207                                return po; 
     208                        } 
    202209 
    203210                        if (po) { 
     
    234241                        if (klass.renderer) 
    235242                                inst.renderer = klass.renderer; 
    236  
     243// inst.g.setAttribute("id", "kid-"+klass.classId); 
    237244                        inst.render(); 
    238245                        /* when replace previous frame */ 
     
    573580        }, 
    574581         
     582        doHandlerAction: function(handler_name) { 
     583                if (!this.klass) 
     584                        return; 
     585                var vlist = this.klass.getVarList(); 
     586                if (!this.handlerActionFuncs[handler_name]) { 
     587                        var a = this.klass.getHandlerOf(handler_name); 
     588                        if (a && a.action) 
     589                                this.handlerActionFuncs[handler_name] = new JSplash.ActionInstance(a.action); 
     590                } 
     591                 
     592                if (this.handlerActionFuncs[handler_name]) { 
     593                        var varlist = this.klass.getVarList(); 
     594                        this.execScript(this.handlerActionFuncs[handler_name], varlist); 
     595                } 
     596        }, 
     597         
    575598        execScript: function(act, local_vlist, local_vlist2) { 
    576599                var P = this.getProxy(); 
     
    693716                var m = [t.sx, t.kx, t.ky, t.sy, t.mx, t.my]; 
    694717 
    695                 this.g.setAttribute("transform", "matrix("+m.join(' ')+") rotate("+t.r+")" ); 
     718                this.g.setAttribute("transform", "matrix("+m.join(' ')+") rotate("+(t.r||0)+")" ); 
    696719        }, 
    697720         
     
    728751                P._xmouse = this.mousePos.x; 
    729752                P._ymouse = this.mousePos.y; 
     753                 
     754                if (this.is_stage) { 
     755                        P.width  = this.width; 
     756                        P.height = this.height; 
     757                } 
    730758 
    731759                this.putViewSize(P); 
     
    745773        }, 
    746774         
     775        addStyleClass: function(nm) { 
     776                if (this.g) { 
     777                        var cls = this.g.getAttribute("class"); 
     778                        if (cls) 
     779                                if (cls.indexOf(nm) >= 0) return; 
     780                                 
     781                        this.g.setAttribute("class", cls ? (cls+" "+nm) : nm); 
     782                } 
     783        }, 
     784         
     785        initButton: function() { 
     786                this.rewind(); 
     787                 
     788                var list = this.klass.buttonDatas; 
     789                if (!list) return; 
     790                var len = list.length; 
     791                for (var i = 0;i < len;i++) { 
     792                        var b = list[i]; 
     793//                      console.log(b.st); 
     794                        if (b.st == 8) 
     795                                continue; // don't place hitArea sprite 
     796                         
     797                        var po = this.placeObject(1+i, b.id, undefined, undefined, 0, false, false); 
     798                        if (po) { 
     799                                if ((b.st&1) != 0) po.addStyleClass("jsplash-btn-up"); 
     800                                if ((b.st&2) != 0) po.addStyleClass("jsplash-btn-over"); 
     801                                if ((b.st&4) != 0) po.addStyleClass("jsplash-btn-down"); 
     802                        } 
     803                } 
     804                 
     805                if (!this.listeningMouse) 
     806                { 
     807                        Event.observe(this.g, "mouseup", this.onMouseUp.bind(this)); 
     808                        this.listeningMouse = true; 
     809                } 
     810                 
     811                this.showFrame(); 
     812        }, 
     813         
     814        onMouseUp: function() { 
     815                this.doHandlerAction("on_release"); 
     816        }, 
     817         
    747818        // Movie Controls 
    748819        stop: function() { 
     
    774845                this.gotoFrame(fi); 
    775846                this.play(); 
     847        }, 
     848         
     849        attachMovie: function(id, inst_name, depth) { 
     850                var inst = this.placeObject(depth, JSplash.gPlayer.stage.lookupExportedSymbol(id), inst_name, undefined, false, false, false); 
     851                inst.dynamic = true; 
     852                this.executor.processAdditionalSprites(); 
     853                this.getProxy().__setChidrenRefs__(); 
     854                return inst.getProxy(); 
    776855        } 
    777856} 
    778857 
    779 JSplash.ObjectInstance.createStageObject = function(taglist, g, label_map) { 
     858JSplash.ObjectInstance.createStageObject = function(taglist, g, label_map, exports) { 
    780859        var s = new JSplash.ObjectInstance(taglist, null, g); 
     860        s.exports = exports; 
    781861        s.label_map = label_map; 
    782862        s.mouse_down = false; 
    783863        s.is_stage = true; 
    784864        s.bitmapRefs = {}; 
     865        s.width = s.height = 100; 
    785866         
    786867        Object.extend(s, { 
     
    836917                getImageRef: function(oid) { 
    837918                        return this.bitmapRefs[oid] || null; 
     919                }, 
     920                 
     921                lookupExportedSymbol: function(name) { 
     922                        if (!this.exports) return null; 
     923                        return this.exports[name]; 
    838924                } 
    839925        } ); // extend 
     
    859945                for (var depth in dmap) { 
    860946                        ch = dmap[depth]; 
    861                         if (!ch.sleeping
     947                        if (!ch.sleeping && !ch.dynamic
    862948                        { 
    863949                                this.depthMap[depth] = ch; 
     
    882968                this.gotoAndStop = obj.gotoAndStop.bind(obj); 
    883969                this.gotoAndPlay = obj.gotoAndPlay.bind(obj); 
     970                this.attachMovie = obj.attachMovie.bind(obj); 
    884971                 
    885972                this._totalframes  = 1; 
  • ruby/jsplash/trunk/client2/jsplash/player.js

    r1579 r1616  
    2222                svg.style.width  = swf.pxWidth  + "px"; 
    2323                svg.style.height = swf.pxHeight + "px"; 
    24                 this.stage = new JSplash.ObjectInstance.createStageObject(swf.taglist, svg, swf.label_map); 
     24                this.stage = new JSplash.ObjectInstance.createStageObject(swf.taglist, svg, swf.label_map, swf.exports); 
     25                this.stage.width  = swf.pxWidth; 
     26                this.stage.height = swf.pxHeight; 
    2527                 
    2628                if (swf.bitmaps) 
     
    126128 
    127129JSplash.initPlayer = function() { 
     130        document.styleSheets[0].insertRule(":hover>.jsplash-btn-up{visibility:hidden;}", 0); 
     131 
     132        document.styleSheets[0].insertRule(".jsplash-btn-over{visibility:hidden;}", 0); 
     133        document.styleSheets[0].insertRule(":hover>.jsplash-btn-over{visibility:visible; cursor:pointer;}", 0); 
     134        document.styleSheets[0].insertRule(":active>.jsplash-btn-over{opacity: 0;}", 0); 
     135 
     136        document.styleSheets[0].insertRule(".jsplash-btn-down{visibility:hidden;}", 0); 
     137        document.styleSheets[0].insertRule(":active>.jsplash-btn-down{visibility:visible;}", 0); 
     138 
    128139        var swf = new JSplash.SWF(JSplash.swfdata); 
    129140        var player = new JSplash.Player(swf, $('svgrt')); 
     
    212223        this.label_map = sdat.label_map; 
    213224        this.bitmaps   = sdat.bitmaps; 
     225        this.exports   = sdat.exports; 
    214226} 
    215227 
  • ruby/jsplash/trunk/client2/jsplash/swfglobal.js

    r1457 r1616  
    1515        g.SharedObject = JSplash.SWFGlobals.SharedObject; 
    1616        g.Sound        = JSplash.SWFGlobals.Sound; 
     17        g.__inherit__    = JSplash.SWFGlobals.inheritClass; 
    1718} 
    1819 
     
    2930} 
    3031 
     32JSplash.SWFGlobals.inheritClass = function(base, subcls) { 
     33        Object.extend(subcls.prototype, base.prototype); 
     34         
     35        subcls.prototype._super = base.prototype; 
     36        subcls.prototype.__super__ = base; 
     37        subcls.prototype.super_ctor = function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){ 
     38                var so = new this.__super__(a,b,c,d,e,f,g,h,i,j,k,l,m,n); 
     39                Object.extend(so, this); 
     40        }; 
     41} 
    3142 
    3243JSplash.SWFGlobals.SharedObject = { 
  • ruby/jsplash/trunk/client2/jsplash/tags.js

    r1565 r1616  
    1313                        var has_trans = (data.mov || data.scl || data.skw); 
    1414                        var has_clrtrans = (data.cfct || data.cofs); 
    15                  
     15 
    1616                        var inst = owner.placeObject(data.d, data.id, data.name, data.cl, data.r, (data.r && !has_trans), (data.r && !has_clrtrans && !data.ctr)); 
    1717                        if (!inst) { 
     
    3838                                        ky = data.skw[1]; 
    3939                                } 
     40 
    4041try { 
    4142                                inst.setTransform(tx, ty, sx, sy, kx, ky); 
     
    7374                                inst.setAlpha(1); 
    7475                        } 
     76                         
     77                        if (inst.klass.isButton) { 
     78                                inst.initButton(); 
     79                        } 
    7580                }, 
    7681                 
     
    9297                                owner.stop(); 
    9398                        owner.rewind(true); 
    94 //                      console.log("END"); 
    9599                }, 
    96100                 
     
    118122                        this.frameActions = null; 
    119123                        this.tagData = data; 
     124                        this.classId = data ? data.id : null; 
    120125                        if (data) { 
    121126                                if (data.tag == JSplash.tDefineShape) { 
     
    134139                                        this.label_map = data.label_map || null; 
    135140                                } 
     141                                else if (data.tag == JSplash.tDefineButton2) { 
     142                                        this.isButton = true; 
     143                                        this.buttonDatas = data.buttons; 
     144                                } 
    136145                        } 
    137146                } 
     
    158167                }, 
    159168                 
     169                getHandlerOf: function(name) { 
     170                        if (!this.frameActions) 
     171                                this.loadActions(); 
     172                         
     173                        if (!this.frameActions) 
     174                                return null; 
     175 
     176                        var a = this.frameActions[name]; 
     177                        return a; 
     178                }, 
     179                 
    160180                frameActionAt: function(fi) { 
    161181                        if (!this.frameActions) 
     
    165185                                return null; 
    166186                                 
    167                         var a = this.frameActions['frame_'+fi] 
     187                        var a = this.frameActions['frame_'+fi]; 
    168188                        return a; 
    169189                }, 
  • ruby/jsplash/trunk/jextract.rb

    r1579 r1616  
    88$shared_jpeg_table = nil 
    99$bitmap_refs = nil 
     10$exports = nil 
     11 
     12def make_trans(trans) 
     13        mov = nil 
     14        scl = nil 
     15        skw = nil 
     16        if trans 
     17                a = trans 
     18 
     19                mov = ",mov:[#{a['transX']},#{a['transY']}]" if a['transX'] 
     20                scl = ",scl:[#{a['scaleX'].to_f},#{a['scaleY'].to_f}]" if a['scaleX'] 
     21                skw = ",skw:[#{a['skewX'].to_f},#{a['skewY'].to_f}]"   if a['skewX'] 
     22        end 
     23 
     24        "#{mov}#{scl}#{skw}" 
     25end 
    1026 
    1127def make_rgb(attrs) 
     
    2440 
    2541        "L:#{vL},R:#{vR},T:#{vT},B:#{vB}" 
     42end 
     43 
     44def read_a_button(btn) 
     45        attrs = btn.attributes 
     46        f_up   = attrs['up'].to_i 
     47        f_over = attrs['over'].to_i << 1 
     48        f_down = attrs['down'].to_i << 2 
     49        f_hit  = attrs['hitTest'].to_i << 3 
     50 
     51        state = f_up | f_over | f_down | f_hit 
     52        return nil if state == 0 
     53 
     54        trans_e = btn.elements['./transform/Transform'] 
     55        trans = trans_e ? make_trans(trans_e.attributes) : nil 
     56 
     57        "{st:#{state},id:#{attrs['objectID'].to_i}#{trans}}" 
     58end 
     59 
     60def read_buttons(buttons) 
     61        parsed_buttons = [] 
     62 
     63        buttons.elements.each{|b| 
     64                next if b.name != "Button" 
     65 
     66                br = read_a_button(b) 
     67                parsed_buttons << br if br 
     68        } 
     69 
     70        parsed_buttons.join(',') 
    2671end 
    2772 
     
    73118                a = trans 
    74119 
    75                 mov = ",mov:[#{a['transX']},#{a['transY']}]" if a['transX'] 
    76                 scl = ",scl:[#{a['scaleX']},#{a['scaleY']}]" if a['scaleX'] 
    77                 skw = ",skw:[#{a['skewX']},#{a['skewY']}]"   if a['skewX'] 
     120                mov = ",mov:[#{a['transX'].to_f},#{a['transY'].to_f}]" if a['transX'] 
     121                scl = ",scl:[#{a['scaleX'].to_f},#{a['scaleY'].to_f}]" if a['scaleX'] 
     122                skw = ",skw:[#{a['skewX'].to_f},#{a['skewY'].to_f}]"   if a['skewX'] 
    78123        end 
    79124 
     
    172217 
    173218class TagReaders 
     219        def self.readExport(tg, nest, fi) 
     220                a = tg.elements['./symbols/Symbol'].attributes 
     221 
     222                oi = a['objectID'].to_i 
     223                nm = a['name'] 
     224 
     225                $exports = Hash.new if !$exports 
     226                $exports[nm] = oi 
     227        end 
     228 
    174229        def self.readSetBackgroundColor(tg, nest, fi) 
    175230                clr = tg.elements['./color/Color'].attributes 
     
    220275        end 
    221276 
    222         def self.readPlaceObject2(tg, nest, fi) 
     277        def self.readPlaceObject3(tg, nest, fi) 
     278                return TagReaders.readPlaceObject2(tg, nest, fi, 3); 
     279        end 
     280 
     281        def self.readPlaceObject2(tg, nest, fi, v = nil) 
    223282                trans = nil 
    224283                trans = tg.elements['./transform/Transform'].attributes if tg.elements['./transform'] 
     
    243302 
    244303                        mov = ",mov:[#{a['transX']},#{a['transY']}]" if a['transX'] 
    245                         scl = ",scl:[#{a['scaleX']},#{a['scaleY']}]" if a['scaleX'] 
    246                         skw = ",skw:[#{a['skewX']},#{a['skewY']}]"   if a['skewX'] 
     304                        scl = ",scl:[#{a['scaleX'].to_f},#{a['scaleY'].to_f}]" if a['scaleX'] 
     305                        skw = ",skw:[#{a['skewX'].to_f},#{a['skewY'].to_f}]"   if a['skewX'] 
    247306                end 
    248307 
     
    266325                pid = ",id:#{tg.attributes['objectID']}" if tg.attributes['objectID'] != nil 
    267326 
    268                 "{tag:JSplash.tPlaceObject2#{pid},d:#{tg.attributes['depth']}#{cl}#{rep}#{mov}#{scl}#{skw}#{nm}#{cofs}#{cfct}}" 
     327                vflg = nil 
     328                vflg = ",v:#{v}" if v 
     329 
     330                "{tag:JSplash.tPlaceObject2#{vflg}#{pid},d:#{tg.attributes['depth']}#{cl}#{rep}#{mov}#{scl}#{skw}#{nm}#{cofs}#{cfct}}" 
    269331        end 
    270332 
     
    299361 
    300362        def self.readDefineButton2(tg, nest, fi) 
    301                 "{tag:JSplash.tDefineButton2,id:#{tg.attributes['objectID']}}" 
     363                buttons = tg.elements['./buttons'] 
     364 
     365                "{tag:JSplash.tDefineButton2,id:#{tg.attributes['objectID']},\n buttons:[\n#{read_buttons(buttons)}\n]}" 
    302366        end 
    303367 
     
    345409        elist.each {|tg| 
    346410                $top_tag_index+=1 if nest==0 
    347                 if tg.name == "Export" || tg.name == "DoInitAction" 
     411                if tg.name == "DoInitAction" 
    348412                        STDERR.puts "ignored [#{tg.name}] at #{$top_tag_index}" 
     413                        next 
     414                elsif tg.name == "Export" 
     415                        TagReaders.readExport(tg, nest, findex) 
    349416                        next 
    350417                elsif tg.name == "UnknownTag" && tg.attributes['id'].to_i(16) == 8 # JPEGTables 
     
    405472end 
    406473 
     474def dump_exports(map) 
     475        ret = [] 
     476        map.each{|k,v| 
     477                ret << "'#{k}':#{v}" 
     478        } 
     479 
     480        ret.join(',') 
     481end 
     482 
    407483#---------------------------- 
    408484 
     
    457533        f1.puts " header: {frameRate: #{swf.frame_rate}, frames: #{swf.frames}, width: #{swf.width}, height: #{swf.height}}," 
    458534        f1.puts " bitmaps: [#{$bitmap_refs.map{|b| "{n:'#{b.id}.#{b.ftype}',w:#{b.width},h:#{b.height}}"}.join(',')}]," if $bitmap_refs 
     535        f1.puts " exports: {#{dump_exports($exports)}}," if $exports 
    459536        f1.puts " taglist: [" 
    460537        f1.puts tags_1.join(",\n")