UIComponentToBitmap

Design Cognition, Flex Add comments

Essa classe converte um UIComponent num bitmap. Eu devia ter marcado o link de onde saiu isso…

[code lang="actionscript"] package utils
{
import mx.core.UIComponent;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Matrix;public class UIComponentToBitmap extends UIComponent{

private var _contentBitmap:Bitmap;

public function UIComponentToBitmap():void{
super();
}

public static function draw(content:UIComponent):Bitmap{
var bitmapData:BitmapData = new BitmapData(content.width,
content.height,
true,
0xFFFFFF);
var m:Matrix= new Matrix();
bitmapData.draw(content, m);
return new Bitmap(bitmapData,"auto", false);
}
}
}[/code]

E aqui um exemplo de uso:
[code lang="actionscript"]
import mx.core.UIComponent;
import utils.UIComponentToBitmap;

public function initApp():void{
	var mypanel:Panel=new Panel;
        addChild(mypanel);

        var comp:UIComponent=new UIComponent;
	addChild(comp);

	var uic2bmp:Bitmap= UIComponentToBitmap.draw(mypanel);
	comp.addChild(uic2bmp);
}
[/code]

3 Responses to “UIComponentToBitmap”

  1. Fagner Says:

    Gabriela desculpe minha ignorancia.. mas teria algum exemplo de aplicação de codigo acima?!
    abraço…

  2. gabrielaperry Says:

    Coloquei no post.

  3. Felipebusiness Says:

    Gabriela, pode me ajudar a aplicar isso com o Flex?
    http://www.bytearray.org/?p=26
    Esse é show de bola…
    Felipebusiness

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in