h1

Calling parent-functions from a loaded SWF

October 1, 2010

If you’re loading an external SWF-file into your Main-SWF (or any other swf), the external SWF cannot call any self-made function you defined in your main by simple write: this.parent.functionName().
The compiler throws an error, saying that he can’t find a method with that name in flash.display:DisplayObjectContainer.

You can avoid this by typecasting the parent as an Object like this:

var fooObject:Object = this.parent as Object;

Now you can call methods from the parent-class: fooObject.functionName();

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.