# AS3 and flex components

**URL:** <https://forum.kirupa.com/t/as3-and-flex-components/241277>\
**Category:** flash\
**Created:** [October 11, 2007, 6:23pm UTC](https://forum.kirupa.com/t/as3-and-flex-components/241277 "2007-10-11T18:23:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![axiomflash](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/axiomflash/32/3952_2.png) [@axiomflash](https://forum.kirupa.com/u/axiomflash)\
**Post date:** [October 11, 2007, 6:23pm UTC](https://forum.kirupa.com/t/as3-and-flex-components/241277/1 "2007-10-11T18:23:29Z")

</div>

(reposting this from the AS3 page, sorry if you’re seeing twice, but this topic is in limbo:) )

I develop my AS3 projects in Flex Builder, which has been magic so far… but now I have a need for components.  
There are two obvious paths here:  
a) Use the Flash 9 component set (sounds like it works, but takes a bunch of hackwork, and its a small set really)  
b) Use the Flex framework components. (I’d like to be able to use these, but am having trouble.)

Does anyone have suggestions regarding this choice?

I am currently trying to use the Flex framework, and have gone through a lot of work (and the entire internet) trying to figure it out. From what I’ve gathered, this is the way to do it:

Create a new FLEX project, with 1 mxml file:

```auto
 <!-- @mxmlc -default-size 400 300 -incremental=false -->
<Main xmlns="*"/> 

```

This file runs my Main.as file (which extends Application):

```auto
package {
    
    import flash.display.*
    import flash.text.*
    import flash.events.*
    
    import mx.core.*;
    import mx.controls.*;
    import mx.events.*
    import mx.skins.halo.*;
    
    public class Main extends Application
    {
        
        public function Main()
        {
            //initialize flex
            super();
            this.layout = "vertical";
            this.setStyle("borderSkin",mx.skins.halo.HaloBorder);
            this.addEventListener(FlexEvent.APPLICATION_COMPLETE, init); 
        }
        
        private function init(eventObj:FlexEvent):void
        {
            trace("init()");
            var clip:Sprite = new Sprite();
            clip.x = 100;
            clip.y = 50;
            clip.graphics.beginFill(0x00aa00, .7);
            clip.graphics.drawRect(0, 0, 300, 200);
            addChild(clip);
        }
        
    }
}

```

Now I am under the impression that all of the above _would_ work, except I get one error. addChild(clip) is not able to run because it is trying to add a sprite to the stage, and Flex will only accept Flex display objects.

Can anyone advise?
