我使用swfloader在主swf中加载一个swf文件。我通过附加到网址将参数传递给加载swf文件。
我的问题是这个加载swf没有缓存,因为每次传递参数都在改变。我的示例代码如下
var context:LoaderContext = new LoaderContext();
context.securityDomain = SecurityDomain.currentDomain;
context.applicationDomain = new ApplicationDomain();
patViewId.loaderContext = context;
patViewId.source = "/Sample/view/flex/file21.swf?patientCode="+patCode;
是否有任何解决方案来实现此swf文件的缓存..有人可以帮我这个吗?
答案 0 :(得分:0)
您可以将任何变量直接传递给loadercontext:
let
apikey = "MYAPIKEY",
proxyendpoint = "URL OF THE FIRST ENDPOINT",
bytesbody = File.Contents("FILE PATH TO BE POSTED"),
headers = [#"Ocp-Apim-Subscription-Key" = apikey],
bytesresp = Web.Contents(proxyendpoint, [Headers=headers, Content=bytesbody]),
jsonresp = Json.Document(bytesresp),
opLoc = jsonresp[OperationLocation],
getResult = (url, apiKeyParam) =>
let
// note the extra header here, which is different in every call
currentHeaders = [#"Ocp-Apim-Subscription-Key" = apiKeyParam, #"CacheHack" = Number.ToText(Number.Random())],
linesBody = Web.Contents(url, [Headers=currentHeaders]),
linesJson = Json.Document(linesBody),
resultStatus = linesJson[status],
result = if (resultStatus = "Succeeded") then linesJson[recognitionResult][lines]
else Function.InvokeAfter(()=>@getResult(url, apiKeyParam), #duration(0,0,0,5))
in result,
linesText = List.Transform(getResult(opLoc, apikey), each _[text]),
table = Table.FromList(linesText)
in table
在你加载的swf(file21.swf)中,你应该能够访问这样的参数:
context.parameters = {'patientCode': patCode};