# Class App extends Box

**URL:** <https://forum.kirupa.com/t/class-app-extends-box/225665>\
**Category:** Uncategorized\
**Created:** [May 14, 2007, 7:20pm UTC](https://forum.kirupa.com/t/class-app-extends-box/225665 "2007-05-14T19:20:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiosk77](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@kiosk77](https://forum.kirupa.com/u/kiosk77)\
**Post date:** [May 14, 2007, 7:20pm UTC](https://forum.kirupa.com/t/class-app-extends-box/225665/1 "2007-05-14T19:20:06Z")

</div>

I hope this is the right forum for this, since this is a Flex/AS3 instead of a purely AS3 question. I couldn’t find a Flex/AS forum. Anyway,

I want to use ActionScript files with Flex, which works if I have as long as I don’t try to draw something, but as soon as I do… it gives me an error (below) Any ideas? I also tried to run the drawing script on Events.ADDED, but no go.

The reason why I want to use external AS is because I am using FlashDevelop for my authoring and it does not have code hinting when writing AS inside of the \<mx:Script\> tag.

(I just started learning Flex/AS3 over the weekend, quite a change from AS2 🙂 )  
Thank you in advance (again)

```auto

<?xml version="1.0" ?>
<!-- @mxmlc -output bin\App.swf -->
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:custom="*"
    width="100%" height="100%">
    <custom:App width="100%" height="100%" backgroundColor="0x00ff00" />
</mx:Application>

```

```auto

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import mx.containers.Box;
    
    [SWF(width="800", height="600", frameRate="31", backgroundColor="#FFFFFF")]
    public class App extends Box {
        public function App() {
            var s:Sprite = new Sprite();
            s.graphics.lineStyle(2,0xff0000);
            s.graphics.drawRect(0,0,100,100);
            addChild(s);
            //addEventListener( Event.ADDED, init );
        }
    }
}

```

> 

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Sprite@1269c91 to mx.core.IUIComponent.  
at mx.core::Container/[http://www.adobe.com/2006/flex/mx/internal::addingChild()](http://www.adobe.com/2006/flex/mx/internal::addingChild())  
at mx.core::Container/addChildAt()  
at mx.core::Container/addChild()  
at App$iinit()  
at mx.core::Container/createComponentFromDescriptor()  
at mx.core::Container/createComponentsFromDescriptors()  
at mx.core::Container/mx.core:Container::createChildren()  
at mx.core::UIComponent/initialize()  
at mx.core::Container/initialize()  
at mx.core::Application/initialize()  
at MindManager/initialize()  
at mx.managers::SystemManager/[http://www.adobe.com/2006/flex/mx/internal::childAdded()](http://www.adobe.com/2006/flex/mx/internal::childAdded())  
at mx.managers::SystemManager/::initializeTopLevelWindow()  
at mx.managers::SystemManager/::docFrameHandler()
