0
votes

So I have a SWF embedded in my AS3 project, but when I try to do anything with it, it says it's null.

The code looks like this:

[Embed(source = "../lib/Introduction.swf", mimeType = "application/octet-stream")]
public var introClass:Class;

(after a bunch of irrelevant stuff...)

var intro:MovieClip = new introClass() as MovieClip;
intro.play();

(The error message it gives me is a standard #1009 error.)

I've tried a bunch of stuff including using Loaders, not using MovieClip, etc, but at best, only the audio (not the video) of the SWF loads up, and at worst, the entire application crashes when the SWF tries to load. How do I get the SWF to be recognized?

(I'm using FlashDevelop if that helps.)

1

1 Answers

0
votes

You can do this:

[Embed(source="asset.swf", symbol="symbol")]
private var symbolClass:Class;

var symbol:MovieClip = new symbolClass();

If you want to embed a symbol from an art SWF.

Instead if you want to import animations this is the solution:

[Embed(source="/loading.swf", mimeType="application/octet-stream")]
public var LoadingAnimation : Class;

// allows us to import SWFs to use as animations
var context : LoaderContext = new LoaderContext (false,
    ApplicationDomain.currentDomain);
context.allowCodeImport = true;
var loader : Loader = new Loader ();
loader.loadBytes (new LoadingAnimation (), context);