Calling parent-functions of a loaded SWF

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 simply write: this.parent.functionName().
The compiler throws an error, saying that it can’t find a method with that name in flash.display:DisplayObjectContainer.

But 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();

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.