简体   繁体   中英

Load external swf into bytearray with adobe flash

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?

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);
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM