Update and compile an external SWF (add image)
Hi,
I'm trying to find a way to load an external swf file then make a change to into and 'save it'.
The basic communication to the external swf is simple enough to setup, but I get stuck on the compiling part.
I looked into this: claus/as3swf · GitHub
But it keeps on giving me a save to location box.
I tried something like this but not getting very far:
import flash.filesystem.File;
import flash.filesystem.FileStream;
import flash.filesystem.FileMode;
var ba :ByteArray
var my_url1: URLRequest = new URLRequest("ParentFile.swf");
var urlloader: URLLoader = new URLLoader(my_url1);
urlloader.dataFormat = URLLoaderDataFormat.BINARY;
urlloader.addEventListener(Event.COMPLETE, function (event: Event): void {
ba = URLLoader(event.target).data as ByteArray;
//trace(ba)
save();
});
function save ():void{
var newfile: File = File.desktopDirectory.resolvePath(getFilename()+"newFile.swf");
trace(newfile.url)
var fileStream: FileStream = new FileStream();
fileStream.open(newfile, FileMode.WRITE);
fileStream.writeBytes(ba);
fileStream.close();
}
//
//var myUrl:String = unescape(LoaderInfo(this.root.loaderInfo).url);
trace(getFilename())
function getFilename():String
{
var filename:String;
var myUrl:String = unescape(LoaderInfo(this.root.loaderInfo).url);
filename = myUrl.substring(myUrl.lastIndexOf("/") + 1,myUrl.lastIndexOf("."));
filename = myUrl.slice(0, -filename.length)
return filename;
}
Any help is appreciated!