大家好,今天我正在尝试获取从Object Embed代码传递到我的Flash电影的XML文件的链接。 (不使用SWFobject)。我有一个swf文件,应该能够连接到3个不同的XML文件。
以下是HTML代码(我正在尝试获取XML路径):
<div class="left">
<h2>300 x 353 Green Accent Color</h2>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','300','height','353','src','TEN','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','TEN' ); //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="300" height="353">
<param name="movie" value="player.swf" />
<param name="quality" value="high" />
<param name="XML" value="client_user.xml" />
<embed src="T.swf" allowscriptaccess="always" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="300" height="353"></embed>
</object></noscript>
</div>
文档类
private var theXML:String = root.loaderInfo.parameters.xmlPath;
public function TEN():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
xmlLoader.addEventListener(Event.COMPLETE, xmlCompleteHandler);
xmlLoader.load(new URLRequest(root.loaderInfo.parameters.xmlPath));
loader = new BulkLoader("bulky");
loader.logLevel = BulkLoader.LOG_INFO;
loader.addEventListener(BulkLoader.COMPLETE, onBulkLoadComplete);
loader.addEventListener(BulkLoader.PROGRESS, onBulkLoadProgress);
//loader.add("client.xml",{id:"xmldata"}); //<- for TESTING
//loader.add(theXML+".xml",{id:"xmldata"}); //<- for LIVE
loader.add(xmlPath+".xml",{id:"xmldata"}); //<- for LIVE
loader.start();
}
使用不同PARAM传递语法的HTML:
<div class="right">
<h2>520 x 477 Blue Accent Color</h2>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','300','height','353','src','TEN','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','TEN' ); //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="300" height="353">
<param name="movie" value="T.swf?xmlPath=0" />
<param name="quality" value="high" />
<param name="xmlPath" value="520.xml" />
<embed src="T.swf" allowscriptaccess="always" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="300" height="353"></embed>
</object></noscript>
</div>
Flash代码已更新:
private var theXML:String = "";
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
theXML = stage.loaderInfo.parameters.xmlPath;
loader = new BulkLoader("bulky");
loader.logLevel = BulkLoader.LOG_INFO;
loader.addEventListener(BulkLoader.COMPLETE, onBulkLoadComplete);
loader.addEventListener(BulkLoader.PROGRESS, onBulkLoadProgress);
//loader.add("client_user.xml",{id:"xmldata"}); //<- for TESTING
loader.add(theXML,{id:"xmldata"}); //<- for LIVE
//loader.add(theXML+".xml",{id:"xmldata"}); //<- for LIVE
loader.start();
}
更新了HTML代码:
<div class="right">
<h2>520 x 477 Blue Accent Color</h2>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','300','height','353','src','TEN','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','T' ); //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="300" height="353">
<param name="movie" value="T.swf?xmlPath=0.xml" />
<param name="quality" value="high" />
<param name="xmlPath" value="520.xml" />
<embed src="T.swf?xmlPath=520.xml" allowscriptaccess="always" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="300" height="353"></embed>
</object></noscript>
</div>
答案 0 :(得分:3)
查看FlashVars - 这是将变量通过对象标记传递给SWF的标准方法。
<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="300" height="353">
<param name="movie" value="http://www.howdini.com/TEN/TEN.swf" />
<param name="quality" value="high" />
<param name="flashVars" value="theXML=client_user.xml" />
<embed src="TEN.swf"
flashVars="theXML=client_user.xml"
allowscriptaccess="always"
quality="high"
pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash" width="300" height="353">
</embed>
</object>
以这种方式使用FlashVars,或在SWF的网址(TEN.SWF?theXML=client_user.xml
)中设置查询参数,将填入您的loaderInfo.parameters字段。
我习惯于Flex(FlashVars存储在application.parameters
中,但在AS3中,我认为您使用的是loaderInfo
:
// constructor
public function init():void {
theXML = this.loaderInfo.parameters.theXML;
...
}
答案 1 :(得分:1)
是的,只需使用swfobject! 在html上
<script>
swfobject.embedSWF("your-movie.swf", "yourdivid", "width", "height", "flashverion", "path to expressIntall.swf", {flashvar:"value", flashvar2:"value"}, {flashparam:"value", flashparam2:"value"});
</script>
<div id="yourdivid">Your alternative content or download links for flash player</div>
在Flash上
var var1:Type = root.loaderInfo.parameters['flashvar'];
var var2:Type = root.loaderInfo.parameters['flashvar2'];