Search code examples
flashactionscript-3

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.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?


Solution

  • 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");