Solved

Display a base64 encoded image in flash?

Posted on 2004-09-22
3
384 Views
Last Modified: 2009-07-06

Hi all,

I am using a service on the net which provides dynamic map images. The idea is basically that you make a "GET" request to the mapping server providing them with co-ordinates of what area of the map would you like to view and the scale to display, and then they send you back XML which has details of the area inside it - and most importantly, a map image which has been dynamically generated for you (can be any format you choose including jpg, gif, png etc).

The image is inside the XML in Base64Binary encoded format (raw image data), for example (truncated this example a lot):

<Image>/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODw...etc</Image>

You are then supposed to base64 decode this, and that will give you your map image.

I have flash/actionscript code that will make a GET request to their server and retrieve the XML. It then goes through the XML and obtains the data between the <Image></Image> tags and puts it into a myImage variable.

My question is...what would I then need to do in flash/actionscript to get this raw image data into something displayed on the screen to the user  as a proper image? Is there any way to create a new image on the fly using raw image data?

The only thing I can think of is that I would make the actionscript write the data out to the hard drive as "newfile.jpg" and then make it read the image back in and display it from there...but I am wondering if there is a better way since a lot of people will be using this and I would like to avoid creating tons of temporary image files on the hard drive.

Does anyone know how to solve this problem (or alternatively, can provide me code on how to write the image data out to a file on the hard drive, and then make flash display the newly created image file on the fly?)

Thank you in advance!
0
Comment
Question by:WangProducts
3 Comments
 

Author Comment

by:WangProducts
ID: 12169022

i'm surprised no-one answered this :) I asked on other flash forums and everyone was eager to help with a genuinely advanced question.

The answer is - this can't be done on the fly in flash/actionscript...however PHP can do it using something similar to:

Therefore, you can put a php script up that grabs the base64 image, decodes it, and displays is - then make flash/actionscript read it in on the fly using loadMovie();

:)
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13130126
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question