1
1
flash . namespace ( 'flash.display.DisplayObject' ) ;
2
2
3
+
4
+
3
5
flash . display . DisplayObject = ( function ( window , undefined ) {
4
6
function DisplayObject ( DOMObject ) {
5
7
@@ -19,21 +21,12 @@ flash.display.DisplayObject = (function(window, undefined){
19
21
if ( DOMObject ) {
20
22
var object = $ ( DOMObject ) ;
21
23
} else {
22
- try {
23
- var objectsNumber = flash . stage . objectsNumber ;
24
- } catch ( e ) {
25
- var objectsNumber = - 1 ;
26
- }
27
- var object = $ ( '<div/>' , { 'id' : objectsNumber , 'style' : 'position: absolute;' } ) ;
28
- object . id = objectsNumber ;
29
- var objectsNumber = - 1 ;
24
+ var object = $ ( '<div/>' , { 'id' : _ . uniqueId ( ) , 'style' : 'position: absolute;' } ) ;
30
25
}
31
26
32
27
object . angleCache = ( 0 ) ;
33
28
object . scaleXCache = ( 1 ) ;
34
29
object . scaleYCache = ( 1 ) ;
35
- object . xCache = ( 0 ) ;
36
- object . yCache = ( 0 ) ;
37
30
object . childs = [ ] ;
38
31
39
32
//Listeners initialization
@@ -52,19 +45,20 @@ flash.display.DisplayObject = (function(window, undefined){
52
45
53
46
//X, Y getters / setters
54
47
objGetSet . xGet = function ( ) {
55
- return parseInt ( this [ 0 ] . style [ 'left' ] ) ;
48
+ return parseInt ( this . css ( 'left' ) ) ;
56
49
}
57
50
objGetSet . xSet = function ( x ) {
58
- this [ 0 ] . style [ 'left' ] = flash . utils . numToPx ( x ) ;
51
+ this . css ( 'left' , flash . utils . numToPx ( x ) ) ;
59
52
if ( flash . stage != undefined && this === flash . stage . cameraTarget ) {
60
53
flash . stage . x = ( - x + flash . stage . width * 0.5 ) * flash . stage . scaleX ;
61
54
}
62
55
}
63
56
objGetSet . yGet = function ( ) {
64
- return parseInt ( this [ 0 ] . style [ 'top' ] ) ;
57
+ return parseInt ( this . css ( 'top' ) ) ;
65
58
}
66
59
objGetSet . ySet = function ( y ) {
67
- this [ 0 ] . style [ 'top' ] = flash . utils . numToPx ( y ) ;
60
+ //console.log("top" + this.css('top'));
61
+ this . css ( 'top' , flash . utils . numToPx ( y ) ) ;
68
62
if ( flash . stage != undefined && this === flash . stage . cameraTarget ) {
69
63
flash . stage . y = ( - y + flash . stage . height * 0.5 ) * flash . stage . scaleY ;
70
64
}
@@ -97,33 +91,33 @@ flash.display.DisplayObject = (function(window, undefined){
97
91
98
92
//Opacity
99
93
objGetSet . alphaGet = function ( ) {
100
- return this [ 0 ] . style [ 'opacity' ] * 100 ;
94
+ return this . css ( 'opacity' ) * 100 ;
101
95
}
102
96
objGetSet . alphaSet = function ( x ) {
103
- this [ 0 ] . style [ 'opacity' ] = x / 100 ;
97
+ this . css ( 'opacity' , x / 100 ) ;
104
98
}
105
99
106
100
//Fill color
107
101
objGetSet . fillColorGet = function ( ) {
108
- return this [ 0 ] . style [ 'backgroundColor' ] ;
102
+ return this . css ( 'background-color' ) ;
109
103
}
110
104
objGetSet . fillColorSet = function ( x ) {
111
- this [ 0 ] . style [ 'backgroundColor' ] = x ;
105
+ this . css ( 'background-color' , x ) ;
112
106
}
113
107
114
108
//Visible
115
109
objGetSet . visibleGet = function ( ) {
116
- if ( this [ 0 ] . style [ 'display' ] === 'none' ) {
110
+ if ( this . css ( 'display' ) === 'none' ) {
117
111
return false ;
118
112
} else {
119
113
return true ;
120
114
}
121
115
}
122
116
objGetSet . visibleSet = function ( x ) {
123
117
if ( x === true ) {
124
- this [ 0 ] . style [ 'display' ] = 'inline' ;
118
+ this . css ( 'display' , 'inline' ) ;
125
119
} else {
126
- this [ 0 ] . style [ 'display' ] = 'none' ;
120
+ this . css ( 'display' , 'none' ) ;
127
121
}
128
122
}
129
123
@@ -147,51 +141,6 @@ flash.display.DisplayObject = (function(window, undefined){
147
141
this . refreshCSSTransform ( ) ;
148
142
}
149
143
150
- objGetSet . setMask = function ( displayObject ) {
151
- if ( displayObject === undefined ) {
152
- this . maskObject . isMask = false ;
153
- this . maskObject = undefined ;
154
- return ;
155
- }
156
-
157
- this . maskObject = displayObject ;
158
- this . maskObject . isMask = true ;
159
-
160
- if ( this . maskObject . _graphics === undefined ) return ;
161
-
162
- var dataurl = this . maskObject . _graphics . canvas . toDataURL ( ) ;
163
-
164
- if ( ( this . dataurl && this . dataurl . length !== dataurl . length ) || this . dataurl === undefined ) {
165
-
166
- this [ 0 ] . style [ '-webkit-mask-box-image' ] = 'url(' + dataurl + ')' ;
167
- this . dataurl = dataurl ;
168
- /*
169
- if (this.tempstyle1 === undefined) {
170
- if (this.tempstyle2 !== undefined) {
171
- this.tempstyle2.remove();
172
- this.tempstyle2 = undefined;
173
- }
174
- this.tempstyle1 = $("<style type='text/css'> .tempstyle1{ -webkit-mask-box-image:" + 'url(' + dataurl + ')' + ";} </style>").appendTo("head");
175
- this.className = 'tempstyle1';
176
- } else {
177
- this.tempstyle1.remove();
178
- this.tempstyle1 = undefined;
179
- this.tempstyle2 = $("<style type='text/css'> .tempstyle2{ -webkit-mask-box-image:" + 'url(' + dataurl + ')' + ";} </style>").appendTo("head");
180
- this.className = 'tempstyle2';
181
- }
182
-
183
- */
184
- }
185
- }
186
-
187
-
188
-
189
- objGetSet . getMask = function ( ) {
190
- return this . maskObject ;
191
- }
192
-
193
- //Mask
194
- defineGetterSetter ( object , "mask" , objGetSet . getMask , objGetSet . setMask ) ;
195
144
196
145
//numChildren getter
197
146
defineGetterSetter ( object , "numChildren" , objGetSet . numChildrenGet , function ( x ) { } ) ;
@@ -220,16 +169,6 @@ flash.display.DisplayObject = (function(window, undefined){
220
169
defineGetterSetter ( object , "scaleX" , objGetSet . scaleXGet , objGetSet . scaleXSet ) ;
221
170
defineGetterSetter ( object , "scaleY" , objGetSet . scaleYGet , objGetSet . scaleYSet ) ;
222
171
223
- //Graphics
224
- // Visible
225
- defineGetterSetter ( object , "graphics" , function ( ) {
226
- if ( this . _graphics === undefined ) {
227
- return flash . display . Graphics ( this ) ;
228
- } else {
229
- return this . _graphics ;
230
- }
231
- } , function ( x ) { } ) ;
232
-
233
172
//CSS transform refresh function to update rotation, scale and potentially skew
234
173
object . refreshCSSTransform = function ( ) {
235
174
flash . display . cssTransformFunction . call ( this , this . angleCache , this . scaleXCache , this . scaleYCache ) ;
@@ -280,9 +219,6 @@ flash.display.DisplayObject = (function(window, undefined){
280
219
}
281
220
282
221
object . addEventListener = object . bind ;
283
- object . dispatchEvent = function ( eventObject ) {
284
- object . trigger ( eventObject . type ) ;
285
- }
286
222
287
223
object . x = 0 ;
288
224
object . y = 0 ;
0 commit comments