A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: JSFL Script help (Simple modification)

  1. #1
    Registered User
    Join Date
    Jan 2016
    Posts
    1

    JSFL Script help (Simple modification)

    Sorry if JSFL isn't actionscript, I am not a coder so am not sure if they are the same

    I use this script:
    Code:
    /*
    *  PNG2SWF_MULTIPLE JSFL v 1.0
    *  by Matus Laco, 
    *  Modified by dark13 to embedd PNGs as uncompressed files and allow smoothing
    *  product URL: 
    *  inspired by Mr.doob 
    *
    *  Description:
    *  Converts multiple png files to multiple swf files.
    *  Input: Select folder dialog box
    *  Output: Same folder, same filename, swf extension
    */
    png2swf();
    function png2swf()
    {
    	var folderURI = fl.browseForFolderURL("Select a folder.");
    	if (folderURI == null) { return; }
    	var folderContents = FLfile.listFolder(folderURI);
        var doc = fl.createDocument();
    doc.backgroundColor = '#00FF00';
    
    var imported = 0;
    	
    for(var i=0; i< folderContents.length; i++){
    	
    				
    	var pngURI = folderURI + "/" +folderContents[i];
    	if (pngURI.substr(pngURI.length-4) != ".png") continue;
    	
    	doc.importFile(pngURI);
    	
    	// get item		
    	var bmp_lib = doc.library.items[imported];
    	bmp_lib.compressionType = "lossless";		
                bmp_lib.allowSmoothing = true;
    	var bmp_tl = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0];
    // Scale from 1080p to 1024*768 and apply 16:9 ratio correction
                    bmp_tl.scaleX = 0.53333 ;
                    bmp_tl.scaleY = 0.7111 ;
                    bmp_tl.x = 0 ;
        	        bmp_tl.y = 0 ;
    // set doc size
    		doc.width = Math.floor(bmp_tl.width)+1;
    		doc.height = Math.floor(bmp_tl.height)+1;	
    // export	
    		var swfURI = pngURI.substr(0,pngURI.lastIndexOf(".")+1)+"swf";
    		doc.exportSWF(swfURI, true );
    		// remove previous from timeline
    		doc.selectAll();
    		doc.deleteSelection();
    		// increase imported count
    		imported++;
    	}
    	doc.close(false);
    	alert(imported + " files created.");
    }
    Works great except I would like it to also look in the subfolders of my selected folder. Tried to sort it out but since I don't know AC3 or anything, I was clueless, lol.

    Thanks in advance.

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    I'd suggest you look into recursive functions. To be able to help you, I could use the full project to look over what you have.
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center