Reputation: 7
i'm trying to load images from Facebook Albums to my flex app, this is the code called when i click on a FB image:
private var loaderFB:Loader;
private var immCaricata:Bitmap = new Bitmap();
//Function where i pass the url of the FB image clicked
private function getFBImage(src:String):void{
var request:URLRequest;
loaderFB=new Loader();
request=new URLRequest(src);
loaderFB.contentLoaderInfo.addEventListener(Event.COMPLETE,onCompleteFBget);
loaderFB.load(request);
}
private function onCompleteFBget(event:Event):void {
var bitmap_dataFB:BitmapData = new BitmapData(640, 480);
bitmap_dataFB.draw(loaderFB.content);
immCaricata = new Bitmap(bitmap_dataFB);
displayOut.addChild(immCaricata);
}
it doesn't work!
If i pass
displayOut.addChild(loaderFB); //instead displayOut.addChild(immCaricata);
It works like a charm!
My problem is that i need to pass loader content to that bitmap (immCaricata) cause i use it in different other functions.
I tried different solution, but probably i do some mistakes somewhere.
Could you please help me? Hope is all clear. Thank you so much
EDIT:
The problem was not the syntax but the security policy file, i had to add it:
in init function:
Security.loadPolicyFile("http://graph.facebook.com/crossdomain.xml");
Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
and then where i load the image
loaderFB=new Loader();
request=new URLRequest(src);
loaderFB.contentLoaderInfo.addEventListener(Event.COMPLETE,onCompleteFBget);
var lc:LoaderContext = new LoaderContext();
lc.checkPolicyFile = true;
loaderFB.load(request,lc);
controlloImm = true;
Hope is clear and hope it helps someone else. :)
Upvotes: 0
Views: 2193
Reputation: 11357
private var loaderFB:Loader;
private var immCaricata:Bitmap;
//Function where i pass the url of the FB image clicked
private function getFBImage(src:String):void{
var request:URLRequest;
loaderFB=new Loader();
request=new URLRequest(src);
loaderFB.contentLoaderInfo.addEventListener(Event.COMPLETE,onCompleteFBget);
loaderFB.load(request);
}
private function onCompleteFBget(event:Event):void {
immCaricata = event.target.content as Bitmap;
displayOut.addChild(immCaricata);
}
Try this if you dont wanna change the loaded image size, hope this will help
Upvotes: 1