• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Odd sandbox error: #2048 and Security error #2044 Flash AS3

New Here ,
Nov 24, 2021 Nov 24, 2021

Copy link to clipboard


The project I am working on has me creating a live music streamer for IMVU that links to a live stream hosting service.  The publish configuration "Local playback security:" is set to Access network only.  The SWF can get to the crossdomain.xml at "https://hugegrooveentertainmentnetwork.com/crossdomain.xml" which has the following:


<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>


The SWF can also get to the DJInfo xml at https://hugegrooveentertainmentnetwork.com/DJInfo.xml which contains:


<?xml version="1.0" encoding="utf-8"?>
<DjName>Huge Groove</DjName>
<ClubName>Huge Groove's Smooth Jazz</ClubName>


The SWF can access the live stream at the <surl> from the DJInfo xml file.  To get the current song playing and cover art, the SWF pulls Json data from the URL <json> in the DJInfo xml file.  In Control>Test Movie>In Animate, everything works just fine. 




However, in Debug>Debug Movie>In Animate everything works except accessing the Json stream to get the song information. 




It throws:


** Security Sandbox Violation ***
Connection to https://3dworlddjstreams.xyz:2000/json/stream/8108 halted - not permitted from file:///C|/Users/clayl/Pictures/DJStreamer/DJStreamer.swf
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: file:///C|/Users/clayl/Pictures/DJStreamer/DJStreamer.swf cannot load data from https://3dworlddjstreams.xyz:2000/json/stream/8108.
at AS3ICYTest/frame1()[AS3ICYTest::frame1:23]
Error: Request for resource at https://3dworlddjstreams.xyz:2000/json/stream/8108 by requestor from file:///C|/Users/clayl/Pictures/DJStreamer/DJStreamer.swf is denied due to lack of policy file permissions.


The following is the AS3 code:

import flash.display.*;
import flash.net.*;
import flash.events.*;
import flash.xml.XMLDocument;
import flash.text.*;
import flash.media.*;
import flash.geom.Rectangle;
import flash.utils.Timer;
import flash.errors.*;
import flash.system.Security;

var myXML: XML = new XML;
var myXMLURL: URLRequest = new URLRequest("https://hugegrooveentertainmentnetwork.com/DJInfo.xml");
var myLoader: URLLoader = new URLLoader(myXMLURL);
var txtClubName: TextField = new TextField();
var txtDjName: TextField = new TextField();
var soundChannel: SoundChannel;
var sound = new Sound();
var req: URLRequest = new URLRequest();
var vol: Number = 0;
var isMuted: Boolean = false;
var request: URLRequest = new URLRequest();
var myJsonLoader: URLLoader = new URLLoader();
var imgRequest: URLRequest = new URLRequest()
var myJsonUrl: String = new String();
var stream: URLStream = new URLStream();
var heartbeat: Timer = new Timer(5000);

myLoader.addEventListener("complete", xmlLoaded);
btnPlay.addEventListener(MouseEvent.CLICK, startPlay);
btnPause.addEventListener(MouseEvent.CLICK, pausePlay);
volume_mc.knob_mc.addEventListener(MouseEvent.MOUSE_DOWN, volume_drag);
volume_mc.knob_mc.addEventListener(MouseEvent.MOUSE_UP, volume_dragStop);
volume_mc.knob_mc.addEventListener(MouseEvent.MOUSE_OUT, volume_dragStop);
volume_mc.knob_mc.addEventListener(Event.ENTER_FRAME, volume_set)
volume_mc.knob_mc.y = -85;

function xmlLoaded(event: Event): void {
	myXML = XML(myLoader.data);
	trace("Data loaded.");
	var xmlDoc: XMLDocument = new XMLDocument();
	xmlDoc.ignoreWhite = true;
	var menuXML: XML = XML(myLoader.data);
	tfDjName.htmlText = "<font color='#ffffff'>" + "DJ: " + myXML.station.DjName.toString() + "</font>";
	tfClubName.htmlText = "<font color='#ffffff'>" + myXML.station.ClubName.toString() + "</font>";

	myJsonUrl = myXML.station.json.toString();

	heartbeat.addEventListener(TimerEvent.TIMER, onHeartbeat);

	req = new URLRequest(myXML.station.surl.toString());
	soundChannel = sound.play();

function volume_set(event: Event): void {
	try {
		if (isMuted) {
			vol = 0;
		} else {
			vol = (volume_mc.knob_mc.y * -1) / 100;

		var st: SoundTransform = new SoundTransform(vol);
		soundChannel.soundTransform = st;
	} catch (error: Error) {


function volume_dragStop(event: MouseEvent): void {

function volume_drag(event: MouseEvent): void {
	volume_mc.knob_mc.startDrag(false, new Rectangle(0, 0, 0, -85));

function pausePlay(event: MouseEvent): void {
	isMuted = true;

function startPlay(event: MouseEvent): void {
	isMuted = false;
	vol = (volume_mc.knob_mc.y * -1) / 100;
	var st: SoundTransform = new SoundTransform(vol);
	soundChannel.soundTransform = st;

function receive(event: Event): void {
	try {
		var myData: Object = JSON.parse(myJsonLoader.data);
		var nowPlaying: Object = myData["nowplaying"];
		var bitRate: Object = myData["bitrate"];
		tfNowPlaying.autoSize = TextFieldAutoSize.RIGHT;
		tfNowPlaying.htmlText = "<font color='#ffffff'>" + nowPlaying.toString() + "</font>";
		tfMPEGBitrate.htmlText = "<font color='#ffffff'>Bit Rate: " + bitRate.toString() + "Kbs</font>";
		var coverArt: Object = myData["coverart"];
		imgRequest = new URLRequest(coverArt.toString());
		var imgLoader: Loader = new Loader();
		imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
	} catch (e: SecurityError) {

function onHeartbeat(event: TimerEvent): void {

	try {
		request = new URLRequest(myJsonUrl);
		request.requestHeaders = [new URLRequestHeader("Content-Type", "application/json")];
		request.method = URLRequestMethod.GET;
		myJsonLoader.addEventListener(Event.COMPLETE, receive);
	} catch (e: SecurityError) {

function loaded(e: Event): void {
	var bitmap: Bitmap = e.target.content;
	var ratio: Number = .75;
	var bmd: BitmapData = new BitmapData(bitmap.width * ratio, bitmap.height * ratio);
	var m: Matrix = new Matrix();
	m.scale(ratio, ratio);
	bmd.draw(bitmap, m);
	bitmap = new Bitmap(bmd, PixelSnapping.NEVER, false);


	e.target.removeEventListener(Event.COMPLETE, loaded);

I have done hours of research on the web looking for an answer that does not seem to exist.

ActionScript , Code , Error






Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation