0

Greatings!

I have yet another question concerning the loading of a .swf inside a existing one.

In my game. I have a introduction screen in which I load another .swf (which is a movie). This all works fine and the URLRequest is this:

request = new URLRequest("Movie.swf");

As I said, this works fine. However when I copy my game.swf and movie.swf to a USB stick. (I put them in the same directory to prevent other issues). It doesn't seem to find the movie.swf.

Now I know that it has to do with the path given in the URLRequest and/or the publish settings. But I do not know how to make this so that it searches in the same directory as the game.swf is in.

I hope you guys have an answer for this issue.

Thanks in advance,

Matti.

Matti Groot
  • 41
  • 10
  • I'm sure it is due to the security error - do you have debug version of flash player? go to the [flash player settings manager](http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html) and add your USB location as safe/trusted location. – Lukasz 'Severiaan' Grela Nov 16 '12 at 13:26
  • Thanks for your fast reply! It didn't seem to work though. Also I don't think this solves the issue I am having. It's not only that I want it to play on my computer. But also on other computers without installing/modifying things. – Matti Groot Nov 16 '12 at 14:00
  • How are you loading the parent SWF when it is on the USB drive. If you are just double clicking the SWF than it will have a network security error. You need to post all code pertaining to the loading of the child swf. – The_asMan Nov 16 '12 at 16:09

1 Answers1

1

Matti, I believe Lukasz's comment is correct about it being a security error.

You can avoid this security error by embedding Movie.swf instead of using a Loader. If you do this, then at compile-time the Movie.swf needs to sit next to the Game.as file, and it will be included in the Game.swf (no need to deliver both files, just Game.swf).

The syntax is:

package
{
  import flash.display.Sprite;

  public class Game extends Sprite
  {

    [Embed(source="MyMovie.swf")]
      private var myMovieClass:Class;

    private var myMovie:DisplayObject;

    public function Game():void
    {
      myMovie = new myMovieClass();

      // Technically myMovie is now a Loader, and once
      // it's loaded, it'll have .content that's a
      // MovieClipLoaderAsset, and .content.getChildAt(0)
      // will be your MyMovie.swf main timeline.
    }
  }
}

Alternately, if you embed it as mimeType="application/octet-stream", you can get the bytes of the SWF and use it in your existing Loader's .loadBytes() method:

package
{
  import flash.display.Sprite;
  import flash.utils.ByteArray;

  public class Game extends Sprite
  {

    [Embed(source="MyMovie.swf", mimeType="application/octet-stream")]
      private var movieBytes:Class;

    private var myMovie:DisplayObject;

    public function Game():void
    {
      // Treat this loader the same as your current loader,
      // but don't call .load(url), call loadbytes():
      var l:Loader = new Loader();
      l.loadBytes(new movieBytes() as ByteArray);
    }
  }
}
Jeff Ward
  • 16,563
  • 6
  • 48
  • 57
  • This is not a fix to his issue. – The_asMan Nov 16 '12 at 16:06
  • Actually what Jeff Ward just posted is exactly what I needed. I can't thank you enough for your help. I tested it and it works. Small thing though: If other people find this helpful it may prevent them some problems. if you remove the ) in this line: [Embed(source="MyMovie.swf"), mimeType="application/octet-stream")] – Matti Groot Nov 16 '12 at 16:21
  • Indeed it's not a fix, it's a workaround of the security problem. Glad it helped. Fixed the copy/paste error, thanks! – Jeff Ward Nov 16 '12 at 17:58