# Access child.swf function from parent.swf

**URL:** <https://forum.kirupa.com/t/access-child-swf-function-from-parent-swf/278090>\
**Category:** Uncategorized\
**Created:** [December 22, 2008, 10:50am UTC](https://forum.kirupa.com/t/access-child-swf-function-from-parent-swf/278090 "2008-12-22T10:50:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shubs6](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@shubs6](https://forum.kirupa.com/u/shubs6)\
**Post date:** [December 22, 2008, 10:50am UTC](https://forum.kirupa.com/t/access-child-swf-function-from-parent-swf/278090/1 "2008-12-22T10:50:31Z")

</div>

I have to access a function in child swf from parent swf. This child swf gets loaded into a canvas object in parent.swf. Everything works fine but I’m unable to call any function that was in child.swf.  
My code is

```auto

    var swf1:SWFLoader = new SWFLoader();
    swf1.source = "CHILD.swf";    
    can.addchild(swf1);

```

I read on google and then I tried this in parent.swf’s code

```auto

    var myrequest:URLRequest = new URLRequest("CHILD.swf");
    var myloader:Loader = new Loader();
    myloader.load(myrequest);
    canvas.addchild(myloader);

```

Now this one throws up a runtime error TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@5934b01 to mx.core.IUIComponent.

I also tried this

```auto

    var myrequest:URLRequest = new URLRequest("CHILD.swf");
    var myloader:Loader = new Loader();
    myloader.load(myrequest);

     var uic:UIComponent = new UIComponent();                
     uic.addChild(myloader);                
     canvas.addChild(uic);

```

But in this case my swf does not show up at all and there are no runtime errors too!

How do I resolve this error and how do I then access the function in child.swf?

PLEASE HELP GUYS…
