I made this work directly from the markup, with a bit of ActionScript thrown in the mix. Assuming that the custom template contains a text element named "myCustomTextElement" and the template has been registered with AGS:
[Bindable] private var customcontent:String ='This is line one.\nThis is line two.';
[Bindable] private var customTextElems:Object;
private function init():void{
customTextElems = new Object;
customTextElems.myCustomTextElement = customcontent;
this.printParameters.layoutOptions.customTextElements = customTextElems;
printTask.getServiceInfo();
}
<esri:PrintParameters id="printParameters"
format="PDF"
layoutTemplate="MyCustomTemplate"
<esri:layoutOptions>
<esri:LayoutOptions author="Author: ArcGIS for Flex Team"
copyright="Copyright: © ArcGIS for Server"
title="My Map">
</esri:LayoutOptions>
</esri:layoutOptions>
</esri:PrintParameters>
For the record, I tried to implement everything in the markup but the Flex compiler did not allow me to bind a fx:String element. This is strange, as Adobe documentation has an example for string binding. Anyway, if the fx:String value is hard-coded, then the code works.
<esri:PrintParameters id="printParameters"
format="PDF"
layoutTemplate="MyCustomTemplate"
map="{map}" >
<esri:layoutOptions>[INDENT]<esri:LayoutOptions author="Author: ArcGIS for Flex Team"
[/INDENT]
[INDENT] copyright="Copyright: © ArcGIS for Server"
[/INDENT]
[INDENT] title="My Map">
[/INDENT]
[INDENT=2]<esri:customTextElements>
[/INDENT]
[INDENT=3]<fx:Object>
[/INDENT]
[INDENT=4]<fx:myCustomTextElement>
[/INDENT]
[INDENT=5]<fx:String id="actualText">{customcontent}</fx:String> (error raised �??Data binding expression not allowed here�?�)
[/INDENT]
[INDENT=4]</fx:myCustomTextElement>
[/INDENT]
[INDENT=3]</fx:Object>
[/INDENT]
[INDENT=2]</esri:customTextElements>
[/INDENT]
[INDENT]</esri:LayoutOptions>
[/INDENT]
</esri:layoutOptions>
</esri:PrintParameters>