# Can't swap child for new class instance IF child is exported for action script

**URL:** <https://forum.kirupa.com/t/cant-swap-child-for-new-class-instance-if-child-is-exported-for-action-script/313042>\
**Category:** flash\
**Created:** [August 18, 2010, 3:12pm UTC](https://forum.kirupa.com/t/cant-swap-child-for-new-class-instance-if-child-is-exported-for-action-script/313042 "2010-08-18T15:12:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cakepizza](https://avatars.discourse-cdn.com/v4/letter/c/45deac/32.png) [@cakepizza](https://forum.kirupa.com/u/cakepizza)\
**Post date:** [August 18, 2010, 3:12pm UTC](https://forum.kirupa.com/t/cant-swap-child-for-new-class-instance-if-child-is-exported-for-action-script/313042/1 "2010-08-18T15:12:18Z")

</div>

I have a movieClip with one frame on the timeline containing one child whose instance name is “myContent”

I am using this function to swap “myContent” with any number of possible class instances.

```auto

function setContentAsClass(c:Class)
{
removeChild(myContent);
myContent=new c;
addChild(myContent);    
} //end

```

It works fine if the initial “myContent” instance on my timeline is movie clip which IS NOT exported as a class for action script. If, however, “myContent” is initially of a class that IS exported for action script, I get errors such as this…

```auto

TypeError: Error #1034: Type Coercion failed: cannot convert possibleContent1@1e2940e9 to myInitialContentClass.

```

Any idea why this is so?
