用flex4实现图片的缩放及移动,可以根据浏览器的大小进行缩放比例 给点具体代码 可以吗
展开全部
//复位锚点
private function backXY():void{
b1.move(0,0);
b2.move(0,10);
}
//左旋转用
private function changeImage():void{
var _matrix:Matrix=finalImage.transform.matrix;
}
/***图片调整***/
//旋转初始值
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 = finalImage.width / 2;
var offsetHeight:Number = finalImage.height / 2;
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(-offsetWidth, -offsetHeight);
tempMatrix.rotate(radians);
tempMatrix.translate(+offsetWidth, +offsetHeight);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//恢复原装
private function resetImage():void {
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.identity();
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//放大
private function toBig():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.scale(1.1, 1.1);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//缩埋做小
private function toSmall():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix. scale(0.9, 0.9);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//上下左右移动
//上移
private function toTop():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(0,-10);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//下移
private function toDown():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(0,10);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//左移
private function toLeft():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(-10, 0);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//右移
private function toRight():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(10, 0);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//快照显示
private function showImage3():void{
var bd:BitmapData = new BitmapData(g3.width,g3.height);
var m:Matrix = new Matrix();
bd.draw(g3,m);
finalImage.source=new Bitmap(bd);
}
private function backXY():void{
b1.move(0,0);
b2.move(0,10);
}
//左旋转用
private function changeImage():void{
var _matrix:Matrix=finalImage.transform.matrix;
}
/***图片调整***/
//旋转初始值
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 = finalImage.width / 2;
var offsetHeight:Number = finalImage.height / 2;
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(-offsetWidth, -offsetHeight);
tempMatrix.rotate(radians);
tempMatrix.translate(+offsetWidth, +offsetHeight);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//恢复原装
private function resetImage():void {
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.identity();
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//放大
private function toBig():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.scale(1.1, 1.1);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//缩埋做小
private function toSmall():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix. scale(0.9, 0.9);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//上下左右移动
//上移
private function toTop():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(0,-10);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//下移
private function toDown():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(0,10);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//左移
private function toLeft():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(-10, 0);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//右移
private function toRight():void{
var tempMatrix:Matrix = finalImage.transform.matrix;
tempMatrix.translate(10, 0);
finalImage.transform.matrix = tempMatrix;
rotateDeg = finalImage.rotation;
}
//快照显示
private function showImage3():void{
var bd:BitmapData = new BitmapData(g3.width,g3.height);
var m:Matrix = new Matrix();
bd.draw(g3,m);
finalImage.source=new Bitmap(bd);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询