# Casting loaderInfo.content (.swf file) to its document class causes compilel err 1180

**URL:** <https://forum.kirupa.com/t/casting-loaderinfo-content-swf-file-to-its-document-class-causes-compilel-err-1180/269246>\
**Category:** flash\
**Created:** [August 25, 2008, 9:20am UTC](https://forum.kirupa.com/t/casting-loaderinfo-content-swf-file-to-its-document-class-causes-compilel-err-1180/269246 "2008-08-25T09:20:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![random0xff](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@random0xff](https://forum.kirupa.com/u/random0xff)\
**Post date:** [August 25, 2008, 9:20am UTC](https://forum.kirupa.com/t/casting-loaderinfo-content-swf-file-to-its-document-class-causes-compilel-err-1180/269246/1 "2008-08-25T09:20:57Z")

</div>

I have a Flash file (Foo.fla) with a document class Foo that has a movieclip in its library named Bar that is linked to a class Bar (generated bij Flash). The Foo constructor:

```auto

public function Foo() {
  addChild(new Bar());
}

```

Foo.fla compiles to Foo.swf and runs with no errors. Now from a different Flash file (Test.fla) with a document class Test I want to load Foo.swf using the flash.display.Loader class:

```auto

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
loader.load(new URLRequest("Foo.swf"));

```

In the event handler I get a compile error for Foo.as (the document class for Foo.swf) when I try to cast the content property of the contentLoaderInfo object to an instance of Foo.

```auto

private function onLoad(e:Event):void {
  var loaderInfo:LoaderInfo = e.target as LoaderInfo;
  loaderInfo.content as Foo; // Cause a compile error in Foo.as
}

```

> 

Foo.as, Line 6  
1180: Call to a possibly undefined method ProgressBar.  
addChild(new Bar());

Foo.as compiles without errors but Test.as causes a compile error in Foo.as which is unexpected.

Why is this happening and what can I do to prevent it?

Thank you!
