Posted by: Yogesh Puri on: September 1, 2008
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;
parentObj.traceMe()
}
You can download the sample files from here . Kindly let me know if you found any other approach
[...] Original post by Yogesh Puri [...]
Thanks man.. I couldnt for the life of me figure out a way to do this.
wooooow,
i’ve been waging hopeless war against as3, looking everywhere for help and calling to my deepest intuition with no success, until 5 am when i ran into this little little post.
thank you
what does the “as” command mean?
Simple, and perfect explanation!!
Thankyou very much! []’s
If you are trying to call a function inside parent loader you should do this:
(root.loaderInfo.loader.root as Object).myFunction();
Thank you very much, i was desperately searching for the same, and atlast got it working, Thanks again!
Hi,
I tried it using timeline scripting it works, but when i am using it with an external .as file it gives an error
TypeError: Error #1006: callTrace is not a function.
at anim_fla::MainTimeline/anim_fla::frame50()
hello, i have main.swf with loaded 1.swf in it and loaded 1.swf in 1.swf
main.swf>1.swf>1.swf
now, how can i access function in main.swf from second 1.swf???
ty
[...] to flashforum.dk and Yogesh Puri I finally found a way to solve this [...]
I love you, thanks for this been annoying me for ages – seems so simple lookin at it now though
Thanks! Your solution saved my ass
Wow .. thanx a lot..
Little script can make such a big difference.
September 9, 2008 at 12:01 am
Hi I like this site im glad you updated it . I like the new options.