How to get blob image from mysql to as3 with php and addChild it in a way of getting byteArray and converting it to image?
this is php:
if($RequestType == 'Select'){ while($row=mysql_fetch_assoc($results)){ $arrdata[]=$row; } foreach($arrdata as $key=>$value){ $output[$key] = $arrdata[$key]; $output[$key]['png'] = base64_encode($arrdata[$key]['png']); } header('Content-type: application/json'); print(json_encode($output));
i've already got something like this, but longer:
VBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAYxUlEQVR42u1bB3Sc1ZWe8k/vvfem6aPpGk2RZjQzGrVRl6xiyZZkWS4gFxyDGyEsxjE1gVBTSGAdQg4keyCxF4NsY1pCDARsBwiE4pBsIJjN7nKWgM3eJ7/hTDhUIyJyNj7nHh3P/DP/f79373e/e98b0oUXXkj6/2ykfwLwTwAW58br1q0j9fX1UQcGBpgjw0Pcy
(In this I'm assuming you have already handled the HTTP request result)
To transform a base64 encoded image to a
DisplayObject, you first need to decode the Base64 to aByteArraythen use theLoaderclass to load the image content, listening for theLoader'sEvent.COMPLETEevent to dispatch. Once you've got that eventLoader.contentwill contain aDisplayObjectthat you can add to the screen usingaddChild().Example: (EDIT: Added an
Arrayto keep track of loaded objects in order they were requested and altered function to calls to cope)