Providing code sample might help people see where your code might be failing. It's a lot easier to look at than words.
<mx:TextArea id="abc" text="abc" width="200" height="200"/> printPDF.addPage(); printPDF.addImage(abc);
And this doesn't work:
var abc:TextArea = new TextArea; abc.text = "abc"; abc.width = 200; abc.height = 200; addChild(abc); printPDF.addPage(); printPDF.addImage(abc);
There is one more thing I just found out - when I run the second (pure AS) code in debug mode it works fine.
I think that it's becouse code executes slowly. And when code executes fast (without debug mode) the 'addImage' statement adds TextArea without it's properties like 'text'. But on the other hand alive pdf must add objects, which are displayed - so the code 'addChild(abc)' must be executed or else I got error that 'abc' is not on stage or something similar. And I don't get this error.
I completly don't understand this
Any ideas, please?
I've had a similar problem with addChild before, details are very sketchy in my mind now, but it was an extenal library and I was trying to add a non-sprite object using addChild which was failing.
Try replacing addChild with addElement and see if that works.
There is no 'addElement' method. At least in my flex 3
Could be something as simple as your text not being enclosed in string double quotes
abc.text = abc;
abc.text = "abc";
I see no mistakes in the code, and there is no such method in flex help system either.
I got some help on other foru:
"most component rely on RENDER event and stage.invalidate() to draw themselves on the screen for efficiency. So in this case the drawing of the actual textarea is delayed until the next RENDER event is called. That's where your problem probably lies."
The solution was to add 'validateNow' function to textArea before sending it to pdf.
addChild(abc); abc.validateNow(); printPDF.addPage();