开发者

AS3 Load Image from Server using Loader

开发者 https://www.devze.com 2023-02-24 05:15 出处:网络
Hey, Im trying to load an image from my server with flash.The point is to do this dynamically so that I can animate it in flash on the fly.Im using ExternalInterface so I can feed flash some variables

Hey, Im trying to load an image from my server with flash. The point is to do this dynamically so that I can animate it in flash on the fly. Im using ExternalInterface so I can feed flash some variables from javascript, but that doesnt seem to be the problem. I have ExternalInterface all sorted out it would seem. Anyway here is the problem code.

function getCover(){
    var year = "slices";
    var cover = "book-face.png"
    var myLoader:Loader = new Loader();
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderReady);

    var fileRequest:URLRequest = new URLRequest("howbizarro.org/clients/westessex/" + year + "/" + cover);
    myLoader.load(fileRequest);
    //Book.addChild(myLoader);
    //Book.play();

    function onProgressStatus(e:ProgressEvent) {   
      // this is where progress will be monitored     
      trace(e.bytesLoaded, e.b开发者_开发知识库ytesTotal); 
    }

    function onLoaderReady(e:Event) {     
          // the image is now loaded, so let's add it to the display tree!     
          Book.cover.addChild(myLoader);
          Book.play();
    }
}

I forgot where I found the code for this from (I'm not all that familiar with AS, let alone AS3) but it worked in some earlier tests that I did. From what I can tell it looks like onLoaderReady is never being called. I have done some tests and getCover is indeed getting called from JavaScript, but it never gets to that final function call that it should get to once the image is loaded


it seems to work fine for me when i add the http:// to the URL.

the only problem that i can see with this is that you don't have http:// in front of your url, which would throw an error otherwise

"Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found."

always put http:// in front of your URLs. thats really what makes it a url.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号