Solved

Display a base64 encoded image in flash?

Posted on 2004-09-22
3
382 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Action Script commands 5 238
Software Restriction Policy 8 865
Adobe flash player memory exhaustion 6 96
Flash Media Live Encoder unreliable encoding start 2 8
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

776 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