Flex‎ > ‎

Flex - Custom Components

In order to build a new component you should simply create a new mxml file.

For example, lets assume I created the file : guy/MyComponent.mxml

In the file I write the following
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="library://ns.adobe.com/flex/mx"
            public var button1Label:String
    <mx:Button label="{button1Label}"/>   

Note that I also defined a parameter that I can initialize in the component

now, in order to use this component in my Main, I add xmlns at the root like this :


and I add it like this

<guy:MyComponent button1Label="myLabel"/>

If I use Flash Builder 4 - I even get auto-complete on my new component