Flex 图片调整(Matrix 矩阵)(放大/放小/左旋转/右旋转/上移/下移/左移/右移/还原/调整 ...
来源:互联网 发布:黑色沙漠捏脸数据放哪 编辑:程序博客网 时间:2024/04/30 09:30
转:http://blog.csdn.net/sjz168/article/details/6597623
很不错的例子,很好的讲解了Matrix的使用
<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="initData();" minWidth="955" minHeight="600"><s:layout><s:VerticalLayout/></s:layout><fx:Declarations><!-- 将非可视元素(例如服务、值对象)放在此处 --></fx:Declarations><fx:Script><![CDATA[//旋转初始值private var rotateDeg:Number=0;private function initData():void{}//旋转private function degreesToRadians(degrees:Number):Number { return (degrees * (Math.PI / 180)); } /** * 判断是左旋转还是有旋转 * */private function button_click(evt:Event):void {var direction:int;switch (evt.currentTarget) {case degreesUp:direction = +1;break;case degreesDown:direction = -1;break;}var radians:Number = degreesToRadians(direction);var offsetWidth:Number = image2.width / 2;var offsetHeight:Number = image2.height / 2;var tempMatrix:Matrix = image2.transform.matrix;tempMatrix.translate(-offsetWidth, -offsetHeight);tempMatrix.rotate(radians);tempMatrix.translate(+offsetWidth, +offsetHeight);image2.transform.matrix = tempMatrix;rotateDeg = image2.rotation;}//恢复原装private function resetImage():void { var tempMatrix:Matrix = image2.transform.matrix;tempMatrix.identity();image2.transform.matrix = tempMatrix;rotateDeg = image2.rotation;} //放大private function toBig():void{var tempMatrix:Matrix = image2.transform.matrix;tempMatrix.scale(1.1, 1.1);image2.transform.matrix = tempMatrix;rotateDeg = image2.rotation;}//缩小private function toSmall():void{var tempMatrix:Matrix = image2.transform.matrix;tempMatrix. scale(0.9, 0.9);image2.transform.matrix = tempMatrix;rotateDeg = image2.rotation;}//上下左右移动//上移private function toTop():void{var tempMatrix:Matrix = image2.transform.matrix;tempMatrix.translate(0,-10);image2.transform.matrix = tempMatrix;rotateDeg = image2.rotation;}//下移private function toDown():void{var tempMatrix:Matrix = image2.transform.matrix;tempMatrix.translate(0,10);image2.transform.matrix = tempMatrix;rotateDeg = image2.rotation;}//左移private function toLeft():void{var tempMatrix:Matrix = image2.transform.matrix;tempMatrix.translate(-10, 0);image2.transform.matrix = tempMatrix;rotateDeg = image2.rotation;}//右移private function toRight():void{var tempMatrix:Matrix = image2.transform.matrix;tempMatrix.translate(10, 0);image2.transform.matrix = tempMatrix;rotateDeg = image2.rotation;}//快照显示private function showImage3():void{var bd:BitmapData = new BitmapData(g3.width,g3.height);var m:Matrix = new Matrix();bd.draw(g3,m);image3.source=new Bitmap(bd);}]]></fx:Script><mx:HBox><s:Button label="+" autoRepeat="true" click="toBig();" buttonDown="toBig();"/><s:Button label="-" autoRepeat="true" click="toSmall();" buttonDown="toSmall();"/><s:Button label="↑" autoRepeat="true" click="toTop();" buttonDown="toTop();"/><s:Button label="←" autoRepeat="true" click="toLeft();" buttonDown="toLeft();"/><s:Button label="→" autoRepeat="true" click="toRight();" buttonDown="toRight();"/><s:Button label="↓" autoRepeat="true" click="toDown();" buttonDown="toDown();"/><s:Button label="左旋转" id="degreesUp" autoRepeat="true" click="button_click(event);" buttonDown="button_click(event);" /><s:Button label="右旋转" id="degreesDown" autoRepeat="true" click="button_click(event);" buttonDown="button_click(event);"/><s:Button label="Reset" click="resetImage();"/></mx:HBox><mx:Canvas id="g3" width="200" height="200" horizontalScrollPolicy="off" verticalScrollPolicy="off"><mx:Image id="image2" source="assets/p4.jpg" width="200" scaleContent="true" maintainAspectRatio="true" height="200" /> </mx:Canvas><s:Button label="生成快照" click="showImage3();"/><mx:Image width="200" id="image3" height="200" source="@Embed('assets/photo03.jpg')"/></s:Application>
- Flex 图片调整(Matrix 矩阵)(放大/放小/左旋转/右旋转/上移/下移/左移/右移/还原/调整 ...
- Flex 图片调整(Matrix 矩阵)(放大/放小/左旋转/右旋转/上移/下移/左移/右移/还原/调整
- Flex 图片调整(Matrix 矩阵)(放大/放小/左旋转/右旋转/上移/下移/左移/右移/还原/调整 ...
- ListBox(上移,下移,左移,右移)
- ListBox(上移,下移,左移,右移)
- ListBox(上移,下移,左移,右移)
- js 上移 下移 左移 右移
- ListBox(上移,下移,左移,右移)(全部是javascript)
- ListBox实现上移,下移,左移,右移操作
- js选择左移 右移 上移 下移
- ListBox实现上移,下移,左移,右移操作
- 位运算:右移,左旋转,右旋转
- 图片的左旋转,右旋转操作!
- 实现俄罗斯方块的左移,右移,加速下移和旋转
- 进一步完善实现俄罗斯方块的左移,右移,下移和旋转
- ListBox控件实现选项的上移、下移、左移、右移
- js实现动画,右移、左移,上移,下移,左上角移动等
- 左旋转字符串与右旋转字符串
- php学习笔记(二十七)php中session的使用(基于url的)
- 链接器解析多重定义的全局变量
- js中top、parent、frame
- 第3章:游戏:石头,剪刀,布
- 重建所有表的索引的存储过程
- Flex 图片调整(Matrix 矩阵)(放大/放小/左旋转/右旋转/上移/下移/左移/右移/还原/调整 ...
- C#和C++的区别与注意(继续整理)
- ioctl的实现
- 算法导论学习笔记(三):堆排序
- 第3章:验证三角形的有效
- android repo 常用命令
- 北京是一个什么地方
- 最好的dwg文件浏览器V12.0(CAD看图软件)下载
- glance命令