4 Replies Latest reply on Feb 15, 2007 8:12 AM by SymTsb

    loading/unloading movie/image in actionscript

    GregConnTelevirtual Level 1
      Hi I'm trying to load an image on the fly in flash which is no problem, but then when i need it to unload it doesn't and i get an

      *** Security Sandbox Violation ***
      Connection to file:///C|/Documents%20and%20Settings/Administrator/Desktop/Latest%20Versions/High%20res% 20newsreader/ halted - not permitted from http://MYSERVER/test/tfl.gif
      -- Remote SWFs may not access local files.

      Why does this happen? why would it load but not unload?

      The load code is

      _root.createEmptyMovieClip("box", 1);
      _root.box.createEmptyMovieClip("pic_mc", 2);
      _root.box.pic_mc._x = -40;
      _root.box.pic_mc._y = 0;
      _root.box.pic_mc.loadMovie( " http://MYSERVER/test/tfl.gif" );

      and unload is

        • 1. Re: loading/unloading movie/image in actionscript
          I had this problem with a Flash ad I was building at work. I never figured out exactly why I would get the sandbox violation when testing the swf locally, but once the ad was published on the server, the unloadMovie() worked perfect.
          • 2. Re: loading/unloading movie/image in actionscript
            SymTsb Level 2
            it has to do with settings in the player. For security reasons, you can only load data from within your domain. Local domain is always or localhost. don't use http:// inside your call to loadMovie. Always use the local method (relative path from the current flash file i.e. /test/tfl.gif) and make sure that the images are local. By using that http://MYSERVER, flash thinks that the domain for the current running movie is MYSERVER and not localhost therefore, it will restrict all access to local files. Now, if you put the flash file up on MYSERVER, chances are like wwscoper just pointed out, it will work perfectly because localhost and MYSERVER refer to the same masked IP.
            • 3. Re: loading/unloading movie/image in actionscript
              That makes sense. The ad I was building used the relative path (when creating), but for the final ad, the external files needed to be posted on the server, therefor I had to change the links to use http://... once i changed the links to this, i would get the sandbox violation on my machine, but worked fine on the server.
              • 4. Re: loading/unloading movie/image in actionscript
                SymTsb Level 2
                I never use the http at any point in production from beginning to end. I've always mapped out my projects so that all my files are in folders relative to the main flash file's location. This way, I simply have to post the final folder containing that main file (with all the other files in folders inside that folder) up to the server and go live. The Flash Player is smart enough to resolve the issues of localhost etc. The only reason I have ever needed to use an http was in a getURL and it was only because I needed to direct them through a secure portal (https). Always try to keep every relative to your documents. It makes your life much easier in the long run.