Decompile a SWF file on Windows

I have recently discovered a great tool to decompile SWF animations (I needed a tool to extract the animation of a game to add design to one of my school projects).

So the only free solution I have found is called SWFTools. But the problems are that you don’t have any GUI for the tools that it provides so you have to do all the operations with the console and that you cannot extract all the objects at a time : you have to specify the ID of the object you want to extract!

So I have written a little batch script to extract all the objects automatically :

First of all, you have to create a sub-folder in your SWFTools folder (“badger” in this example).
Then copy the swf file you want to decompile in your SWFTools folder (“badger.swf” in this example).
Then decide how many objects you want to try to extract (200 in this example), it depends on the size of the swf file. The bigger the number the longer it will take.

Then create a bat file in your SWFTools folder, edit it with notepad, copy/paste the following script in it and finally replace the values.

:: To extract all the elements of the animation
FOR /L %%i IN (0,1,200) DO (
swfextract.exe -i %%i -o badger/%%i.swf badger.swf
)

:: To ajust the dimentions of the windows
FOR /L %%i IN (0,1,200) DO (
swfbbox.exe -o badger/%%i.swf -Oe badger/%%i.swf
)

Once you have extracted the object you were looking for (123.swf in this example), if you want to extract the png images of the different frames, copy paste it to the SWFTools folder and execute the following script.

:: To extract all the images of an animation
FOR /L %%i IN (0,1,50) DO (
swfextract.exe -p %%i -o badger/%%i.png 123.swf
)

Else, if you want to extract the vectors from the swf you have isolated, use Flash Exploit

AS3 : Tool for freelancers

You have computing skills and you are looking for a little job online? The best solution for you is to go to a freelancer website like rentacoder or getafreelancer.

But there is a problem : their interface are awful and you cannot see all the lastest jobs and the price that is offered for it on just one page, so here is my solution : An AS3 script that connects to these sites and gather you the important informations and the link to the offers page.

These lines of code can also help you to get your head into the AS3 if you want to learn how to make XML requests and simple animations with ActionScript3.

Please don’t juge me too hard, i’m not as good as I would like to be in this language!

package{
	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.xml.*;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import fl.controls.DataGrid;
	import flash.text.TextField;
	import fl.controls.dataGridClasses.DataGridColumn;
	import fl.events.DataGridEvent;
	import fl.transitions.Tween;
	import fl.transitions.easing.*;
	import flash.text.TextFormat;
	import fl.containers.ScrollPane;
	import fl.controls.Button;

	public class main extends Sprite{
		var mystream:URLLoader = new URLLoader();
		var mystream2:URLLoader = new URLLoader();
		var entriesDG:DataGrid = new DataGrid();
		var rectMC:MovieClip = new MovieClip();
		var popupText:TextField = new TextField();

		public function main(){
			var myrequest:URLRequest = new URLRequest("http://www.rentacoder.com/RentACoder/misc/LinkToUs/RssFeed_newBidRequests.asp")
			var myrequest2:URLRequest = new URLRequest("http://www.getafreelancer.com/rss.xml");
			mystream.load(myrequest);
			mystream2.load(myrequest2);
			mystream.addEventListener("complete",parseIt);
			mystream2.addEventListener("complete",parseIt2);
			entriesDG.width = 530;
			entriesDG.height = 360;
			entriesDG.x = 10;
			entriesDG.y = 10;
			entriesDG.editable = true;
			entriesDG.addEventListener(DataGridEvent.ITEM_EDIT_BEGIN,gridlistener);
			var datec:DataGridColumn = new DataGridColumn("Date");
			datec.width = 150;
			entriesDG.addColumn(datec);
			var salaryc:DataGridColumn = new DataGridColumn("Max Salary");
			salaryc.sortOptions = Array.NUMERIC;
			salaryc.width = 80;
			entriesDG.addColumn(salaryc);
			var titlec:DataGridColumn = new DataGridColumn("Title");
			titlec.width = 300;
			entriesDG.addColumn(titlec);
			addChild(entriesDG);

			var reloadBtn:Button = new Button();
			reloadBtn.label = "Reload";
			reloadBtn.y = 374;
			reloadBtn.x = 230;
			reloadBtn.addEventListener("click",function(e){
				entriesDG.removeAll();
				myrequest = new URLRequest("http://www.rentacoder.com/RentACoder/misc/LinkToUs/RssFeed_newBidRequests.asp")
				mystream.load(myrequest)
				parseIt(e)
			})
			addChild(reloadBtn);
			var square:Sprite = new Sprite();
			rectMC.addChild(square);
			square.graphics.beginFill(0x0000FF);
			square.graphics.drawRoundRect(0,10,600,380,50);
			square.graphics.endFill();
			square.alpha = 1;
			rectMC.x = 540;
			addChild(rectMC);
			popupText.width = 490;
			popupText.height = 400;
			popupText.x = 35;
			popupText.y = 35;
			popupText.wordWrap = true;

			rectMC.addChild(popupText)
			rectMC.addEventListener("click",foldPopup);
		}
		public function parseIt(e)
		{
			var curxml:XML = XML(mystream.data);
			var lines:Array = new Array;
			for each (var entry in curxml.channel.item)
			{
				var subObj:Object = new Object();
				subObj.title = entry.title;
				subObj.link = entry.link;
				subObj.date = entry.pubDate;
				subObj.description = entry.description;
				lines.push(subObj);
			}
			display(lines)
		}
		public function parseIt2(e)
		{
			var curxml:XML = XML(mystream2.data);
			var lines:Array = new Array;
			for each (var entry in curxml.channel.item)
			{
				var subObj:Object = new Object();
				subObj.title = entry.title;
				subObj.link = entry.link;
				subObj.date = entry.pubDate;
				subObj.description = entry.description;
				lines.push(subObj);
			}
			display2(lines)
		}
		public function display(entries:Array)
		{
			entriesDG.sortItemsOn("Date",  Array.DESCENDING);
			var pos = 0;
			for each (var entry in entries)
			{
				var textline:TextField = new TextField();
				var explosion:Array = entry.title.split('--');
				var priceStr:String = explosion.pop().replace("Max Bid: ","");
				explosion.pop();
				var priceInt:int;
				priceInt = int(Number(priceStr.replace(",","").replace("\x24","")))

				if(priceInt == 0)
				{
					priceInt = 1000000;
				}
				var temptitle:TextField = new TextField();
				var tempTF:TextField = new TextField();
				tempTF.htmlText = explosion.join(", ");
				entriesDG.addItem({"Max Salary":priceInt,"Title":tempTF.text,"Date":String(entry.date).replace(" EST",""),"description":entry.description,"link":entry.link});
			}
		}
		public function display2(entries:Array)
		{
			entriesDG.sortItemsOn("Date",  Array.DESCENDING);
			var pos = 0;
			for each (var entry in entries)
			{
				var budgetRegExp:RegExp = /Budget: \$[0-9]+\-([0-9]+)/;
				var catches:Object = budgetRegExp.exec(entry.description);
				var salary;
				if(catches)
				{
					salary = catches[1];
				}
				else
				{
					salary = 1000000;
				}
				entriesDG.addItem({"Max Salary":salary,"Title":entry.title,"Date":String(entry.date).replace(" -0400",""),"description":entry.description,"link":entry.link});
			}
		}
		public function gridlistener(e:DataGridEvent)
		{
			var ev:DataGridEvent = e
			var curEl = entriesDG.getItemAt(int(ev.rowIndex));
			var curtf:TextFormat = new TextFormat();
			curtf.color = 0xFFFFFF;
			curtf.size = 15;
			popupText.htmlText = curEl.description+"\n\rGo to the site";
			popupText.setTextFormat(curtf);
			popupText.autoSize = "left";

			var myTweenX:Tween = new Tween(rectMC, "x", Back.easeInOut, 540, 10, 1, true);
		}
		public function foldPopup(e)
		{
			var myTweenX:Tween = new Tween(e.currentTarget, "x", Back.easeInOut, e.currentTarget.x, 540, 1, true);
		}
	}
}