2011-03-11 85 views
0

我有一個使用SoundMixer控制音量的較大文件加載的AS3預加載電影。當兩個文件位於同一臺服務器上時,一切都可以在本地和在線上運行。Flash AS3 SoundMixer沙盒違規?

然而,當我分割文件時,假設有一個服務器上的加載程序swf和另一個上的較大內容,當我單擊音量按鈕時出現此錯誤。 (這個錯誤其實輸出,而測試的加載程序SWF文件,加載從在線服務器的內容。)

*安全沙箱衝突* 的SecurityDomain「http://www.onlinedomain.com/content.swf」試圖訪問不兼容的上下文'文件:///LocalDisc/WORK//loader.swf'

SecurityError:錯誤#2070:安全沙箱衝突:調用者http://www.onlinedomain.com/content.swf無法訪問由file:/// LocalDisc/WORK // loader加載的階段瑞士法郎。 在flash.media::SoundMixer$/set的SoundTransform() 在content_fla :: MainTimeline/stopSound() 在content_fla :: MainTimeline/soundMenuHandler()

我已經加入的crossdomain.xml文件,以兩個服務器允許訪問。

該處理的聲音在我的content.swf的功能是:

import flash.media.Sound; 
import flash.media.SoundChannel; 
import flash.media.SoundMixer; 


    function soundMenuHandler(event:MouseEvent):void { 

    if (sound == "ON") { 
    sound_btn.gotoAndStop(3); 
    stopSound(); 

    } else { 

    sound_btn.gotoAndStop(1); 
    playSound(); 

    } 
    } 

    function playSound():void { 
    sound = "ON"; 
    SoundMixer.soundTransform = new SoundTransform(1); 

    } 

    function stopSound():void 
    { 
    sound = "OFF"; 
    SoundMixer.soundTransform = new SoundTransform(0); 

    } 

The issue seems to be because of the SoundMixer accessing the loader.swf. Has anyone any idea what is going on and how this can be resolved? 

Many thanks, 

Mark 

回答

0

找到解決方案!

雖然crossdomain.xml策略文件確實包含此域(所以我不知道爲什麼它不起作用)。我可以通過將此代碼添加到加載程序文件來明確授予訪問權限。

Security.allowDomain(「www.loadeedomain.com」);

0

文件:///LocalDisc/WORK//loader.swf聽起來你是在本地測試。在本地測試,您可以禁用安全檢查在Flash安全管理器文件或文件夾:

http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html#117502

+0

感謝您的回覆。是的,我僅在本地進行測試才能看到Flash IDE中的輸出跟蹤。 – crooksy88 2011-03-11 15:44:14

+0

我只是這樣做才能看到Flash IDE中的錯誤輸出。問題是,當我在線運行文件時,每個文件都來自不同的服務器,內容文件確實會加載但立即停止工作,因爲調用了startSound函數併發生了安全違規。 – crooksy88 2011-03-11 16:21:18

+0

有一個鏈接,我可以看到發生的錯誤,並看看crossdomains.xml? – 2011-03-12 14:14:15

0

解決您的嵌入代碼,你有跨域問題 另外,還要確保你的crossdomain.xml是達到標準並且是交付

allowscriptaccess = "sameDomain"; 
allownetworking = "all";