In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

mp3 asset extraction

i.e., steal music from flash games
Select a SWF, then click the buttons to save MP3 files.
Get Adobe Flash player
by wh0 26 Feb 2011

    Talk

    makc3d at 11 Oct 2011 13:37
    swftools.org could do that since forever. not to mention commercial decompilers :)

    Tags

    Embed
/**
 * Copyright wh0 ( http://wonderfl.net/user/wh0 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/gwTR
 */

package {
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.net.*;
    import flash.utils.*;
    import com.codeazur.as3swf.*;
    import com.codeazur.as3swf.tags.*;
    import com.codeazur.as3swf.data.consts.*;
    import com.bit101.components.*;
    public class FlashTest extends Sprite {
        
        private var flow:Number = 21;
        private var it:InputText;
        private var pb1:PushButton;
        private var pb2:PushButton;
        
        public function FlashTest() {
            loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, function(e:UncaughtErrorEvent):void { trace(e.error); });
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            it = new InputText(this, 0, 0);
            it.width = 379;
            it.height = 18;
            pb1 = new PushButton(this, 382, 0, 'url', urlClick);
            pb1.width = 40;
            pb1.height = 18;
            pb2 = new PushButton(this, 425, 0, 'file', fileClick);
            pb2.width = 40;
            pb2.height = 18;
        }
        
        private function disable():void {
            it.textField.filters = [new BlurFilter(16, 2)];
            it.enabled = false;
            pb1.enabled = false;
            pb2.enabled = false;
        }
        
        private function urlClick(e:MouseEvent):void {
            disable();
            var l:Loader = new Loader();
            l.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void {
                parse(l.contentLoaderInfo.bytes);
                l.unloadAndStop();
            });
            l.load(new URLRequest(it.text));
        }
        
        private function fileClick(e:MouseEvent):void {
            var fr:FileReference = new FileReference();
            fr.addEventListener(Event.SELECT, function(e:Event):void {
                fr.load();
            });
            fr.addEventListener(Event.COMPLETE, function(e:Event):void {
                parse(fr.data);
            });
            fr.browse([new FileFilter('Flash Movies (*.swf)', '*.swf')]);
        }
        
        private function parse(ba:ByteArray):void {
            for each (var tag:ITag in new SWF(ba).tags) {
                if (tag is TagDefineSound) addButton(tag as TagDefineSound);
            }
        }
        
        private function addButton(tds:TagDefineSound):void {
            var name:String = tds.characterId.toString();
            var pb:PushButton = new PushButton(this, 0, flow, name, function(e:MouseEvent):void {
                new FileReference().save(tds.soundData, name + '.mp3');
            });
            pb.width = 40;
            pb.height = 18;
            if (tds.soundFormat != SoundCompression.MP3) pb.enabled = false;
            new Label(this, 42, flow, tds.toString().substr(17));
            flow += 21;
        }
        
    }
}