0

如何在 flex 应用程序中拆分此图像。事实上,我正在考虑从 xml 调用图像并将其拆分为“flex application”

我尝试了一些方法。但它不起作用!
我会很高兴你的帮助。

 <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"   />
4

1 回答 1

0

无需将位图添加到图像元素,只需将 bitmapData 设置为源:

function leftpart(e:Event):void 
{
    var bmpd1:BitmapData = new BitmapData    (loader.width/2,loader.height,false)
    bmpd1.draw(loader);
    image_loader.source = bmpd1;
}

您甚至不必创建一个Bitmap对象作为source接受BitmapData

于 2013-03-18T15:51:52.053 回答