CS5 Flash应用程序在本地运行时有声音,但在服务器中运行时它是静音的

时间:2010-10-12 23:28:36

标签: actionscript-3 audio flash-cs5

我正在使用AS3在Flash CS5中创建这个小应用程序。使用flash.media.Sound和flash.media.SoundChannel重现声音。在本地,一切听起来都很完美,但是当我从服务器上运行游戏时,它就会变得无声。

任何帮助都是相关的。

感谢。

1 个答案:

答案 0 :(得分:0)

这看起来像是一个安全问题,您需要使用跨域策略文件。

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
 "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">

<cross-domain-policy>
   <site-control permitted-cross-domain-policies="master-only"/>
   <allow-access-from domain="yourDomainName.com"/>
</cross-domain-policy>

加载声音时,你会这样做:

private var sound:Sound = new Sound();
private var bufferTime:Number = 1000;// set your bufferTime here
// the second argument sets checkPolicyFile to true
private var context:SoundLoaderContext 
                  = new SoundLoaderContext( bufferTime , true );

//anywhere in your code
//assuming you have defined your URLRequest variable.
sound.load( request , context );