Skip navigation
adii08
Currently Being Moderated

Server site php and As3 data

May 23, 2011 9:55 PM

Hi,

 

I am new in php coding. I want to get image data from php and also display in flash.

I want to know... how to read and display imagejpeg( $imgData ); from php.

 

I am able to get php data in flash through below method...

 

/* AS3 */------------------

 

var src:String = "pic.jpg";

var width:String = "250";

var height:String = "250";

 

var urlReq:URLRequest = new URLRequest(src);

var urlLoader:URLLoader = new URLLoader();

 

var urlVar:URLVariable = new URLVariable();

urlVar.src= src;

 

urlReq.mehtod = URLRequestMethod.POST;

urlReq.data = urlVar;

 

urlLoader.load ( urlReq );

urlLoader.addEventListener(Event.Complete, doneProcFnc)

 

function doneProcFnc(ev:Event):void{

      trace ( "data access from php done" );

}

 

------------/*   */

 

/* PHP */

 

$src = $_POST [ 'src' ];

$wd = $_POST [ ' width' ];

$ht = $_POST [ ' height' ];

 

/*  this function will create one black color area for croping refence */

$cropImg = imagecreatetruecolor ( cropImageWd, cropImageHt );

 

/* this function will reproduce particular image required width and height without reducing the image quality */

imagecopyresampled ( cropImage , sourceImage, destX , destY, sourX, sourY, ect... );

 

 

imagejpeg( $imgData ) ;

 

------------------/* */

 

Now, here the problem comes. I don't know how to display that imagejpeg data into flash.


I need help.

Thanks.

 
Replies
  • Currently Being Moderated
    May 24, 2011 10:00 AM   in reply to adii08

    Hi

     

    In PHP simply echo your image back to flash:

     

    echo imagejpeg($imgData);

     

    In flash:

     

    For images it's best to use the Loader class rather than the URLLoader which is better suited to text or XML.

     

    I think you'll find the loader class far easier for your project.

     

    Hope it helps

     
    |
    Mark as:
  • Currently Being Moderated
    May 25, 2011 10:22 AM   in reply to adii08

    OK

     

    I am still not sure why your sending an image reference from flash to php and back again.

    Why not use the BitMap Class within flash to do your image sizing. It's far easier and more reliable.

     

    Google 'AS3 BitMap Class'

     

    Hope it helps

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points