Php 如何获取URL参数';什么是闪光?

Php 如何获取URL参数';什么是闪光?,php,xml,flash,actionscript-2,Php,Xml,Flash,Actionscript 2,我在一个Flash网站上工作了一段时间,但刚才我注意到链接没有改变(这对于Flash应用程序来说是正常的)。但问题是,网站需要“可共享”。所以我的问题是, 如何从URL获取参数并在Flash中读取? 例如,当url为http://www.thewebsite.ext/index.php?article=245 Flash应用程序必须知道文章是245,这样它就可以转到正确的文章,而不仅仅是主页。 如何做到这一点? (顺便说一下,我正在使用actionscript 2) 编辑: 这是SWF文件的源代


我在一个Flash网站上工作了一段时间,但刚才我注意到链接没有改变(这对于Flash应用程序来说是正常的)。但问题是,网站需要“可共享”。所以我的问题是,
如何从URL获取参数并在Flash中读取?
例如,当url为
http://www.thewebsite.ext/index.php?article=245

Flash应用程序必须知道文章是
245
,这样它就可以转到正确的文章,而不仅仅是主页。
如何做到这一点?
(顺便说一下,我正在使用actionscript 2)

编辑:
这是SWF文件的源代码

<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','100%','height','100%','id','PortfolioScroller','src','media/casescroller2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','wmode','opaque','movie','media/casescroller2', 'FlashVars', 'pfcase=1' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="100%" height="100%">
    <param name="movie" value="media/casescroller2.swf?pfcase=1" />
    <param name="quality" value="high" />
    <param name="id" value="PortfolioScroller" />
    <param name="wmode" value="opaque" />
    <param name="FlashVars" value="pfcase=1">
    <embed src="media/casescroller2.swf?pfcase=1" FlashVars="pfcase=1" width="100%" height="100%" id="PortfolioScroller" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="opaque" name="PortfolioScroller"></embed>
  </object>
</noscript>

这个脚本只是为了测试一下。(如果pfcase不为空,则可以看到MovieClip?

您应该使用flashvars来实现此功能。
另一种方法是使用。 这使用url哈希,因此您的url如下:

http://www.thewebsite.ext/#article=245


下载中包含了使用flashvars的示例。

。在Flash中,您必须收听具体的flashvar,例如articleUrl,在HTML中必须设置

<object ... >
     <param name="FlashVars" value="articleUrl=http://www.thewebsite.ext/index.php?article=245"/>
</object>

<embed ... FlashVars="articleUrl=http://www.thewebsite.ext/index.php?article=245" ... />

您可以通过外部接口调用JavaScript来获取页面的URL(或仅获取参数)

这是我最近发送给同事的一段AS3代码(此处稍作修改),我相信它也适用于AS2:

// Get the entire URL for the page, like "http://www.thewebsite.ext/index.php?article=245"
var url:String = String(ExternalInterface.call("function() { return String(window.location); }")).toLowerCase();

// Split the string on the argument that we are after, incl. the =
var parts:Array = url.split("article=");

// parts[1] will be the string following "article=", or undefined if there was no "article=" in the URL
if(parts[1])
{
    // There was an article argument. 
    // parseInt() can be used to convert it to an int, and will also get rid of whatever comes after, if anything.
    // For example, parseInt("123&foo=bar") will return 123, ignoring what comes after the last number in the string.
    trace(parseInt(parts[1]));
}
您可以使用
document.location.search
而不是
document.location
,只获取URL的参数部分,包括?在本例中类似于?article=245“


编辑:但由于您使用PHP标记了这个问题,我同意Tania和shadyyx的观点,即使用flashvars向Flash应用程序提供值可能更好,因为它不依赖JavaScript和对ExternalInterface的支持,并且在加载swf后会立即提供值。无论如何,我将把JavaScript/ExternalInterface解决方案留在这里,它可能会对某些人有用

我试过用闪光灯,但没用,也许我用错了?我用代码更新了OP。你可以将文章id作为flash参数传递。然后通过actionscript检查id并转到相应的页面(我的意思是说使用flash转到特定的页面,而不是页面url),这就是我尝试的(检查原始帖子),但它不起作用。我想我做错了什么。我使用一个PHP-XML文件来更新Flash中的内容,这意味着我不能(或者我根本不知道如何)给帧命名,如SWFAddress的Flash示例。
// Get the entire URL for the page, like "http://www.thewebsite.ext/index.php?article=245"
var url:String = String(ExternalInterface.call("function() { return String(window.location); }")).toLowerCase();

// Split the string on the argument that we are after, incl. the =
var parts:Array = url.split("article=");

// parts[1] will be the string following "article=", or undefined if there was no "article=" in the URL
if(parts[1])
{
    // There was an article argument. 
    // parseInt() can be used to convert it to an int, and will also get rid of whatever comes after, if anything.
    // For example, parseInt("123&foo=bar") will return 123, ignoring what comes after the last number in the string.
    trace(parseInt(parts[1]));
}