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 3978436
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:02:50+00:00 2026-05-20T05:02:50+00:00

In a plugin context (a swf loaded by an another swf), is there any

  • 0

In a plugin context (a swf loaded by an another swf), is there any way to restrict access to file system and network in the same time to the loaded swf ?

Compiler option “-use-network=true|false” does not fit because you cannot restrict both file/network.

Code example :

Air App :

package
{
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.filesystem.File;
    import flash.net.URLRequest;

    public class TestContentSecurity extends Sprite
    {
        private var l :Loader = new Loader;
        public function TestContentSecurity()
        {
            addChild(l);
            l.load(new URLRequest(File.documentsDirectory.nativePath + "/Content.swf"));
        }
    }
}

Loaded swf :

    package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.system.ApplicationDomain;
    import flash.text.TextField;

    public class Content extends Sprite
    {
        private var _log : TextField = new TextField;
        private var l: URLLoader;
        public function Content()
        {
            addChild(_log)
            _log.multiline = true;
            _log.width = 500;
            _log.height = 500;
            l = new URLLoader();
            l.addEventListener(Event.COMPLETE, onLoad);
            l.addEventListener(IOErrorEvent.IO_ERROR, onError);
            l.load(new URLRequest("c:/Windows/regedit.exe"))
        }

        public function onLoad(e:Event) : void{
            _log.text += "SUCCESS\n" ;
        }
        public function onError(e:IOErrorEvent) : void{
            _log.text += "ERROR\n";
        }
    }
}

The loaded swf is in user’s document folder, outside Air app folder. Currently, the loaded swf is abble to load “c:/Windows/regedit.exe” and I don’t want it (neither sending informations on the network).

  • 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-05-20T05:02:51+00:00Added an answer on May 20, 2026 at 5:02 am

    I’ve found one solution in AIR, I don’t like it but it works. The idea is to have a mini http server and to load content from this server.

    I load targeted file with :

    new URLRequest("http://localhost:1111/Content.swf")

    By doing this, flash will load “Content.swf” as a remote file and place it in a REMOTE security sandbox. Loaded swf won’t be able to access to any local files neither to network.

    If anyone have a cleaner solution to get this REMOTE security sand box, I will be happy.

    /**
     * HTTP server original idea :
     * http://coenraets.org/blog/2009/12/air-2-0-web-server-using-the-new-server-socket-api/
     */
    package
    {
        import flash.display.Loader;
        import flash.display.Sprite;
        import flash.filesystem.File;
        import flash.filesystem.FileMode;
        import flash.filesystem.FileStream;
        import flash.net.URLRequest;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        import flash.events.ServerSocketConnectEvent;
        import flash.net.ServerSocket;
        import flash.net.Socket;
        import flash.utils.ByteArray;
    
        public class TestContentSecurity extends Sprite
        {
            private var l :Loader = new Loader;
            private var serverSocket:ServerSocket;
    
            public function TestContentSecurity()
            {
                init();
                l.load(new URLRequest("http://localhost:1111/Content.swf"));
            }
    
    
            private function init():void
            {
                // Initialize the web server directory (in applicationStorageDirectory) with sample files
                listen(1111);
            }
    
            private function listen(port : uint):void
            {
                try
                {
                    serverSocket = new ServerSocket();
                    serverSocket.addEventListener(Event.CONNECT, socketConnectHandler);
                    serverSocket.bind(port, "127.0.0.1");
                    serverSocket.listen();
                    trace("Listening on port " + port + "...\n");
                }
                catch (error:Error)
                {
                    trace("Port " + port +
                        " may be in use. Enter another port number and try again.\n(" +
                        error.message +")", "Error");
                }
            }
    
            private function socketConnectHandler(event:ServerSocketConnectEvent):void
            {
                var socket:Socket = event.socket;
                socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
            }
    
            private function socketDataHandler(event:ProgressEvent):void
            {
                try
                {
                    var socket:Socket = event.target as Socket;
                    var bytes:ByteArray = new ByteArray();
                    socket.readBytes(bytes);
                    var request:String = "" + bytes;
    
                    var filePath:String = request.substring(5, request.indexOf("HTTP/") - 1);
                    var file:File = File.applicationDirectory.resolvePath(filePath);
                    if (file.exists && !file.isDirectory)
                    {
                        var stream:FileStream = new FileStream();
                        stream.open( file, FileMode.READ );
                        var content:ByteArray = new ByteArray();
                        stream.readBytes(content);
                        stream.close();
                        socket.writeUTFBytes("HTTP/1.1 200 OK\n");
                        socket.writeUTFBytes("Content-Type: application/x-shockwave-flash\n\n");
                        socket.writeBytes(content);
                    }
                    else
                    {
                        socket.writeUTFBytes("HTTP/1.1 404 Not Found\n");
                        socket.writeUTFBytes("Content-Type: text/html\n\n");
                        socket.writeUTFBytes("<html><body><h2>Page Not Found</h2></body></html>");
                    }
                    socket.flush();
                    socket.close();
                }
                catch (error:Error)
                {
                    trace("Error");
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way of detecting an error when a Flash-plugin loads its content?
There is a nice hierarchical jQuery PlugIn for context-menus from web-delicious: wdContextMenu . I
this code in my plugin used to work just fine: jQuery('#embedded_obj', context).get(0).getVersion(); and the
what plugin or gem do you recommened for tagging? There are many of them,
I'm using a context-menu jQuery plugin and I need to detect what browsers support
I have a Joomla plugin (not important in this context), which is designed to
I've looked at UIkit , and some other jQuery Context Menu Plugin's but they
I'm using jeegoo context menu jquery plugin which overrides the arrow keys in order
I have a problem with glassfish to serve swf files. In my application there
I am using jQuery context menu plugin by Chris Domigan to appy a context

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.