关于CSS裁剪图片参考->http://lpyyn.iteye.com/admin/blogs/2066496
Flex中引用图片的方式:
1.多个图片文件封装到swf中,使用Embed元数据标签声明图片引用的Class属性。具体操作参考附件“[Embed]标签嵌入外部资源 .rar”。
2.分别使用Embed标签嵌入单个图片文件。引用的方式和方式1一样,这是引用的图片文件是单个的图片文件。
3.直接在Imag标签中使用Embed引入图片、指定图片的路径、使用图片的bitmap对象。如下:
4.在flex中根据指定的位置(x、y)、裁剪图片宽度和高度裁剪图片。这种方式实现的效果类似于CSS样式对图片的裁剪。
裁剪图片类:
package com.imageSplit{
import flash.display.Bitmap;
public class ImageInfo{
public function ImageInfo(source:Bitmap,width:Number,height:Number){
this.source = source ;
this.width = width ;
this.height = height ;
}
[Bindable]
public var source:Bitmap ;
[Bindable]
public var width:Number ;
[Bindable]
public var height:Number ;
}
}
裁剪图片配置文件:
<?xml version="1.0" ?> <configuration> <srcImage source="com/markers_new.png"> <!-- 在地图上结果标签 --> <image id="MAP_A" x="0" y="0" width="23" height="31"/> <image id="MAP_B" x="28" y="0" width="23" height="31"/> <image id="MAP_C" x="56" y="0" width="23" height="31"/> <image id="MAP_D" x="86" y="0" width="23" height="31"/> <image id="MAP_E" x="115" y="0" width="23" height="31"/> <image id="MAP_F" x="144" y="0" width="23" height="31"/> <image id="MAP_G" x="172" y="0" width="23" height="31"/> <image id="MAP_H" x="201" y="0" width="23" height="31