Solved

Display a base64 encoded image in flash?

Posted on 2004-09-22
3
377 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
Comment Utility

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
Comment Utility
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now