Question

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?

Était-ce utile?

La solution

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);
    });
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top