Flash redirect problem when not loaded from the same vhost
We've got a flash file that takes a URL parameter for redirecting on click. When it's hosted from the primary domain, and the SWF is included in HTML from the primary domain, the redirect works properly.
However, when it's hosted on the secondary dom开发者_如何学运维ain, and the SWF is included in HTML from the primary domain, the redirect doesn't work. I've added a crossdomain.xml
file to both the primary and secondary domain, thinking that might help. The contents of both crossdomain.xml
files are included below.
What is it that I'm missing?
crossdomain.xml
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
EDIT: Here's the actionscript used for the "redirect".
actionscript
on (release) {
getURL(clickTag);
}
clickTag is a parameter we're passing in through the querystring.
EDIT: After adding allowScriptAccess="always"
to the embed code, and <param name="allowScriptAccess" value="always" />
to the object
tag, the window opens, and the location goes to /undefined
. Thoughts?
EDIT: As requested, here's the actual object/embed code we're using:
<object type="application/x-shockwave-flash" data="/files/2348.swc" width="300" height="250" class="ad" onclick="ad_click(169);">
<param name="movie" value="/files/2348.swc?clickTAG=http://www.google.com"/>
<param value="high" name="quality">
<param value="#FFFFFF" name="bgcolor">
<param value="always" name="allowScriptAccess">
<param value="transparent" name="wmode">
</object>
Try setting allowScriptAccess
to always
in the object and embed tags of the including HTML.
The default value is "sameDomain" for recent versions of Flash Player, which explains your current behavior.
For your edit, it may help to have more information, but you likely need to access your parameters using _root
or _level0
, rather than directly as above. See Adobe's docs on this problem and description of _root
.
Based on your embed code, I still think it may be worth your while to look into _root
.
Your object tag is a bit nonstandard, so there may be some issues:
- You seem to have the case issues suggested by Josh here:
clickTag
vsclickTAG
- Does it help to add the parameter to the
data
attribute URL? - Perhaps trying the Adobe suggested tags would help?
- Also, what's the significance of packaging your file as a SWC rather than a SWF?
If you have control over the SWF, you might consider going directly to FlashVars.
to answer the second part of the question regarding the undefined - the click tag is case sensitive make sure the parameter and variable match case or you could add the following snippet just to be sure:
on (release) {
var myCT:String = clickTAG;
if(myCT == ""){
myCT = clickTag;
}
if(myCT == ""){
myCT = clicktag;
}
getURL(myCT, "_blank");
}
Perhaps you could use Javascript to do the actual redirection.
For example, from the AS3 code, use ExternalInterface to call a JS function that does the redirect.
import flash.external.ExternalInterface;
var retval:int = ExternalInterface.call("redirect()", "http://the_redirect_url/");
Then in the JS:
function redirect(url) {
window.location = url;
}
Disclaimer: haven't tested it. ;-)
精彩评论