0

I want to load an image and then use its bitmapData. The program worked when I ran it from flash, but not when I uploaded it online. There seem to be a bunch of weird problems. The addChild(myLoader) works online but addChild(loadedPic) does not, and the myLoader doesn't seem to have bitmapData I can access. For some reason the urlInput.text = "Done." will work online but not the urlInput.text = ... that I added to see what's going on. When I run this on my computer I get the urlInput saying "[object Bitmap] hi" like it should, but online it just says "Loading..." still

var myLoader:Loader = new Loader();

submitButton.addEventListener(MouseEvent.CLICK, buttonRelease);
function buttonRelease(event:MouseEvent){
    var fileRequest:URLRequest = new URLRequest(urlInput.text);
    urlInput.text = "Loading...";
    myLoader.load(fileRequest);
}

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event){
    urlInput.text = "Done.";
    //addChild(myLoader);

    //var loadedBitmap = new BitmapData(myLoader.width, myLoader.height);
    //loadedBitmap.draw(myLoader);
    //var loadedPic = e.target.content;
    //loadedPic.width = 300;
    //loadedPic.height = 300;
    //addChild(loadedPic);
    urlInput.text = e.target.content.toString() + " hi";
    //usedPic = loadedPic;
}
James
  • 31
  • 1
  • where are you loading the bitmap from? what is the path, is it relative or absolute, and is it on the same domain as your swf? – Neil May 19 '12 at 17:31
  • Be sure you're using the flash debug player when you're checking it online, it sounds to me lie you may be getting a security violation but not seeing the error, verify you are running the flash player debug version here (near bottom of the page): http://helpx.adobe.com/flash-player/kb/find-version-flash-player.html note that chrome normally maintains it's flash player internally special steps are needed to replace it. – shaunhusain May 19 '12 at 18:24

1 Answers1

0

If you're loading an image and you want to access it's data (to do the draw() call), then you'll need to load it with a LoaderContext object with the checkPolicyFile bool set to true. The reason it works on local is that everything is implicitly trusted on local so you don't really run into security problems

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/LoaderContext.html?filter_flash=cs5&filter_flashplayer=10.2&filter_air=2.6

divillysausages
  • 7,883
  • 3
  • 25
  • 39