Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8405133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:46:22+00:00 2026-06-09T22:46:22+00:00

I seem to be running into an interesting problem while saving a Sprite to

  • 0

I seem to be running into an interesting problem while saving a Sprite to my server. When I run the swf (remote) on my MAC it works fine but when I run the exact same URL from my windows computer I get a #2048 SecurityError.

Here my AS3 code:

    public function saveSprite(s:Sprite):void {
        var bmpData:BitmapData = new BitmapData(s.width, s.height, true, 0xFFFFFF);
        bmpData.draw(s);
        var byteArray:ByteArray = PNGEncoder.encode(bmpData);
        var encodedFile:Base64Encoder = new Base64Encoder();
        encodedFile.encodeBytes(byteArray);

        var data:URLVariables = new URLVariables();
        data.fileData = encodedFile;
        data.fileName = "test.png";
        data.location = "temp/";

        var request:URLRequest = new URLRequest(scriptLocation);
        request.method = URLRequestMethod.POST;
        request.data = data;

        var loader:URLLoader = new URLLoader();
        loader.addEventListener(Event.COMPLETE, errorLog);
        loader.addEventListener(Event.OPEN, errorLog);
        loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, errorLog);
        loader.addEventListener(IOErrorEvent.IO_ERROR, errorLog);
        loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorLog);
        loader.addEventListener(ProgressEvent.PROGRESS, errorLog)

        try {
            loader.load(request);
        } catch (e:*) {
            debug.updateLog(e + "\n");
        }
    }

    private function errorLog(e:*):void {
        debug.updateLog(e + "\n");
    }

The AS3 connects with the following one-line PHP-file:

<?php file_put_contents($_POST['location'] . $_POST['fileName'], base64_decode($_POST['fileData']));

When I run the SWF on my mac the output is as follows:
Log Start
[Event type=”open” bubbles=false cancelable=false eventPhase=2]
[ProgressEvent type=”progress” bubbles=false cancelable=false eventPhase=2 bytesLoaded=7 bytesTotal=0]
[HTTPStatusEvent type=”httpStatus” bubbles=false cancelable=false eventPhase=2 status=200 responseURL=null]
[Event type=”complete” bubbles=false cancelable=false eventPhase=2]

Where on a Windows I get the following output:
Log Start
[HTTPStatusEvent type=”httpStatus” bubbles=false cancelable=false eventPhase=2 status=0 responseURL=null]
[SecurityErrorEvent type=”securityError” bubbles=false cancelable=false eventPhase=2 text=”Error #2048″]

Any thoughts on this will be appreciated. My own guess would be something with file permissions but what?

Thanks in advance!

[EDIT]
It gets more interesting.
1. When I move my whole project to a different server I get a #2048 on windows and mac.
2. If I change my file permissions to 777 I get a #2048 on windows and mac as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:46:24+00:00Added an answer on June 9, 2026 at 10:46 pm

    Finally! I’ve found it.

    Adding a crossdomain.xml to the root of my webserver solved the issue.
    It seems wierd to me that this solves the problem as the php file I access is on the same server. Not only that, it’s in the same folder!

    It seems that under MAC OSX the flashplayer recognizes that the request is within the same domain but under windows fails to do so. That would explain why under windows the security error is trown. Which resulted in my swf working under MAC but not on a windows machine. For now I have added the following crossdomain.xml file to the root of my server:

    <?xml version="1.0" ?>
    
    <cross-domain-policy>
        <site-control permitted-cross-domain-policies="master-only"/>
        <allow-access-from domain="*.mydomain.com" to-ports="*"/>
        <allow-http-request-headers-from domain="*.mydomain.com" headers="*"/>
    </cross-domain-policy>
    

    If you want to use this solution please change the ‘mydomain.com’ to the specific domain you want to allow. Read everything about the crossdomain.xml and how to use it here: http://learn.adobe.com/wiki/download/attachments/64389123/CrossDomain_PolicyFile_Specification.pdf?version=1

    As I stated in the question the following error was caught: [SecurityErrorEvent type=”securityError” bubbles=false cancelable=false eventPhase=2 text=”Error #2048″]

    Note that usually the error contains: [SecurityErrorEvent type=”securityError” bubbles=false cancelable=false eventPhase=2 text=”Error #2048: Security Sandbox Violation : http://www.domain1.com/file.swf can not load data from http://www.domain2.com/file.*”]

    The fact that a part of the error is missing in my case could indicate that a file in the same domain is requested.

    So the crossdomain.xml did the trick!
    I hope this answer will be of benefit to someone.

    Happy coding!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running into a problem that I can't seem to solve. The code works
I seem to be running into a problem with temp table garbage collection: CREATE
I am running into a problem that just doesn't seem right. I've got a
I'm running into a problem that I can't seem to get past. Whenever I
Here's a problem that I seem to be running into working with an accounting
I'm running into an odd problem where window.addEventListener (or window.attachEvent) doesn't seem to be
I seem to be running into a problem with Rails 3 and I can't
I've run into some interesting code in our legacy application running under Internet Explorer.
I seem to be running into an odd problem. When using my GWT application
I seem to be running into a problem. Considering the follow XML structure: <data>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.