チェンジセット 1619

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

4.0.12: button events

ファイル:

凡例:

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

    r1579 r1619  
    5656                <p id="statusout"> </p> 
    5757                <p>playing on javascript with JSplash</p> 
    58                 <p id="sout">starting <em>JSplash Player 0.4.10</em>...<br />-------------------------------------<br /></p> 
     58                <p id="sout">starting <em>JSplash Player 0.4.12</em>...<br />-------------------------------------<br /></p> 
    5959                <svg id="svgrt" xmlns="http://www.w3.org/2000/svg" style="width: 100px; height: 100px;"> 
    6060                </svg> 
  • ruby/jsplash/trunk/client2/index.xml

    r1616 r1619  
    5454                <div id="progbar"><div>  </div></div> 
    5555                <p id="statusout"> </p> 
    56                 <p id="sout"><em>JSplash Player</em> 0.4.11<br />-------------------------------------<br /></p> 
     56                <p id="sout"><em>JSplash Player</em> 0.4.12<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/objects.js

    r1616 r1619  
    4747                this.overridden = false; 
    4848                this.dynamic = false; 
     49                this.dynDepthBase = null; 
    4950 
    5051                this.mousePos = {x:0, y:0}; 
     
    201202                        if (this.depthMap[depth] != po) 
    202203                        { 
     204if (this.depthMap[depth] && this.depthMap[depth].klass.classId == 4) console.log(depth); 
    203205                                this.removeObject(depth); 
    204206                        } 
     
    352354                var o = this.pickPlacedObjectAt(depth); 
    353355 
    354                 if (o
     356                if (o && !o.dynamic
    355357                { 
     358//if (o.klass.classId == 4) console.log(arguments.callee.caller); 
    356359                        //if (this.clipMap[depth]) 
    357360                        //      this.applyAClip(depth, this.clipMap[depth], false); 
     
    559562                var vlist = this.klass.getVarList(); 
    560563 
    561                 var handler = this.getProxy().onEnterFrame; 
     564                var P = this.getProxy(); 
     565                var handler = P.onEnterFrame; 
    562566                if (handler) { 
    563567                 
     
    565569                                handler._ai_ = new JSplash.ActionInstance(handler); 
    566570                         
     571                        P.__mapGlobal__(); 
    567572                        this.execScript(handler._ai_, vlist, this.getProxy().onEnterFrame_env); 
     573                        P.__unmapGlobal__(); 
    568574                } 
    569575 
    570576                // next, check mousedown 
    571577                if (JSplash.gPlayer.stage.mouse_down) { 
    572                         handler = this.getProxy().onMouseDown; 
     578                        handler = P.onMouseDown; 
    573579                        if (handler) { 
    574580                                if (!handler._ai_) 
    575581                                        handler._ai_ = new JSplash.ActionInstance(handler); 
    576582 
     583                                P.__mapGlobal__(); 
    577584                                this.execScript(handler._ai_, vlist); 
    578                         } 
     585                                P.__unmapGlobal__(); 
     586                        } 
     587                } 
     588        }, 
     589         
     590        doDynamicAction: function(name) { 
     591                if (!this.klass) 
     592                        return; 
     593                var vlist = this.klass.getVarList(); 
     594 
     595                var P = this.getProxy(); 
     596                var handler = P[name]; 
     597                if (handler) { 
     598                 
     599                        if (!handler._ai_) 
     600                                handler._ai_ = new JSplash.ActionInstance(handler); 
     601                         
     602                        P.__mapGlobal__(); 
     603                        this.execScript(handler._ai_, vlist); 
     604                        P.__unmapGlobal__(); 
    579605                } 
    580606        }, 
     
    726752                        P._xscale != T.sx || P._yscale != T.sy || 
    727753                        P._rotation != T.r) { 
    728                         T.mx = P._x
    729                         T.my = P._y
    730                         T.sx = P._xscale / 100.0
    731                         T.sy = P._yscale / 100.0
     754                        T.mx = P._x || 0
     755                        T.my = P._y || 0
     756                        T.sx = (P._xscale==undefined) ? 1 : (P._xscale / 100.0)
     757                        T.sy = (P._yscale==undefined) ? 1 : (P._yscale / 100.0)
    732758                        T.r  = P._rotation; 
    733759 
     
    749775                P._rotation = T.r; 
    750776 
     777                if (!this.is_stage) 
     778                        this.setMousePos(); 
    751779                P._xmouse = this.mousePos.x; 
    752780                P._ymouse = this.mousePos.y; 
     
    758786 
    759787                this.putViewSize(P); 
     788        }, 
     789         
     790        setMousePos: function() { 
     791                var o = this; 
     792                var ox = 0; 
     793                var oy = 0; 
     794                 
     795                for (;;) { 
     796                        ox -= o.pxTransform.mx; 
     797                        oy -= o.pxTransform.my; 
     798                 
     799                        o = o.parent; 
     800                        if (o.is_stage) { 
     801                                this.mousePos.x = o.mousePos.x - ox; 
     802                                this.mousePos.y = o.mousePos.y - oy; 
     803                                return; 
     804                        } 
     805                } 
    760806        }, 
    761807 
     
    791837                for (var i = 0;i < len;i++) { 
    792838                        var b = list[i]; 
    793 //                      console.log(b.st); 
    794                         if (b.st == 8) 
    795                                 continue; // don't place hitArea sprite 
    796839                         
    797840                        var po = this.placeObject(1+i, b.id, undefined, undefined, 0, false, false); 
     
    800843                                if ((b.st&2) != 0) po.addStyleClass("jsplash-btn-over"); 
    801844                                if ((b.st&4) != 0) po.addStyleClass("jsplash-btn-down"); 
     845                                if (b.st == 8) po.addStyleClass("jsplash-hitarea"); 
    802846                        } 
    803847                } 
     
    806850                { 
    807851                        Event.observe(this.g, "mouseup", this.onMouseUp.bind(this)); 
     852                        Event.observe(this.g, "mousedown", this.onPress.bind(this)); 
    808853                        this.listeningMouse = true; 
    809854                } 
     
    811856                this.showFrame(); 
    812857        }, 
    813          
     858 
    814859        onMouseUp: function() { 
     860                JSplash.gPlayer.unregisterDraggingObject(this.instance_uid); 
     861                this.doDynamicAction("onRelease"); 
    815862                this.doHandlerAction("on_release"); 
     863        }, 
     864 
     865        onPress: function() { 
     866                JSplash.gPlayer.registerDraggingObject(this.instance_uid, this); 
     867                this.doDynamicAction("onPress"); 
     868        }, 
     869         
     870        releaseOutside: function() { 
     871                this.doDynamicAction("onReleaseOutside"); 
    816872        }, 
    817873         
     
    847903        }, 
    848904         
     905        calcDynDepth: function() { 
     906                var tags = this.taglist; 
     907                var len = tags.length; 
     908                var d = 1; 
     909                for (var i = 0;i < len;i++) { 
     910                        if (tags[i].d && tags[i].d>d) 
     911                                d = tags[i].d; 
     912                } 
     913                 
     914                this.dynDepthBase = d + 1; 
     915        }, 
     916         
    849917        attachMovie: function(id, inst_name, depth) { 
    850                 var inst = this.placeObject(depth, JSplash.gPlayer.stage.lookupExportedSymbol(id), inst_name, undefined, false, false, false); 
     918                if (this.dynDepthBase == null) 
     919                        this.calcDynDepth(); 
     920         
     921                var inst = this.placeObject(this.dynDepthBase+depth, JSplash.gPlayer.stage.lookupExportedSymbol(id), inst_name, undefined, false, false, false); 
    851922                inst.dynamic = true; 
    852923                this.executor.processAdditionalSprites(); 
     
    9781049        }, 
    9791050         
     1051        __mapGlobal__: function() { 
     1052                window._xmouse = this._xmouse; 
     1053                window._ymouse = this._ymouse; 
     1054        }, 
     1055 
     1056        __unmapGlobal__: function() { 
     1057                delete window._xmouse; 
     1058                delete window._ymouse; 
     1059        }, 
     1060         
    9801061        __setChidrenRefs__: function() { 
    9811062                var m = this.owner.nameMap; 
     
    9951076                if (!this.onMouseDown) 
    9961077                        this.onMouseDown = null; 
     1078                if (!this.onPress) 
     1079                        this.onPress = null; 
     1080                if (!this.onRelease) 
     1081                        this.onRelease = null; 
    9971082        }, 
    9981083         
  • ruby/jsplash/trunk/client2/jsplash/player.js

    r1616 r1619  
    1515                JSplash.gPlayer = this; 
    1616 
     17                this.draggingObjects = {}; 
    1718                this.executor = new JSplash.Executor(); 
    1819                this.executor.frameRate = swf.frameRate; 
     
    3839                svg.addEventListener("mousemove", this.onTopMouseMove.bind(this, svg), false); 
    3940                svg.addEventListener("mousedown", this.onTopMouseDown.bind(this), false); 
     41                document.getElementsByTagName("body")[0].addEventListener("mouseup", this.onGlobalMouseUp.bind(this), false); 
    4042 
    4143                JSplash.SWFGlobals.setup(this); 
     
    8385                delete Object.prototype.addProperty; 
    8486        }, 
     87         
     88        unregisterDraggingObject: function(uid) { 
     89                if (this.draggingObjects[uid]) 
     90                        delete this.draggingObjects[uid]; 
     91        }, 
     92 
     93        registerDraggingObject: function(uid, obj) { 
     94                this.draggingObjects[uid] = obj; 
     95        }, 
     96         
     97        onGlobalMouseUp: function(e) { 
     98                var map = this.draggingObjects; 
     99                for (var i in map) 
     100                { 
     101                        map[i].releaseOutside(); 
     102                        delete map[i]; 
     103                } 
     104        }, 
    85105 
    86106        onTopMouseDown: function(e) { 
     
    136156        document.styleSheets[0].insertRule(".jsplash-btn-down{visibility:hidden;}", 0); 
    137157        document.styleSheets[0].insertRule(":active>.jsplash-btn-down{visibility:visible;}", 0); 
     158         
     159        document.styleSheets[0].insertRule(".jsplash-hitarea{opacity:0; cursor:pointer;}", 0); 
    138160 
    139161        var swf = new JSplash.SWF(JSplash.swfdata); 
  • ruby/jsplash/trunk/client2/jsplash/swfglobal.js

    r1616 r1619  
    1515        g.SharedObject = JSplash.SWFGlobals.SharedObject; 
    1616        g.Sound        = JSplash.SWFGlobals.Sound; 
     17        g.Mouse        = JSplash.SWFGlobals.Mouse; 
    1718        g.__inherit__    = JSplash.SWFGlobals.inheritClass; 
    1819} 
     
    3031} 
    3132 
     33JSplash.SWFGlobals.Mouse = { 
     34        hide: function() { 
     35        }, 
     36 
     37        show: function() { 
     38        } 
     39} 
     40 
    3241JSplash.SWFGlobals.inheritClass = function(base, subcls) { 
    33         Object.extend(subcls.prototype, base.prototype); 
     42 
     43        for (var p in base.prototype) 
     44        { 
     45                if (!subcls.prototype[p]) 
     46                        subcls.prototype[p] = base.prototype[p]; 
     47                else 
     48                        subcls.prototype["super_"+p] = base.prototype[p]; 
     49        } 
     50//      throw "hoge"; 
     51//      Object.extend(subcls.prototype, base.prototype); 
     52//      Object.extend(subcls.prototype, overrides); 
    3453         
    35         subcls.prototype._super = base.prototype; 
    3654        subcls.prototype.__super__ = base; 
    3755        subcls.prototype.super_ctor = function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){ 
    3856                var so = new this.__super__(a,b,c,d,e,f,g,h,i,j,k,l,m,n); 
    39                 Object.extend(so, this); 
     57 
     58                for (var q in so) 
     59                { 
     60                        if (so[q] != this.__super__.prototype[q]) 
     61                                this[q] = so[q]; 
     62                } 
    4063        }; 
    4164} 
  • ruby/jsplash/trunk/client2/rocket_demo.xml

    r1579 r1619  
    5656                <p id="statusout"> </p> 
    5757                <p>playing on javascript with JSplash</p> 
    58                 <p id="sout">starting <em>JSplash Player 0.4.10</em>...<br />-------------------------------------<br /></p> 
     58                <p id="sout">starting <em>JSplash Player 0.4.12</em>...<br />-------------------------------------<br /></p> 
    5959                <svg id="svgrt" xmlns="http://www.w3.org/2000/svg" style="width: 100px; height: 100px;"> 
    6060                </svg>