title: From Loader to Bitmap AS3 Flex
body: <p>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:</p>
  
  <pre><code>        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);
          }
  </code></pre>
  
  <p>it doesn't work!</p>
  
  <p>If i pass </p>
  
  <pre><code>displayOut.addChild(loaderFB); //instead displayOut.addChild(immCaricata);
  </code></pre>
  
  <p>It works like a charm!</p>
  
  <p>My problem is that i need to pass loader content to that bitmap (immCaricata) cause i use it in different other functions.</p>
  
  <p>I tried different solution, but probably i do some mistakes somewhere.</p>
  
  <p>Could you please help me? Hope is all clear.
  Thank you so much </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The problem was not the syntax but the security policy file, i had to add it:</p>
  
  <p>in <strong>init</strong> function:</p>
  
  <pre><code>Security.loadPolicyFile("http://graph.facebook.com/crossdomain.xml");
  Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
  </code></pre>
  
  <p>and then where i load the image</p>
  
  <pre><code>            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;
  </code></pre>
  
  <p>Hope is clear and hope it helps someone else. :)</p>