Responsive Design Studio

Website development company Melbourne Australia

AS3 – calling myFunction() on main timeline from loaded SWF

The post is about loading an external swf in a main swf file with some function on main timeline and calling those functions from loaded swf file.

Now the problem is when you try to compile the external swf file with any reference to the main timeline using parent.parent or loader.parent etc. it gives error in compilation time due to the behaviour of concrete classes i.e. MovieClip, Sprite, DisplayObject so how to make a call on parent timeline where there is no direct reference. Following is one of the approach i have found quickly. It is a tricky way to do this. What you need to do is typecast the parent of loader as an Object which is a dynamic class and then call the method which gets compiled without any error. Following is the statement for the same
if(this.parent.parent != null){
var parentObj:Object = this.parent.parent as Object;

You can download the sample files from here . Kindly let me know if you found any other approach

Posted under: Actionscript 3.0, Flash CS3, Flash Player

Tagged as:


Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>