Jump to content
Search Community

Adding external images (from proxy) to Manager

petervee test
Moderator Tag

Recommended Posts

Hi there

 

I realised an older version of this question has been asked, however I believe mine is different. I'm using the new AS3 version to load an image (from an external domain I do not control) through a proxy PHP file (on my server)... I can't add it to the manager to be transformed. Code below

 

private function loadImage(url:String):void {
  var image_url:URLRequest = new URLRequest("http://localhost:8888/proxy.php?http://OTHERDOMAIN.com/image.jpg");
  imageLoader.load(image_url, new LoaderContext(true));
  imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}

 

And it's loaded, my callback fires...

 

private function imageLoaded(event:Event) {
  var imageBMP:BitmapData = new BitmapData(400, 500);  
  imageBMP.draw(imageLoader);
  var b:Bitmap = new Bitmap(imageBMP);
  container_mc.addChild( // WORKS TILL HERE

  manager.addItem(; // 
}

Link to comment
Share on other sites

Solving your own issues is always fun! Ok I worked it out, I had to first add the bitmap to a movieclip

 

new_mc = new MovieClip;
new_mc.addChild(;
manager.addItem(new_mc);

 

There probably is a better way to do it, but works for me :)

 

Also - I thought that the addChild method uses DisplayObject and effectively turns bitmaps into movie clips? Maybe I'm missing something

 

Cheers, gr8 library once more.

Link to comment
Share on other sites

I wonder if this line is generating a security error:

imageBMP.draw(imageLoader);

Because Flash won't allow you to draw() content that is loaded from another domain unless it is specifically granted permission via a crossdomain.xml file. That's just a Flash security thing and it's not related to TransformManager.

 

Your MovieClip solution is fine, but you could also try a regular Bitmap without draw()-ing. You can simply pass the Loader's content as the BitmapData:

var b:Bitmap = new Bitmap(imageLoader.content);

 

Just a thought. Glad you got things working though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...