tags:

views:

8

answers:

0

Hi Everyone, please help me.. i want to create flash file, that will load images from microsoft SQL server 2008. i am using ImageRequestHandler.ashx to get images from database and pass it into flash.

ImageRequestHandler.ashx file

    public class ImageRequestHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            try
            {
                int ObjectID = Convert.ToInt32(context.Request["ObjectID"]);
                if (ObjectID == 0)
                    return;
                Int16 IsBackground = Convert.ToInt16(context.Request["IsBackground"]);
                ObjectDetailsDAL od = new ObjectDetailsDAL();

                byte[] bImage = od.GetImage(ObjectID, IsBackground); 
                if (bImage != null)
                {
                context.Response.ContentType = "image/jpeg";
                context.Response.OutputStream.Write(bImage,0,bImage.Length);
                context.Response.Flush();
                }
            }
      }
  }

image.fla file

import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;

var URLvariables = new URLVariables();
var URLrequest = new URLRequest("http://localhost:1290/GenericHandlersWebServices/ImageRequestHandler.ashx");
var URLloader = new URLLoader();

URLvariables.ObjectID = "3";
URLvariables.IsBackground = true;

//URLrequest.data = URLvariables;
URLrequest.method = URLRequestMethod.POST;

URLloader.dataFormat = URLLoaderDataFormat.BINARY;

URLloader.load(URLrequest);
URLloader.addEventListener(Event.COMPLETE,recieve);

function recieve(event:Event):void
{
 trace(event.target.data.length)
}

and it outputes 0. but when i am trying to load simple text. it's work. what is my mistake?