Load external swf into bytearray with adobe flash

限于喜欢 提交于 2019-12-10 11:29:14

问题


How can I load external swf into bytearray with adobe flash AS3.. Here is my code..

var my_url1:URLRequest = new URLRequest("SWF/Lesson1.swf");
my_url1.method = URLRequestMethod.GET;
my_url1.contentType = "application/x-shockwave-flash";

var urlloader:URLLoader = new URLLoader(my_url1);

var myByteArray:ByteArray = new ByteArray(); 
urlloader.data = myByteArray;

It not works well. But it isn't give any error. How can I fix this problem?


回答1:


You should listen for COMPLETE event and set the data format to BINARY:

    var my_url1:URLRequest = new URLRequest("SWF/Lesson1.swf");
    var urlloader:URLLoader = new URLLoader(my_url1);
    urlloader.dataFormat = URLLoaderDataFormat.BINARY;
    urlloader.addEventListener(Event.COMPLETE, function(event:Event):void
    {
        var myByteArray:ByteArray = URLLoader(event.target).data as ByteArray;
        trace(myByteArray.length);
    });


来源:https://stackoverflow.com/questions/21274476/load-external-swf-into-bytearray-with-adobe-flash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!