Lets name our component, BooleanComboBox. You create this custom component, by extending the ComboBox, which is a built-in component. Your component class must be created inside a package for it to be referenced later on. The code is shown below :
package components
{
import mx.controls.ComboBox;
public class BooleanComboBox extends ComboBox
{
public function CountryComboBox()
{
dataProvider = [ "True", "False" ];
}
}
}
For you to use it in your MXML, there is nothing new to be done. Use it the way you had when you created the component using MXML alone.
<?xml version="1.0"?>
<mx:application mx="http://www.adobe.com/2006/mxml" cc="components.*">
<!-- Use the filename as the MXML tag name. -->
<cc:BooleanComboBox/>
</mx:Application>
So, you now know how you can create your own custom components. Couldn't get simpler than that.
Will talk about communicating with a server in the next post.
No comments:
Post a Comment