@@ -81,16 +81,28 @@ var Display;
8181/// <reference path="Filter.ts" />
8282var Display ;
8383( function ( Display ) {
84+ var Transform = ( function ( ) {
85+ function Transform ( ) {
86+ }
87+ return Transform ;
88+ } ) ( ) ;
8489 var DisplayObject = ( function ( ) {
8590 function DisplayObject ( id ) {
86- if ( typeof id === "undefined" ) { id = Runtime . getId ( ) ; }
91+ if ( typeof id === "undefined" ) { id = Runtime . generateId ( ) ; }
8792 this . _alpha = 1 ;
8893 this . _x = 0 ;
8994 this . _y = 0 ;
9095 this . _scaleX = 1 ;
9196 this . _scaleY = 1 ;
9297 this . _filters = [ ] ;
98+ this . _visible = false ;
99+ this . _listeners = { } ;
100+ this . _parent = null ;
101+ this . _name = "" ;
102+ this . _children = [ ] ;
103+ this . _transform = new Transform ( ) ;
93104 this . _id = id ;
105+ this . _visible = true ;
94106 }
95107 DisplayObject . prototype . propertyUpdate = function ( propertyName , updatedValue ) {
96108 __pchannel ( "Runtime:UpdateProperty" , {
@@ -100,6 +112,14 @@ var Display;
100112 } ) ;
101113 } ;
102114
115+ DisplayObject . prototype . methodCall = function ( methodName , params ) {
116+ __pchannel ( "Runtime:CallMethod" , {
117+ "id" : this . _id ,
118+ "name" : methodName ,
119+ "value" : params
120+ } ) ;
121+ } ;
122+
103123
104124 Object . defineProperty ( DisplayObject . prototype , "alpha" , {
105125 get : function ( ) {
@@ -223,8 +243,80 @@ var Display;
223243 configurable : true
224244 } ) ;
225245
246+
247+ Object . defineProperty ( DisplayObject . prototype , "visible" , {
248+ get : function ( ) {
249+ return this . _visible ;
250+ } ,
251+ set : function ( visible ) {
252+ this . _visible = visible ;
253+ this . propertyUpdate ( "visible" , visible ) ;
254+ } ,
255+ enumerable : true ,
256+ configurable : true
257+ } ) ;
258+
259+
260+ Object . defineProperty ( DisplayObject . prototype , "transform" , {
261+ get : function ( ) {
262+ return this . _transform ;
263+ } ,
264+ set : function ( t ) {
265+ this . _transform = t ;
266+ } ,
267+ enumerable : true ,
268+ configurable : true
269+ } ) ;
270+
226271 /** AS3 Stuff **/
272+ DisplayObject . prototype . dispatchListener = function ( event , data ) {
273+ if ( this . _listeners . hasOwnProperty ( event ) ) {
274+ if ( this . _listeners [ event ] !== null ) {
275+ for ( var i = 0 ; i < this . _listeners [ event ] . length ; i ++ ) {
276+ try {
277+ this . _listeners [ event ] [ i ] ( data ) ;
278+ } catch ( e ) {
279+ if ( e . hasOwnProperty ( "stack" ) ) {
280+ __trace ( e . stack . toString ( ) , 'err' ) ;
281+ } else {
282+ __trace ( e . toString ( ) , 'err' ) ;
283+ }
284+ }
285+ }
286+ }
287+ }
288+ } ;
289+
227290 DisplayObject . prototype . addEventListener = function ( event , listener ) {
291+ if ( ! this . _listeners . hasOwnProperty ( event ) ) {
292+ this . _listeners [ event ] = [ ] ;
293+ }
294+ this . _listeners [ event ] . push ( listener ) ;
295+ } ;
296+
297+ DisplayObject . prototype . removeEventListener = function ( event , listener ) {
298+ if ( ! this . _listeners . hasOwnProperty ( event ) ) {
299+ return ;
300+ }
301+ var index = this . _listeners [ event ] . indexOf ( listener ) ;
302+ if ( index >= 0 ) {
303+ this . _listeners [ event ] . splice ( index , 1 ) ;
304+ }
305+ } ;
306+
307+ DisplayObject . prototype . addChild = function ( o ) {
308+ this . _children . push ( o ) ;
309+ o . _parent = this ;
310+ this . methodCall ( "addChild" , o . _id ) ;
311+ } ;
312+
313+ DisplayObject . prototype . removeChild = function ( o ) {
314+ var index = this . _children . indexOf ( o ) ;
315+ if ( index >= 0 ) {
316+ this . _children . splice ( index , 1 ) ;
317+ o . _parent = null ;
318+ this . methodCall ( "removeChild" , o . _id ) ;
319+ }
228320 } ;
229321
230322 /** Common Functions **/
@@ -243,6 +335,7 @@ var Display;
243335 } ;
244336
245337 DisplayObject . prototype . unload = function ( ) {
338+ this . _visible = false ;
246339 __pchannel ( "Runtime:CallMethod" , {
247340 "id" : this . _id ,
248341 "method" : "unload" ,
@@ -284,7 +377,22 @@ var Display;
284377var Display ;
285378( function ( Display ) {
286379 Display . root ;
287- var _root = new Display . Sprite ( ) ;
380+ Display . loaderInfo ;
381+ Display . stage ;
382+ Display . version ;
383+ Display . width ;
384+ Display . height ;
385+ Display . fullScreenWidth ;
386+ Display . fullScreenHeight ;
387+ Display . frameRate ;
388+
389+ var _root = new Display . Sprite ( "__root" ) ;
390+ var _width = 0 ;
391+ var _height = 0 ;
392+ var _fullScreenWidth = 0 ;
393+ var _fullScreenHeight = 0 ;
394+ var _frameRate = 24 ;
395+
288396 Object . defineProperty ( Display , 'root' , {
289397 get : function ( ) {
290398 return _root ;
@@ -293,6 +401,70 @@ var Display;
293401 __trace ( "Display.root is read-only" , "warn" ) ;
294402 }
295403 } ) ;
404+ Object . defineProperty ( Display , 'loaderInfo' , {
405+ get : function ( ) {
406+ return { } ;
407+ } ,
408+ set : function ( value ) {
409+ __trace ( "Display.loaderInfo is disabled" , "warn" ) ;
410+ }
411+ } ) ;
412+ Object . defineProperty ( Display , 'stage' , {
413+ get : function ( ) {
414+ return _root ;
415+ } ,
416+ set : function ( value ) {
417+ __trace ( "Display.stage is read-only" , "warn" ) ;
418+ }
419+ } ) ;
420+ Object . defineProperty ( Display , 'version' , {
421+ get : function ( ) {
422+ return "CCLDisplay/1.0 HTML5/* (bilibili, like BSE, like flash, AS3 compatible)" ;
423+ } ,
424+ set : function ( value ) {
425+ __trace ( "Display.version is read-only" , "warn" ) ;
426+ }
427+ } ) ;
428+ Object . defineProperty ( Display , 'width' , {
429+ get : function ( ) {
430+ return _width ;
431+ } ,
432+ set : function ( value ) {
433+ __trace ( "Display.width is read-only" , "warn" ) ;
434+ }
435+ } ) ;
436+ Object . defineProperty ( Display , 'height' , {
437+ get : function ( ) {
438+ return _height ;
439+ } ,
440+ set : function ( value ) {
441+ __trace ( "Display.height is read-only" , "warn" ) ;
442+ }
443+ } ) ;
444+ Object . defineProperty ( Display , 'fullScreenWidth' , {
445+ get : function ( ) {
446+ return _fullScreenWidth ;
447+ } ,
448+ set : function ( value ) {
449+ __trace ( "Display.fullScreenWidth is read-only" , "warn" ) ;
450+ }
451+ } ) ;
452+ Object . defineProperty ( Display , 'fullScreenHeight' , {
453+ get : function ( ) {
454+ return _fullScreenHeight ;
455+ } ,
456+ set : function ( value ) {
457+ __trace ( "Display.fullScreenHeight is read-only" , "warn" ) ;
458+ }
459+ } ) ;
460+ Object . defineProperty ( Display , 'frameRate' , {
461+ get : function ( ) {
462+ return _frameRate ;
463+ } ,
464+ set : function ( value ) {
465+ __pchannel ( "Display:SetFrameRate" , value ) ;
466+ }
467+ } ) ;
296468} ) ( Display || ( Display = { } ) ) ;
297469
298470/// <reference path="CommentButton.ts" />
0 commit comments