Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 Flash在Windows中保存,而不是在Linux中,FileReference.save()_Actionscript 3_Filereference - Fatal编程技术网

Actionscript 3 Flash在Windows中保存,而不是在Linux中,FileReference.save()

Actionscript 3 Flash在Windows中保存,而不是在Linux中,FileReference.save(),actionscript-3,filereference,Actionscript 3,Filereference,下面的代码在Fedora15上的Flex4SDK上编译得很好。鼠标单击打开对话框,单击“确定”,保存一个文件,但该文件为空。我在Windows机器上运行相同的SWF文件(在Linux机器上编译),创建的文件包含预期的数据 然后,我将FileReference声明从函数分解到类级别,希望避免,但同样的问题仍然存在 为了建立一个解决方案,我将调试Flash播放器添加到我的路径中,并在没有浏览器的情况下从Flash运行该文件,它可以运行。所以现在Flex的问题已经变成了Firefox的问题,可能是因为

下面的代码在Fedora15上的Flex4SDK上编译得很好。鼠标单击打开对话框,单击“确定”,保存一个文件,但该文件为空。我在Windows机器上运行相同的SWF文件(在Linux机器上编译),创建的文件包含预期的数据

然后,我将FileReference声明从函数分解到类级别,希望避免,但同样的问题仍然存在

为了建立一个解决方案,我将调试Flash播放器添加到我的路径中,并在没有浏览器的情况下从Flash运行该文件,它可以运行。所以现在Flex的问题已经变成了Firefox的问题,可能是因为没有真正了解发生了什么。我正在运行Firefox5.0

从本质上说,我的工作流是固定的,但执行上述操作的人员可能无法使用FileReference.save()项目?我应该担心这个边缘案件吗

/*
WriteTheFile.as
Original code by Brian Hodge (brian@hodgedev.com)
Test to see if ActionScript/Flash can write files
*/
package{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.utils.ByteArray;
    import flash.net.FileReference;

    public class WriteTheFile extends Sprite 
    {
        private var _xml:String;
        private var fr:FileReference;

        public function WriteTheFile():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            //Calling the save method requires user interaction and Flash Player 10
            stage.addEventListener(MouseEvent.MOUSE_DOWN, _onMouseDown);
        }
        private function _onMouseDown(e:MouseEvent):void
        {
            fr = new FileReference()
            fr.save("<xml><test>data</test></xml>", "filename.txt");
        }
    }
}
/*
WriteTheFile.as
Brian Hodge的原始代码(brian@hodgedev.com)
测试ActionScript/Flash是否可以写入文件
*/
包装{
导入flash.display.Sprite;
导入flash.events.Event;
导入flash.events.MouseEvent;
导入flash.utils.ByteArray;
导入flash.net.FileReference;
公共类writefile扩展了Sprite
{
私有变量xml:String;
私有var-fr:FileReference;
公共函数WriteTheFile():void
{
if(stage)init();
else addEventListener(Event.ADDED_TO_STAGE,init);
}
私有函数init(e:Event=null):void
{
removeEventListener(Event.ADDED_TO_STAGE,init);
//调用save方法需要用户交互和Flash Player 10
stage.addEventListener(MouseEvent.MOUSE\u DOWN,\u onMouseDown);
}
私有函数_onMouseDown(e:MouseEvent):void
{
fr=新文件引用()
fr.save(“数据”,“filename.txt”);
}
}
}
编辑:缺少一行,已在上面修复

编辑:在上面的代码中找到答案,但同样的问题也存在

编辑:当调用独立播放机时,它在同一系统上工作。因此,这是一个浏览器(FF 5.0)插件问题。

试着把这一行

var-fr:FileReference=newfilereference()

在类级别(函数外部)。显然这是一个已知的错误:


这真的是你所有的代码吗?
fr
来自哪里?是的,谢谢你指出。在变量fr:FileReference=newfilereference()中添加了缺少的行;谢谢你的建议,但同样的问题也存在。对上面代码的更改。请重新编辑上面的代码。这是一个浏览器问题。我明白了。。。那么问题解决了吗?阅读本页上的答案,了解Firefox为什么会出现问题以及可能的解决方法: