Did you make datagrid.mxml a component? When I build, I tend
to store my custom components in a folder under main.mxml. Here's
how I'd do it:
1. Make new folder "components" for example.
2. File > New > MXML Component, call it DG (its a class
so name it with caps) for example, dump datagrid code in here and
make sure it's in the components folder.
3. In main.mxml in the Application tag, enter an xml name
space for your custom component. In this example:
Also, in your script, don't forget to import the full path:
I would wait for the button click on main.mxml, then
addChild() in the Panel to bring in the DG. In the Eventhandler()
function on main.mxml put:
var dg:DG = new DG();
I would probably also make dg dispatch a close event when the
user hits the close button and listen for it on the main.mxml, then
you can removeChild etc.