I have a Flex Project that is set to use both MX+ Spark.
The project is almost entirely built in AS3 but I would like to use a couple of Flex components.
In an ActionScript Class, how does one add a Flex Component such as DateSpinner?
I have included the spark.swc in the build path.
I am using Flash Builder 4.7.
This is intended to be used as a Desktop app.
It should be as easy as instantiating the class ( and adding it to a container). Just look up the class documentation and have a go.
I'm having no luck.
I have added the mobilecomponents.swc where I believe the DateSpinner lives and tried the following:
var dateSpinner:DateSpinner = new DateSpinner();
dateSpinner.selectedDate = new Date(2013, 10, 10);
dateSpinner.minDate=new Date(2000, 0, 1);
dateSpinner.maxDate=new Date(2014, 0, 1);
No luck as it just does not display.
If I add a DateChooser via mxml it works.
If I add it via actionscript - it does not appear and throws no errors like DateSpinner.
var dateChooser:DateChooser = new DateChooser();
This is called from a class extending MovieClip and is added to the stage already after the ADDED_TO_STAGE event is called.
It is mostly an actionscript project but has an initial Flex layer that lets me use Flex components outside of the AS portions.
I can call up a Flex component added to that layer.
It is not ideal though so I am trying to find a better way to add Flex components from AS classes.
I was hoping there was going to be a better solution than this which I initiated a year ago.
Ideally if you have a project using Flex, you should use Flex components, so your class should be subclassing a Flex container, not a MovieClip (unless there's a specific reason for using a MovieClip ).
I really don't have enough spare time to do anything but give you a nod in the right direction.
Almost entirely this project is built in AS3.
I would love to keep it there but I am trying to add some Flex Components as the man in charge does not have them available directly through actionscript.
And now some I find are only available in Mobile ( DateSpinner ).
I try to use as few Flex Components as possible.
So although it is set to Flex, it is for the most part an AS project.
Also, there are a number of things drawn. I'm not sure how flex containers deal with this but i do know it works fine in AS using MovieClips.