Category Archives: DisplayObject

Skew DisplayObject

Actionscript:
  1. var box:Shape = Shape(addChild(new Shape()));
  2. with (box.graphics) beginFill(0x006666), drawRect(0,0,50,50);
  3. box.x = box.y = 100;
  4.  
  5. addEventListener(Event.ENTER_FRAME, onLoop);
  6.  
  7. function onLoop(evt:Event):void {
  8.    
  9.     var m:Matrix = box.transform.matrix;
  10.     // skew on the X
  11.     m.c = (mouseX - stage.stageWidth / 2 ) / stage.stageWidth;
  12.    
  13.     // skew on the Y
  14.     // m.b = (mouseX - stage.stageWidth / 2 ) / stage.stageWidth
  15.    
  16.     box.transform.matrix = m
  17. }

This skews a box Shape using the c and b properties of the transformation matrix. Note that these values don't match those in the IDE's transform window. This is good further reading if your interested in this topic.

Also posted in motion | Tagged , , | Leave a comment

DisplayObject describeType()

Actionscript:
  1. for each(var prop:String in describeType(DisplayObject).factory.accessor.@name){
  2.     trace(prop);
  3. }
  4. /* outputs
  5. scaleY
  6. mouseX
  7. mouseY
  8. mask
  9. rotation
  10. alpha
  11. transform
  12. blendMode
  13. x
  14. root
  15. loaderInfo
  16. width
  17. z
  18. rotationX
  19. scale9Grid
  20. filters
  21. rotationY
  22. y
  23. stage
  24. scaleZ
  25. parent
  26. accessibilityProperties
  27. scrollRect
  28. rotationZ
  29. height
  30. name
  31. opaqueBackground
  32. blendShader
  33. cacheAsBitmap
  34. visible
  35. scaleX
  36. */

I First saw describeType() at senocular's AS3 Tip of the Day on Kirupa.

Also posted in XML | 1 Comment