<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Displaying an image saved as a Base64 encoded string in Flex 3</title>
	<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Fri, 05 Dec 2008 01:14:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Suvendu</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-16392</link>
		<author>Suvendu</author>
		<pubDate>Fri, 24 Oct 2008 15:18:03 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-16392</guid>
		<description>Hi There,

Very Nice article.just wanted a little help.

I have an array containing the bytearrays of the images .How can i display the images in an horizontal scroll bar.


Can you please help me in this???</description>
		<content:encoded><![CDATA[<p>Hi There,</p>
<p>Very Nice article.just wanted a little help.</p>
<p>I have an array containing the bytearrays of the images .How can i display the images in an horizontal scroll bar.</p>
<p>Can you please help me in this???</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-14727</link>
		<author>peterd</author>
		<pubDate>Fri, 15 Aug 2008 14:20:48 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-14727</guid>
		<description>ken larkin,

I don't know if this would work, but you could try converting the list of numbers into an array using the &lt;code&gt;split()&lt;/code&gt; method, then loop over the array of numbers and add them to a ByteArray using the &lt;code&gt;writeInt()&lt;/code&gt; method. Something like this:
&lt;pre class="code"&gt;
private function stringToByteArray(value:String):ByteArray {
	var arr:Array = value.split(",");
	var idx:uint;
	var len:uint = arr.length;
	var byteArr:ByteArray = new ByteArray();
	for (idx=0; idx&#60;len; idx++) {
		byteArr.writeInt(arr[idx]);
	}
	return byteArr;
}
&lt;/pre&gt;

But I'm sure there may be a few missing pieces. You could try asking on the FlexCoders mailing list, I'm sure somebody there has attemped what you're trying to do.

Peter</description>
		<content:encoded><![CDATA[<p>ken larkin,</p>
<p>I don&#8217;t know if this would work, but you could try converting the list of numbers into an array using the <code>split()</code> method, then loop over the array of numbers and add them to a ByteArray using the <code>writeInt()</code> method. Something like this:</p>
<pre class="code">
private function stringToByteArray(value:String):ByteArray {
	var arr:Array = value.split(",");
	var idx:uint;
	var len:uint = arr.length;
	var byteArr:ByteArray = new ByteArray();
	for (idx=0; idx&lt;len; idx++) {
		byteArr.writeInt(arr[idx]);
	}
	return byteArr;
}
</pre>
<p>But I&#8217;m sure there may be a few missing pieces. You could try asking on the FlexCoders mailing list, I&#8217;m sure somebody there has attemped what you&#8217;re trying to do.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ken larkin</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-14725</link>
		<author>ken larkin</author>
		<pubDate>Fri, 15 Aug 2008 13:27:11 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-14725</guid>
		<description>thanks this worked.  However I am receiving an image as a byte array in a string not base64hex in a string.  Data in string looks like this...34,645,234,653,122,12,32,43,543,...


Ho do i convert this string of numbers to a bytearray and in turn into an image

By the way this is a magnificent site, well done.

thanks,
Ken</description>
		<content:encoded><![CDATA[<p>thanks this worked.  However I am receiving an image as a byte array in a string not base64hex in a string.  Data in string looks like this&#8230;34,645,234,653,122,12,32,43,543,&#8230;</p>
<p>Ho do i convert this string of numbers to a bytearray and in turn into an image</p>
<p>By the way this is a magnificent site, well done.</p>
<p>thanks,<br />
Ken</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dustin</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-14332</link>
		<author>Dustin</author>
		<pubDate>Thu, 24 Jul 2008 20:48:10 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-14332</guid>
		<description>Thanks for the info on this! It saved my butt. 

I had been trying to figure out how to create Power Point presentations from Flex and ColdFusion, and this was the trick. 

By encoding the images, I am able to embed the images into a .MHT file (which is basically xml), and Power Point can read this file and display the images, just like a ppt file. I even named the file with a .ppt extension so Power Point is the default app to open it, and its all working great.

cheers!
Dustin</description>
		<content:encoded><![CDATA[<p>Thanks for the info on this! It saved my butt. </p>
<p>I had been trying to figure out how to create Power Point presentations from Flex and ColdFusion, and this was the trick. </p>
<p>By encoding the images, I am able to embed the images into a .MHT file (which is basically xml), and Power Point can read this file and display the images, just like a ppt file. I even named the file with a .ppt extension so Power Point is the default app to open it, and its all working great.</p>
<p>cheers!<br />
Dustin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Tolley</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-14216</link>
		<author>Richard Tolley</author>
		<pubDate>Fri, 18 Jul 2008 12:05:17 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-14216</guid>
		<description>First things first - superb blog - would be lost without it.  Thank you.

I'm working on some code at the moment and need to display a Base64 String as an image.  Used the example above and it worked first time.  Thank you.

*BUT* (isn't there always a but...)

What to do when the String is coming from a database and sometimes contains invalid data.

I thought it would be a simple matter to trap the error and display an alternative image.

Nothing seems to work.

I've tried try/catch blocks.  I've tried using ioError event on the image component.

I'm going out of my mind - Could you suggest a way to trap invalid data.  If I can trap the error I can deal with it.  Nothing seems to work.

Kind Regards

Once again - the blog is superb :)

Rich</description>
		<content:encoded><![CDATA[<p>First things first - superb blog - would be lost without it.  Thank you.</p>
<p>I&#8217;m working on some code at the moment and need to display a Base64 String as an image.  Used the example above and it worked first time.  Thank you.</p>
<p>*BUT* (isn&#8217;t there always a but&#8230;)</p>
<p>What to do when the String is coming from a database and sometimes contains invalid data.</p>
<p>I thought it would be a simple matter to trap the error and display an alternative image.</p>
<p>Nothing seems to work.</p>
<p>I&#8217;ve tried try/catch blocks.  I&#8217;ve tried using ioError event on the image component.</p>
<p>I&#8217;m going out of my mind - Could you suggest a way to trap invalid data.  If I can trap the error I can deal with it.  Nothing seems to work.</p>
<p>Kind Regards</p>
<p>Once again - the blog is superb :)</p>
<p>Rich</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Magnus</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12927</link>
		<author>Magnus</author>
		<pubDate>Sat, 24 May 2008 18:39:04 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12927</guid>
		<description>Thank you, this is indeed helpful.</description>
		<content:encoded><![CDATA[<p>Thank you, this is indeed helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12642</link>
		<author>peterd</author>
		<pubDate>Mon, 12 May 2008 14:28:37 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12642</guid>
		<description>&lt;a href="http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12640" rel="nofollow"&gt;anoop&lt;/a&gt;,

Are you using Flex 3? This class was added in Flex 3, and isn't available in Flex 2 projects.
Also, make sure you've imported the Base64Encoder/Base64Decoder class as well:

&lt;pre class="code"&gt;
import mx.utils.Base64Decoder;
import mx.utils.Base64Encoder;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p><a href="http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12640" rel="nofollow">anoop</a>,</p>
<p>Are you using Flex 3? This class was added in Flex 3, and isn&#8217;t available in Flex 2 projects.<br />
Also, make sure you&#8217;ve imported the Base64Encoder/Base64Decoder class as well:</p>
<pre class="code">
import mx.utils.Base64Decoder;
import mx.utils.Base64Encoder;
</pre>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anoop</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12640</link>
		<author>anoop</author>
		<pubDate>Mon, 12 May 2008 13:42:02 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12640</guid>
		<description>base64Eec = new Base64Eecoder();

There shows one more error 4 me like thaat:call to a possibly undefined method Base64Eecoder

my code is.....
&lt;pre class="code"&gt;
public function postData():void {
var request:HTTPService = new HTTPService();
var base64Eec:Base64Encoder;
request.url = "http://twitter.com/statuses/update.xml";
request.method = "POST";
request.addEventListener(ResultEvent.RESULT,
handleComplete);
var username:String = "username";
var password:String = "password";
 base64Eec = new Base64Eecoder();
 base64Eec.encode(username + ":" + password);
var encodedCredentials:String = base64Eec.toString();
var headerArray = new Array(
new URLRequestHeader("Authentication",
"Basic " + encodedCredentials));
&lt;/pre&gt;

can u help me please.......</description>
		<content:encoded><![CDATA[<p>base64Eec = new Base64Eecoder();</p>
<p>There shows one more error 4 me like thaat:call to a possibly undefined method Base64Eecoder</p>
<p>my code is&#8230;..</p>
<pre class="code">
public function postData():void {
var request:HTTPService = new HTTPService();
var base64Eec:Base64Encoder;
request.url = "http://twitter.com/statuses/update.xml";
request.method = "POST";
request.addEventListener(ResultEvent.RESULT,
handleComplete);
var username:String = "username";
var password:String = "password";
 base64Eec = new Base64Eecoder();
 base64Eec.encode(username + ":" + password);
var encodedCredentials:String = base64Eec.toString();
var headerArray = new Array(
new URLRequestHeader("Authentication",
"Basic " + encodedCredentials));
</pre>
<p>can u help me please&#8230;&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David H</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12281</link>
		<author>David H</author>
		<pubDate>Fri, 25 Apr 2008 07:09:35 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-12281</guid>
		<description>thanks! it works with flex 3!! it took me hours to find out this solution
this post should put into the flex api document</description>
		<content:encoded><![CDATA[<p>thanks! it works with flex 3!! it took me hours to find out this solution<br />
this post should put into the flex api document</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-7676</link>
		<author>peterd</author>
		<pubDate>Tue, 18 Mar 2008 14:49:27 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/03/17/displaying-an-image-saved-as-a-base64-encoded-string-in-flex-3/#comment-7676</guid>
		<description>Tony,

Are you using Flex 3? I believe I compiled this using Flex 3.0.0.477 (the retail Flex 3 SDK)

It is in Flex 3: http://livedocs.adobe.com/flex/3/langref/mx/utils/Base64Decoder.html
But not Flex 2: http://livedocs.adobe.com/flex/201/langref/mx/utils/package-detail.html

Peter</description>
		<content:encoded><![CDATA[<p>Tony,</p>
<p>Are you using Flex 3? I believe I compiled this using Flex 3.0.0.477 (the retail Flex 3 SDK)</p>
<p>It is in Flex 3: <a href="http://livedocs.adobe.com/flex/3/langref/mx/utils/Base64Decoder.html" rel="nofollow">http://livedocs.adobe.com/flex/3/langref/mx/utils/Base64Decoder.html</a><br />
But not Flex 2: <a href="http://livedocs.adobe.com/flex/201/langref/mx/utils/package-detail.html" rel="nofollow">http://livedocs.adobe.com/flex/201/langref/mx/utils/package-detail.html</a></p>
<p>Peter</p>
]]></content:encoded>
	</item>
</channel>
</rss>
