66var Display ;
77( function ( Display ) {
88 var Point = ( function ( ) {
9- function Point ( ) {
9+ function Point ( x , y ) {
10+ if ( typeof x === "undefined" ) { x = 0 ; }
11+ if ( typeof y === "undefined" ) { y = 0 ; }
12+ this . x = x ;
13+ this . y = y ;
1014 }
15+
16+ Object . defineProperty ( Point . prototype , "length" , {
17+ get : function ( ) {
18+ return Math . sqrt ( this . x * this . x + this . y * this . y ) ;
19+ } ,
20+ set : function ( l ) {
21+ __trace ( "Point.length is read-only" , "err" ) ;
22+ } ,
23+ enumerable : true ,
24+ configurable : true
25+ } ) ;
26+
27+ Point . prototype . add = function ( p ) {
28+ return new Point ( p . x + this . x , p . y + this . y ) ;
29+ } ;
30+
31+ Point . prototype . subtract = function ( p ) {
32+ return new Point ( this . x - p . x , this . y - p . y ) ;
33+ } ;
34+
35+ Point . interpolate = function ( a , b , f ) {
36+ return new Point ( ( b . x - a . x ) * f + a . x , ( b . y - a . y ) * f + a . y ) ;
37+ } ;
38+
39+ Point . prototype . offset = function ( dx , dy ) {
40+ this . x += dx ;
41+ this . y += dy ;
42+ } ;
43+
44+ Point . prototype . normalize = function ( thickness ) {
45+ var ratio = thickness / this . length ;
46+ this . x *= ratio ;
47+ this . y *= ratio ;
48+ } ;
49+
50+ Point . polar = function ( r , theta ) {
51+ return new Point ( r * Math . cos ( theta ) , r * Math . sin ( theta ) ) ;
52+ } ;
53+
54+ Point . prototype . setTo = function ( x , y ) {
55+ this . x = x ;
56+ this . y = y ;
57+ } ;
58+
59+ Point . prototype . equals = function ( p ) {
60+ if ( p . x === this . x && p . y === this . y )
61+ return true ;
62+ return false ;
63+ } ;
64+
65+ Point . prototype . toString = function ( ) {
66+ return "(x=" + this . x + ", y=" + this . y + ")" ;
67+ } ;
68+
69+ Point . prototype . clone = function ( ) {
70+ return new Point ( this . x , this . y ) ;
71+ } ;
1172 return Point ;
1273 } ) ( ) ;
1374 Display . Point = Point ;
@@ -97,8 +158,10 @@ var Display;
97158 var Matrix3D = ( function ( ) {
98159 function Matrix3D ( iv ) {
99160 if ( typeof iv === "undefined" ) { iv = [ 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 ] ; }
100- if ( iv . length == 16 ) {
161+ if ( iv . length === 16 ) {
101162 this . _data = iv ;
163+ } else if ( iv . length === 0 ) {
164+ this . identity ( ) ;
102165 } else {
103166 __trace ( "Matrix3D initialization vector invalid" , "warn" ) ;
104167 this . identity ( ) ;
@@ -270,8 +333,8 @@ var Display;
270333 } ) ( ) ;
271334 Display . Vector3D = Vector3D ;
272335
273- function createMatrix ( ) {
274- return new Matrix ( ) ;
336+ function createMatrix ( a , b , c , d , tx , ty ) {
337+ return new Matrix ( a , b , c , d , tx , ty ) ;
275338 }
276339 Display . createMatrix = createMatrix ;
277340
@@ -285,8 +348,10 @@ var Display;
285348 }
286349 Display . createColorTransform = createColorTransform ;
287350
288- function createGradientBox ( ) {
289- return null ;
351+ function createGradientBox ( width , height , rotation , tX , tY ) {
352+ var m = new Matrix ( ) ;
353+ m . createGradientBox ( width , height , rotation , tX , tY ) ;
354+ return m ;
290355 }
291356 Display . createGradientBox = createGradientBox ;
292357
@@ -300,7 +365,7 @@ var Display;
300365 Display . createVector3D = createVector3D ;
301366
302367 function projectVector ( matrix , vector ) {
303- return [ ] ;
368+ return matrix . transformVector ( vector ) ;
304369 }
305370 Display . projectVector = projectVector ;
306371
@@ -324,7 +389,7 @@ var Display;
324389 function createPoint ( x , y ) {
325390 if ( typeof x === "undefined" ) { x = 0 ; }
326391 if ( typeof y === "undefined" ) { y = 0 ; }
327- return new Point ( ) ;
392+ return new Point ( x , y ) ;
328393 }
329394 Display . createPoint = createPoint ;
330395
@@ -576,6 +641,7 @@ var Display;
576641 set : function ( m ) {
577642 this . _matrix = null ;
578643 this . _matrix3d = m ;
644+ this . update ( ) ;
579645 } ,
580646 enumerable : true ,
581647 configurable : true
@@ -588,6 +654,7 @@ var Display;
588654 set : function ( m ) {
589655 this . _matrix3d = null ;
590656 this . _matrix = m ;
657+ this . update ( ) ;
591658 } ,
592659 enumerable : true ,
593660 configurable : true
@@ -629,6 +696,8 @@ var Display;
629696 } ;
630697
631698 Transform . prototype . update = function ( ) {
699+ if ( this . _parent === null )
700+ return ;
632701 this . _parent . transform = this ;
633702 } ;
634703
@@ -654,12 +723,14 @@ var Display;
654723
655724 /**
656725 * Clones the current transform object
657- * The new transform still binds to the old DisplayObject
658- * unless the parent is modifed
726+ * The new transform does not bind to any object until it
727+ * is bound to an object. Before that, updates don't
728+ * take effect.
729+ *
659730 * @returns {Transform } - Clone of transform object
660731 */
661732 Transform . prototype . clone = function ( ) {
662- var t = new Transform ( this . _parent ) ;
733+ var t = new Transform ( null ) ;
663734 t . _matrix = this . _matrix ;
664735 t . _matrix3d = this . _matrix3d ;
665736 return t ;
@@ -1507,6 +1578,23 @@ var Display;
15071578 return Sprite ;
15081579 } ) ( Display . DisplayObject ) ;
15091580 Display . Sprite = Sprite ;
1581+
1582+ var RootSprite = ( function ( _super ) {
1583+ __extends ( RootSprite , _super ) ;
1584+ function RootSprite ( ) {
1585+ _super . call ( this , "__root" ) ;
1586+ }
1587+ Object . defineProperty ( RootSprite . prototype , "parent" , {
1588+ get : function ( ) {
1589+ __trace ( "SecurityError: No access above root sprite." , "err" ) ;
1590+ return null ;
1591+ } ,
1592+ enumerable : true ,
1593+ configurable : true
1594+ } ) ;
1595+ return RootSprite ;
1596+ } ) ( Sprite ) ;
1597+ Display . RootSprite = RootSprite ;
15101598} ) ( Display || ( Display = { } ) ) ;
15111599/**
15121600* MotionManager Polyfill for AS3.
@@ -2157,6 +2245,11 @@ var Display;
21572245 return new CommentField ( text , params ) ;
21582246 }
21592247 Display . createComment = createComment ;
2248+
2249+ function createTextField ( ) {
2250+ return new CommentField ( "" , { } ) ;
2251+ }
2252+ Display . createTextField = createTextField ;
21602253} ) ( Display || ( Display = { } ) ) ;
21612254/**
21622255* Display Adapter
@@ -2182,7 +2275,7 @@ var Display;
21822275 Display . fullScreenHeight ;
21832276 Display . frameRate ;
21842277
2185- var _root = new Display . Sprite ( "__root" ) ;
2278+ var _root = new Display . RootSprite ( ) ;
21862279 var _width = 0 ;
21872280 var _height = 0 ;
21882281 var _fullScreenWidth = 0 ;
0 commit comments