<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Save UIComponent to a file (jpg) in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58623#M1353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmm, sorry, at this point, I'm at a loss.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried pretty much the same to save a map and it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you see the preview on your screen with everything added to it?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 May 2011 17:39:19 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2011-05-12T17:39:19Z</dc:date>
    <item>
      <title>Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58616#M1346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am attempting to save a UIComponent that includes a title, subtitle, map and textarea to a file in jpg format. Can anyone provide a simple example of this?&amp;nbsp; Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 12:05:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58616#M1346</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2011-05-12T12:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58617#M1347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's been a while since I've done this, but you can turn the component to a bitmap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var bmd:BitmapData = new BitmapData(com.width, comp.height);
bmd.draw(comp, new Matrix());
var bm:Bitmap = new Bitmap(bmd);&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you can use a jpeg encoder to save the bitmapdata to a jpeg file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Flex Framework provides it's own JPEGEncoder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mx.graphics.codec.JPEGEncoderYou just pass the BitmapData to the encoder and it does the work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a demo of how to use the jpegencoder to save the image to disc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://ntt.cc/2009/01/09/as3corelib-tutorialhow-to-use-jpegencoder-and-pngencoder-class-in-flex.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://ntt.cc/2009/01/09/as3corelib-tutorialhow-to-use-jpegencoder-and-pngencoder-class-in-flex.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:13:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58617#M1347</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-10T22:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58618#M1348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for your response!&amp;nbsp; I keep getting error "ArgumentError: Error #2015: Invalid BitmapData." on the line where I create my BitmapData object (scroll to the bottom of the code to see where I create my BitmapData).&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private function saveFile():void
{
 var zoomSliderVisibleBeforePrint:Boolean;
 if (map.zoomSliderVisible)
 {
&amp;nbsp; map.zoomSliderVisible = false;
&amp;nbsp; zoomSliderVisibleBeforePrint = true;
 }
 var printJob:FlexPrintJob = new FlexPrintJob();
 var h:Number = printJob.pageHeight;
 var w:Number = printJob.pageWidth;
 //VGROUP
 var printBox:VGroup = new VGroup();
 printBox.styleName = "PrintBox";
 printBox.width = map.width;
 //VGROUP inner
 var printBoxTitle:VGroup = new VGroup();
 var printBoxSubTitle:VGroup = new VGroup();
 var selectedAlign:String = LRCa[LRCcbo.selectedIndex];
 printBox.horizontalAlign=LRCa[LRCcbo.selectedIndex].toString().toLocaleLowerCase();

 this.addChild(printBox);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 
 try
 {
&amp;nbsp; //TITLE
&amp;nbsp; var printTitle:Label = new Label();
&amp;nbsp; printTitle.text = txtTitle.text;
&amp;nbsp; if (titleFontSize!=0)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; printTitle.setStyle("fontSize", titleFontSize);
&amp;nbsp; }
&amp;nbsp; else
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; printTitle.setStyle("fontSize", h / 12);
&amp;nbsp; }
&amp;nbsp; if (titleFontWeight!="")
&amp;nbsp;&amp;nbsp; printTitle.setStyle("fontWeight", titleFontWeight);
&amp;nbsp; printTitle.percentWidth = 100;
&amp;nbsp; printBoxTitle.addElement(printTitle);
&amp;nbsp; //SUBTITLE
&amp;nbsp; var printSubtitle:Label = new Label();
&amp;nbsp; printSubtitle.text = txtSubtitle.text;
&amp;nbsp; if (subtitleFontSize!=0)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; printSubtitle.setStyle("fontSize", subtitleFontSize);
&amp;nbsp; }
&amp;nbsp; else
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; printSubtitle.setStyle("fontSize", h / 24);
&amp;nbsp; }
&amp;nbsp; if (subtitleFontWeight!="")
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; printSubtitle.setStyle("fontWeight", subtitleFontWeight); 
&amp;nbsp; }
&amp;nbsp; printSubtitle.percentWidth = 100;
&amp;nbsp; printBoxSubTitle.addElement(printSubtitle);


&amp;nbsp; printBox.addElement(printBoxTitle);
&amp;nbsp; printBox.addElement(printBoxSubTitle);
&amp;nbsp; 
&amp;nbsp; //MAP
&amp;nbsp; var bmpMap:BitmapData = ImageSnapshot.captureBitmapData(map);
&amp;nbsp; var printImg:BitmapImage = new BitmapImage();
&amp;nbsp; printImg.smooth = true;
&amp;nbsp; printImg.source = bmpMap;
&amp;nbsp; printBox.addElement(printImg);
&amp;nbsp; //COPYRIGHT
&amp;nbsp; var now:Date = new Date();
&amp;nbsp; var printCopy:Label = new Label();
&amp;nbsp; printCopy.text = copyright + " " + now.toLocaleString() + ".";
&amp;nbsp; if (copyrightFontSize!=0)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; printCopy.setStyle("fontSize", copyrightFontSize);
&amp;nbsp; }
&amp;nbsp; else
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; printCopy.setStyle("fontSize", h / 48);
&amp;nbsp; }
&amp;nbsp; if (copyrightFontWeight!="")
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; printCopy.setStyle("fontWeight", copyrightFontWeight); 
&amp;nbsp; }
&amp;nbsp; printCopy.percentWidth = 100;
&amp;nbsp; printBox.addElement(printCopy);

&amp;nbsp; //COMMENTS
&amp;nbsp; if(txtComments.textFlow.getText())
&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; var spacerLabel:Label = new Label();
&amp;nbsp;&amp;nbsp; spacerLabel.text = " ";
&amp;nbsp;&amp;nbsp; //set the comment title:
&amp;nbsp;&amp;nbsp; var printCommentTitleLabel:Label = new Label();
&amp;nbsp;&amp;nbsp; printCommentTitleLabel.setStyle("fontSize", h / 24);
&amp;nbsp;&amp;nbsp; printCommentTitleLabel.text = "Comments:&amp;nbsp; ";
&amp;nbsp;&amp;nbsp; //set the comments:
&amp;nbsp;&amp;nbsp; var printComment:Label = new Label();
&amp;nbsp;&amp;nbsp; printComment.setStyle("fontSize", h / 48);
&amp;nbsp;&amp;nbsp; printComment.text = txtComments.textFlow.getText();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; //add to container:
&amp;nbsp;&amp;nbsp; var printBoxComments:VGroup = new VGroup();
&amp;nbsp;&amp;nbsp; printBoxComments.percentWidth = 100;
&amp;nbsp;&amp;nbsp; printBoxComments.addElement(spacerLabel);
&amp;nbsp;&amp;nbsp; printBoxComments.addElement(printCommentTitleLabel);
&amp;nbsp;&amp;nbsp; printBoxComments.addElement(printComment);
&amp;nbsp;&amp;nbsp; printBox.addElement(printBoxComments); 
&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 }
 finally
 {
 }&amp;nbsp;&amp;nbsp;&amp;nbsp; 

 var bd:BitmapData = new BitmapData(printBox.width, printBox.height); //ArgumentError: Error #2015: Invalid BitmapData.&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 bd.draw(printBox, new Matrix());
 var pngEnc:PNGEncoder = new PNGEncoder();
 var imgData:ByteArray = pngEnc.encode(bd);&amp;nbsp; 
 fileReference = new FileReference();
 fileReference.save(imgData,"TIGER.png");
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:13:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58618#M1348</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2021-12-10T22:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58619#M1349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It looks like it should work and I just tested the BitmapData to PNG part and it works for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The only thing I can think of is maybe you need to explicitly set height where you set the width.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;printBox.width = map.width;
printBox.height = map.height;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since you are creating the printBox in your function, it never actually gets added to the application stage, which is ok. But the events that occur when a Component is added (visually) to an application do the leg work for you of defining the componets width/height based on it's children.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In this case, since the component is just used in this function, those lifecycle events never happen, thus printBox.height is proabably null.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Explicitly setting it should work... I think &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:13:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58619#M1349</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-10T22:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58620#M1350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Rene!&amp;nbsp; It now prompts me to save the file.&amp;nbsp; When I open the saved file, however, the image is blank.&amp;nbsp; Seems like I'm still missing something...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 17:04:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58620#M1350</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2011-05-12T17:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58621#M1351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking at your code, I see that you are adding the printbox to your app at some point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think the bitmap-&amp;gt;png code is firing before the component has had a chance to draw.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can try waiting for the addedToStage event&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;printBox.addEventListener(Event.ADDED_TO_STAGE, printBoxReady);
this.addChild(printBox);

function printBoxReady(e:Event):void
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; // code to turn your printbox into bitmapdata and encode to png
&amp;nbsp;&amp;nbsp;&amp;nbsp; // and initialize your filereference
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At that point, you should be able to see your component, so it is fully drawn and ready.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You'll probably want to wait to do this.addChild() until after you have added everything into printbox you want to add.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:13:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58621#M1351</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-10T22:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58622#M1352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I added the following to my finally block -&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;finally
{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 printBox.addEventListener(Event.ADDED_TO_STAGE, printBoxReady);
 this.addChild(printBox); 
}&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;And then created the printBoxReady function -&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function printBoxReady(e:Event):void
{&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 var bd:BitmapData = new BitmapData(printBox.width, printBox.height); 
 bd.draw(printBox, new Matrix());
 var pngEnc:PNGEncoder = new PNGEncoder();
 var imgData:ByteArray = pngEnc.encode(bd);&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 fileReference = new FileReference();
 fileReference.save(imgData,"TIGER.png");
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But the resulting saved PNG is still blank!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:13:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58622#M1352</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2021-12-10T22:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58623#M1353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmm, sorry, at this point, I'm at a loss.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried pretty much the same to save a map and it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you see the preview on your screen with everything added to it?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 17:39:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58623#M1353</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2011-05-12T17:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58624#M1354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's weird, a preview shows up just underneath my widget when I click "Save to File". I can see the subtitle and map, and the map is displaying backwards! See attached screen shot.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 17:54:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58624#M1354</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2011-05-12T17:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58625#M1355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, I tried a few things, modifying the Print Widget in Flexviewer and it's not the addedToStage event you want to listen for. Sorry, I forgot that in Flex, the FlexEvent.CreationComplete is what fires when all flex components are done being created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When that fiires, you can encode the component to PNG/JPG. But, here's the rub. You can't use FileReference on FlexEvents, they're sandboxed for security purposes. So, you would probably need to create a small preview window, then have second button to actually save the data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I reviewed the print functionality in one of my apps,and this how we do it for PDF saves. I need to create a preview, then a button to actually save the file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rather than post snippets or the whole thing here, you can see the dirty way I modified the print widget to do this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://gist.github.com/969352"&gt;https://gist.github.com/969352&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry I had to dust off the cobwebs on this one &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 19:21:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58625#M1355</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2011-05-12T19:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58626#M1356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you! It works! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; For some reason though, the map that is saved is backwards. Have you seen this before?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 11:11:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58626#M1356</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2011-05-13T11:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58627#M1357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That was a weird one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It happened to me while testing, but if I waited for the addedToStage event, then add the image, it worked fine. That shouldn't happen if you wait for the creationComplete event, then view it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 12:23:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58627#M1357</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2011-05-13T12:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58628#M1358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you explain more about how to &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- wait for the addedToStage event, then add the image, or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- wait for the creationComplete event, then view it&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(sorry, I'm still really new with Flex!)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 14:53:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58628#M1358</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2011-05-13T14:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58629#M1359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sure. The image data doesn't seem to like being added to the printBox until after the printBox is added to the stage.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I updated the code sample in the link to reflect this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// I commented out this line of code
// where printImg is created
//printBox.addElement(printImg);

// I added this listener
printBox.addEventListener(Event.ADDED_TO_STAGE, function(e:Event):void {
 trace("added to stage");
 printBox.addElement(printImg);
});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, the image should display and save correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have to admit, I don't know why the image displays backwards if it's added to the component before the component is added to the stage.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AddedToStage fires as soon as the component comes on screen (not necessarily viewable), but before it's done being rendered. CreationComplete should fire when the component is fully rendered and ready to be viewed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't seem to find a Component Lifecycle reference online directly from Adobe, but here are some slides&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://www.flex888.com/1219/flex-4-components-life-cycle.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.flex888.com/1219/flex-4-components-life-cycle.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a diagram of the UIComponent lifecycle (I have this printed and tacked to my office wall)&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://danorlando.com/?p=122" rel="nofollow noopener noreferrer" target="_blank"&gt;http://danorlando.com/?p=122&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;Spark skins have a few more things that happen to manage skinning&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.adobe.com/en_US/flex/using/WS460ee381960520ad-2811830c121e9107ecb-7fff.html#WS460ee381960520ad-2811830c121e9107ecb-7ffc" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.adobe.com/en_US/flex/using/WS460ee381960520ad-2811830c121e9107ecb-7fff.html#WS460ee381960520ad-2811830c121e9107ecb-7ffc&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And I know there are quite a few god Flex books that should include a more detailed description of the lifecycle process of what happens when you create a component.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You don't usually need to worry about waiting for most of these events anymore, maybe creationComplete if you are modifying an MXML component. Flex 4 and Skinnning have made build components much easier than it used to be.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is just an odd case because we are using a component as a reference to generate an image, so there are considerations that need to be made about when that component is actually fully rendered and ready to be captured.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:13:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58629#M1359</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-10T22:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58630#M1360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are a WEALTH of knowledge!&amp;nbsp; Thank you so much for all your help!&amp;nbsp; I am still working through some kinks, but overall it is working well and I am SO MUCH FARTHER along than I was. Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 18:47:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58630#M1360</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2011-05-13T18:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58631#M1361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Do you know if there's a way to save a file without doing a "preview" first? I tried adding &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var fr:FileReference = new FileReference();&amp;nbsp;&amp;nbsp;&amp;nbsp; 
fr.save(printData, "TIGER.png");&lt;/PRE&gt;&lt;SPAN&gt; several different places and I can't get it to work. One thing I tried was creating a handler for addedToStage and included the above code, but the function was only called when the widget first loaded.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Just wondering if it was possible to execute the "preview" code, then prompt the user to save to a file immediately.&amp;nbsp; It seems there needs to be a pause in between "preview" and "save".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:13:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58631#M1361</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2021-12-10T22:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58632#M1362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, is there a way to save a multi-page file? I have a title, subtitle &amp;amp; comments above my map, which causes my map to run off the page.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 May 2011 15:44:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58632#M1362</guid>
      <dc:creator>AshleyOwens</dc:creator>
      <dc:date>2011-05-16T15:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Save UIComponent to a file (jpg)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58633#M1363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If it weren't for the mirror image issue, you could. Unfortuntely, I don't know how to get around that without first doing the preview because the Flash player has built in security that will not allow you to save a file without some sort of user interaction such as a button click. You can't do it off a timer or another other event. I have not tried to simulate a button click, but I don't think that would work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to look into a multi-page option, maybe PDF would be a better solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://code.google.com/p/alivepdf/"&gt;http://code.google.com/p/alivepdf/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;AlivePDF is an actionscript library to save PDF files directly from Flash. It's very popular among many users on this forum and the process is similar to the way you are saving an image.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2011 12:44:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/save-uicomponent-to-a-file-jpg/m-p/58633#M1363</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2011-05-17T12:44:59Z</dc:date>
    </item>
  </channel>
</rss>

