Durai_ram
02-17-2009, 03:36 PM
Hi Dude!
I had problem with masking, i drawn a mask on text area which reside in the canvas. Using PNGEncoder to capture the canvas as an image on button click. I can capture the image as a canvas, but the problem was text invisible in text area on canvas becaz of mask. i need to solve this issue! .
coding for Canvas:
private function createTextArea():void
{
myText.setStyle("fontFamily","Verdana");
myText.setStyle("fontSize",12);
myText.setStyle("backgroundColor","undefined");
myText.setStyle("borderStyle","none");
myText.setStyle("textAlign","center");
myText.width=150;
myText.height =40;
myText.editable=false;
myText.wordWrap=true;
maskText.graphics.beginFill(0xFFFFFF, 0.5);
maskText.graphics.drawRect(0, 0,250,80);
maskText.graphics.endFill();
maskText.height=80;
maskText.width=180;
maskText.x=220;
maskText.y=312;
myText.mask=maskText;
this.addChild(maskText);
oh.addChildAt(myText,0);
oh.x=150;
oh.y=280;
oh.mouseChildren=true;
oh.setStyle("borderStyle","none");
oh.allowRotate=true;
oh.allowHMove=false;
oh.allowVMove=false;
oh.alwaysMaintainAspectRatio=false;
oh.allowKeyboardManipulation=false;
myArea.addEventListener(MouseEvent.MOUSE_OUT,showF ontStyleHandler);
oh.addEventListener(MouseEvent.MOUSE_DOWN,setMouse PointHandler);
oh.addEventListener(MouseEvent.MOUSE_UP,resetMouse PointHandler);
oh.addEventListener(ObjectHandleEvent.OBJECT_RESIZ ING_EVENT,resizingTextHandler);
oh.addEventListener(ObjectHandleEvent.OBJECT_RESIZ ED_EVENT,resizedTextHandler);
myCan1.addChild(oh);
}
coding for JPEGEncoder:
protected function doSave():void
{
var bitmapData:BitmapData = new BitmapData(myCan1.width, myCan1.height);
bitmapData.draw(myCan1,new Matrix());
var bitmap : Bitmap = new Bitmap(bitmapData);
var jpg:JPEGEncoder = new JPEGEncoder();
var bytes:ByteArray = jpg.encode(bitmapData);
file.save(bytes,"myImage"+image+".jpg");
image++;
}
Thanx Buddy!
I had problem with masking, i drawn a mask on text area which reside in the canvas. Using PNGEncoder to capture the canvas as an image on button click. I can capture the image as a canvas, but the problem was text invisible in text area on canvas becaz of mask. i need to solve this issue! .
coding for Canvas:
private function createTextArea():void
{
myText.setStyle("fontFamily","Verdana");
myText.setStyle("fontSize",12);
myText.setStyle("backgroundColor","undefined");
myText.setStyle("borderStyle","none");
myText.setStyle("textAlign","center");
myText.width=150;
myText.height =40;
myText.editable=false;
myText.wordWrap=true;
maskText.graphics.beginFill(0xFFFFFF, 0.5);
maskText.graphics.drawRect(0, 0,250,80);
maskText.graphics.endFill();
maskText.height=80;
maskText.width=180;
maskText.x=220;
maskText.y=312;
myText.mask=maskText;
this.addChild(maskText);
oh.addChildAt(myText,0);
oh.x=150;
oh.y=280;
oh.mouseChildren=true;
oh.setStyle("borderStyle","none");
oh.allowRotate=true;
oh.allowHMove=false;
oh.allowVMove=false;
oh.alwaysMaintainAspectRatio=false;
oh.allowKeyboardManipulation=false;
myArea.addEventListener(MouseEvent.MOUSE_OUT,showF ontStyleHandler);
oh.addEventListener(MouseEvent.MOUSE_DOWN,setMouse PointHandler);
oh.addEventListener(MouseEvent.MOUSE_UP,resetMouse PointHandler);
oh.addEventListener(ObjectHandleEvent.OBJECT_RESIZ ING_EVENT,resizingTextHandler);
oh.addEventListener(ObjectHandleEvent.OBJECT_RESIZ ED_EVENT,resizedTextHandler);
myCan1.addChild(oh);
}
coding for JPEGEncoder:
protected function doSave():void
{
var bitmapData:BitmapData = new BitmapData(myCan1.width, myCan1.height);
bitmapData.draw(myCan1,new Matrix());
var bitmap : Bitmap = new Bitmap(bitmapData);
var jpg:JPEGEncoder = new JPEGEncoder();
var bytes:ByteArray = jpg.encode(bitmapData);
file.save(bytes,"myImage"+image+".jpg");
image++;
}
Thanx Buddy!