Flash AS3 SoundMixer Sandbox Violation?
I have an AS3 preloading movie loading in a larger file which uses SoundMixer to control the volume. Everything works great locally and online when both files are on the same server.
When I split the files however, say to have the loader swf on one server and the larger content on another, when I click on the volume button I get this error. (This error actually outputs whilst testing the loader swf, loading the content from an online server.)
Security Sandbox Violation
SecurityDomain 'http://www.onlinedomain.com/content.swf' tried to access incompatible context 'file:///LocalDisc/WORK//loader.swf'
SecurityError: Error #2070: Security sandbox violation: caller http://www.onlinedomain.com/content.swf cannot access Stage owned by file:///LocalDisc/WORK//loader.swf.
at flash.media::SoundMixer$/set soundTransform()
at content_fla::MainTimeline/stopSound()
at content_fla::MainTimeline/soundMenuHandler()
I have added crossdomain.xml
files to both servers allowing access.
The functions that handle the sound in my content.swf are:
import flash.m开发者_如何学JAVAedia.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?
file:///LocalDisc/WORK//loader.swf sounds like you are testing locally. To test locally you can disable security checks for files or folders at the Flash security manager:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html#117502
Fix your embed code you have cross domain issues Also make sure your crossdomain.xml is up to par and being delivered
allowscriptaccess = "sameDomain";
allownetworking = "all";
Solution found!
Although the crossdomain.xml policy file did include this domain (so I'm not sure why it didn't work). I can explicitly give access by adding this code to the loader file.
Security.allowDomain("www.loadeedomain.com");
精彩评论