Sergey
Sergey

Reputation: 963

Why won't Flex Load My Images

I have Flex application(not AIR) thats load image and perform some effects, application works well in flash builder and in the debug folder. But when I am trying to copy *.swf to another local folder, appears problems with image loading.

Can anybody help me? May be need specify some restriction or rules?

UPDATE You don't understand me, i am trying to load image from desktop using FileReference class, image shows successfully, but origBitmap after saveAsBitmap() method is null

public function loadImage():void
{
  fileRef.addEventListener(Event.SELECT, onFileSelected); 
  var textTypeFilter:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif,*.png)", "*.jpg; *.jpeg; *.gif; *.png"); 
  fileRef.browse([textTypeFilter]); 
}

public function onFileSelected(evt:Event):void 
{ 

  fileRef.addEventListener(Event.COMPLETE, onComplete); 
  fileRef.load(); 

} 

public function onComplete(evt:Event):void 
{ 
byteArr = fileRef.data as ByteArray;
ldr = new Loader();
ldr.loadBytes(byteArr);
fileRef.removeEventListener(Event.SELECT, onFileSelected);
fileRef.removeEventListener(Event.COMPLETE, onComplete); 
callLater(show);
} 

public function show():void
{    
 currImg.source = ldr;
 callLater(saveAsBitmap);

}
public function saveAsBitmap():void
{
 bd = new BitmapData(currImg.contentWidth * currImg.scaleX, currImg.contentHeight *  currImg.scaleY,true);
 bd.draw(currImg as IBitmapDrawable);
 origBitmap = new Bitmap(bd);
 }

//.....

<mx:Image id="currImg"/>

//.....

Upvotes: 1

Views: 372

Answers (2)

jhocking
jhocking

Reputation: 5577

Please post your code. My guess is that when you moved the swf you didn't also move your images along with it or change your code to reflect the new location. However without seeing your code there's no way for us to know.

Upvotes: 1

Jacob Eggers
Jacob Eggers

Reputation: 9322

You aren't loading images because of sandbox security errors. You will need to add a crossdomain.xml to the the server that is storing the image files.

I believe that adobe has recently loosened their crossdomain restrictions for bitmaps. However, I think you still won't be able to manipulate the bytearray data.

Upvotes: 1

Related Questions