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:
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
Ok, I did not know about the ‘generate’ attribute previously. Thanks for the info.
I googled more info on generate attribute here: http://www.openfl.org/learn/tutorials/using-swf-assets/
PS: I first tried to check the project.xml documentation here https://gist.github.com/jgranick/1763850 but it’s not mentioned there.
Is there any way I can get information of all tags and attributes I can use in project.xml ? Or is that documentation mostly complete?
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
SWFMyActionScriptSymbol for the generated class