gpt4 book ai didi

actionscript-3 - As3 FileReference 下载动态 url

转载 作者:行者123 更新时间:2023-12-02 03:45:36 24 4
gpt4 key购买 nike

As3 FileReference 下载动态url 不发送变量数据;示例:

downloadXls.buttonMode=true;
import flash.net.FileReference;
import flash.events.Event;

var localRef:FileReference;
var fileRequest:URLRequest= new URLRequest("http://[sitename].com/xlsexport.php?id=456");
downloadXls.addEventListener(MouseEvent.CLICK,downloadXlsH);
function downloadXlsH(event:MouseEvent):void{
localRef = new FileReference();
localRef.addEventListener(Event.COMPLETE, completeHandler);
localRef.download( fileRequest, 'myfile.xls' );
}
function completeHandler(e:Event):void{
trace('OK. Dosya Kaydedildi.');
}

问题:http://[sitename].com/xls.php?id=456 id 变量不发送 xlsexport.php

代码只是“filename = xlsexport”变量产生一个我要发送不同的变量“id = 4545 & pass = 87665”

最佳答案

您可以使用 URLVariables 类做您想做的事。

创建一个 ActionScript 3 类文件 (*.as) 并在其中粘贴以下代码:

package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.FileReference;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;

public class Download extends Sprite
{
var localRef:FileReference;
var urlVars:URLVariables;
var fileRequest:URLRequest;

public function Download(downloadXls:*)
{
downloadXls.buttonMode=true;
downloadXls.addEventListener(MouseEvent.CLICK,downloadXlsH);
}

private function downloadXlsH(event:MouseEvent):void
{
localRef = new FileReference();
localRef.addEventListener(Event.COMPLETE, completeHandler);

urlVars = new URLVariables();
urlVars.id = 456;

fileRequest = new URLRequest();
fileRequest.method = URLRequestMethod.GET;
fileRequest.data = urlVars;
fileRequest.url = "http://[sitename].com/xlsexport.php";

localRef.download(fileRequest);
}

private function completeHandler(e:Event):void
{
trace('OK. Dosya Kaydedildi.');
}
}
}

并使用以下行在您的 Adob​​e Flash 项目(*.fla 文件)的时间轴中调用它。

import Temp_Example4;
var temp:Temp_Example4 = new Temp_Example4(downloadXls);

请记住,如果您想添加多个 URL 变量,则必须为每个 URL 变量使用以下代码行:

nameOfYourURLVariablesInstance.yourUrlVariableName = yourUrlVariableValue;

像这样:

urlVars.id = 456;

在示例 ActionScript 3 类文件中。

您也可以从以下地址下载示例工程:

4Shared -> Sample Project

SendSpace -> Sample Project

关于actionscript-3 - As3 FileReference 下载动态 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17397343/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com