Playing around with the powerful and versatile object Matrix (matrix), linked to the changes, you can do bizarre things. These tools are used to apply special transformations to a visual object, such as a Sprite. You can, for example, scale, rotate, or twist (skew) a Sprite. e rotation ), per l'effetto Skew bisogna ricorrere direttamente alle matrici. While the first two functions (scale and rotation) Sprite objects (not just) make available directly to the properties ( scaleX / scaleY , and rotation ), the skew effect should appeal directly to the matrices. What I would like to emphasize here is that when we modify a graphic object all its internal coordinates are moved:
The code for this play is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | . MouseEvent ; import flash.events. MouseEvent ; . Matrix ; flash.geom imports. Matrix ; / / / / Flag to detect the mousedown Boolean = false ; md var: Boolean = false; / / / / Create a blackboard front Sprite = new Sprite ( ) ; var lvg1: Sprite = new Sprite (); . lineStyle ( 0 , 0xffffff ) ; lvg1. graphics. lineStyle (0, 0xffffff); . beginFill ( 0x666666 ) ; lvg1. graphics. beginFill (0x666666); . drawRect ( 0 , 0 , 199 , 199 ) ; lvg1. graphics. drawRect (0, 0, 199, 199); . endFill ( ) ; lvg1. graphics. endFill (); lvg1 ) ; addChild (lvg1); = lvg1 . y = 30 ; lvg1. lvg1 x =. y = 30; / / / / Create the board tilted Sprite = new Sprite ( ) ; var lvg2: Sprite = new Sprite (); . lineStyle ( 0 , 0xffffff ) ; lvg2. graphics. lineStyle (0, 0xffffff); . beginFill ( 0x666666 ) ; lvg2. graphics. beginFill (0x666666); . drawRect ( 0 , 0 , 199 , 199 ) ; lvg2. graphics. drawRect (0, 0, 199, 199); . endFill ( ) ; lvg2. graphics. endFill (); lvg2 ) ; addChild (lvg2); / / / / Create and imposed a matrix for the inclination of the / / Board lvg2 Matrix = new Matrix ( ) ; var myMatrix: Matrix = new Matrix (); / / Is inclined -25 degrees : Number = Math . PI * 2 * - 25 / 360 ; var angle: Number = Math . * PI * 2 - 25 / 360; / / Stacker = 300 ; myMatrix. tx = 300; = 100 ; myMatrix. ty = 100; = Math . tan ( angle ) ; myMatrix. b = Math . tan (angle); . matrix = myMatrix ; lvg2. transform. myMatrix = matrix; / / / / Paint event ( MouseEvent . MOUSE_DOWN , _onMouseDown ) ; lvg1. addEventListener ( MouseEvent . MOUSE_DOWN, _onMouseDown); ( MouseEvent . MOUSE_MOVE , _onMouseMove ) ; lvg1. addEventListener ( MouseEvent . MOUSE_MOVE, _onMouseMove); ( MouseEvent . MOUSE_UP , _onMouseUp ) ; lvg1. addEventListener ( MouseEvent . MOUSE_UP, _onMouseUp); / / e : MouseEvent ) : void { _onMouseDown function (e: MouseEvent ): void { "_onMouseDown" ) ; trace ("_onMouseDown"); : uint = 0xffffff ; var c: uint = 0xffffff; . graphics . lineStyle ( 10 , c , 1 ) ; and. target. graphics. lineStyle (10, c, 1); . lineStyle ( 10 , c , 1 ) ; lvg2. graphics. lineStyle (10, c, 1); . graphics . moveTo ( e . localX , e . localY ) ; and. target. graphics. moveTo (and. localX, and. localY); . moveTo ( e . localX , e . localY ) ; lvg2. graphics. moveTo (and. localX, and. localY); md = true; } / / e : MouseEvent ) : void { _onMouseUp function (e: MouseEvent ): void { md = false; } / / e : MouseEvent ) : void { _onMouseMove function (e: MouseEvent ): void { "_onMouseMove" ) ; trace ("_onMouseMove"); md ) { if (md) { . graphics . lineTo ( e . localX , e . localY ) ; and. target. graphics. lineTo (and. localX, and. localY); . lineTo ( e . localX , e . localY ) ; lvg2. graphics. lineTo (and. localX, and. localY); } } |
e non via x e y . Note, lines 30 and 31, the second Sprite ( lvg2 ) is translated using the Matrix and not on x and y .
In addition, lines 46 and 58, the sprite drawing functions on tilted maintain the same form as those of the Sprite front ( lvg1 ).










[...] Painting Flash CS3: Matrix matrix effects with Paint Create a Flash [...]