Considering how hard it is to find information about custom component setup I thought i would clear up some aspects of the process based on what I have experienced.
INIT EVENT:
For the most part aaaidan example above is correct with one exception.
addEventListener(Event.INIT, onInit);
should be:
loaderInfo.addEventListener(Event.INIT, onInit);
the loaderInfo property of a DisplayObject refrences a LoaderInfo from which your component gets its parameter settings from. the INIT event is called when it has gotten its data (alternativly you could use the COMPLETE event, which should fire directly after the INIT)
INSPECTABLE METADATA:
when your setting up properties to be accessed using the metadata [Inspectable] tag, you can also define default values using:
[Inspectable(defaultValue="whatevervalue")]
from what I have experience the parameters seem to have trouble dealing with anything other then a String (and perhaps Numbers), so I would suggest using set functions that take string values and use them to obtain the other values you may want. for example if you want to load a new instance of a specific named class
[Inspectable(defaultValue="flash.display.Sprite")]
public function set className(value:String):void{
var ClassReference:Class = getDefinitionByName(value) as Class;
_class = new ClassReference();
}
in this example if the parameter is set to "flash.display.Sprite" calling "new _class() will create a new Sprite instance.
SETSIZE FUNCTION:
if you want your custom component to resize in a way other then simply stretching the height and width values you need a public setSize function. this function will be called every time you resize your component in flash.
public function setSize(w:Number, h:Number):void{
_menuWidth = w;
_menuHeight = h;
}
now this works great when your resizing the component in flash but once you actually publish your swf file you will notice that it switches back to stretching width and height rather then using your setSize function (i dont know why but thats what it does). to fix this, in your onInit function you need to take the width and height, feed them into your setSize, and then reset the scaleX and scaleY values back to 1 :
public function onInit(e:Event):void{
setSize(width,height);
scaleX = 1;
scaleY = 1;
//add other functions that need to be run once the parameters are loaded
}
(if anyone finds a less messy way of doing this let know)
hope this helps someone get their custom components up and runing.