[英]how can I split an image at flex application
how can I split this image in flex application. 如何在Flex应用程序中拆分此图像。 in fact I'm thinking to call an image from xml and split it at " flex application"
实际上,我正在考虑从xml调用图像,然后在“ flex application”处将其拆分
I tried a few methods.but it doesn't work! 我尝试了几种方法,但是没有用!
I'll glad for your help. 我会很高兴您的帮助。
<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" initialize="image_loader_completeHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function image_loader_completeHandler(event:Event):void
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, leftpart);
loader.load( new URLRequest("http://www.helpexamples.com/flash/images/image1.jpg"));
function leftpart(e:Event):void
{
var bmpd1:BitmapData = new BitmapData (loader.width/2,loader.height,false)
bmpd1.draw(loader,null,null,null,rec);
var rec:Rectangle = new Rectangle (0,0,bmpd1.width,bmpd1.height);
var bmp:Bitmap = new Bitmap (bmpd1);
image_loader.addChild(bmp);
}
}
]]>
</fx:Script>
<s:Image id="image_loader" />
Instead of adding the bitmap to the image element, simply set the bitmapData as the source: 无需将位图添加到图像元素,只需将bitmapData设置为源:
function leftpart(e:Event):void
{
var bmpd1:BitmapData = new BitmapData (loader.width/2,loader.height,false)
bmpd1.draw(loader);
image_loader.source = bmpd1;
}
You don't even have to create a Bitmap
object as source
accepts BitmapData
您甚至不必创建
Bitmap
对象,因为source
接受BitmapData
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.