Downloadify:使用JavaScript和Flash生成客户端文件

    技术2022-07-11  137

    The following tools is in its very beta stages and works intermittently. Its so damn useful that I had to show it off now though!

    以下工具处于测试阶段,并且会间歇性地工作。 它是如此有用,以至于我现在不得不炫耀它!

    I recently stumbled upon Downloadify, a client-side file generation tool based on JavaScript and Flash ActionScript code. A huge advantage to creating files on the client-side is that you can reduce the load on the server -- especially when there's no need for the server to get involved (the data is available within the page, etc.) Lets take a look at how we can use Downloadify.

    最近,我偶然发现了Downloadify ,这是一个基于JavaScript和Flash ActionScript代码的客户端文件生成工具。 在客户端创建文件的一个巨大优势是,您可以减少服务器上的负载-尤其是在不需要服务器参与(页面中的数据可用等)的情况下。我们如何使用Downloadify。

    View Demo 观看演示

    下载使用情况 (Downloadify Usage)

    Downloadify.create('downloader',{ filename: function(){ return 'secret-message.txt'; //static file -- you could retrieve from form input box }, data: function(){ return 'MooTools FTW!'; //static content -- you could retrieve from form input box }, onComplete: function(){ alert('The file has been saved!'); }, onCancel: function(){ alert('You have cancelled the saving of this file.'); }, onError: function(){ alert('Error! Damn!'); }, transparent: false, swf: 'media/downloadify.swf', downloadImage: 'images/download.png', width: 210, height: 55, transparent: true, append: false });

    Downloadify provides numerous options which you may pass per instance within the create method -- this should look familiar to notice to advanced JavaScript users. What I really love about Downloadify is that it provides just the right amount of customization -- events and filename/content settings. Too many JavaScript classes/functions try to do too much; Downloadify gets it right. My only criticism of Downloadify is it's requirement of a 4-state sprite; it would be great if that were an option or the ActionScript could detect the height setting vs. the image file's actual height and use the sprite if available.

    Downloadify提供了许多选项,您可以在create方法中为每个实例传递这些选项-对于高级JavaScript用户而言,应该看起来很熟悉。 我真正喜欢Downloadify的地方在于,它提供了适量的自定义功能-事件和文件名/内容设置。 太多JavaScript类/函数尝试做太多事情; Downloadify正确无误。 我对Downloadify的唯一批评是它需要4状态精灵。 如果那是一个选择,或者ActionScript可以检测高度设置与图像文件的实际高度,并使用Sprite(如果可用),那就太好了。

    MooTools帮助器 (MooTools Helper)

    /* mootools helper */ if(typeof(MooTools) != 'undefined'){ Element.implement({ downloadify: function(options) { options = $merge(Downloadify.defaultOptions,options); return this.store('Downloadify',Downloadify.create(this,options)); } }); }

    Downloadify comes with a jQuery helper but not a MooTools helper...I've remedied this.

    Downloadify带有jQuery助手,但没有MooTools助手...我已对此进行了补救。

    View Demo 观看演示

    Downloadify fills a need for many developers. Avoid unnecessary server load and jump on Downloadify!

    Downloadify满足了许多开发人员的需求。 避免不必要的服务器负载,并跳上Downloadify!

    翻译自: https://davidwalsh.name/downloadify

    相关资源:Downloadify-master 导出下载插件
    Processed: 0.011, SQL: 9