FLEX 图片旋转与缩放

<?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" minWidth="955" minHeight="600"
applicationComplete="initDragAndDrop()"
>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.display.BitmapData;
import flash.net.URLLoader;
import flash.net.URLRequest;
  import flash.text.TextField;
import mx.collections.ArrayCollection;
import mx.containers.Canvas;
import mx.controls.Alert;
import mx.controls.VideoDisplay;
import mx.core.DragSource;
import mx.core.UIComponent;
import mx.events.*;
import mx.graphics.ImageSnapshot;
import mx.graphics.codec.JPEGEncoder;
import mx.managers.DragManager;
import spark.components.Button;
import spark.components.Image;

private function rotateImage():void{
var img:Image = myGroup.getChildAt( 1 ) as Image;
var matrix:Matrix = new Matrix() ;
var tmpMatrix:Matrix = img.transform.matrix;
var oHeight:Number = img.height / 2;
var oWidth:Number = img.width / 2;
tmpMatrix.translate(-oWidth, -oHeight);
var rotateNum:Number = parseInt( rotateNum.text );
tmpMatrix.rotate( Math.PI / 180 * rotateNum );
tmpMatrix.translate(oWidth, oHeight);
img.transform.matrix = tmpMatrix;
}

private function scaleImage():void{
var img:Image = myGroup.getChildAt( 1 ) as Image;
img.scaleX = zoomSlider.value ;
img.scaleY = zoomSlider.value ;
}

]]>
</fx:Script>
<s:VGroup id = "Catalog">
<s:Image id = "panada" source = "100.jpeg"
width = "100" height = "100"
mouseMove = "initJpgDrag(event)"
/>
 </s:VGroup>
<s:TextInput id = "rotateNum" restrict="0-9\-\+" />
<s:Button click="rotateImage()" label = "旋转" />
<s:HSlider id="zoomSlider"
height="10"
buttonMode = "true" useHandCursor = "true"
minimum = "1" maximum = "5"
snapInterval = "0.5" value = "1" change = "scaleImage()" />
</s:Application>

你可能感兴趣的:(.net,xml,Flex,Flash,Adobe)