Is there any direct way to get SimpleButton asset from the library. Just like how it’s done for a movieclip asset using Assets.getMovieClip() ?
To clarify further, I have a SimpleButton asset in library. Classname is “MyButtonComponent”. So I tried this:
var myButton_Sb:SimpleButton;
myButton_Sb = cast ( Assets.getMovieClip('MyButtonComponent'), SimpleButton) ;
However, the above lines give a runtime error saying coercion failed when converting from SimpleButton to MovieClip.
PS: It works, if I put the button inside a movieclip, load that movieclip first, and then cast the child button into Simplebutton. But I am looking for some direct way to load it from the library.
The only way (I know of) to get a SimpleButton instance directly is to use <library path="my.swf" generate="true" preload="true" /> and then use new MyButtonComponent () in your code
Adding another path to get support for SimpleButton instances may be nice, I’ll have to think about it
That link is the best source of documentation on it at the moment, we need to do some more work on documentation for some of these features.
You can also set prefix="SWF" or whatever you like to prefix the generated class names, in case there is a conflict with other class names in your project. That will turn MyActionScriptSymbol to SWFMyActionScriptSymbol for the generated class