package { import flash.display.*; import flash.geom.Point; import mx.core.UIComponent; public class quad extends UIComponent //UIComponent is Flex's basic display object class { public var im:BitmapData; private var bdTransform:BitmapTransformer; public var tl3:point3D, bl3:point3D, br3:point3D, tr3:point3D; private var tl3base:point3D, bl3base:point3D, br3base:point3D, tr3base:point3D; public function quad(topLeft:point3D, bottomLeft:point3D, bottomRight:point3D, topRight:point3D){ bdTransform=new BitmapTransformer(512,512,10,10); //Initialise the quad's four x,y,z vertices and their copies tl3base=tl3=topLeft; tr3base=tr3=topRight; bl3base=bl3=bottomLeft; br3base=br3=bottomRight; } public function show():void{ this.graphics.clear(); //Use bdTransform to map rectangular bitmap onto this quad bdTransform.mapBitmapData(im, tl3.twoD, tr3.twoD, br3.twoD, bl3.twoD, this); } public function resetTransformations():void{ tl3.resetTransformation(); tr3.resetTransformation(); bl3.resetTransformation(); br3.resetTransformation(); } public function rotateAboutY(angle:Number):void{ tl3.rotateAboutY(angle); bl3.rotateAboutY(angle); br3.rotateAboutY(angle); tr3.rotateAboutY(angle); } public function translate(tx:Number, ty:Number, tz:Number):void{ tl3.translate(tx, ty, tz); bl3.translate(tx, ty, tz); br3.translate(tx, ty, tz); tr3.translate(tx, ty, tz); } } }